diff --git a/.gitignore b/.gitignore index cd29d84..40bf91a 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,4 @@ /Users/jlopezvi/Flowgen/flowdoc/aux_files/simple_demo_src.flowdb /Users/jlopezvi/Flowgen/flowdoc/aux_files/source1.flowdb .DS_Store +.*.swp diff --git a/forVINCIA/build_db.py b/forVINCIA/build_db.py index 957cd1b..97f9ccb 100755 --- a/forVINCIA/build_db.py +++ b/forVINCIA/build_db.py @@ -3,6 +3,7 @@ import sys import clang.cindex import os +import filecmp #clang node types (CursorKind) #21: CXX_METHOD @@ -92,6 +93,13 @@ def find_functions(node): print ('Translation unit:', tu.spelling.decode("utf-8")) infile_str=os.path.splitext(os.path.basename(sys.argv[1]))[0] print (infile_str) -writefunc = open('flowdoc/aux_files/'+infile_str+'.flowdb',"w") +provfilename = os.path.join('flowdoc/aux_files/',infile_str+'_provisional.flowdb') +origfilename = os.path.join('flowdoc/aux_files/',infile_str+'.flowdb') +writefunc = open(provfilename,"w") find_functions(tu.cursor) -writefunc.close() \ No newline at end of file +writefunc.close() +# check whether the name of the provisional file has to be changed into origfilename +if (not(os.path.isfile(origfilename)) or (os.path.isfile(origfilename) and not filecmp.cmp(origfilename, provfilename, shallow=False))): + os.rename(provfilename, origfilename) +else: + os.remove(provfilename) diff --git a/forVINCIA/makeflows.py b/forVINCIA/makeflows.py index eb9c10d..42adfea 100755 --- a/forVINCIA/makeflows.py +++ b/forVINCIA/makeflows.py @@ -803,10 +803,15 @@ def find_functions(node): #global variable for the name of the input file. It will be defined later on. infile_str='' find_functions(tu.cursor) +#touch an empty file so that make knows this source code file has been processed +prcfilename = sys.argv[1] +prcfilename = os.path.join("flowdoc/aux_files", os.path.splitext(os.path.basename(prcfilename))[0]+".mfdone") +with open(prcfilename, 'a'): + os.utime(prcfilename, None) #print(os.path.splitext(infile_str)[0]) #print(os.path.basename(infile_str)) #print(os.path.splitext(os.path.basename(infile_str))[0]) #f = open('flowdoc/'+os.path.splitext(os.path.basename(infile_str))[0]+".html","w") #f.write(htmlonline_str) -#f.close() \ No newline at end of file +#f.close()