mirror of
https://github.com/godotengine/godot.git
synced 2024-11-21 19:42:43 +00:00
Merge pull request #99217 from dustdfg/refactor_compiler_min_detection
Buildsystem: Refactor compiler detection code
This commit is contained in:
commit
6c9337de36
38
SConstruct
38
SConstruct
@ -663,40 +663,32 @@ elif methods.using_gcc(env):
|
|||||||
"to switch to posix threads."
|
"to switch to posix threads."
|
||||||
)
|
)
|
||||||
Exit(255)
|
Exit(255)
|
||||||
if env["debug_paths_relative"] and cc_version_major < 8:
|
|
||||||
print_warning("GCC < 8 doesn't support -ffile-prefix-map, disabling `debug_paths_relative` option.")
|
|
||||||
env["debug_paths_relative"] = False
|
|
||||||
elif methods.using_clang(env):
|
elif methods.using_clang(env):
|
||||||
# Apple LLVM versions differ from upstream LLVM version \o/, compare
|
# Apple LLVM versions differ from upstream LLVM version \o/, compare
|
||||||
# in https://en.wikipedia.org/wiki/Xcode#Toolchain_versions
|
# in https://en.wikipedia.org/wiki/Xcode#Toolchain_versions
|
||||||
if env["platform"] == "macos" or env["platform"] == "ios":
|
if methods.is_apple_clang(env):
|
||||||
vanilla = methods.is_vanilla_clang(env)
|
if cc_version_major < 10:
|
||||||
if vanilla and cc_version_major < 6:
|
|
||||||
print_error(
|
|
||||||
"Detected Clang version older than 6, which does not fully support "
|
|
||||||
"C++17. Supported versions are Clang 6 and later."
|
|
||||||
)
|
|
||||||
Exit(255)
|
|
||||||
elif not vanilla and cc_version_major < 10:
|
|
||||||
print_error(
|
print_error(
|
||||||
"Detected Apple Clang version older than 10, which does not fully "
|
"Detected Apple Clang version older than 10, which does not fully "
|
||||||
"support C++17. Supported versions are Apple Clang 10 and later."
|
"support C++17. Supported versions are Apple Clang 10 and later."
|
||||||
)
|
)
|
||||||
Exit(255)
|
Exit(255)
|
||||||
if env["debug_paths_relative"] and not vanilla and cc_version_major < 12:
|
elif env["debug_paths_relative"] and cc_version_major < 12:
|
||||||
print_warning(
|
print_warning(
|
||||||
"Apple Clang < 12 doesn't support -ffile-prefix-map, disabling `debug_paths_relative` option."
|
"Apple Clang < 12 doesn't support -ffile-prefix-map, disabling `debug_paths_relative` option."
|
||||||
)
|
)
|
||||||
env["debug_paths_relative"] = False
|
env["debug_paths_relative"] = False
|
||||||
elif cc_version_major < 6:
|
else:
|
||||||
print_error(
|
if cc_version_major < 6:
|
||||||
"Detected Clang version older than 6, which does not fully support "
|
print_error(
|
||||||
"C++17. Supported versions are Clang 6 and later."
|
"Detected Clang version older than 6, which does not fully support "
|
||||||
)
|
"C++17. Supported versions are Clang 6 and later."
|
||||||
Exit(255)
|
)
|
||||||
if env["debug_paths_relative"] and cc_version_major < 10:
|
Exit(255)
|
||||||
print_warning("Clang < 10 doesn't support -ffile-prefix-map, disabling `debug_paths_relative` option.")
|
elif env["debug_paths_relative"] and cc_version_major < 10:
|
||||||
env["debug_paths_relative"] = False
|
print_warning("Clang < 10 doesn't support -ffile-prefix-map, disabling `debug_paths_relative` option.")
|
||||||
|
env["debug_paths_relative"] = False
|
||||||
|
|
||||||
elif env.msvc:
|
elif env.msvc:
|
||||||
# Ensure latest minor builds of Visual Studio 2017/2019.
|
# Ensure latest minor builds of Visual Studio 2017/2019.
|
||||||
# https://github.com/godotengine/godot/pull/94995#issuecomment-2336464574
|
# https://github.com/godotengine/godot/pull/94995#issuecomment-2336464574
|
||||||
@ -760,7 +752,7 @@ else:
|
|||||||
project_path = Dir("#").abspath
|
project_path = Dir("#").abspath
|
||||||
env.Append(CCFLAGS=[f"-ffile-prefix-map={project_path}=."])
|
env.Append(CCFLAGS=[f"-ffile-prefix-map={project_path}=."])
|
||||||
else:
|
else:
|
||||||
if methods.using_clang(env) and not methods.is_vanilla_clang(env):
|
if methods.is_apple_clang(env):
|
||||||
# Apple Clang, its linker doesn't like -s.
|
# Apple Clang, its linker doesn't like -s.
|
||||||
env.Append(LINKFLAGS=["-Wl,-S", "-Wl,-x", "-Wl,-dead_strip"])
|
env.Append(LINKFLAGS=["-Wl,-S", "-Wl,-x", "-Wl,-dead_strip"])
|
||||||
else:
|
else:
|
||||||
|
@ -654,7 +654,9 @@ def detect_darwin_sdk_path(platform, env):
|
|||||||
raise
|
raise
|
||||||
|
|
||||||
|
|
||||||
def is_vanilla_clang(env):
|
def is_apple_clang(env):
|
||||||
|
if env["platform"] not in ["macos", "ios"]:
|
||||||
|
return False
|
||||||
if not using_clang(env):
|
if not using_clang(env):
|
||||||
return False
|
return False
|
||||||
try:
|
try:
|
||||||
@ -662,7 +664,7 @@ def is_vanilla_clang(env):
|
|||||||
except (subprocess.CalledProcessError, OSError):
|
except (subprocess.CalledProcessError, OSError):
|
||||||
print_warning("Couldn't parse CXX environment variable to infer compiler version.")
|
print_warning("Couldn't parse CXX environment variable to infer compiler version.")
|
||||||
return False
|
return False
|
||||||
return not version.startswith("Apple")
|
return version.startswith("Apple")
|
||||||
|
|
||||||
|
|
||||||
def get_compiler_version(env):
|
def get_compiler_version(env):
|
||||||
|
@ -2,7 +2,7 @@ import os
|
|||||||
import sys
|
import sys
|
||||||
from typing import TYPE_CHECKING
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
from methods import detect_darwin_sdk_path, get_compiler_version, is_vanilla_clang, print_error, print_warning
|
from methods import detect_darwin_sdk_path, get_compiler_version, is_apple_clang, print_error, print_warning
|
||||||
from platform_methods import detect_arch, detect_mvk, validate_arch
|
from platform_methods import detect_arch, detect_mvk, validate_arch
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
@ -101,10 +101,9 @@ def configure(env: "SConsEnvironment"):
|
|||||||
cc_version = get_compiler_version(env)
|
cc_version = get_compiler_version(env)
|
||||||
cc_version_major = cc_version["apple_major"]
|
cc_version_major = cc_version["apple_major"]
|
||||||
cc_version_minor = cc_version["apple_minor"]
|
cc_version_minor = cc_version["apple_minor"]
|
||||||
vanilla = is_vanilla_clang(env)
|
|
||||||
|
|
||||||
# Workaround for Xcode 15 linker bug.
|
# Workaround for Xcode 15 linker bug.
|
||||||
if not vanilla and cc_version_major == 1500 and cc_version_minor == 0:
|
if is_apple_clang(env) and cc_version_major == 1500 and cc_version_minor == 0:
|
||||||
env.Prepend(LINKFLAGS=["-ld_classic"])
|
env.Prepend(LINKFLAGS=["-ld_classic"])
|
||||||
|
|
||||||
env.Append(CCFLAGS=["-fobjc-arc"])
|
env.Append(CCFLAGS=["-fobjc-arc"])
|
||||||
|
Loading…
Reference in New Issue
Block a user