summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoraka-adi <[email protected]>2025-01-03 00:17:56 +0800
committerGitHub <[email protected]>2025-01-03 00:17:56 +0800
commit9291946c74524bab2d4d8ccd44e0450671607462 (patch)
tree9ec03af7c0276db09db5b83cd036434bb9421f11
parent73ea6dab02f82f5a2259c914653a9d742fa322bd (diff)
[tools]: fix the issue of missing commands in compile_commands.json (#9856)
* [tools]: fix the issue of missing commands in compile_commands.json * [tools]: fix the path of compile_commands.json
-rw-r--r--tools/building.py10
-rw-r--r--tools/vsc.py10
2 files changed, 10 insertions, 10 deletions
diff --git a/tools/building.py b/tools/building.py
index 61fd040ff4..471f3f2e8a 100644
--- a/tools/building.py
+++ b/tools/building.py
@@ -823,6 +823,11 @@ def DoBuilding(target, objects):
break
else:
+ # 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')
+
# remove source files with local flags setting
for group in Projects:
if 'LOCAL_CFLAGS' in group or 'LOCAL_CXXFLAGS' in group or 'LOCAL_CCFLAGS' in group or 'LOCAL_CPPPATH' in group or 'LOCAL_CPPDEFINES' in group:
@@ -843,11 +848,6 @@ def DoBuilding(target, objects):
objects = sorted(objects)
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)
EndBuilding(target, program)
diff --git a/tools/vsc.py b/tools/vsc.py
index b0c9daf46a..c005bcf053 100644
--- a/tools/vsc.py
+++ b/tools/vsc.py
@@ -162,7 +162,7 @@ def generate_code_workspace_file(source_dirs,command_json_path,root_path):
def command_json_to_workspace(root_path,command_json_path):
- with open('compile_commands.json', 'r') as f:
+ with open('build/compile_commands.json', 'r') as f:
compile_commands = json.load(f)
source_dirs = extract_source_dirs(compile_commands)
@@ -246,11 +246,11 @@ def GenerateCFiles(env):
vsc_file.close()
"""
- Generate vscode.code-workspace files by compile_commands.json
+ Generate vscode.code-workspace files by build/compile_commands.json
"""
- if os.path.exists('compile_commands.json'):
+ if os.path.exists('build/compile_commands.json'):
- command_json_to_workspace(env['RTT_ROOT'],'compile_commands.json')
+ command_json_to_workspace(env['RTT_ROOT'],'build/compile_commands.json')
return
"""
Generate vscode.code-workspace files
@@ -282,7 +282,7 @@ def GenerateCFiles(env):
segments = [p for p in normalized_path.split(os.path.sep) if p != '..']
path['name'] = 'rtthread/' + '/'.join(segments)
json_obj['folders'] = path_list
- if os.path.exists('compile_commands.json'):
+ if os.path.exists('build/compile_commands.json'):
json_obj['settings'] = {
"clangd.arguments": [
"--compile-commands-dir=.",