Skip to content

Commit 1f56d96

Browse files
authored
Merge pull request #104893 from Repiteo/scons/external-includes-alt
SCons: Add `CPPEXTPATH` for external includes
2 parents c9c8556 + f25fc34 commit 1f56d96

File tree

55 files changed

+141
-290
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+141
-290
lines changed

SConstruct

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ from types import ModuleType
1515

1616
from SCons import __version__ as scons_raw_version
1717
from SCons.Builder import ListEmitter
18+
from SCons.Util import CLVar
1819

1920
# Explicitly resolve the helper modules, this is done to avoid clash with
2021
# modules of the same name that might be randomly added (e.g. someone adding
@@ -445,10 +446,19 @@ for tool in custom_tools:
445446
env.Tool(tool)
446447

447448

448-
# add default include paths
449-
449+
# Add default include paths.
450450
env.Prepend(CPPPATH=["#"])
451451

452+
# Allow marking includes as external/system to avoid raising warnings.
453+
env["_CCCOMCOM"] += " $_CPPEXTINCFLAGS"
454+
env["CPPEXTPATH"] = CLVar("")
455+
if env.scons_version < (4, 2):
456+
env["_CPPEXTINCFLAGS"] = "${_concat(EXTINCPREFIX, CPPEXTPATH, EXTINCSUFFIX, __env__, RDirs, TARGET, SOURCE)}"
457+
else:
458+
env["_CPPEXTINCFLAGS"] = (
459+
"${_concat(EXTINCPREFIX, CPPEXTPATH, EXTINCSUFFIX, __env__, RDirs, TARGET, SOURCE, affect_signature=False)}"
460+
)
461+
452462
# configure ENV for platform
453463
env.platform_exporters = platform_exporters
454464
env.platform_apis = platform_apis
@@ -912,6 +922,17 @@ else: # GCC, Clang
912922
if env["werror"]:
913923
env.Append(CCFLAGS=["-Werror"])
914924

925+
# Configure external includes.
926+
if env.msvc:
927+
if cc_version_major < 16 or (cc_version_major == 16 and cc_version_minor < 10):
928+
env.AppendUnique(CCFLAGS=["/experimental:external"])
929+
env.AppendUnique(CCFLAGS=["/external:W0"])
930+
env["EXTINCPREFIX"] = "/external:I"
931+
env["EXTINCSUFFIX"] = ""
932+
else:
933+
env["EXTINCPREFIX"] = "-isystem "
934+
env["EXTINCSUFFIX"] = ""
935+
915936
if hasattr(detect, "get_program_suffix"):
916937
suffix = "." + detect.get_program_suffix()
917938
else:

core/SCsub

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ if env["brotli"] and env["builtin_brotli"]:
5151
]
5252
thirdparty_brotli_sources = [thirdparty_brotli_dir + file for file in thirdparty_brotli_sources]
5353

54-
env_thirdparty.Prepend(CPPPATH=[thirdparty_brotli_dir + "include"])
55-
env.Prepend(CPPPATH=[thirdparty_brotli_dir + "include"])
54+
env_thirdparty.Prepend(CPPEXTPATH=[thirdparty_brotli_dir + "include"])
55+
env.Prepend(CPPEXTPATH=[thirdparty_brotli_dir + "include"])
5656

5757
if env.get("use_ubsan") or env.get("use_asan") or env.get("use_tsan") or env.get("use_lsan") or env.get("use_msan"):
5858
env_thirdparty.Append(CPPDEFINES=["BROTLI_BUILD_PORTABLE"])
@@ -69,8 +69,8 @@ if env["builtin_clipper2"]:
6969
]
7070
thirdparty_clipper_sources = [thirdparty_clipper_dir + file for file in thirdparty_clipper_sources]
7171

72-
env_thirdparty.Prepend(CPPPATH=[thirdparty_clipper_dir + "include"])
73-
env.Prepend(CPPPATH=[thirdparty_clipper_dir + "include"])
72+
env_thirdparty.Prepend(CPPEXTPATH=[thirdparty_clipper_dir + "include"])
73+
env.Prepend(CPPEXTPATH=[thirdparty_clipper_dir + "include"])
7474

7575
env_thirdparty.Append(CPPDEFINES=["CLIPPER2_ENABLED"])
7676
env.Append(CPPDEFINES=["CLIPPER2_ENABLED"])
@@ -94,9 +94,9 @@ if env["builtin_zlib"]:
9494
]
9595
thirdparty_zlib_sources = [thirdparty_zlib_dir + file for file in thirdparty_zlib_sources]
9696

97-
env_thirdparty.Prepend(CPPPATH=[thirdparty_zlib_dir])
97+
env_thirdparty.Prepend(CPPEXTPATH=[thirdparty_zlib_dir])
9898
# Needs to be available in main env too
99-
env.Prepend(CPPPATH=[thirdparty_zlib_dir])
99+
env.Prepend(CPPEXTPATH=[thirdparty_zlib_dir])
100100
if env.dev_build:
101101
env_thirdparty.Append(CPPDEFINES=["ZLIB_DEBUG"])
102102
# Affects headers so it should also be defined for Godot code
@@ -148,9 +148,9 @@ if env["builtin_zstd"]:
148148
thirdparty_zstd_sources.append("decompress/huf_decompress_amd64.S")
149149
thirdparty_zstd_sources = [thirdparty_zstd_dir + file for file in thirdparty_zstd_sources]
150150

151-
env_thirdparty.Prepend(CPPPATH=[thirdparty_zstd_dir, thirdparty_zstd_dir + "common"])
151+
env_thirdparty.Prepend(CPPEXTPATH=[thirdparty_zstd_dir, thirdparty_zstd_dir + "common"])
152152
env_thirdparty.Append(CPPDEFINES=["ZSTD_STATIC_LINKING_ONLY"])
153-
env.Prepend(CPPPATH=thirdparty_zstd_dir)
153+
env.Prepend(CPPEXTPATH=thirdparty_zstd_dir)
154154
# Also needed in main env includes will trigger warnings
155155
env.Append(CPPDEFINES=["ZSTD_STATIC_LINKING_ONLY"])
156156

core/crypto/SCsub

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ if is_builtin or not has_module:
1313
# Use our headers for builtin or if the module is not going to be compiled.
1414
# We decided not to depend on system mbedtls just for these few files that can
1515
# be easily extracted.
16-
env_crypto.Prepend(CPPPATH=["#thirdparty/mbedtls/include"])
16+
env_crypto.Prepend(CPPEXTPATH=["#thirdparty/mbedtls/include"])
1717

1818
# MbedTLS core functions (for CryptoCore).
1919
# If the mbedtls module is compiled we don't need to add the .c files with our

drivers/backtrace/SCsub

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ thirdparty_sources = [
2626
]
2727
thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources]
2828

29-
env_backtrace.Prepend(CPPPATH=[thirdparty_dir])
29+
env_backtrace.Prepend(CPPEXTPATH=[thirdparty_dir])
3030

3131
env_thirdparty = env_backtrace.Clone()
3232
env_thirdparty.disable_warnings()

drivers/d3d12/SCsub

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@ thirdparty_obj = []
1515

1616
# DirectX Headers (must take precedence over Windows SDK's).
1717

18-
env.Prepend(CPPPATH=["#thirdparty/directx_headers/include/directx"])
19-
env_d3d12_rdd.Prepend(CPPPATH=["#thirdparty/directx_headers/include/directx"])
20-
env_d3d12_rdd.Prepend(CPPPATH=["#thirdparty/directx_headers/include/dxguids"])
18+
env.Prepend(CPPEXTPATH=["#thirdparty/directx_headers/include/directx"])
19+
env_d3d12_rdd.Prepend(CPPEXTPATH=["#thirdparty/directx_headers/include/directx"])
20+
env_d3d12_rdd.Prepend(CPPEXTPATH=["#thirdparty/directx_headers/include/dxguids"])
2121

2222

2323
# Direct3D 12 Memory Allocator.
2424

25-
env.Append(CPPPATH=["#thirdparty/d3d12ma"])
26-
env_d3d12_rdd.Append(CPPPATH=["#thirdparty/d3d12ma"])
25+
env.Append(CPPEXTPATH=["#thirdparty/d3d12ma"])
26+
env_d3d12_rdd.Append(CPPEXTPATH=["#thirdparty/d3d12ma"])
2727

2828

2929
# Agility SDK.
@@ -38,7 +38,7 @@ if env["agility_sdk_path"] != "" and os.path.exists(env["agility_sdk_path"]):
3838

3939
if env["use_pix"]:
4040
env_d3d12_rdd.Append(CPPDEFINES=["PIX_ENABLED"])
41-
env_d3d12_rdd.Append(CPPPATH=[env["pix_path"] + "/Include"])
41+
env_d3d12_rdd.Append(CPPEXTPATH=[env["pix_path"] + "/Include"])
4242

4343

4444
# Mesa (SPIR-V to DXIL functionality).
@@ -147,7 +147,7 @@ else:
147147
env.Append(CCFLAGS=["-Wno-unknown-pragmas"])
148148

149149
# This is needed since rendering_device_d3d12.cpp needs to include some Mesa internals.
150-
env_d3d12_rdd.Prepend(CPPPATH=mesa_private_inc_paths)
150+
env_d3d12_rdd.Prepend(CPPEXTPATH=mesa_private_inc_paths)
151151
# For the same reason as above, the defines must be the same as in the 3rd-party code itself.
152152
env_d3d12_rdd.Append(CPPDEFINES=extra_defines)
153153

drivers/d3d12/d3d12ma.cpp

Lines changed: 1 addition & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -30,35 +30,4 @@
3030

3131
#include "rendering_context_driver_d3d12.h"
3232

33-
#if defined(__GNUC__) && !defined(__clang__)
34-
#pragma GCC diagnostic push
35-
#pragma GCC diagnostic ignored "-Wnon-virtual-dtor"
36-
#pragma GCC diagnostic ignored "-Wshadow"
37-
#pragma GCC diagnostic ignored "-Wswitch"
38-
#pragma GCC diagnostic ignored "-Wmissing-field-initializers"
39-
#pragma GCC diagnostic ignored "-Wduplicated-branches"
40-
#pragma GCC diagnostic ignored "-Wunused-variable"
41-
#pragma GCC diagnostic ignored "-Wsign-compare"
42-
#pragma GCC diagnostic ignored "-Wimplicit-fallthrough"
43-
#pragma GCC diagnostic ignored "-Wunused-function"
44-
#pragma GCC diagnostic ignored "-Wnonnull-compare"
45-
#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
46-
#elif defined(__clang__)
47-
#pragma clang diagnostic push
48-
#pragma clang diagnostic ignored "-Wnon-virtual-dtor"
49-
#pragma clang diagnostic ignored "-Wstring-plus-int"
50-
#pragma clang diagnostic ignored "-Wswitch"
51-
#pragma clang diagnostic ignored "-Wmissing-field-initializers"
52-
#pragma clang diagnostic ignored "-Wtautological-undefined-compare"
53-
#pragma clang diagnostic ignored "-Wunused-variable"
54-
#pragma clang diagnostic ignored "-Wunused-but-set-variable"
55-
#pragma clang diagnostic ignored "-Wunused-function"
56-
#pragma clang diagnostic ignored "-Wunused-private-field"
57-
#pragma clang diagnostic ignored "-Wimplicit-fallthrough"
58-
#endif
59-
60-
#if defined(_MSC_VER)
61-
#pragma warning(disable : 4189 4505)
62-
#endif
63-
64-
#include "thirdparty/d3d12ma/D3D12MemAlloc.cpp"
33+
#include <D3D12MemAlloc.cpp>

drivers/d3d12/rendering_context_driver_d3d12.cpp

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -37,27 +37,7 @@
3737
#include "core/version.h"
3838
#include "servers/rendering/rendering_device.h"
3939

40-
#if defined(__GNUC__) && !defined(__clang__)
41-
#pragma GCC diagnostic push
42-
#pragma GCC diagnostic ignored "-Wnon-virtual-dtor"
43-
#pragma GCC diagnostic ignored "-Wshadow"
44-
#pragma GCC diagnostic ignored "-Wswitch"
45-
#pragma GCC diagnostic ignored "-Wmissing-field-initializers"
46-
#elif defined(__clang__)
47-
#pragma clang diagnostic push
48-
#pragma clang diagnostic ignored "-Wnon-virtual-dtor"
49-
#pragma clang diagnostic ignored "-Wstring-plus-int"
50-
#pragma clang diagnostic ignored "-Wswitch"
51-
#pragma clang diagnostic ignored "-Wmissing-field-initializers"
52-
#endif
53-
54-
#include "dxcapi.h"
55-
56-
#if defined(__GNUC__) && !defined(__clang__)
57-
#pragma GCC diagnostic pop
58-
#elif defined(__clang__)
59-
#pragma clang diagnostic pop
60-
#endif
40+
#include <dxcapi.h>
6141

6242
#if !defined(_MSC_VER)
6343
#include <guiddef.h>

drivers/d3d12/rendering_context_driver_d3d12.h

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -37,22 +37,6 @@
3737
#include "servers/display_server.h"
3838
#include "servers/rendering/rendering_context_driver.h"
3939

40-
#if defined(__GNUC__) && !defined(__clang__)
41-
#pragma GCC diagnostic push
42-
#pragma GCC diagnostic ignored "-Wnon-virtual-dtor"
43-
#pragma GCC diagnostic ignored "-Wshadow"
44-
#pragma GCC diagnostic ignored "-Wswitch"
45-
#pragma GCC diagnostic ignored "-Wmissing-field-initializers"
46-
#pragma GCC diagnostic ignored "-Wimplicit-fallthrough"
47-
#elif defined(__clang__)
48-
#pragma clang diagnostic push
49-
#pragma clang diagnostic ignored "-Wnon-virtual-dtor"
50-
#pragma clang diagnostic ignored "-Wstring-plus-int"
51-
#pragma clang diagnostic ignored "-Wswitch"
52-
#pragma clang diagnostic ignored "-Wmissing-field-initializers"
53-
#pragma clang diagnostic ignored "-Wimplicit-fallthrough"
54-
#endif
55-
5640
#if defined(AS)
5741
#undef AS
5842
#endif
@@ -71,17 +55,11 @@
7155
#include <dcomp.h>
7256
#endif
7357

74-
#include "d3dx12.h"
58+
#include <d3dx12.h>
7559
#include <dxgi1_6.h>
7660

7761
#include <wrl/client.h>
7862

79-
#if defined(__GNUC__) && !defined(__clang__)
80-
#pragma GCC diagnostic pop
81-
#elif defined(__clang__)
82-
#pragma clang diagnostic pop
83-
#endif
84-
8563
using Microsoft::WRL::ComPtr;
8664

8765
#define ARRAY_SIZE(a) std::size(a)

drivers/d3d12/rendering_device_driver_d3d12.cpp

Lines changed: 4 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -39,44 +39,13 @@
3939
#include "dxil_hash.h"
4040
#include "rendering_context_driver_d3d12.h"
4141

42-
// No point in fighting warnings in Mesa.
43-
#if defined(_MSC_VER)
44-
#pragma warning(push)
45-
#pragma warning(disable : 4200) // "nonstandard extension used: zero-sized array in struct/union".
46-
#pragma warning(disable : 4806) // "'&': unsafe operation: no value of type 'bool' promoted to type 'uint32_t' can equal the given constant".
47-
#endif
48-
49-
#if defined(__GNUC__) && !defined(__clang__)
50-
#pragma GCC diagnostic push
51-
#pragma GCC diagnostic ignored "-Wnon-virtual-dtor"
52-
#pragma GCC diagnostic ignored "-Wshadow"
53-
#pragma GCC diagnostic ignored "-Wswitch"
54-
#pragma GCC diagnostic ignored "-Wmissing-field-initializers"
55-
#elif defined(__clang__)
56-
#pragma clang diagnostic push
57-
#pragma clang diagnostic ignored "-Wnon-virtual-dtor"
58-
#pragma clang diagnostic ignored "-Wstring-plus-int"
59-
#pragma clang diagnostic ignored "-Wswitch"
60-
#pragma clang diagnostic ignored "-Wmissing-field-initializers"
61-
#endif
62-
63-
#include "nir_spirv.h"
64-
#include "nir_to_dxil.h"
65-
#include "spirv_to_dxil.h"
42+
#include <nir_spirv.h>
43+
#include <nir_to_dxil.h>
44+
#include <spirv_to_dxil.h>
6645
extern "C" {
67-
#include "dxil_spirv_nir.h"
46+
#include <dxil_spirv_nir.h>
6847
}
6948

70-
#if defined(__GNUC__) && !defined(__clang__)
71-
#pragma GCC diagnostic pop
72-
#elif defined(__clang__)
73-
#pragma clang diagnostic pop
74-
#endif
75-
76-
#if defined(_MSC_VER)
77-
#pragma warning(pop)
78-
#endif
79-
8049
#if !defined(_MSC_VER)
8150
#include <guiddef.h>
8251

drivers/d3d12/rendering_device_driver_d3d12.h

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -40,26 +40,10 @@
4040
#define __REQUIRED_RPCNDR_H_VERSION__ 475
4141
#endif
4242

43-
#if defined(__GNUC__) && !defined(__clang__)
44-
#pragma GCC diagnostic push
45-
#pragma GCC diagnostic ignored "-Wnon-virtual-dtor"
46-
#pragma GCC diagnostic ignored "-Wshadow"
47-
#pragma GCC diagnostic ignored "-Wswitch"
48-
#pragma GCC diagnostic ignored "-Wmissing-field-initializers"
49-
#pragma GCC diagnostic ignored "-Wimplicit-fallthrough"
50-
#elif defined(__clang__)
51-
#pragma clang diagnostic push
52-
#pragma clang diagnostic ignored "-Wnon-virtual-dtor"
53-
#pragma clang diagnostic ignored "-Wstring-plus-int"
54-
#pragma clang diagnostic ignored "-Wswitch"
55-
#pragma clang diagnostic ignored "-Wmissing-field-initializers"
56-
#pragma clang diagnostic ignored "-Wimplicit-fallthrough"
57-
#endif
58-
59-
#include "d3dx12.h"
43+
#include <d3dx12.h>
6044
#include <dxgi1_6.h>
6145
#define D3D12MA_D3D12_HEADERS_ALREADY_INCLUDED
62-
#include "D3D12MemAlloc.h"
46+
#include <D3D12MemAlloc.h>
6347

6448
#include <wrl/client.h>
6549

@@ -68,12 +52,6 @@
6852
#undef MemoryBarrier
6953
#endif
7054

71-
#if defined(__GNUC__) && !defined(__clang__)
72-
#pragma GCC diagnostic pop
73-
#elif defined(__clang__)
74-
#pragma clang diagnostic pop
75-
#endif
76-
7755
using Microsoft::WRL::ComPtr;
7856

7957
#define D3D12_BITCODE_OFFSETS_NUM_STAGES 3

drivers/gl_context/SCsub

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,7 @@ if env["platform"] in ["macos", "windows", "linuxbsd"]:
1313

1414
thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources]
1515

16-
# Treat glad headers as system headers to avoid raising warnings. Not supported on MSVC.
17-
if not env.msvc:
18-
env.Append(CPPFLAGS=["-isystem", Dir(thirdparty_dir).path])
19-
else:
20-
env.Prepend(CPPPATH=[thirdparty_dir])
21-
16+
env.Prepend(CPPEXTPATH=[thirdparty_dir])
2217
env.Append(CPPDEFINES=["GLAD_ENABLED"])
2318
env.Append(CPPDEFINES=["EGL_ENABLED"])
2419

drivers/metal/SCsub

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ thirdparty_sources = [
2222
]
2323
thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources]
2424

25-
env_metal.Prepend(CPPPATH=[thirdparty_dir, thirdparty_dir + "/include"])
25+
env_metal.Prepend(CPPEXTPATH=[thirdparty_dir, thirdparty_dir + "/include"])
2626

2727
# Must enable exceptions for SPIRV-Cross; otherwise, it will abort the process on errors.
2828
if "-fno-exceptions" in env_metal["CXXFLAGS"]:

drivers/png/SCsub

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ if env["builtin_libpng"]:
3030
]
3131
thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources]
3232

33-
env_png.Prepend(CPPPATH=[thirdparty_dir])
33+
env_png.Prepend(CPPEXTPATH=[thirdparty_dir])
3434
# Needed for drivers includes and in platform/web.
35-
env.Prepend(CPPPATH=[thirdparty_dir])
35+
env.Prepend(CPPEXTPATH=[thirdparty_dir])
3636

3737
env_thirdparty = env_png.Clone()
3838
env_thirdparty.disable_warnings()

drivers/vulkan/SCsub

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ thirdparty_dir = "#thirdparty/vulkan"
88
thirdparty_volk_dir = "#thirdparty/volk"
99

1010
# Use bundled Vulkan headers
11-
env.Prepend(CPPPATH=[thirdparty_dir, thirdparty_dir + "/include"])
11+
env.Prepend(CPPEXTPATH=[thirdparty_dir, thirdparty_dir + "/include"])
1212

1313
if env["use_volk"]:
1414
env.AppendUnique(CPPDEFINES=["USE_VOLK"])
15-
env.Prepend(CPPPATH=[thirdparty_volk_dir])
15+
env.Prepend(CPPEXTPATH=[thirdparty_volk_dir])
1616

1717
if env["platform"] == "android":
1818
env.AppendUnique(CPPDEFINES=["VK_USE_PLATFORM_ANDROID_KHR"])

0 commit comments

Comments
 (0)