Skip to content

Commit c723b7c

Browse files
committed
Fix compile_commands.json having incorrect include paths for clean builds in some scenarios
Assisted-by: Claude Opus 4.7
1 parent dc70d15 commit c723b7c

7 files changed

Lines changed: 31 additions & 4 deletions

File tree

CHANGES.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER
9494
- Update documentation for linking-related construction variables.
9595
Add a few more live links.
9696

97+
From Will Toohey:
98+
- Fix compile_commands.json having incorrect include paths for clean builds in some scenarios
9799

98100
RELEASE 4.10.1 - Sun, 16 Nov 2025 10:51:57 -0700
99101

RELEASE.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ FIXES
5151
directory for each writer before doing the move, instead of depending
5252
on a one-time uuid to make a path to the file.
5353

54+
- Fix compile_commands.json having incorrect include paths for clean builds in some scenarios
55+
5456
IMPROVEMENTS
5557
------------
5658

SCons/Node/FS.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3305,7 +3305,6 @@ def built(self) -> None:
33053305
self._specific_sources = False
33063306
self._labspath = ""
33073307
self._save_str()
3308-
self.cwd = None
33093308

33103309
self.scanner_paths = None
33113310

test/CompilationDatabase/fixture/SConstruct_variant

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,5 @@ env.Program('build2/main', 'build2/test_main.c')
4949
env.VariantDir('build3','src', duplicate=0)
5050
env.InstallAs('build3/test_main_copy.c', 'src/test_main.c')
5151
env.Program('build3/main', 'build3/test_main_copy.c')
52+
53+
SConscript('src/SConscript_cpppath', variant_dir='build4', duplicate=0, exports={'env': env})
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Import('env')
2+
env.Object('test_main.c', CPPPATH=['inc'])

test/CompilationDatabase/variant_dir.py

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040

4141
test.verbose_set(1)
4242
test.file_fixture('fixture/SConstruct_variant', 'SConstruct')
43+
test.file_fixture('fixture/src_SConscript_cpppath', 'src/SConscript_cpppath')
4344
test.file_fixture('test_main.c', 'src/test_main.c')
4445
test.run()
4546

@@ -84,6 +85,12 @@
8485
"directory": "%(workdir)s",
8586
"file": "%(variant3_src_file)s",
8687
"output": "%(output3_file)s"
88+
},
89+
{
90+
"command": "%(exe)s mygcc.py cc -o %(output4_file)s -c -I%(inc_build4)s -I%(inc_src)s %(src_file)s",
91+
"directory": "%(workdir)s",
92+
"file": "%(src_file)s",
93+
"output": "%(output4_file)s"
8794
}
8895
]
8996
""" % {'exe': sys.executable,
@@ -92,8 +99,11 @@
9299
'output_file': os.path.join('build', 'test_main.o'),
93100
'output2_file': os.path.join('build2', 'test_main.o'),
94101
'output3_file': os.path.join('build3', 'test_main_copy.o'),
102+
'output4_file': os.path.join('build4', 'test_main.o'),
95103
'variant_src_file': os.path.join('build', 'test_main.c'),
96-
'variant3_src_file': os.path.join('build3', 'test_main_copy.c')
104+
'variant3_src_file': os.path.join('build3', 'test_main_copy.c'),
105+
'inc_build4': os.path.join('build4', 'inc'),
106+
'inc_src': os.path.join('src', 'inc'),
97107
}
98108

99109
if sys.platform == 'win32':
@@ -122,6 +132,12 @@
122132
"directory": "%(workdir)s",
123133
"file": "%(abs_variant3_src_file)s",
124134
"output": "%(abs_output3_file)s"
135+
},
136+
{
137+
"command": "%(exe)s mygcc.py cc -o %(output4_file)s -c -I%(inc_build4)s -I%(inc_src)s %(src_file)s",
138+
"directory": "%(workdir)s",
139+
"file": "%(abs_src_file)s",
140+
"output": "%(abs_output4_file)s"
125141
}
126142
]
127143
""" % {'exe': sys.executable,
@@ -131,12 +147,16 @@
131147
'abs_output_file': os.path.join(test.workdir, 'build', 'test_main.o'),
132148
'abs_output2_file': os.path.join(test.workdir, 'build2', 'test_main.o'),
133149
'abs_output3_file': os.path.join(test.workdir, 'build3', 'test_main_copy.o'),
150+
'abs_output4_file': os.path.join(test.workdir, 'build4', 'test_main.o'),
134151
'output_file': os.path.join('build', 'test_main.o'),
135152
'output2_file': os.path.join('build2', 'test_main.o'),
136153
'output3_file': os.path.join('build3', 'test_main_copy.o'),
154+
'output4_file': os.path.join('build4', 'test_main.o'),
137155
'abs_variant3_src_file': os.path.join(test.workdir, 'build3', 'test_main_copy.c'),
138156
'variant_src_file': os.path.join('build', 'test_main.c'),
139-
'variant3_src_file': os.path.join('build3', 'test_main_copy.c')
157+
'variant3_src_file': os.path.join('build3', 'test_main_copy.c'),
158+
'inc_build4': os.path.join('build4', 'inc'),
159+
'inc_src': os.path.join('src', 'inc'),
140160
}
141161

142162
if sys.platform == 'win32':

test/fixture/mygcc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def fake_gcc():
3333
sys.exit(0)
3434

3535
compiler = sys.argv[1].encode('utf-8')
36-
opts, args = getopt.getopt(sys.argv[2:], 'co:xf:K:')
36+
opts, args = getopt.getopt(sys.argv[2:], 'co:xf:K:I:')
3737
for opt, arg in opts:
3838
if opt == '-o':
3939
out = arg

0 commit comments

Comments
 (0)