@@ -47,11 +47,18 @@ def parseTheArg():
47
47
48
48
parser = argparse .ArgumentParser (description = 'Convert the provided project into Checked C.' )
49
49
50
+ parser .add_argument ('--updateIncludes' ,
51
+ dest = 'update_includes' , action = 'store_true' ,
52
+ default = False ,
53
+ help = ('Update `#include <foo.h>` to `#include <foo_checked.h>` in '
54
+ 'source files before running 3c. Should normally no longer '
55
+ 'be needed with implicit checked header inclusion.' ))
50
56
parser .add_argument ('--includeDir' ,
51
57
default = checkedcHeaderDir if os .path .exists (checkedcHeaderDir ) else pathBasedDir ,
52
58
required = False ,
53
59
dest = 'includeDir' ,
54
- help = 'Path to the checkedC headers, run from a checkedCclang repo' )
60
+ help = ('Path to the checkedC headers, run from a checkedCclang repo '
61
+ '(used only if --updateIncludes is on)' ))
55
62
parser .add_argument ("-p" , "--prog_name" , dest = 'prog_name' , type = str , default = _3c_bin ,
56
63
help = 'Program name to run. i.e., path to 3c' )
57
64
@@ -100,7 +107,7 @@ def parseTheArg():
100
107
logging .error ("Provided argument: {} is not a file." .format (args .prog_name ))
101
108
sys .exit ()
102
109
103
- if not args .includeDir or not os .path .isdir (args .includeDir ):
110
+ if args . update_includes and ( not args .includeDir or not os .path .isdir (args .includeDir ) ):
104
111
logging .error ("Error: --includeDir argument must be the name of a directory." )
105
112
logging .error ("Provided argument: {} is not a directory." .format (args .includeDir ))
106
113
sys .exit ()
@@ -129,10 +136,11 @@ def parseTheArg():
129
136
logging .error ("Error: Build directory does not contain compile_commands.json." )
130
137
logging .error ("compile_commands.json file: {} does not exist." .format (compileCmdsJson ))
131
138
sys .exit ()
132
- # replace include files
133
- logging .info ("Updating include lines of all the source files." )
134
- updateProjectIncludes (progArgs .project_path , progArgs .includeDir )
135
- logging .info ("Finished updating project files." )
139
+ if progArgs .update_includes :
140
+ # replace include files
141
+ logging .info ("Updating include lines of all the source files." )
142
+ updateProjectIncludes (progArgs .project_path , progArgs .includeDir )
143
+ logging .info ("Finished updating project files." )
136
144
137
145
logging .info ("Trying to convert all the source files to header files" )
138
146
run3C (progArgs .prog_name , progArgs .extra_3c_args ,
0 commit comments