Build System: Extract `validate_arch` helper function
Signed-off-by: Yevhen Babiichuk (DustDFG) <dfgdust@gmail.com>
This commit is contained in:
parent
76a135926a
commit
89ff209957
|
@ -5,6 +5,7 @@ import sys
|
||||||
from typing import TYPE_CHECKING
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
from methods import print_error, print_warning
|
from methods import print_error, print_warning
|
||||||
|
from platform_methods import validate_arch
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from SCons.Script.SConscript import SConsEnvironment
|
from SCons.Script.SConscript import SConsEnvironment
|
||||||
|
@ -98,12 +99,7 @@ def install_ndk_if_needed(env: "SConsEnvironment"):
|
||||||
def configure(env: "SConsEnvironment"):
|
def configure(env: "SConsEnvironment"):
|
||||||
# Validate arch.
|
# Validate arch.
|
||||||
supported_arches = ["x86_32", "x86_64", "arm32", "arm64"]
|
supported_arches = ["x86_32", "x86_64", "arm32", "arm64"]
|
||||||
if env["arch"] not in supported_arches:
|
validate_arch(env["arch"], get_name(), supported_arches)
|
||||||
print_error(
|
|
||||||
'Unsupported CPU architecture "%s" for Android. Supported architectures are: %s.'
|
|
||||||
% (env["arch"], ", ".join(supported_arches))
|
|
||||||
)
|
|
||||||
sys.exit(255)
|
|
||||||
|
|
||||||
if get_min_sdk_version(env["ndk_platform"]) < get_min_target_api():
|
if get_min_sdk_version(env["ndk_platform"]) < get_min_target_api():
|
||||||
print_warning(
|
print_warning(
|
||||||
|
|
|
@ -3,6 +3,7 @@ import sys
|
||||||
from typing import TYPE_CHECKING
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
from methods import detect_darwin_sdk_path, print_error
|
from methods import detect_darwin_sdk_path, print_error
|
||||||
|
from platform_methods import validate_arch
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from SCons.Script.SConscript import SConsEnvironment
|
from SCons.Script.SConscript import SConsEnvironment
|
||||||
|
@ -60,12 +61,7 @@ def get_flags():
|
||||||
def configure(env: "SConsEnvironment"):
|
def configure(env: "SConsEnvironment"):
|
||||||
# Validate arch.
|
# Validate arch.
|
||||||
supported_arches = ["x86_64", "arm64"]
|
supported_arches = ["x86_64", "arm64"]
|
||||||
if env["arch"] not in supported_arches:
|
validate_arch(env["arch"], get_name(), supported_arches)
|
||||||
print_error(
|
|
||||||
'Unsupported CPU architecture "%s" for iOS. Supported architectures are: %s.'
|
|
||||||
% (env["arch"], ", ".join(supported_arches))
|
|
||||||
)
|
|
||||||
sys.exit(255)
|
|
||||||
|
|
||||||
## LTO
|
## LTO
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ import sys
|
||||||
from typing import TYPE_CHECKING
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
from methods import get_compiler_version, print_error, print_warning, using_gcc
|
from methods import get_compiler_version, print_error, print_warning, using_gcc
|
||||||
from platform_methods import detect_arch
|
from platform_methods import detect_arch, validate_arch
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from SCons.Script.SConscript import SConsEnvironment
|
from SCons.Script.SConscript import SConsEnvironment
|
||||||
|
@ -74,12 +74,7 @@ def get_flags():
|
||||||
def configure(env: "SConsEnvironment"):
|
def configure(env: "SConsEnvironment"):
|
||||||
# Validate arch.
|
# Validate arch.
|
||||||
supported_arches = ["x86_32", "x86_64", "arm32", "arm64", "rv64", "ppc32", "ppc64"]
|
supported_arches = ["x86_32", "x86_64", "arm32", "arm64", "rv64", "ppc32", "ppc64"]
|
||||||
if env["arch"] not in supported_arches:
|
validate_arch(env["arch"], get_name(), supported_arches)
|
||||||
print_error(
|
|
||||||
'Unsupported CPU architecture "%s" for Linux / *BSD. Supported architectures are: %s.'
|
|
||||||
% (env["arch"], ", ".join(supported_arches))
|
|
||||||
)
|
|
||||||
sys.exit(255)
|
|
||||||
|
|
||||||
## Build type
|
## Build type
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ 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
|
from methods import detect_darwin_sdk_path, get_compiler_version, is_vanilla_clang, print_error
|
||||||
from platform_methods import detect_arch, detect_mvk
|
from platform_methods import detect_arch, detect_mvk, validate_arch
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from SCons.Script.SConscript import SConsEnvironment
|
from SCons.Script.SConscript import SConsEnvironment
|
||||||
|
@ -64,12 +64,7 @@ def get_flags():
|
||||||
def configure(env: "SConsEnvironment"):
|
def configure(env: "SConsEnvironment"):
|
||||||
# Validate arch.
|
# Validate arch.
|
||||||
supported_arches = ["x86_64", "arm64"]
|
supported_arches = ["x86_64", "arm64"]
|
||||||
if env["arch"] not in supported_arches:
|
validate_arch(env["arch"], get_name(), supported_arches)
|
||||||
print_error(
|
|
||||||
'Unsupported CPU architecture "%s" for macOS. Supported architectures are: %s.'
|
|
||||||
% (env["arch"], ", ".join(supported_arches))
|
|
||||||
)
|
|
||||||
sys.exit(255)
|
|
||||||
|
|
||||||
## Build type
|
## Build type
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,7 @@ from emscripten_helpers import (
|
||||||
from SCons.Util import WhereIs
|
from SCons.Util import WhereIs
|
||||||
|
|
||||||
from methods import get_compiler_version, print_error, print_warning
|
from methods import get_compiler_version, print_error, print_warning
|
||||||
|
from platform_methods import validate_arch
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from SCons.Script.SConscript import SConsEnvironment
|
from SCons.Script.SConscript import SConsEnvironment
|
||||||
|
@ -86,12 +87,7 @@ def get_flags():
|
||||||
def configure(env: "SConsEnvironment"):
|
def configure(env: "SConsEnvironment"):
|
||||||
# Validate arch.
|
# Validate arch.
|
||||||
supported_arches = ["wasm32"]
|
supported_arches = ["wasm32"]
|
||||||
if env["arch"] not in supported_arches:
|
validate_arch(env["arch"], get_name(), supported_arches)
|
||||||
print_error(
|
|
||||||
'Unsupported CPU architecture "%s" for Web. Supported architectures are: %s.'
|
|
||||||
% (env["arch"], ", ".join(supported_arches))
|
|
||||||
)
|
|
||||||
sys.exit(255)
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
env["initial_memory"] = int(env["initial_memory"])
|
env["initial_memory"] = int(env["initial_memory"])
|
||||||
|
|
|
@ -6,7 +6,7 @@ from typing import TYPE_CHECKING
|
||||||
|
|
||||||
import methods
|
import methods
|
||||||
from methods import print_error, print_warning
|
from methods import print_error, print_warning
|
||||||
from platform_methods import detect_arch
|
from platform_methods import detect_arch, validate_arch
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from SCons.Script.SConscript import SConsEnvironment
|
from SCons.Script.SConscript import SConsEnvironment
|
||||||
|
@ -950,12 +950,7 @@ def configure_mingw(env: "SConsEnvironment"):
|
||||||
def configure(env: "SConsEnvironment"):
|
def configure(env: "SConsEnvironment"):
|
||||||
# Validate arch.
|
# Validate arch.
|
||||||
supported_arches = ["x86_32", "x86_64", "arm32", "arm64"]
|
supported_arches = ["x86_32", "x86_64", "arm32", "arm64"]
|
||||||
if env["arch"] not in supported_arches:
|
validate_arch(env["arch"], get_name(), supported_arches)
|
||||||
print_error(
|
|
||||||
'Unsupported CPU architecture "%s" for Windows. Supported architectures are: %s.'
|
|
||||||
% (env["arch"], ", ".join(supported_arches))
|
|
||||||
)
|
|
||||||
sys.exit(255)
|
|
||||||
|
|
||||||
# At this point the env has been set up with basic tools/compilers.
|
# At this point the env has been set up with basic tools/compilers.
|
||||||
env.Prepend(CPPPATH=["#platform/windows"])
|
env.Prepend(CPPPATH=["#platform/windows"])
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import os
|
import os
|
||||||
import platform
|
import platform
|
||||||
import subprocess
|
import subprocess
|
||||||
|
import sys
|
||||||
|
|
||||||
import methods
|
import methods
|
||||||
|
|
||||||
|
@ -40,6 +41,15 @@ def detect_arch():
|
||||||
return "x86_64"
|
return "x86_64"
|
||||||
|
|
||||||
|
|
||||||
|
def validate_arch(arch, platform_name, supported_arches):
|
||||||
|
if arch not in supported_arches:
|
||||||
|
methods.print_error(
|
||||||
|
'Unsupported CPU architecture "%s" for %s. Supported architectures are: %s.'
|
||||||
|
% (arch, platform_name, ", ".join(supported_arches))
|
||||||
|
)
|
||||||
|
sys.exit(255)
|
||||||
|
|
||||||
|
|
||||||
def get_build_version(short):
|
def get_build_version(short):
|
||||||
import version
|
import version
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue