diff --git a/SConstruct b/SConstruct index acf3807a1..925ad15c5 100644 --- a/SConstruct +++ b/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") diff --git a/methods.py b/methods.py index 55cf2108c..39d02f844 100644 --- a/methods.py +++ b/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): diff --git a/modules/freetype/config.py b/modules/freetype/config.py index d22f9454e..c6f699c9d 100644 --- a/modules/freetype/config.py +++ b/modules/freetype/config.py @@ -1,3 +1,4 @@ + def can_build(env, platform): return True diff --git a/modules/opus/config.py b/modules/opus/config.py index d22f9454e..aaf2131fb 100644 --- a/modules/opus/config.py +++ b/modules/opus/config.py @@ -1,5 +1,7 @@ + + def can_build(env, platform): - return True + return env.module_check_dependencies("opus", ["ogg"]) def configure(env): diff --git a/modules/theora/config.py b/modules/theora/config.py index 413acce2d..05a1426ae 100644 --- a/modules/theora/config.py +++ b/modules/theora/config.py @@ -1,5 +1,6 @@ + def can_build(env, platform): - return True + return env.module_check_dependencies("theora", ["ogg", "vorbis"]) def configure(env): diff --git a/modules/vorbis/config.py b/modules/vorbis/config.py index d22f9454e..5799d96e4 100644 --- a/modules/vorbis/config.py +++ b/modules/vorbis/config.py @@ -1,5 +1,6 @@ + def can_build(env, platform): - return True + return env.module_check_dependencies("vorbis", ["ogg"]) def configure(env):