Extract common check functions in windows_detect.py file

Signed-off-by: Yevhen Babiichuk (DustDFG) <dfgdust@gmail.com>
This commit is contained in:
Yevhen Babiichuk (DustDFG) 2024-09-27 21:11:43 +03:00
parent 76a135926a
commit 9c50312f0d

View file

@ -483,9 +483,7 @@ def configure_msvc(env: "SConsEnvironment", vcvars_msvc_config):
else: else:
print_warning("Missing environment variable: WindowsSdkDir") print_warning("Missing environment variable: WindowsSdkDir")
if int(env["target_win_version"], 16) < 0x0601: validate_win_version(env)
print_error("`target_win_version` should be 0x0601 or higher (Windows 7).")
sys.exit(255)
env.AppendUnique( env.AppendUnique(
CPPDEFINES=[ CPPDEFINES=[
@ -549,15 +547,7 @@ def configure_msvc(env: "SConsEnvironment", vcvars_msvc_config):
LIBS += ["vulkan"] LIBS += ["vulkan"]
if env["d3d12"]: if env["d3d12"]:
# Check whether we have d3d12 dependencies installed. check_d3d12_installed(env)
if not os.path.exists(env["mesa_libs"]):
print_error(
"The Direct3D 12 rendering driver requires dependencies to be installed.\n"
"You can install them by running `python misc\\scripts\\install_d3d12_sdk_windows.py`.\n"
"See the documentation for more information:\n\t"
"https://docs.godotengine.org/en/latest/contributing/development/compiling/compiling_for_windows.html"
)
sys.exit(255)
env.AppendUnique(CPPDEFINES=["D3D12_ENABLED", "RD_ENABLED"]) env.AppendUnique(CPPDEFINES=["D3D12_ENABLED", "RD_ENABLED"])
LIBS += ["dxgi", "dxguid"] LIBS += ["dxgi", "dxguid"]
@ -819,9 +809,7 @@ def configure_mingw(env: "SConsEnvironment"):
## Compile flags ## Compile flags
if int(env["target_win_version"], 16) < 0x0601: validate_win_version(env)
print_error("`target_win_version` should be 0x0601 or higher (Windows 7).")
sys.exit(255)
if not env["use_llvm"]: if not env["use_llvm"]:
env.Append(CCFLAGS=["-mwindows"]) env.Append(CCFLAGS=["-mwindows"])
@ -899,15 +887,7 @@ def configure_mingw(env: "SConsEnvironment"):
env.Append(LIBS=["vulkan"]) env.Append(LIBS=["vulkan"])
if env["d3d12"]: if env["d3d12"]:
# Check whether we have d3d12 dependencies installed. check_d3d12_installed(env)
if not os.path.exists(env["mesa_libs"]):
print_error(
"The Direct3D 12 rendering driver requires dependencies to be installed.\n"
"You can install them by running `python misc\\scripts\\install_d3d12_sdk_windows.py`.\n"
"See the documentation for more information:\n\t"
"https://docs.godotengine.org/en/latest/contributing/development/compiling/compiling_for_windows.html"
)
sys.exit(255)
env.AppendUnique(CPPDEFINES=["D3D12_ENABLED", "RD_ENABLED"]) env.AppendUnique(CPPDEFINES=["D3D12_ENABLED", "RD_ENABLED"])
env.Append(LIBS=["dxgi", "dxguid"]) env.Append(LIBS=["dxgi", "dxguid"])
@ -983,3 +963,20 @@ def configure(env: "SConsEnvironment"):
else: # MinGW else: # MinGW
configure_mingw(env) configure_mingw(env)
def check_d3d12_installed(env):
if not os.path.exists(env["mesa_libs"]):
print_error(
"The Direct3D 12 rendering driver requires dependencies to be installed.\n"
"You can install them by running `python misc\\scripts\\install_d3d12_sdk_windows.py`.\n"
"See the documentation for more information:\n\t"
"https://docs.godotengine.org/en/latest/contributing/development/compiling/compiling_for_windows.html"
)
sys.exit(255)
def validate_win_version(env):
if int(env["target_win_version"], 16) < 0x0601:
print_error("`target_win_version` should be 0x0601 or higher (Windows 7).")
sys.exit(255)