[tools] Add --cdb to make compile_commands.json.
This commit is contained in:
parent
b632dc1aaf
commit
c4e7a0e5e3
|
@ -850,6 +850,11 @@ def DoBuilding(target, objects):
|
||||||
objects = sorted(objects)
|
objects = sorted(objects)
|
||||||
objects.append(objects_in_group)
|
objects.append(objects_in_group)
|
||||||
|
|
||||||
|
# generate build/compile_commands.json
|
||||||
|
if GetOption('cdb') and utils.VerTuple(SCons.__version__) >= (4, 0, 0):
|
||||||
|
Env.Tool("compilation_db")
|
||||||
|
Env.CompilationDatabase('build/compile_commands.json')
|
||||||
|
|
||||||
program = Env.Program(target, objects)
|
program = Env.Program(target, objects)
|
||||||
|
|
||||||
EndBuilding(target, program)
|
EndBuilding(target, program)
|
||||||
|
|
|
@ -136,3 +136,8 @@ def AddOptions():
|
||||||
action = 'store_true',
|
action = 'store_true',
|
||||||
default = False,
|
default = False,
|
||||||
help = 'make menuconfig for RT-Thread BSP')
|
help = 'make menuconfig for RT-Thread BSP')
|
||||||
|
AddOption('--cdb',
|
||||||
|
dest = 'cdb',
|
||||||
|
action = 'store_true',
|
||||||
|
default = False,
|
||||||
|
help = 'make compile_commands.json')
|
||||||
|
|
|
@ -303,3 +303,9 @@ def ImportModule(module):
|
||||||
return module
|
return module
|
||||||
else:
|
else:
|
||||||
return __import__(module, fromlist=[module])
|
return __import__(module, fromlist=[module])
|
||||||
|
|
||||||
|
def VerTuple(version_str):
|
||||||
|
ver_parts = version_str.split('.')
|
||||||
|
ver = tuple(int(part) for part in ver_parts)
|
||||||
|
|
||||||
|
return ver
|
||||||
|
|
11
tools/vsc.py
11
tools/vsc.py
|
@ -52,12 +52,19 @@ def GenerateCFiles(env):
|
||||||
cc = os.path.abspath(cc).replace('\\', '/')
|
cc = os.path.abspath(cc).replace('\\', '/')
|
||||||
|
|
||||||
config_obj = {}
|
config_obj = {}
|
||||||
config_obj['name'] = 'Win32'
|
config_obj['name'] = 'rt-thread'
|
||||||
config_obj['defines'] = info['CPPDEFINES']
|
config_obj['defines'] = info['CPPDEFINES']
|
||||||
config_obj['intelliSenseMode'] = 'clang-x64'
|
|
||||||
|
intelliSenseMode = 'gcc-arm'
|
||||||
|
if cc.find('aarch64') != -1:
|
||||||
|
intelliSenseMode = 'gcc-arm64'
|
||||||
|
elif cc.find('arm') != -1:
|
||||||
|
intelliSenseMode = 'gcc-arm'
|
||||||
|
config_obj['intelliSenseMode'] = intelliSenseMode
|
||||||
config_obj['compilerPath'] = cc
|
config_obj['compilerPath'] = cc
|
||||||
config_obj['cStandard'] = "c99"
|
config_obj['cStandard'] = "c99"
|
||||||
config_obj['cppStandard'] = "c++11"
|
config_obj['cppStandard'] = "c++11"
|
||||||
|
config_obj['compileCommands'] ="build/compile_commands.json"
|
||||||
|
|
||||||
# format "a/b," to a/b. remove first quotation mark("),and remove end (",)
|
# format "a/b," to a/b. remove first quotation mark("),and remove end (",)
|
||||||
includePath = []
|
includePath = []
|
||||||
|
|
Loading…
Reference in New Issue