mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2025-01-13 22:31:11 +01:00
Backported: SCons: Validate dependencies for linked multimedia modules
This is still a bit hacky and eventually we should rework the way we handle
optional dependencies (especially with regard to builtin/system libs), but
it's a simple first step.
- akien-mga
7c74312217
This commit is contained in:
parent
4c4e19223e
commit
4732493761
30
SConstruct
30
SConstruct
@ -94,6 +94,7 @@ env_base.__class__.add_library = methods.add_library
|
||||
env_base.__class__.add_program = methods.add_program
|
||||
env_base.__class__.CommandNoCache = methods.CommandNoCache
|
||||
env_base.__class__.disable_warnings = methods.disable_warnings
|
||||
env_base.__class__.module_check_dependencies = methods.module_check_dependencies
|
||||
|
||||
env_base["x86_libtheora_opt_gcc"] = False
|
||||
env_base["x86_libtheora_opt_vc"] = False
|
||||
@ -576,19 +577,7 @@ if selected_platform in platform_list:
|
||||
env.current_module = name
|
||||
import config
|
||||
|
||||
# can_build changed number of arguments between 3.0 (1) and 3.1 (2),
|
||||
# so try both to preserve compatibility for 3.0 modules
|
||||
can_build = False
|
||||
try:
|
||||
can_build = config.can_build(env, selected_platform)
|
||||
except TypeError:
|
||||
print(
|
||||
"Warning: module '%s' uses a deprecated `can_build` "
|
||||
"signature in its config.py file, it should be "
|
||||
"`can_build(env, platform)`." % x
|
||||
)
|
||||
can_build = config.can_build(selected_platform)
|
||||
if can_build:
|
||||
if config.can_build(env, selected_platform):
|
||||
config.configure(env)
|
||||
# Get doc classes paths (if present)
|
||||
try:
|
||||
@ -635,6 +624,7 @@ if selected_platform in platform_list:
|
||||
env.Append(CPPDEFINES=["PTRCALL_ENABLED"])
|
||||
if env["tools"]:
|
||||
env.Append(CPPDEFINES=["TOOLS_ENABLED"])
|
||||
|
||||
if env["disable_3d"]:
|
||||
if env["tools"]:
|
||||
print(
|
||||
@ -644,6 +634,7 @@ if selected_platform in platform_list:
|
||||
sys.exit(255)
|
||||
else:
|
||||
env.Append(CPPDEFINES=["_3D_DISABLED"])
|
||||
|
||||
if env["disable_advanced_gui"]:
|
||||
if env["tools"]:
|
||||
print(
|
||||
@ -657,14 +648,9 @@ if selected_platform in platform_list:
|
||||
env.Append(CPPDEFINES=["MINIZIP_ENABLED"])
|
||||
|
||||
editor_module_list = ["freetype"]
|
||||
for x in editor_module_list:
|
||||
if not env["module_" + x + "_enabled"]:
|
||||
if env["tools"]:
|
||||
print(
|
||||
"Build option 'module_" + x + "_enabled=no' cannot be used with 'tools=yes' (editor), "
|
||||
"only with 'tools=no' (export template)."
|
||||
)
|
||||
sys.exit(255)
|
||||
if env["tools"] and not env.module_check_dependencies("tools", editor_module_list):
|
||||
print("The editor (tools=yes) can't be built if it's dependencies are not satisfied! Stopping.")
|
||||
sys.exit(255)
|
||||
|
||||
if not env["verbose"]:
|
||||
methods.no_verbose(sys, env)
|
||||
@ -694,8 +680,10 @@ if selected_platform in platform_list:
|
||||
SConscript("core/SCsub")
|
||||
SConscript("servers/SCsub")
|
||||
SConscript("scene/SCsub")
|
||||
|
||||
if env["tools"]:
|
||||
SConscript("editor/SCsub")
|
||||
|
||||
SConscript("drivers/SCsub")
|
||||
|
||||
SConscript("platform/SCsub")
|
||||
|
22
methods.py
22
methods.py
@ -306,6 +306,28 @@ def convert_custom_modules_path(path):
|
||||
def disable_module(self):
|
||||
self.disabled_modules.append(self.current_module)
|
||||
|
||||
def module_check_dependencies(self, module, dependencies):
|
||||
"""
|
||||
Checks if module dependencies are enabled for a given module,
|
||||
and prints a warning if they aren't.
|
||||
Meant to be used in module `can_build` methods.
|
||||
Returns a boolean (True if dependencies are satisfied).
|
||||
"""
|
||||
missing_deps = []
|
||||
for dep in dependencies:
|
||||
opt = "module_{}_enabled".format(dep)
|
||||
if not opt in self or not self[opt]:
|
||||
missing_deps.append(dep)
|
||||
|
||||
if missing_deps != []:
|
||||
print(
|
||||
"Disabling '{}' module as the following dependencies are not satisfied: {}".format(
|
||||
module, ", ".join(missing_deps)
|
||||
)
|
||||
)
|
||||
return False
|
||||
else:
|
||||
return True
|
||||
|
||||
def use_windows_spawn_fix(self, platform=None):
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
|
||||
def can_build(env, platform):
|
||||
return True
|
||||
|
||||
|
@ -1,5 +1,7 @@
|
||||
|
||||
|
||||
def can_build(env, platform):
|
||||
return True
|
||||
return env.module_check_dependencies("opus", ["ogg"])
|
||||
|
||||
|
||||
def configure(env):
|
||||
|
@ -1,5 +1,6 @@
|
||||
|
||||
def can_build(env, platform):
|
||||
return True
|
||||
return env.module_check_dependencies("theora", ["ogg", "vorbis"])
|
||||
|
||||
|
||||
def configure(env):
|
||||
|
@ -1,5 +1,6 @@
|
||||
|
||||
def can_build(env, platform):
|
||||
return True
|
||||
return env.module_check_dependencies("vorbis", ["ogg"])
|
||||
|
||||
|
||||
def configure(env):
|
||||
|
Loading…
Reference in New Issue
Block a user