Skip to content

Commit 3f932b8

Browse files
committed
SCons: Ensure scanner parses external includes
- Migrate remaining thirdparty includes from `CPPPATH` to `CPPEXTPATH`
1 parent 0f3e975 commit 3f932b8

File tree

12 files changed

+81
-39
lines changed

12 files changed

+81
-39
lines changed

SConstruct

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1163,6 +1163,12 @@ for key in (emitters := env.StaticObject.builder.emitter):
11631163
for key in (emitters := env.SharedObject.builder.emitter):
11641164
emitters[key] = ListEmitter([methods.redirect_emitter] + env.Flatten(emitters[key]))
11651165

1166+
# Ensure external paths are scanned for includes.
1167+
env["CSCANNERADVANCED"] = methods.c_scanner_advanced()
1168+
for key in (scanner_base := env["SCANNERS"][0]).get_skeys(env):
1169+
if isinstance(scanner_base.function[key], type(CScan)):
1170+
scanner_base.function[key] = env["CSCANNERADVANCED"]
1171+
11661172
# Prepend compiler launchers
11671173
if "c_compiler_launcher" in env:
11681174
env["CC"] = " ".join([env["c_compiler_launcher"], env["CC"]])

drivers/accesskit/SCsub

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ if env["accesskit_sdk_path"] == "":
1313
env.add_source_files(env.drivers_sources, "dynwrappers/accesskit-dylib_wrap.c")
1414
if env["platform"] == "linuxbsd":
1515
env.add_source_files(env.drivers_sources, "dynwrappers/accesskit-so_wrap.c")
16-
env.Prepend(CPPPATH=["#thirdparty/accesskit/include"])
16+
env.Prepend(CPPEXTPATH=["#thirdparty/accesskit/include"])

drivers/apple_embedded/SCsub

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ env_apple_embedded.Append(CCFLAGS=["-fmodules", "-fcxx-modules"])
1010

1111
# Use bundled Vulkan headers
1212
vulkan_dir = "#thirdparty/vulkan"
13-
env_apple_embedded.Prepend(CPPPATH=[vulkan_dir, vulkan_dir + "/include"])
13+
env_apple_embedded.Prepend(CPPEXTPATH=[vulkan_dir, vulkan_dir + "/include"])
1414

1515
# Driver source files
1616
env_apple_embedded.add_source_files(env.drivers_sources, "*.mm")

drivers/sdl/SCsub

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ if env["builtin_sdl"]:
1818
# Common sources.
1919

2020
env_sdl.Prepend(
21-
CPPPATH=[
21+
CPPEXTPATH=[
2222
thirdparty_dir,
2323
thirdparty_dir + "include",
2424
thirdparty_dir + "include/build_config",

methods.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,44 @@ def redirect_emitter(target, source, env):
106106
return redirected_targets, source
107107

108108

109+
_c_scanner_advanced = None
110+
111+
112+
def c_scanner_advanced():
113+
"""
114+
Returns a `ClassicCPP` subclass which accounts for external includes when parsing.
115+
"""
116+
117+
global _c_scanner_advanced
118+
if _c_scanner_advanced is not None:
119+
return _c_scanner_advanced
120+
121+
from SCons.Scanner import ClassicCPP
122+
123+
class AdvancedCPP(ClassicCPP):
124+
def __init__( # Default values lifted from SCons.Scanner.C.CScanner
125+
self,
126+
name="CScannerAdvanced",
127+
suffixes="$CPPSUFFIXES",
128+
path_variables=["CPPPATH", "CPPEXTPATH"],
129+
regex=r'^[ \t]*#[ \t]*(?:include|import)[ \t]*(<|")([^>"]+)(>|")',
130+
*args,
131+
**kwargs,
132+
) -> None:
133+
super().__init__(name, suffixes, "", regex, *args, **kwargs)
134+
self.path_variables = path_variables
135+
self.path_function = self._path_function
136+
137+
def _path_function(self, env, dir=None, target=None, source=None, argument=None):
138+
from SCons.PathList import PathList
139+
140+
paths = env.Flatten([env.get(path, []) for path in self.path_variables])
141+
return tuple((dir or env.fs._cwd).Rfindalldirs(PathList(paths).subst_path(env, target, source)))
142+
143+
_c_scanner_advanced = AdvancedCPP()
144+
return _c_scanner_advanced
145+
146+
109147
def disable_warnings(self):
110148
# 'self' is the environment
111149
if self.msvc and not using_clang(self):

modules/text_server_adv/SCsub

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,14 @@ if env["builtin_icu4c"]:
450450
]
451451
thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources]
452452

453-
if not env.editor_build:
453+
if env.editor_build:
454+
env_icu.CommandNoCache(
455+
"#thirdparty/icu4c/icudata.gen.h",
456+
"#thirdparty/icu4c/icudt_godot.dat",
457+
env.Run(text_server_adv_builders.make_icu_data),
458+
)
459+
env_text_server_adv.Prepend(CPPEXTPATH=["#thirdparty/icu4c/"])
460+
else:
454461
thirdparty_sources += ["icu_data/icudata_stub.cpp"]
455462

456463
env_icu.Prepend(CPPEXTPATH=["#thirdparty/icu4c/common/", "#thirdparty/icu4c/i18n/"])
@@ -487,15 +494,6 @@ if env["builtin_icu4c"]:
487494
lib = env_icu.add_library("icu_builtin", thirdparty_sources)
488495
thirdparty_obj += lib
489496

490-
if env.editor_build:
491-
icudata = env_icu.CommandNoCache(
492-
"#thirdparty/icu4c/icudata.gen.h",
493-
"#thirdparty/icu4c/icudt_godot.dat",
494-
env.Run(text_server_adv_builders.make_icu_data),
495-
)
496-
env_text_server_adv.Prepend(CPPEXTPATH=["#thirdparty/icu4c/"])
497-
env_icu.Depends(lib, icudata)
498-
499497
# Needs to be appended to arrive after libscene in the linker call,
500498
# but we don't want it to arrive *after* system libs, so manual hack
501499
# LIBS contains first SCons Library objects ("SCons.Node.FS.File object")

modules/text_server_adv/gdextension_build/SConstruct

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ if env["thorvg_enabled"] and env["freetype_enabled"]:
8484
thirdparty_tvg_sources = [thirdparty_tvg_dir + file for file in thirdparty_tvg_sources]
8585

8686
env_tvg.Append(
87-
CPPPATH=[
87+
CPPEXTPATH=[
8888
"../../../thirdparty/thorvg/inc",
8989
"../../../thirdparty/thorvg/src/common",
9090
"../../../thirdparty/thorvg/src/renderer",
@@ -101,7 +101,7 @@ if env["thorvg_enabled"] and env["freetype_enabled"]:
101101
env_tvg.Append(CPPDEFINES=["TVG_STATIC"])
102102

103103
env.Append(
104-
CPPPATH=[
104+
CPPEXTPATH=[
105105
"../../../thirdparty/thorvg/inc",
106106
"../../../thirdparty/thorvg/src/common",
107107
"../../../thirdparty/thorvg/src/renderer",
@@ -149,8 +149,8 @@ if env["msdfgen_enabled"] and env["freetype_enabled"]:
149149
thirdparty_msdfgen_sources = [thirdparty_msdfgen_dir + file for file in thirdparty_msdfgen_sources]
150150

151151
env_msdfgen.Append(CPPDEFINES=[("MSDFGEN_PUBLIC", "")])
152-
env_msdfgen.Append(CPPPATH=["../../../thirdparty/freetype/include", "../../../thirdparty/msdfgen"])
153-
env.Append(CPPPATH=["../../../thirdparty/msdfgen"])
152+
env_msdfgen.Append(CPPEXTPATH=["../../../thirdparty/freetype/include", "../../../thirdparty/msdfgen"])
153+
env.Append(CPPEXTPATH=["../../../thirdparty/msdfgen"])
154154
env.Append(CPPDEFINES=[("MSDFGEN_PUBLIC", "")])
155155
env.Append(CPPDEFINES=["MODULE_MSDFGEN_ENABLED"])
156156

@@ -265,11 +265,11 @@ if env["freetype_enabled"]:
265265
]
266266
thirdparty_freetype_sources += [thirdparty_brotli_dir + file for file in thirdparty_brotli_sources]
267267
env_freetype.Append(CPPDEFINES=["FT_CONFIG_OPTION_USE_BROTLI"])
268-
env_freetype.Prepend(CPPPATH=[thirdparty_brotli_dir + "include"])
268+
env_freetype.Prepend(CPPEXTPATH=[thirdparty_brotli_dir + "include"])
269269
env.Append(CPPDEFINES=["FT_CONFIG_OPTION_USE_BROTLI"])
270270

271-
env_freetype.Append(CPPPATH=[thirdparty_freetype_dir + "/include", thirdparty_zlib_dir, thirdparty_png_dir])
272-
env.Append(CPPPATH=[thirdparty_freetype_dir + "/include"])
271+
env_freetype.Append(CPPEXTPATH=[thirdparty_freetype_dir + "/include", thirdparty_zlib_dir, thirdparty_png_dir])
272+
env.Append(CPPEXTPATH=[thirdparty_freetype_dir + "/include"])
273273

274274
env_freetype.Append(
275275
CPPDEFINES=[
@@ -379,7 +379,7 @@ if env["freetype_enabled"]:
379379
thirdparty_harfbuzz_sources = [thirdparty_harfbuzz_dir + file for file in thirdparty_harfbuzz_sources]
380380

381381
env_harfbuzz.Append(
382-
CPPPATH=[
382+
CPPEXTPATH=[
383383
"../../../thirdparty/harfbuzz/src",
384384
"../../../thirdparty/icu4c/common/",
385385
"../../../thirdparty/icu4c/i18n/",
@@ -388,7 +388,7 @@ env_harfbuzz.Append(
388388

389389
if env["freetype_enabled"]:
390390
env_harfbuzz.Append(
391-
CPPPATH=[
391+
CPPEXTPATH=[
392392
"../../../thirdparty/freetype/include",
393393
"../../../thirdparty/graphite/include",
394394
]
@@ -416,7 +416,7 @@ if env["freetype_enabled"]:
416416
]
417417
)
418418

419-
env.Append(CPPPATH=["../../../thirdparty/harfbuzz/src"])
419+
env.Append(CPPEXTPATH=["../../../thirdparty/harfbuzz/src"])
420420

421421
lib = env_harfbuzz.Library(
422422
f"harfbuzz_builtin{env['suffix']}{env['LIBSUFFIX']}",
@@ -469,7 +469,7 @@ if env["graphite_enabled"] and env["freetype_enabled"]:
469469

470470
thirdparty_graphite_sources = [thirdparty_graphite_dir + file for file in thirdparty_graphite_sources]
471471

472-
env_graphite.Append(CPPPATH=["../../../thirdparty/graphite/src", "../../../thirdparty/graphite/include"])
472+
env_graphite.Append(CPPEXTPATH=["../../../thirdparty/graphite/src", "../../../thirdparty/graphite/include"])
473473
env_graphite.Append(
474474
CPPDEFINES=[
475475
"GRAPHITE2_STATIC",
@@ -704,11 +704,11 @@ if env["static_icu_data"]:
704704
"../../../thirdparty/icu4c/icudata.gen.h", "../../../thirdparty/icu4c/icudt_godot.dat", methods.make_icu_data
705705
)
706706
env.Append(CPPDEFINES=["ICU_STATIC_DATA"])
707-
env.Append(CPPPATH=["../../../thirdparty/icu4c/"])
707+
env.Append(CPPEXTPATH=["../../../thirdparty/icu4c/"])
708708
else:
709709
thirdparty_icu_sources += ["../icu_data/icudata_stub.cpp"]
710710

711-
env_icu.Append(CPPPATH=["../../../thirdparty/icu4c/common/", "../../../thirdparty/icu4c/i18n/"])
711+
env_icu.Append(CPPEXTPATH=["../../../thirdparty/icu4c/common/", "../../../thirdparty/icu4c/i18n/"])
712712
env_icu.Append(
713713
CPPDEFINES=[
714714
"U_STATIC_IMPLEMENTATION",
@@ -733,7 +733,7 @@ env.Append(
733733
("U_LIB_SUFFIX_C_NAME", "_godot"),
734734
]
735735
)
736-
env.Append(CPPPATH=["../../../thirdparty/icu4c/common/", "../../../thirdparty/icu4c/i18n/"])
736+
env.Append(CPPEXTPATH=["../../../thirdparty/icu4c/common/", "../../../thirdparty/icu4c/i18n/"])
737737

738738
if env["platform"] == "windows":
739739
env.Append(LIBS=["advapi32"])

modules/text_server_fb/gdextension_build/SConstruct

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ if env["thorvg_enabled"] and env["freetype_enabled"]:
7979
thirdparty_tvg_sources = [thirdparty_tvg_dir + file for file in thirdparty_tvg_sources]
8080

8181
env_tvg.Append(
82-
CPPPATH=[
82+
CPPEXTPATH=[
8383
"../../../thirdparty/thorvg/inc",
8484
"../../../thirdparty/thorvg/src/common",
8585
"../../../thirdparty/thorvg/src/renderer",
@@ -96,7 +96,7 @@ if env["thorvg_enabled"] and env["freetype_enabled"]:
9696
env_tvg.Append(CPPDEFINES=["TVG_STATIC"])
9797

9898
env.Append(
99-
CPPPATH=[
99+
CPPEXTPATH=[
100100
"../../../thirdparty/thorvg/inc",
101101
"../../../thirdparty/thorvg/src/common",
102102
"../../../thirdparty/thorvg/src/renderer",
@@ -144,8 +144,8 @@ if env["msdfgen_enabled"] and env["freetype_enabled"]:
144144
thirdparty_msdfgen_sources = [thirdparty_msdfgen_dir + file for file in thirdparty_msdfgen_sources]
145145

146146
env_msdfgen.Append(CPPDEFINES=[("MSDFGEN_PUBLIC", "")])
147-
env_msdfgen.Append(CPPPATH=["../../../thirdparty/freetype/include", "../../../thirdparty/msdfgen"])
148-
env.Append(CPPPATH=["../../../thirdparty/msdfgen"])
147+
env_msdfgen.Append(CPPEXTPATH=["../../../thirdparty/freetype/include", "../../../thirdparty/msdfgen"])
148+
env.Append(CPPEXTPATH=["../../../thirdparty/msdfgen"])
149149
env.Append(CPPDEFINES=[("MSDFGEN_PUBLIC", "")])
150150
env.Append(CPPDEFINES=["MODULE_MSDFGEN_ENABLED"])
151151

@@ -260,11 +260,11 @@ if env["freetype_enabled"]:
260260
]
261261
thirdparty_freetype_sources += [thirdparty_brotli_dir + file for file in thirdparty_brotli_sources]
262262
env_freetype.Append(CPPDEFINES=["FT_CONFIG_OPTION_USE_BROTLI"])
263-
env_freetype.Prepend(CPPPATH=[thirdparty_brotli_dir + "include"])
263+
env_freetype.Prepend(CPPEXTPATH=[thirdparty_brotli_dir + "include"])
264264
env.Append(CPPDEFINES=["FT_CONFIG_OPTION_USE_BROTLI"])
265265

266-
env_freetype.Append(CPPPATH=[thirdparty_freetype_dir + "/include", thirdparty_zlib_dir, thirdparty_png_dir])
267-
env.Append(CPPPATH=[thirdparty_freetype_dir + "/include"])
266+
env_freetype.Append(CPPEXTPATH=[thirdparty_freetype_dir + "/include", thirdparty_zlib_dir, thirdparty_png_dir])
267+
env.Append(CPPEXTPATH=[thirdparty_freetype_dir + "/include"])
268268

269269
env_freetype.Append(
270270
CPPDEFINES=[

platform/linuxbsd/detect.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,7 @@ def configure(env: "SConsEnvironment"):
488488

489489
if env["accesskit"]:
490490
if env["accesskit_sdk_path"] != "":
491-
env.Prepend(CPPPATH=[env["accesskit_sdk_path"] + "/include"])
491+
env.Prepend(CPPEXTPATH=[env["accesskit_sdk_path"] + "/include"])
492492
if env["arch"] == "arm64":
493493
env.Append(LIBPATH=[env["accesskit_sdk_path"] + "/lib/linux/arm64/static/"])
494494
elif env["arch"] == "arm32":

platform/macos/detect.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ def configure(env: "SConsEnvironment"):
184184

185185
if env["accesskit"]:
186186
if env["accesskit_sdk_path"] != "":
187-
env.Prepend(CPPPATH=[env["accesskit_sdk_path"] + "/include"])
187+
env.Prepend(CPPEXTPATH=[env["accesskit_sdk_path"] + "/include"])
188188
if env["arch"] == "arm64" or env["arch"] == "universal":
189189
env.Append(LINKFLAGS=["-L" + env["accesskit_sdk_path"] + "/lib/macos/arm64/static/"])
190190
if env["arch"] == "x86_64" or env["arch"] == "universal":

0 commit comments

Comments
 (0)