diff --git a/CHANGES.txt b/CHANGES.txt index f56910c97b..20cb47019e 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -94,6 +94,10 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER - Update documentation for linking-related construction variables. Add a few more live links. + From Will Toohey: + - Fix compile_commands.json having incorrect include paths for clean builds + when a variant dir is used, duplicate=0, and a relative CPPPATH is used in + a child SConscript. RELEASE 4.10.1 - Sun, 16 Nov 2025 10:51:57 -0700 diff --git a/RELEASE.txt b/RELEASE.txt index 36a06067a4..88c7991b25 100644 --- a/RELEASE.txt +++ b/RELEASE.txt @@ -51,6 +51,9 @@ FIXES directory for each writer before doing the move, instead of depending on a one-time uuid to make a path to the file. +- Fix compile_commands.json having incorrect include paths for clean builds when a + variant dir is used, duplicate=0, and a relative CPPPATH is used in a child SConscript. + IMPROVEMENTS ------------ diff --git a/SCons/Node/FS.py b/SCons/Node/FS.py index 4420a83c32..d7c6376654 100644 --- a/SCons/Node/FS.py +++ b/SCons/Node/FS.py @@ -3305,7 +3305,6 @@ def built(self) -> None: self._specific_sources = False self._labspath = "" self._save_str() - self.cwd = None self.scanner_paths = None diff --git a/test/CompilationDatabase/fixture/SConstruct_variant b/test/CompilationDatabase/fixture/SConstruct_variant index c70c5273be..cd78a4d228 100644 --- a/test/CompilationDatabase/fixture/SConstruct_variant +++ b/test/CompilationDatabase/fixture/SConstruct_variant @@ -49,3 +49,5 @@ env.Program('build2/main', 'build2/test_main.c') env.VariantDir('build3','src', duplicate=0) env.InstallAs('build3/test_main_copy.c', 'src/test_main.c') env.Program('build3/main', 'build3/test_main_copy.c') + +SConscript('src/SConscript_cpppath', variant_dir='build4', duplicate=0, exports={'env': env}) diff --git a/test/CompilationDatabase/fixture/src_SConscript_cpppath b/test/CompilationDatabase/fixture/src_SConscript_cpppath new file mode 100644 index 0000000000..8b50de9080 --- /dev/null +++ b/test/CompilationDatabase/fixture/src_SConscript_cpppath @@ -0,0 +1,2 @@ +Import('env') +env.Object('test_main.c', CPPPATH=['inc']) diff --git a/test/CompilationDatabase/variant_dir.py b/test/CompilationDatabase/variant_dir.py index b0441fa9cb..d462fed43a 100644 --- a/test/CompilationDatabase/variant_dir.py +++ b/test/CompilationDatabase/variant_dir.py @@ -40,6 +40,7 @@ test.verbose_set(1) test.file_fixture('fixture/SConstruct_variant', 'SConstruct') +test.file_fixture('fixture/src_SConscript_cpppath', 'src/SConscript_cpppath') test.file_fixture('test_main.c', 'src/test_main.c') test.run() @@ -84,6 +85,12 @@ "directory": "%(workdir)s", "file": "%(variant3_src_file)s", "output": "%(output3_file)s" + }, + { + "command": "%(exe)s mygcc.py cc -o %(output4_file)s -c -I%(inc_build4)s -I%(inc_src)s %(src_file)s", + "directory": "%(workdir)s", + "file": "%(src_file)s", + "output": "%(output4_file)s" } ] """ % {'exe': sys.executable, @@ -92,8 +99,11 @@ 'output_file': os.path.join('build', 'test_main.o'), 'output2_file': os.path.join('build2', 'test_main.o'), 'output3_file': os.path.join('build3', 'test_main_copy.o'), + 'output4_file': os.path.join('build4', 'test_main.o'), 'variant_src_file': os.path.join('build', 'test_main.c'), - 'variant3_src_file': os.path.join('build3', 'test_main_copy.c') + 'variant3_src_file': os.path.join('build3', 'test_main_copy.c'), + 'inc_build4': os.path.join('build4', 'inc'), + 'inc_src': os.path.join('src', 'inc'), } if sys.platform == 'win32': @@ -122,6 +132,12 @@ "directory": "%(workdir)s", "file": "%(abs_variant3_src_file)s", "output": "%(abs_output3_file)s" + }, + { + "command": "%(exe)s mygcc.py cc -o %(output4_file)s -c -I%(inc_build4)s -I%(inc_src)s %(src_file)s", + "directory": "%(workdir)s", + "file": "%(abs_src_file)s", + "output": "%(abs_output4_file)s" } ] """ % {'exe': sys.executable, @@ -131,12 +147,16 @@ 'abs_output_file': os.path.join(test.workdir, 'build', 'test_main.o'), 'abs_output2_file': os.path.join(test.workdir, 'build2', 'test_main.o'), 'abs_output3_file': os.path.join(test.workdir, 'build3', 'test_main_copy.o'), + 'abs_output4_file': os.path.join(test.workdir, 'build4', 'test_main.o'), 'output_file': os.path.join('build', 'test_main.o'), 'output2_file': os.path.join('build2', 'test_main.o'), 'output3_file': os.path.join('build3', 'test_main_copy.o'), + 'output4_file': os.path.join('build4', 'test_main.o'), 'abs_variant3_src_file': os.path.join(test.workdir, 'build3', 'test_main_copy.c'), 'variant_src_file': os.path.join('build', 'test_main.c'), - 'variant3_src_file': os.path.join('build3', 'test_main_copy.c') + 'variant3_src_file': os.path.join('build3', 'test_main_copy.c'), + 'inc_build4': os.path.join('build4', 'inc'), + 'inc_src': os.path.join('src', 'inc'), } if sys.platform == 'win32': diff --git a/test/fixture/mygcc.py b/test/fixture/mygcc.py index 0e65bac07b..435d5ef52b 100644 --- a/test/fixture/mygcc.py +++ b/test/fixture/mygcc.py @@ -33,7 +33,7 @@ def fake_gcc(): sys.exit(0) compiler = sys.argv[1].encode('utf-8') - opts, args = getopt.getopt(sys.argv[2:], 'co:xf:K:') + opts, args = getopt.getopt(sys.argv[2:], 'co:xf:K:I:') for opt, arg in opts: if opt == '-o': out = arg