Skip to content

Commit b59378a

Browse files
committed
Adding more flags
1 parent 08b9470 commit b59378a

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

clang/tools/cconv-standalone/utils/cc_conv/convert_project.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,12 @@ def parseTheArg():
5858
parser.add_argument("--skip", dest='skip_paths', action='append', type=str, default=[],
5959
help='Relative path to source files that should be skipped.')
6060

61+
parser.add_argument("-dr", dest='skip_exec', action='store_true', default=False,
62+
help='Do not run the conversion. Just create the conversion script.')
63+
6164
args = parser.parse_args()
6265

63-
if not args.prog_name or not os.path.isfile(args.prog_name):
66+
if not args.skip_exec and (not args.prog_name or not os.path.isfile(args.prog_name)):
6467
logging.error("Error: --prog_name argument is not a valid file..")
6568
logging.error("Provided argument: {} is not a file.".format(args.prog_name))
6669
sys.exit()
@@ -93,7 +96,8 @@ def parseTheArg():
9396
logging.info("Finished updating project files.")
9497

9598
logging.info("Trying to convert all the source files to header files")
96-
runCheckedCConvert(progArgs.prog_name, compileCmdsJson, progArgs.includeDir, progArgs.skip_paths)
99+
runCheckedCConvert(progArgs.prog_name, compileCmdsJson, progArgs.includeDir,
100+
progArgs.skip_paths, progArgs.skip_exec)
97101
logging.info("Finished converting all the files to checkedc files.")
98102

99103

clang/tools/cconv-standalone/utils/cc_conv/generate_ccommands.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,8 @@ def tryFixUp(s):
8989
return
9090

9191

92-
def runCheckedCConvert(checkedc_bin, compile_commands_json, checkedc_include_dir, skip_paths, run_individual=False):
92+
def runCheckedCConvert(checkedc_bin, compile_commands_json, checkedc_include_dir, skip_paths,
93+
skip_running=False, run_individual=False):
9394
global INDIVIDUAL_COMMANDS_FILE
9495
global TOTAL_COMMANDS_FILE
9596
runs = 0
@@ -150,6 +151,7 @@ def runCheckedCConvert(checkedc_bin, compile_commands_json, checkedc_include_dir
150151
compilation_base_dir = os.path.dirname(compilation_base_dir)
151152
prog_name = checkedc_bin
152153
f = open(INDIVIDUAL_COMMANDS_FILE, 'w')
154+
f.write("#!/bin/bash\n")
153155
for compiler_args, target_directory, src_file in s:
154156
args = []
155157
# get the command to change the working directory
@@ -176,11 +178,13 @@ def runCheckedCConvert(checkedc_bin, compile_commands_json, checkedc_include_dir
176178
f.write("\n")
177179
f.close()
178180
logging.debug("Saved all the individual commands into the file:" + INDIVIDUAL_COMMANDS_FILE)
181+
os.system("chmod +x " + INDIVIDUAL_COMMANDS_FILE)
179182

180183
vcodewriter = VSCodeJsonWriter()
181184
# get path to icconv
182185
vcodewriter.setClangdPath(os.path.join(os.path.dirname(prog_name), "icconv"))
183186
args = []
187+
args.append("#!/bin/bash")
184188
args.append(prog_name)
185189
args.extend(DEFAULT_ARGS)
186190
args.extend(list(set(total_x_args)))
@@ -195,8 +199,9 @@ def runCheckedCConvert(checkedc_bin, compile_commands_json, checkedc_include_dir
195199
f = open(TOTAL_COMMANDS_FILE, 'w')
196200
f.write(" \\\n".join(args))
197201
f.close()
202+
os.system("chmod +x " + TOTAL_COMMANDS_FILE)
198203
# run whole command
199-
if not run_individual:
204+
if not run_individual and not skip_running:
200205
logging.info("Running:" + str(' '.join(args)))
201206
subprocess.check_call(' '.join(args), shell=True)
202207
logging.debug("Saved the total command into the file:" + TOTAL_COMMANDS_FILE)

0 commit comments

Comments
 (0)