From d166af8a2193c8133e007e1a04931cc779580cae Mon Sep 17 00:00:00 2001 From: Mathias Ritzmann Date: Fri, 30 May 2014 15:40:13 +0200 Subject: [PATCH 1/3] changed makeflows.py to touch a file *.processed at the end for make --- .gitignore | 1 + forVINCIA/makeflows.py | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) 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/makeflows.py b/forVINCIA/makeflows.py index 4a376d2..f31e519 100755 --- a/forVINCIA/makeflows.py +++ b/forVINCIA/makeflows.py @@ -775,10 +775,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) +#create .processed 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]+".processed") +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() From 620d7eadefed8cb09427374297979a2327e780d1 Mon Sep 17 00:00:00 2001 From: Mathias Ritzmann Date: Sat, 31 May 2014 15:53:38 +0200 Subject: [PATCH 2/3] changed marker file name from .processed to .mfdone changed makeflows.py to only change the .flowdb file if anything changed to avoid unnecessary reprocessing --- forVINCIA/build_db.py | 12 ++++++++++-- forVINCIA/makeflows.py | 4 ++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/forVINCIA/build_db.py b/forVINCIA/build_db.py index 957cd1b..6b23caf 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 = 'flowdoc/aux_files/'+infile_str+'_provisional.flowdb' +origfilename = 'flowdoc/aux_files/'+infile_str+'.flowdb' +writefunc = open('flowdoc/aux_files/'+infile_str+'_provisional.flowdb',"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 f31e519..bbcf1e5 100755 --- a/forVINCIA/makeflows.py +++ b/forVINCIA/makeflows.py @@ -775,9 +775,9 @@ 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) -#create .processed file so that make knows this source code file has been processed +#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]+".processed") +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]) From 7ea90e9365dbc38abd17aedad1f905a0bf520309 Mon Sep 17 00:00:00 2001 From: Mathias Ritzmann Date: Sat, 31 May 2014 16:00:39 +0200 Subject: [PATCH 3/3] cosmetic change, eliminated repetition of filename and inserted os.path.join --- forVINCIA/build_db.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/forVINCIA/build_db.py b/forVINCIA/build_db.py index 6b23caf..97f9ccb 100755 --- a/forVINCIA/build_db.py +++ b/forVINCIA/build_db.py @@ -93,9 +93,9 @@ 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) -provfilename = 'flowdoc/aux_files/'+infile_str+'_provisional.flowdb' -origfilename = 'flowdoc/aux_files/'+infile_str+'.flowdb' -writefunc = open('flowdoc/aux_files/'+infile_str+'_provisional.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() # check whether the name of the provisional file has to be changed into origfilename