-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathcreate_json_db
executable file
·56 lines (45 loc) · 4.5 KB
/
create_json_db
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/usr/bin/env python3
import os
import sys
import argparse
import jsonast
prog = os.path.realpath(__file__)
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="MAIN_DESCRIPTION", formatter_class=argparse.RawDescriptionHelpFormatter)
# execution control
parser.add_argument("-P", "--proc-binary", action="store", help="Path to the processor binary based on clang")
parser.add_argument("-j", "--jobs", action="store", type=int, help="Run only with specific number of jobs", required=False)
parser.add_argument("-Q", "--unique-cdb", action="store_true", help="Make compilation database unique while processing",required=False)
# output control
parser.add_argument("-img", "--image", action="store_true", help="generate .img file for database")
parser.add_argument("-q", "--quiet", action="store_true", help="don't print any information on stdout")
parser.add_argument("-d", "--debug", action="store_true", help="print debug information")
parser.add_argument("-v", "--verbose", action="store_true", help="print verbose errors")
parser.add_argument("-o", "--output", action="store", help="Output file")
parser.add_argument("-O", "--forward-output", required=False, action="store", help="Store program output to the provided file")
parser.add_argument("-S", "--clean-slate", action="store_true", help="Remove error (and debug) file(s) and store potential errors (debugs) from scratch",required=False)
# target info
parser.add_argument("-V", "--sw-version", required=False, action="store", help="Put information about S/W version to JSON database")
parser.add_argument("-m", "--module-info", required=False, action="store", help="Put information about module being processed to JSON database")
parser.add_argument("-C", "--compilation-database", action="store", help="Path to compilation database file (default compile_commands.json file in the current directory", required=False)
parser.add_argument("-cdm", "--compilation-dependency-map", required=False, action="store", help="Path to compile dependency map file that contains mapping between modules and corresponding source files")
# clang-proc options
parser.add_argument("-B", "--skip-body", action="store_true", help="skip adding function body to the JSON database")
parser.add_argument("-W", "--skip-switches", action="store_true", help="skip adding switch/case information the JSON database")
parser.add_argument("-X", "--skip-defs", action="store_true", help="skip adding type definitions for certain types")
parser.add_argument("-A", "--with-cta", action="store_true", help="merge compile time asserts into one declaration")
parser.add_argument("-T", "--taint", action="store", help="add taint information for the function parameters to the JSON database (default: dbtaint.json file in script directory)")
parser.add_argument("-fu", "--field-usage", required=False, action="store_true", help="Enable field usage information in JSON database (default: True)")
parser.add_argument("-i", "--include-path", action="store_true", help="Add clang builtin include path to underlying clang processor",required=False)
parser.add_argument("-L", "--additional-include-paths", action="append", help="Add additional include paths to underlying clang processor",required=False)
parser.add_argument("-E", "--processor-error", action="store_true", help="pass '-E' option to the underlying processor",required=False)
parser.add_argument("-DD", "--additional-defines", required=False, action="store", help="Path to JSON file that contains a list of additional preprocessor definitions to pass to all source files")
parser.add_argument("-mr", "--macro-replacement", required=False, action="store", help="Path to JSON file that describes macro replacement to be done on sources")
parser.add_argument("-me", "--macro-expansion", required=False, action="store_true", help="Enable tracking macro expansions for functions")
parser.add_argument("-sa", "--enable-static-assert", required=False, action="store_true", help="Enable printing of static_assert in definitions' code")
# for debugging
parser.add_argument("-r", "--range", action="store", help="Range of input files to process (e.g. \"0:60\")")
parser.add_argument("-c", "--compilation-list", action="store", help="List of compiled files to process (by default all unique compiled files from compilation database are processed)", required=False)
parser.add_argument("-e", "--exit-on-error", action="store_true", help="Stop and exit on first error encountered",required=False)
args = parser.parse_args()
sys.exit(jsonast.create_json_db_main(args))