|
1 | 1 | #!/usr/bin/env python |
2 | 2 | from misc.utility.scons_hints import * |
3 | 3 |
|
4 | | -EnsureSConsVersion(3, 1, 2) |
5 | | -EnsurePythonVersion(3, 6) |
| 4 | +EnsureSConsVersion(4, 0) |
| 5 | +EnsurePythonVersion(3, 8) |
6 | 6 |
|
7 | 7 | # System |
8 | 8 | import atexit |
@@ -59,7 +59,7 @@ import glsl_builders |
59 | 59 | import methods |
60 | 60 | import scu_builders |
61 | 61 | from methods import print_error, print_warning |
62 | | -from platform_methods import architecture_aliases, architectures |
| 62 | +from platform_methods import architecture_aliases, architectures, compatibility_platform_aliases |
63 | 63 |
|
64 | 64 | if ARGUMENTS.get("target", "editor") == "editor": |
65 | 65 | _helper_module("editor.editor_builders", "editor/editor_builders.py") |
@@ -271,6 +271,8 @@ opts.Add(BoolVariable("scu_build", "Use single compilation unit build", False)) |
271 | 271 | opts.Add("scu_limit", "Max includes per SCU file when using scu_build (determines RAM use)", "0") |
272 | 272 | opts.Add(BoolVariable("engine_update_check", "Enable engine update checks in the Project Manager", True)) |
273 | 273 | opts.Add(BoolVariable("steamapi", "Enable minimal SteamAPI integration for usage time tracking (editor only)", False)) |
| 274 | +opts.Add("cache_path", "Path to a directory where SCons cache files will be stored. No value disables the cache.", "") |
| 275 | +opts.Add("cache_limit", "Max size (in GiB) for the SCons cache. 0 means no limit.", "0") |
274 | 276 |
|
275 | 277 | # Thirdparty libraries |
276 | 278 | opts.Add(BoolVariable("builtin_brotli", "Use the built-in Brotli library", True)) |
@@ -321,6 +323,9 @@ opts.Add("rcflags", "Custom flags for Windows resource compiler") |
321 | 323 | # in following code (especially platform and custom_modules). |
322 | 324 | opts.Update(env) |
323 | 325 |
|
| 326 | +# Setup caching logic early to catch everything. |
| 327 | +methods.prepare_cache(env) |
| 328 | + |
324 | 329 | # Copy custom environment variables if set. |
325 | 330 | if env["import_env_vars"]: |
326 | 331 | for env_var in str(env["import_env_vars"]).split(","): |
@@ -350,27 +355,18 @@ if env["platform"] == "": |
350 | 355 | if env["platform"] != "": |
351 | 356 | print(f'Automatically detected platform: {env["platform"]}') |
352 | 357 |
|
353 | | -if env["platform"] == "osx": |
354 | | - # Deprecated alias kept for compatibility. |
355 | | - print_warning('Platform "osx" has been renamed to "macos" in Redot 4. Building for platform "macos".') |
356 | | - env["platform"] = "macos" |
357 | | - |
358 | | -if env["platform"] == "iphone": |
359 | | - # Deprecated alias kept for compatibility. |
360 | | - print_warning('Platform "iphone" has been renamed to "ios" in Redot 4. Building for platform "ios".') |
361 | | - env["platform"] = "ios" |
362 | | - |
363 | | -if env["platform"] in ["linux", "bsd", "x11"]: |
364 | | - if env["platform"] == "x11": |
365 | | - # Deprecated alias kept for compatibility. |
366 | | - print_warning('Platform "x11" has been renamed to "linuxbsd" in Redot 4. Building for platform "linuxbsd".') |
367 | | - # Alias for convenience. |
368 | | - env["platform"] = "linuxbsd" |
| 358 | +# Deprecated aliases kept for compatibility. |
| 359 | +if env["platform"] in compatibility_platform_aliases: |
| 360 | + alias = env["platform"] |
| 361 | + platform = compatibility_platform_aliases[alias] |
| 362 | + print_warning( |
| 363 | + f'Platform "{alias}" has been renamed to "{platform}" in Redot 4. Building for platform "{platform}".' |
| 364 | + ) |
| 365 | + env["platform"] = platform |
369 | 366 |
|
370 | | -if env["platform"] == "javascript": |
371 | | - # Deprecated alias kept for compatibility. |
372 | | - print_warning('Platform "javascript" has been renamed to "web" in Redot 4. Building for platform "web".') |
373 | | - env["platform"] = "web" |
| 367 | +# Alias for convenience. |
| 368 | +if env["platform"] in ["linux", "bsd"]: |
| 369 | + env["platform"] = "linuxbsd" |
374 | 370 |
|
375 | 371 | if env["platform"] not in platform_list: |
376 | 372 | text = "The following platforms are available:\n\t{}\n".format("\n\t".join(platform_list)) |
@@ -667,40 +663,32 @@ elif methods.using_gcc(env): |
667 | 663 | "to switch to posix threads." |
668 | 664 | ) |
669 | 665 | Exit(255) |
670 | | - if env["debug_paths_relative"] and cc_version_major < 8: |
671 | | - print_warning("GCC < 8 doesn't support -ffile-prefix-map, disabling `debug_paths_relative` option.") |
672 | | - env["debug_paths_relative"] = False |
673 | 666 | elif methods.using_clang(env): |
674 | 667 | # Apple LLVM versions differ from upstream LLVM version \o/, compare |
675 | 668 | # in https://en.wikipedia.org/wiki/Xcode#Toolchain_versions |
676 | | - if env["platform"] == "macos" or env["platform"] == "ios": |
677 | | - vanilla = methods.is_vanilla_clang(env) |
678 | | - if vanilla and cc_version_major < 6: |
679 | | - print_error( |
680 | | - "Detected Clang version older than 6, which does not fully support " |
681 | | - "C++17. Supported versions are Clang 6 and later." |
682 | | - ) |
683 | | - Exit(255) |
684 | | - elif not vanilla and cc_version_major < 10: |
| 669 | + if methods.is_apple_clang(env): |
| 670 | + if cc_version_major < 10: |
685 | 671 | print_error( |
686 | 672 | "Detected Apple Clang version older than 10, which does not fully " |
687 | 673 | "support C++17. Supported versions are Apple Clang 10 and later." |
688 | 674 | ) |
689 | 675 | Exit(255) |
690 | | - if env["debug_paths_relative"] and not vanilla and cc_version_major < 12: |
| 676 | + elif env["debug_paths_relative"] and cc_version_major < 12: |
691 | 677 | print_warning( |
692 | 678 | "Apple Clang < 12 doesn't support -ffile-prefix-map, disabling `debug_paths_relative` option." |
693 | 679 | ) |
694 | 680 | env["debug_paths_relative"] = False |
695 | | - elif cc_version_major < 6: |
696 | | - print_error( |
697 | | - "Detected Clang version older than 6, which does not fully support " |
698 | | - "C++17. Supported versions are Clang 6 and later." |
699 | | - ) |
700 | | - Exit(255) |
701 | | - if env["debug_paths_relative"] and cc_version_major < 10: |
702 | | - print_warning("Clang < 10 doesn't support -ffile-prefix-map, disabling `debug_paths_relative` option.") |
703 | | - env["debug_paths_relative"] = False |
| 681 | + else: |
| 682 | + if cc_version_major < 6: |
| 683 | + print_error( |
| 684 | + "Detected Clang version older than 6, which does not fully support " |
| 685 | + "C++17. Supported versions are Clang 6 and later." |
| 686 | + ) |
| 687 | + Exit(255) |
| 688 | + elif env["debug_paths_relative"] and cc_version_major < 10: |
| 689 | + print_warning("Clang < 10 doesn't support -ffile-prefix-map, disabling `debug_paths_relative` option.") |
| 690 | + env["debug_paths_relative"] = False |
| 691 | + |
704 | 692 | elif env.msvc: |
705 | 693 | # Ensure latest minor builds of Visual Studio 2017/2019. |
706 | 694 | # https://github.com/godotengine/godot/pull/94995#issuecomment-2336464574 |
@@ -764,7 +752,7 @@ else: |
764 | 752 | project_path = Dir("#").abspath |
765 | 753 | env.Append(CCFLAGS=[f"-ffile-prefix-map={project_path}=."]) |
766 | 754 | else: |
767 | | - if methods.using_clang(env) and not methods.is_vanilla_clang(env): |
| 755 | + if methods.is_apple_clang(env): |
768 | 756 | # Apple Clang, its linker doesn't like -s. |
769 | 757 | env.Append(LINKFLAGS=["-Wl,-S", "-Wl,-x", "-Wl,-dead_strip"]) |
770 | 758 | else: |
@@ -1050,23 +1038,7 @@ GLSL_BUILDERS = { |
1050 | 1038 | } |
1051 | 1039 | env.Append(BUILDERS=GLSL_BUILDERS) |
1052 | 1040 |
|
1053 | | -scons_cache_path = os.environ.get("SCONS_CACHE") |
1054 | | -if scons_cache_path is not None: |
1055 | | - CacheDir(scons_cache_path) |
1056 | | - print("Scons cache enabled... (path: '" + scons_cache_path + "')") |
1057 | | - |
1058 | | -if env["vsproj"]: |
1059 | | - env.vs_incs = [] |
1060 | | - env.vs_srcs = [] |
1061 | | - |
1062 | 1041 | if env["compiledb"]: |
1063 | | - if env.scons_version < (4, 0, 0): |
1064 | | - # Generating the compilation DB (`compile_commands.json`) requires SCons 4.0.0 or later. |
1065 | | - print_error( |
1066 | | - "The `compiledb=yes` option requires SCons 4.0 or later, but your version is %s." % scons_raw_version |
1067 | | - ) |
1068 | | - Exit(255) |
1069 | | - |
1070 | 1042 | env.Tool("compilation_db") |
1071 | 1043 | env.Alias("compiledb", env.CompilationDatabase()) |
1072 | 1044 |
|
@@ -1148,5 +1120,3 @@ def purge_flaky_files(): |
1148 | 1120 |
|
1149 | 1121 |
|
1150 | 1122 | atexit.register(purge_flaky_files) |
1151 | | - |
1152 | | -methods.clean_cache(env) |
0 commit comments