From aaebd450bbdd0a375e5607dea16618d641e9bcab Mon Sep 17 00:00:00 2001 From: Relintai Date: Thu, 25 Jan 2024 12:37:48 +0100 Subject: [PATCH] Initial build fix. --- SConstruct | 186 ++--------------------------------------- methods.py | 115 ------------------------- platform/sfwl.cpp | 18 ++-- platform/sfwl_compat.h | 5 ++ 4 files changed, 19 insertions(+), 305 deletions(-) create mode 100644 platform/sfwl_compat.h diff --git a/SConstruct b/SConstruct index 81ef3b0..8f5d335 100644 --- a/SConstruct +++ b/SConstruct @@ -13,8 +13,6 @@ from collections import OrderedDict # Local import methods -import gles_builders -import scu_builders from platform_methods import run_in_subprocess # scan possible build platforms @@ -54,8 +52,6 @@ for x in sorted(glob.glob("platform/*")): sys.path.remove(tmppath) sys.modules.pop("detect") -methods.save_active_platforms(active_platforms, active_platform_ids) - custom_tools = ["default"] platform_arg = ARGUMENTS.get("platform", ARGUMENTS.get("p", False)) @@ -121,7 +117,6 @@ opts = Variables(customs, ARGUMENTS) # Target build options opts.Add("p", "Platform (alias for 'platform')", "") opts.Add("platform", "Target platform (%s)" % ("|".join(platform_list),), "") -opts.Add(BoolVariable("tools", "Build the tools (a.k.a. the Pandemonium editor)", True)) opts.Add(EnumVariable("target", "Compilation target", "debug", ("debug", "release_debug", "release"))) opts.Add("arch", "Platform-dependent architecture (arm/arm64/x86/x64/mips/...)", "") opts.Add(EnumVariable("bits", "Target platform bits", "default", ("default", "32", "64"))) @@ -135,8 +130,6 @@ opts.Add(BoolVariable("deprecated", "Enable deprecated features", True)) opts.Add(BoolVariable("minizip", "Enable ZIP archive support using minizip", True)) opts.Add(BoolVariable("xaudio2", "Enable the XAudio2 audio driver", False)) opts.Add(BoolVariable("disable_exceptions", "Force disabling exception handling code", True)) -opts.Add("custom_modules", "A list of comma-separated directory paths containing custom modules to build.", "") -opts.Add(BoolVariable("custom_modules_recursive", "Detect custom modules recursively for each specified path.", True)) # Advanced options opts.Add(BoolVariable("dev", "If yes, alias for verbose=yes warnings=extra werror=yes", False)) @@ -266,55 +259,6 @@ if selected_platform in platform_opts: opts.Update(env_base) env_base["platform"] = selected_platform # Must always be re-set after calling opts.Update(). -# Detect modules. -modules_detected = OrderedDict() -module_search_paths = [ "modules", methods.convert_custom_modules_path("editor_modules") ] # Built-in path. - -# maybe? -#if env_base["tools"]: -# module_search_paths.append(methods.convert_custom_modules_path("editor_modules")) - -if env_base["custom_modules"]: - paths = env_base["custom_modules"].split(",") - for p in paths: - try: - module_search_paths.append(methods.convert_custom_modules_path(p)) - except ValueError as e: - print(e) - sys.exit(255) - -for path in module_search_paths: - if path == "modules": - # Built-in modules don't have nested modules, - # so save the time it takes to parse directories. - modules = methods.detect_modules(path, recursive=False) - else: # Custom. - modules = methods.detect_modules(path, env_base["custom_modules_recursive"]) - # Provide default include path for both the custom module search `path` - # and the base directory containing custom modules, as it may be different - # from the built-in "modules" name (e.g. "custom_modules/summator/summator.h"), - # so it can be referenced simply as `#include "summator/summator.h"` - # independently of where a module is located on user's filesystem. - env_base.Prepend(CPPPATH=[path, os.path.dirname(path)]) - # Note: custom modules can override built-in ones. - modules_detected.update(modules) - -# Add module options -for name, path in modules_detected.items(): - enabled = True - sys.path.insert(0, path) - import config - - try: - enabled = config.is_enabled() - except AttributeError: - pass - sys.path.remove(path) - sys.modules.pop("config") - opts.Add(BoolVariable("module_" + name + "_enabled", "Enable module '%s'" % (name,), enabled)) - -methods.write_modules(modules_detected) - # Update the environment again after all the module options are added. opts.Update(env_base) env_base["platform"] = selected_platform # Must always be re-set after calling opts.Update(). @@ -423,12 +367,6 @@ if selected_platform in platform_list: env["debug_symbols"] = methods.get_cmdline_bool("debug_symbols", False) # LTO "auto" means we handle the preferred option in each platform detect.py. env["lto"] = ARGUMENTS.get("lto", "auto") - if not env["tools"] and env["target"] == "debug": - print( - "WARNING: Requested `production` build with `tools=no target=debug`, " - "this will give you a full debug template (use `target=release_debug` " - "for an optimized template with debug features)." - ) # Run SCU file generation script if in a SCU build. if env["scu_build"]: @@ -561,27 +499,14 @@ if selected_platform in platform_list: suffix = "." + selected_platform if env["target"] == "release": - if env["tools"]: - print("ERROR: The editor can only be built with `target=debug` or `target=release_debug`.") - print(" Use `tools=no target=release` to build a release export template.") - Exit(255) suffix += ".opt" elif env["target"] == "release_debug": - if env["tools"]: - suffix += ".opt.tools" - else: - suffix += ".opt.debug" + suffix += ".opt.debug" else: - if env["tools"]: - print( - "Note: Building a debug binary (which will run slowly). Use `target=release_debug` to build an optimized release binary." - ) - suffix += ".tools" - else: - print( - "Note: Building a debug binary (which will run slowly). Use `target=release` to build an optimized release binary." - ) - suffix += ".debug" + print( + "Note: Building a debug binary (which will run slowly). Use `target=release` to build an optimized release binary." + ) + suffix += ".debug" if env["arch"] != "": suffix += "." + env["arch"] @@ -601,67 +526,9 @@ if selected_platform in platform_list: env.module_license_files = [] env.doc_class_path = {} - for name, path in modules_detected.items(): - if not env["module_" + name + "_enabled"]: - continue - - sys.path.insert(0, path) - env.current_module = name - import config - - if config.can_build(env, selected_platform): - # Disable it if a required dependency is missing. - if not env.module_check_dependencies(name): - continue - - config.configure(env) - - # Get doc classes paths (if present) - try: - doc_classes = config.get_doc_classes() - doc_path = config.get_doc_path() - for c in doc_classes: - env.doc_class_path[c] = path + "/" + doc_path - except Exception: - pass - - # Get icon paths (if present) - try: - icons_path = config.get_icons_path() - env.module_icons_paths.append(path + "/" + icons_path) - except Exception: - # Default path for module icons - env.module_icons_paths.append(path + "/" + "icons") - - # Get license path (if present) - try: - license_file = config.get_license_file() - - if not os.path.isabs(path): - env.module_license_files.append("#" + path + "/" + license_file) - else: - env.module_license_files.append(path + "/" + license_file) - - except Exception: - pass - - modules_enabled[name] = path - else: - env["module_" + name + "_enabled"] = False - - sys.path.remove(path) - sys.modules.pop("config") - - #TODO hack, the editor should be a module as well - if env["tools"] and not env["module_freetype_enabled"]: - print("The editor (tools=yes) can't be built if freetype is disabled! Stopping.") - sys.exit(255) - env.module_list = modules_enabled methods.sort_module_list(env) - methods.generate_version_header(env.module_version_string) - env["PROGSUFFIX"] = suffix + env.module_version_string + env["PROGSUFFIX"] env["OBJSUFFIX"] = suffix + env["OBJSUFFIX"] # (SH)LIBSUFFIX will be used for our own built libraries @@ -679,43 +546,13 @@ if selected_platform in platform_list: if env.use_ptrcall: env.Append(CPPDEFINES=["PTRCALL_ENABLED"]) - if env["tools"]: - env.Append(CPPDEFINES=["TOOLS_ENABLED"]) - if env["disable_3d"]: - if env["tools"]: - print( - "Build option 'disable_3d=yes' cannot be used with 'tools=yes' (editor), " - "only with 'tools=no' (export template)." - ) - sys.exit(255) - else: - env.Append(CPPDEFINES=["_3D_DISABLED"]) - - if env["disable_advanced_gui"]: - if env["tools"]: - print( - "Build option 'disable_advanced_gui=yes' cannot be used with 'tools=yes' (editor), " - "only with 'tools=no' (export template)." - ) - sys.exit(255) - else: - env.Append(CPPDEFINES=["ADVANCED_GUI_DISABLED"]) if env["minizip"]: env.Append(CPPDEFINES=["MINIZIP_ENABLED"]) if not env["verbose"]: methods.no_verbose(sys, env) - if not env["platform"] == "server": - env.Append( - BUILDERS={ - "GLES2_GLSL": env.Builder( - action=run_in_subprocess(gles_builders.build_gles2_headers), suffix="glsl.gen.h", src_suffix=".glsl" - ) - } - ) - scons_cache_path = os.environ.get("SCONS_CACHE") if scons_cache_path != None: CacheDir(scons_cache_path) @@ -742,20 +579,7 @@ if selected_platform in platform_list: # build subdirs, the build order is dependent on link order. - SConscript("core/SCsub") - SConscript("servers/SCsub") - SConscript("scene/SCsub") - - if env["tools"]: - SConscript("editor/SCsub") - - SConscript("drivers/SCsub") - SConscript("platform/SCsub") - SConscript("modules/SCsub") - SConscript("main/SCsub") - - SConscript("platform/" + selected_platform + "/SCsub") # build selected platform # Microsoft Visual Studio Project Generation if env["vsproj"]: diff --git a/methods.py b/methods.py index 159d659..ab4cb11 100644 --- a/methods.py +++ b/methods.py @@ -224,47 +224,6 @@ def get_version_info(module_version_string="", silent=False): return version_info -def generate_version_header(module_version_string=""): - version_info = get_version_info(module_version_string) - - # NOTE: It is safe to generate these files here, since this is still executed serially. - - f = open("core/version_generated.gen.h", "w") - f.write( - """/* THIS FILE IS GENERATED DO NOT EDIT */ -#ifndef VERSION_GENERATED_GEN_H -#define VERSION_GENERATED_GEN_H -#define VERSION_SHORT_NAME "{short_name}" -#define VERSION_NAME "{name}" -#define VERSION_MAJOR {major} -#define VERSION_MINOR {minor} -#define VERSION_PATCH {patch} -#define VERSION_STATUS "{status}" -#define VERSION_BUILD "{build}" -#define VERSION_MODULE_CONFIG "{module_config}" -#define VERSION_YEAR {year} -#define VERSION_WEBSITE "{website}" -#define VERSION_DOCS_BRANCH "{docs_branch}" -#define VERSION_DOCS_URL "https://github.com/Relintai/pandemonium_engine_docs/blob/" VERSION_DOCS_BRANCH -#endif // VERSION_GENERATED_GEN_H -""".format( - **version_info - ) - ) - f.close() - - fhash = open("core/version_hash.gen.cpp", "w") - fhash.write( - """/* THIS FILE IS GENERATED DO NOT EDIT */ -#include "core/version.h" -const char *const VERSION_HASH = "{git_hash}"; -""".format( - **version_info - ) - ) - fhash.close() - - def parse_cg_file(fname, uniforms, sizes, conditionals): fs = open(fname, "r") @@ -381,51 +340,6 @@ def is_module(path): return False return True - -def write_modules(modules): - includes_cpp = "" - register_cpp = "" - unregister_cpp = "" - - for name, path in modules.items(): - try: - with open(os.path.join(path, "register_types.h")): - includes_cpp += '#include "' + path + '/register_types.h"\n' - register_cpp += "#ifdef MODULE_" + name.upper() + "_ENABLED\n" - register_cpp += "\tregister_" + name + "_types(p_level);\n" - register_cpp += "#endif\n" - unregister_cpp += "#ifdef MODULE_" + name.upper() + "_ENABLED\n" - unregister_cpp += "\tunregister_" + name + "_types(p_level);\n" - unregister_cpp += "#endif\n" - except IOError: - pass - - modules_cpp = """// register_module_types.gen.cpp -/* THIS FILE IS GENERATED DO NOT EDIT */ -#include "register_module_types.h" - -#include "modules/modules_enabled.gen.h" - -%s - -void register_module_types(ModuleRegistrationLevel p_level) { -%s -} - -void unregister_module_types(ModuleRegistrationLevel p_level) { -%s -} -""" % ( - includes_cpp, - register_cpp, - unregister_cpp, - ) - - # NOTE: It is safe to generate this file here, since this is still executed serially - with open("modules/register_module_types.gen.cpp", "w") as f: - f.write(modules_cpp) - - def convert_custom_modules_path(path): if not path: return path @@ -612,34 +526,6 @@ def split_lib(self, libname, src_list=None, env_lib=None): env["SHLINKCOM"] = str(env["LINKCOM"]).replace("$_LIBFLAGS", "-Wl,--start-group $_LIBFLAGS -Wl,--end-group") -def save_active_platforms(apnames, ap): - - for x in ap: - names = ["logo"] - if os.path.isfile(x + "/run_icon.png"): - names.append("run_icon") - - for name in names: - pngf = open(x + "/" + name + ".png", "rb") - b = pngf.read(1) - str = " /* AUTOGENERATED FILE, DO NOT EDIT */ \n" - str += " static const unsigned char _" + x[9:] + "_" + name + "[]={" - while len(b) == 1: - str += hex(ord(b)) - b = pngf.read(1) - if len(b) == 1: - str += "," - - str += "};\n" - - pngf.close() - - # NOTE: It is safe to generate this file here, since this is still executed serially - wf = x + "/" + name + ".gen.h" - with open(wf, "w") as pngw: - pngw.write(str) - - def no_verbose(sys, env): colors = {} @@ -954,7 +840,6 @@ def generate_vs_project(env, num_jobs): common_build_prefix = [ 'cmd /V /C set "plat=$(PlatformTarget)"', '(if "$(PlatformTarget)"=="x64" (set "plat=x86_amd64"))', - 'set "tools=%s"' % env["tools"], f'(if "{configuration_getter}"=="release" (set "tools=no"))', 'call "' + batch_file + '" !plat!', ] diff --git a/platform/sfwl.cpp b/platform/sfwl.cpp index d2af85e..0ac921f 100644 --- a/platform/sfwl.cpp +++ b/platform/sfwl.cpp @@ -1597,7 +1597,7 @@ template class MutexImpl; void check_lockless_atomics() { // Doing the check for the types we actually care about if (!std::atomic{}.is_lock_free() || !std::atomic{}.is_lock_free() || !std::atomic_bool{}.is_lock_free()) { - WARN_PRINT("Your compiler doesn't seem to support lockless atomics. Performance will be degraded. Please consider upgrading to a different or newer compiler."); + LOG_WARN("Your compiler doesn't seem to support lockless atomics. Performance will be degraded. Please consider upgrading to a different or newer compiler."); } } @@ -7773,7 +7773,7 @@ static double built_in_strtod( if (exp > maxExponent) { exp = maxExponent; - //WARN_PRINT("Exponent too high"); + //LOG_WARN("Exponent too high"); } dblExp = 1.0; for (d = powersOf10; exp != 0; exp >>= 1, ++d) { @@ -8421,13 +8421,13 @@ void StringName::cleanup() { } } - print_line("\nStringName reference ranking (from most to least referenced):\n"); + LOG_MSG("\nStringName reference ranking (from most to least referenced):\n"); data.sort_custom(); int unreferenced_stringnames = 0; int rarely_referenced_stringnames = 0; for (int i = 0; i < data.size(); i++) { - print_line(itos(i + 1) + ": " + data[i]->get_name() + " - " + itos(data[i]->debug_references)); + LOG_MSG(itos(i + 1) + ": " + data[i]->get_name() + " - " + itos(data[i]->debug_references)); if (data[i]->debug_references == 0) { unreferenced_stringnames += 1; } else if (data[i]->debug_references < 5) { @@ -8435,8 +8435,8 @@ void StringName::cleanup() { } } - print_line(vformat("\nOut of %d StringNames, %d StringNames were never referenced during this run (0 times) (%.2f%%).", data.size(), unreferenced_stringnames, unreferenced_stringnames / float(data.size()) * 100)); - print_line(vformat("Out of %d StringNames, %d StringNames were rarely referenced during this run (1-4 times) (%.2f%%).", data.size(), rarely_referenced_stringnames, rarely_referenced_stringnames / float(data.size()) * 100)); + LOG_MSG(vformat("\nOut of %d StringNames, %d StringNames were never referenced during this run (0 times) (%.2f%%).", data.size(), unreferenced_stringnames, unreferenced_stringnames / float(data.size()) * 100)); + LOG_MSG(vformat("Out of %d StringNames, %d StringNames were rarely referenced during this run (1-4 times) (%.2f%%).", data.size(), rarely_referenced_stringnames, rarely_referenced_stringnames / float(data.size()) * 100)); } #endif @@ -8450,9 +8450,9 @@ void StringName::cleanup() { lost_strings++; if (OS::get_singleton()->is_stdout_verbose()) { if (d->cname) { - print_line("Orphan StringName: " + String(d->cname)); + LOG_MSG("Orphan StringName: " + String(d->cname)); } else { - print_line("Orphan StringName: " + String(d->name)); + LOG_MSG("Orphan StringName: " + String(d->name)); } } } @@ -9663,7 +9663,7 @@ Error FileAccess::_open(const String &p_path, int p_mode_flags) { if (fname != String()) { String base_file = path.get_file(); if (base_file != fname && base_file.findn(fname) == 0) { - WARN_PRINT("Case mismatch opening requested file '" + base_file + "', stored as '" + fname + "' in the filesystem. This file will not open when exported to other case-sensitive platforms."); + LOG_WARN("Case mismatch opening requested file '" + base_file + "', stored as '" + fname + "' in the filesystem. This file will not open when exported to other case-sensitive platforms."); } } diff --git a/platform/sfwl_compat.h b/platform/sfwl_compat.h new file mode 100644 index 0000000..25364ac --- /dev/null +++ b/platform/sfwl_compat.h @@ -0,0 +1,5 @@ + +#ifndef SFWL_COMPAT_H +#define SFWL_COMPAT_H + +#endif