mirror of
https://github.com/AntonioND/architectds.git
synced 2025-06-18 16:45:32 -04:00
core: docs: Add support to generate compile_commands.json
Thanks to ninja-build, all we need to do is to run one command [1] and we can get a compile_commands.json from a ninja.build file. This commit adds a new argument (-j or --compdb) to let users generate a compile_commands.json file. [1] https://ninja-build.org/manual.html#_extra_tools
This commit is contained in:
parent
f2aa6f6e0d
commit
fc09001a4b
@ -177,14 +177,15 @@ class GenericBinary():
|
|||||||
clean = '-c' in args or '--clean' in args
|
clean = '-c' in args or '--clean' in args
|
||||||
graph = '-g' in args or '--graph' in args
|
graph = '-g' in args or '--graph' in args
|
||||||
help_ = '-h' in args or '--help' in args
|
help_ = '-h' in args or '--help' in args
|
||||||
|
compdb = '-j' in args or '--compdb' in args
|
||||||
ninja = '-n' in args or '--ninja' in args
|
ninja = '-n' in args or '--ninja' in args
|
||||||
|
|
||||||
# Build ROM if the script has been called with no arguments.
|
# Build ROM if the script has been called with no arguments.
|
||||||
if not build and not clean and not graph and not ninja and not help_:
|
if not (build or clean or compdb or graph or ninja or help_):
|
||||||
build = True
|
build = True
|
||||||
|
|
||||||
# If there is any argument that requires the ninja file, generate it.
|
# If there is any argument that requires the ninja file, generate it.
|
||||||
if build or graph:
|
if build or compdb or graph:
|
||||||
ninja = True
|
ninja = True
|
||||||
|
|
||||||
if help_:
|
if help_:
|
||||||
@ -192,11 +193,12 @@ class GenericBinary():
|
|||||||
print('')
|
print('')
|
||||||
print('Options:')
|
print('Options:')
|
||||||
print('')
|
print('')
|
||||||
print(' -b / --build : Generate ninja file and build ROM.')
|
print(' -b / --build : Generate ninja file and build ROM.')
|
||||||
print(' -c / --clean : Clean build outputs and ninja file.')
|
print(' -c / --clean : Clean build outputs and ninja file.')
|
||||||
print(' -g / --graph : Generate dependency graph as a PNG file.')
|
print(' -g / --graph : Generate dependency graph as a PNG file.')
|
||||||
print(' -n / --ninja : Generate ninja file.')
|
print(' -n / --ninja : Only generate ninja file.')
|
||||||
print(' -h / --help : Show this message.')
|
print(' -j / --compdb : Generate compile_commands.json.')
|
||||||
|
print(' -h / --help : Show this message.')
|
||||||
print('')
|
print('')
|
||||||
print('If no option is used, the tool will act the same as if')
|
print('If no option is used, the tool will act the same as if')
|
||||||
print('--build had been used.')
|
print('--build had been used.')
|
||||||
@ -224,6 +226,13 @@ class GenericBinary():
|
|||||||
my_env["BLOCKSDS"] = BLOCKSDS
|
my_env["BLOCKSDS"] = BLOCKSDS
|
||||||
subprocess.run(['ninja', '-f', ninja_file_path], env=my_env)
|
subprocess.run(['ninja', '-f', ninja_file_path], env=my_env)
|
||||||
|
|
||||||
|
if compdb:
|
||||||
|
print('[*] COMPDB')
|
||||||
|
proc = subprocess.run(['ninja', '-f', ninja_file_path, '-t', 'compdb'],
|
||||||
|
encoding='utf-8', stdout=subprocess.PIPE)
|
||||||
|
with open('compile_commands.json', 'w') as f:
|
||||||
|
f.write(proc.stdout)
|
||||||
|
|
||||||
if graph:
|
if graph:
|
||||||
print('[*] GRAPH')
|
print('[*] GRAPH')
|
||||||
ninja_process = subprocess.Popen(
|
ninja_process = subprocess.Popen(
|
||||||
|
@ -276,6 +276,8 @@ arguments passed to the python script:
|
|||||||
|
|
||||||
- ``python3 build.py --clean``: Clean all build files.
|
- ``python3 build.py --clean``: Clean all build files.
|
||||||
|
|
||||||
|
- ``python3 build.py --compdb``: Generate a ``compile_commands.json`` file.
|
||||||
|
|
||||||
- ``python3 build.py --graph``: If you have ``graphviz`` installed in your
|
- ``python3 build.py --graph``: If you have ``graphviz`` installed in your
|
||||||
system, this will generate a PNG file with the dependency graph of your
|
system, this will generate a PNG file with the dependency graph of your
|
||||||
project.
|
project.
|
||||||
|
Loading…
Reference in New Issue
Block a user