Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions clang/tools/3c/utils/port_tools/compile_converted_project.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash
# usage: compile_converted_project.sh PATH_TO_clang [MAKE_ARGS...]
# The working directory must be the project.

clang="$1"
shift

find . -name '*.checked.*' | while read f_checked; do
Comment thread
mattmccutchen-cci marked this conversation as resolved.
Outdated
[[ "$f_checked" =~ ^(.*)\.checked(\..*)$ ]] || {
echo >&2 "Weird filename: $f_checked"
continue
}
f="${BASH_REMATCH[1]}${BASH_REMATCH[2]}"
mv "$f_checked" "$f"
Comment thread
mattmccutchen-cci marked this conversation as resolved.
Outdated
# Be sure to trigger the build system to recompile.
touch "$f"
done

# Keep going after one file fails to compile so we can see compile errors in all
# files.
make -k CC="$clang" "$@"
Comment thread
mattmccutchen-cci marked this conversation as resolved.
Outdated
8 changes: 7 additions & 1 deletion clang/tools/3c/utils/port_tools/convert_project.py
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env python

"""
Given the path to the project and 3c binary,
this script runs 3c on all the files.
Expand Down Expand Up @@ -52,6 +54,10 @@ def parseTheArg():
parser.add_argument("-p", "--prog_name", dest='prog_name', type=str, default=_3c_bin,
help='Program name to run. i.e., path to 3c')

parser.add_argument("-extra-3c-arg", dest='extra_3c_args', type=str, default=[], nargs='*',
help=('Extra argument to pass to 3c. '
'Multiple -extra-3c-arg options can be used.'))

parser.add_argument("-pr", "--project_path", dest='project_path', type=str, required=True,
help='Path to the folder containing all project sources.')

Expand Down Expand Up @@ -96,7 +102,7 @@ def parseTheArg():
logging.info("Finished updating project files.")

logging.info("Trying to convert all the source files to header files")
run3C(progArgs.prog_name, compileCmdsJson, progArgs.includeDir,
run3C(progArgs.prog_name, progArgs.extra_3c_args, compileCmdsJson, progArgs.includeDir,
progArgs.skip_paths, progArgs.skip_exec)
logging.info("Finished converting all the files to checkedc files.")

Expand Down
15 changes: 10 additions & 5 deletions clang/tools/3c/utils/port_tools/generate_ccommands.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
VSCODE_SETTINGS_JSON = os.path.realpath("settings.json")

# to separate multiple commands in a line
CMD_SEP = " &"
CMD_SEP = " &&"
Comment thread
mattmccutchen-cci marked this conversation as resolved.
DEFAULT_ARGS = ["-dump-stats", "-output-postfix=checked", "-dump-intermediate"]
if os.name == "nt":
DEFAULT_ARGS.append("-extra-arg-before=--driver-mode=cl")
Expand Down Expand Up @@ -89,7 +89,8 @@ def tryFixUp(s):
return


def run3C(checkedc_bin, compile_commands_json, checkedc_include_dir, skip_paths,
def run3C(checkedc_bin, extra_3c_args, compile_commands_json,
checkedc_include_dir, skip_paths,
skip_running=False, run_individual=False):
global INDIVIDUAL_COMMANDS_FILE
global TOTAL_COMMANDS_FILE
Expand All @@ -111,7 +112,6 @@ def run3C(checkedc_bin, compile_commands_json, checkedc_include_dir, skip_paths,
return

s = set()
total_x_args = []
all_files = []
for i in cmds:
file_to_add = i['file']
Expand All @@ -128,7 +128,6 @@ def run3C(checkedc_bin, compile_commands_json, checkedc_include_dir, skip_paths,
file_to_add = i['directory'] + SLASH + file_to_add
# get the 3c and compiler arguments
compiler_x_args = getCheckedCArgs(i["arguments"], checkedc_include_dir, i['directory'])
total_x_args.extend(compiler_x_args)
# get the directory used during compilation.
target_directory = i['directory']
file_to_add = os.path.realpath(file_to_add)
Expand Down Expand Up @@ -166,6 +165,7 @@ def run3C(checkedc_bin, compile_commands_json, checkedc_include_dir, skip_paths,
args.extend(list(compiler_args))
args.append('-base-dir="' + compilation_base_dir + '"')
args.extend(DEFAULT_ARGS)
args.extend(extra_3c_args)
args.append(src_file)
# run individual commands.
if run_individual:
Expand All @@ -190,7 +190,12 @@ def run3C(checkedc_bin, compile_commands_json, checkedc_include_dir, skip_paths,
args = []
args.append(prog_name)
args.extend(DEFAULT_ARGS)
args.extend(list(set(total_x_args)))
Comment thread
mattmccutchen-cci marked this conversation as resolved.
args.extend(extra_3c_args)
args.append('-p')
args.append(compile_commands_json)
# Same as in getCheckedCArgs
args.append('-extra-arg-before=-I' + checkedc_include_dir)
args.append('-extra-arg-before=-w')
Comment thread
mattmccutchen-cci marked this conversation as resolved.
Outdated
vcodewriter.addClangdArg("-log=verbose")
vcodewriter.addClangdArg(args[1:])
args.append('-base-dir="' + compilation_base_dir + '"')
Expand Down