Simplify the build.

This commit is contained in:
Relintai 2024-01-25 17:08:05 +01:00
parent dd85d5888b
commit 99404b7df1
4 changed files with 3 additions and 217 deletions

View File

@ -226,42 +226,7 @@ opts.Add(
False, False,
) )
) )
opts.Add(BoolVariable("disable_3d", "Disable 3D nodes for a smaller executable", False))
opts.Add(BoolVariable("disable_advanced_gui", "Disable advanced GUI nodes and behaviors", False))
opts.Add(BoolVariable("no_editor_splash", "Don't use the custom splash screen for the editor", True))
opts.Add("system_certs_path", "Use this path as SSL certificates default for editor (for package maintainers)", "")
opts.Add(BoolVariable("use_precise_math_checks", "Math checks use very precise epsilon (debug option)", False)) opts.Add(BoolVariable("use_precise_math_checks", "Math checks use very precise epsilon (debug option)", False))
opts.Add(BoolVariable("scu_build", "Use single compilation unit build", False))
opts.Add(
EnumVariable(
"rids",
"Server object management technique (debug option)",
"pointers",
("pointers", "handles", "tracked_handles"),
)
)
opts.Add(BoolVariable("editor_docs", "Whether to add docs to an editor build or not. Disabling this can significantly reduce incremental compile times. Only relevant for editor builds!", True))
# Thirdparty libraries
opts.Add(BoolVariable("builtin_certs", "Use the built-in SSL certificates bundles", True))
opts.Add(BoolVariable("builtin_enet", "Use the built-in ENet library", True))
opts.Add(BoolVariable("builtin_freetype", "Use the built-in FreeType library", True))
opts.Add(BoolVariable("builtin_libogg", "Use the built-in libogg library", True))
opts.Add(BoolVariable("builtin_libpng", "Use the built-in libpng library", True))
opts.Add(BoolVariable("builtin_libtheora", "Use the built-in libtheora library", True))
opts.Add(BoolVariable("builtin_libvorbis", "Use the built-in libvorbis library", True))
opts.Add(BoolVariable("builtin_wslay", "Use the built-in wslay library", True))
opts.Add(BoolVariable("builtin_mbedtls", "Use the built-in mbedTLS library", True))
opts.Add(BoolVariable("builtin_miniupnpc", "Use the built-in miniupnpc library", True))
opts.Add(BoolVariable("builtin_opus", "Use the built-in Opus library", True))
opts.Add(BoolVariable("builtin_pcre2", "Use the built-in PCRE2 library", True))
opts.Add(BoolVariable("builtin_pcre2_with_jit", "Use JIT compiler for the built-in PCRE2 library", True))
opts.Add(BoolVariable("builtin_recast", "Use the built-in Recast library", True))
opts.Add(BoolVariable("builtin_rvo2_2d", "Use the built-in RVO2 2D library", True))
opts.Add(BoolVariable("builtin_rvo2_3d", "Use the built-in RVO2 3D library", True))
opts.Add(BoolVariable("builtin_squish", "Use the built-in squish library", True))
opts.Add(BoolVariable("builtin_zlib", "Use the built-in zlib library", True))
opts.Add(BoolVariable("builtin_zstd", "Use the built-in Zstd library", True))
# Compilation environment setup # Compilation environment setup
opts.Add("CXX", "C++ compiler") opts.Add("CXX", "C++ compiler")
@ -382,24 +347,9 @@ if methods.get_cmdline_bool("fast_unsafe", env_base["target"] == "debug"):
if env_base["use_precise_math_checks"]: if env_base["use_precise_math_checks"]:
env_base.Append(CPPDEFINES=["PRECISE_MATH_CHECKS"]) env_base.Append(CPPDEFINES=["PRECISE_MATH_CHECKS"])
if not env_base.File("#main/splash_editor.png").exists():
# Force disabling editor splash if missing.
env_base["no_editor_splash"] = True
if env_base["no_editor_splash"]:
env_base.Append(CPPDEFINES=["NO_EDITOR_SPLASH"])
if not env_base["deprecated"]: if not env_base["deprecated"]:
env_base.Append(CPPDEFINES=["DISABLE_DEPRECATED"]) env_base.Append(CPPDEFINES=["DISABLE_DEPRECATED"])
if env_base["rids"] == "handles":
env_base.Append(CPPDEFINES=["RID_HANDLES_ENABLED"])
print("WARNING: Building with RIDs as handles.")
if env_base["rids"] == "tracked_handles":
env_base.Append(CPPDEFINES=["RID_HANDLES_ENABLED"])
env_base.Append(CPPDEFINES=["RID_HANDLE_ALLOCATION_TRACKING_ENABLED"])
print("WARNING: Building with RIDs as tracked handles.")
#env_base.Append(LIBS=["stdc++"]) #env_base.Append(LIBS=["stdc++"])
if selected_platform in platform_list: if selected_platform in platform_list:
@ -452,10 +402,6 @@ if selected_platform in platform_list:
# LTO "auto" means we handle the preferred option in each platform detect.py. # LTO "auto" means we handle the preferred option in each platform detect.py.
env["lto"] = ARGUMENTS.get("lto", "auto") env["lto"] = ARGUMENTS.get("lto", "auto")
# Run SCU file generation script if in a SCU build.
if env["scu_build"]:
methods.set_scu_folders(scu_builders.generate_scu_files(env["verbose"], env_base["target"] != "debug"))
# Must happen after the flags' definition, as configure is when most flags # Must happen after the flags' definition, as configure is when most flags
# are actually handled to change compile options, etc. # are actually handled to change compile options, etc.
detect.configure(env) detect.configure(env)
@ -631,9 +577,6 @@ if selected_platform in platform_list:
if env.use_ptrcall: if env.use_ptrcall:
env.Append(CPPDEFINES=["PTRCALL_ENABLED"]) env.Append(CPPDEFINES=["PTRCALL_ENABLED"])
if env["minizip"]:
env.Append(CPPDEFINES=["MINIZIP_ENABLED"])
if not env["verbose"]: if not env["verbose"]:
methods.no_verbose(sys, env) methods.no_verbose(sys, env)

View File

@ -20,16 +20,13 @@ from os.path import normpath, basename
base_folder_path = str(os.path.abspath(Path(__file__).parent)) + "/" base_folder_path = str(os.path.abspath(Path(__file__).parent)) + "/"
base_folder_only = os.path.basename(os.path.normpath(base_folder_path)) base_folder_only = os.path.basename(os.path.normpath(base_folder_path))
# Listing all the folders we have converted # Listing all the folders we have converted
# for SCU in scu_builders.py
_scu_folders = set()
def set_scu_folders(scu_folders): def set_scu_folders(scu_folders):
global _scu_folders global _scu_folders
_scu_folders = scu_folders _scu_folders = scu_folders
def add_source_files_orig(self, sources, files, allow_gen=False): def add_source_files(self, sources, files, allow_gen=False):
# Convert string to list of absolute paths (including expanding wildcard) # Convert string to list of absolute paths (including expanding wildcard)
if isbasestring(files): if isbasestring(files):
# Keep SCons project-absolute path as they are (no wildcard support) # Keep SCons project-absolute path as they are (no wildcard support)
@ -83,43 +80,6 @@ def _find_scu_section_name(subdir):
return section_name return section_name
def add_source_files_scu(self, sources, files, allow_gen=False):
if self["scu_build"] and isinstance(files, str):
if "*." not in files:
return False
# If the files are in a subdirectory, we want to create the scu gen
# files inside this subdirectory.
subdir = os.path.dirname(files)
if subdir != "":
subdir += "/"
section_name = _find_scu_section_name(subdir)
# if the section name is in the hash table?
# i.e. is it part of the SCU build?
global _scu_folders
if section_name not in (_scu_folders):
return False
if self["verbose"]:
print("SCU building " + section_name)
# Add all the gen.cpp files in the SCU directory
add_source_files_orig(self, sources, subdir + ".scu/scu_*.gen.cpp", True)
return True
return False
# Either builds the folder using the SCU system,
# or reverts to regular build.
def add_source_files(self, sources, files, allow_gen=False):
if not add_source_files_scu(self, sources, files, allow_gen):
# Wraps the original function when scu build is not active.
add_source_files_orig(self, sources, files, allow_gen)
return False
return True
def disable_warnings(self): def disable_warnings(self):
# 'self' is the environment # 'self' is the environment
if self.msvc: if self.msvc:

View File

@ -236,7 +236,6 @@ def configure_msvc(env, manual_msvc_config):
env.AppendUnique( env.AppendUnique(
CPPDEFINES=[ CPPDEFINES=[
"WINDOWS_ENABLED", "WINDOWS_ENABLED",
"OPENGL_ENABLED",
"WASAPI_ENABLED", "WASAPI_ENABLED",
"WINMIDI_ENABLED", "WINMIDI_ENABLED",
"TYPED_METHOD_BIND", "TYPED_METHOD_BIND",
@ -426,7 +425,7 @@ def configure_mingw(env):
env.Append(CCFLAGS=["-mwindows"]) env.Append(CCFLAGS=["-mwindows"])
env.Append(LINKFLAGS=["-Wl,--nxcompat"]) # DEP protection. Not enabling ASLR for now, Mono crashes. env.Append(LINKFLAGS=["-Wl,--nxcompat"]) # DEP protection. Not enabling ASLR for now, Mono crashes.
env.Append(CPPDEFINES=["WINDOWS_ENABLED", "OPENGL_ENABLED", "WASAPI_ENABLED", "WINMIDI_ENABLED"]) env.Append(CPPDEFINES=["WINDOWS_ENABLED", "WASAPI_ENABLED", "WINMIDI_ENABLED"])
env.Append(CPPDEFINES=[("WINVER", env["target_win_version"]), ("_WIN32_WINNT", env["target_win_version"])]) env.Append(CPPDEFINES=[("WINVER", env["target_win_version"]), ("_WIN32_WINNT", env["target_win_version"])])
env.Append( env.Append(
LIBS=[ LIBS=[

View File

@ -249,124 +249,8 @@ def configure(env):
env.Append(CCFLAGS=["-fpie"]) env.Append(CCFLAGS=["-fpie"])
env.Append(LINKFLAGS=["-no-pie"]) env.Append(LINKFLAGS=["-no-pie"])
## Dependencies
env.ParseConfig("pkg-config x11 --cflags --libs")
env.ParseConfig("pkg-config xcursor --cflags --libs")
env.ParseConfig("pkg-config xinerama --cflags --libs")
env.ParseConfig("pkg-config xext --cflags --libs")
env.ParseConfig("pkg-config xrandr --cflags --libs")
env.ParseConfig("pkg-config xrender --cflags --libs")
env.ParseConfig("pkg-config xi --cflags --libs")
if env["touch"]:
env.Append(CPPDEFINES=["TOUCH_ENABLED"])
# FIXME: Check for existence of the libs before parsing their flags with pkg-config
# freetype depends on libpng and zlib, so bundling one of them while keeping others
# as shared libraries leads to weird issues
if env["builtin_freetype"] or env["builtin_libpng"] or env["builtin_zlib"]:
env["builtin_freetype"] = True
env["builtin_libpng"] = True
env["builtin_zlib"] = True
if not env["builtin_freetype"]:
env.ParseConfig("pkg-config freetype2 --cflags --libs")
if not env["builtin_libpng"]:
env.ParseConfig("pkg-config libpng16 --cflags --libs")
if False: # not env['builtin_assimp']:
# FIXME: Add min version check
env.ParseConfig("pkg-config assimp --cflags --libs")
if not env["builtin_enet"]:
env.ParseConfig("pkg-config libenet --cflags --libs")
if not env["builtin_squish"]:
env.ParseConfig("pkg-config libsquish --cflags --libs")
if not env["builtin_zstd"]:
env.ParseConfig("pkg-config libzstd --cflags --libs")
# Sound and video libraries
# Keep the order as it triggers chained dependencies (ogg needed by others, etc.)
if not env["builtin_libtheora"]:
env["builtin_libogg"] = False # Needed to link against system libtheora
env["builtin_libvorbis"] = False # Needed to link against system libtheora
env.ParseConfig("pkg-config theora theoradec --cflags --libs")
else:
list_of_x86 = ["x86_64", "x86", "i386", "i586"]
if env["arch"] == "":
if any(platform.machine() in s for s in list_of_x86):
env["x86_libtheora_opt_gcc"] = True
else:
if any(env["arch"] in s for s in list_of_x86):
env["x86_libtheora_opt_gcc"] = True
if not env["builtin_libvorbis"]:
env["builtin_libogg"] = False # Needed to link against system libvorbis
env.ParseConfig("pkg-config vorbis vorbisfile --cflags --libs")
if not env["builtin_opus"]:
env["builtin_libogg"] = False # Needed to link against system opus
env.ParseConfig("pkg-config opus opusfile --cflags --libs")
if not env["builtin_libogg"]:
env.ParseConfig("pkg-config ogg --cflags --libs")
if not env["builtin_mbedtls"]:
# mbedTLS does not provide a pkgconfig config yet. See https://github.com/ARMmbed/mbedtls/issues/228
env.Append(LIBS=["mbedtls", "mbedcrypto", "mbedx509"])
if not env["builtin_wslay"]:
env.ParseConfig("pkg-config libwslay --cflags --libs")
if not env["builtin_miniupnpc"]:
# No pkgconfig file so far, hardcode default paths.
env.Prepend(CPPPATH=["/usr/include/miniupnpc"])
env.Append(LIBS=["miniupnpc"])
# On Linux wchar_t should be 32-bits
# 16-bit library shouldn't be required due to compiler optimisations
if not env["builtin_pcre2"]:
env.ParseConfig("pkg-config libpcre2-32 --cflags --libs")
## Flags
if os.system("pkg-config --exists alsa") == 0: # 0 means found
env["alsa"] = True
env.Append(CPPDEFINES=["ALSA_ENABLED", "ALSAMIDI_ENABLED"])
env.ParseConfig("pkg-config alsa --cflags") # Only cflags, we dlopen the library.
else:
print("Warning: ALSA libraries not found. Disabling the ALSA audio driver.")
if env["pulseaudio"]:
if os.system("pkg-config --exists libpulse") == 0: # 0 means found
env.Append(CPPDEFINES=["PULSEAUDIO_ENABLED"])
env.ParseConfig("pkg-config libpulse --cflags") # Only cflags, we dlopen the library.
else:
print("Warning: PulseAudio development libraries not found. Disabling the PulseAudio audio driver.")
if platform.system() == "Linux":
env.Append(CPPDEFINES=["JOYDEV_ENABLED"])
if env["udev"]:
if os.system("pkg-config --exists libudev") == 0: # 0 means found
env.Append(CPPDEFINES=["UDEV_ENABLED"])
env.ParseConfig("pkg-config libudev --cflags") # Only cflags, we dlopen the library.
else:
print("Warning: libudev development libraries not found. Disabling controller hotplugging support.")
else:
env["udev"] = False # Linux specific
# Linkflags below this line should typically stay the last ones
if not env["builtin_zlib"]:
env.ParseConfig("pkg-config zlib --cflags --libs")
env.Prepend(CPPPATH=["#platform/x11"]) env.Prepend(CPPPATH=["#platform/x11"])
env.Append(CPPDEFINES=["X11_ENABLED", "UNIX_ENABLED", "OPENGL_ENABLED", "GLES_ENABLED", ("_FILE_OFFSET_BITS", 64)]) env.Append(CPPDEFINES=["X11_ENABLED", "UNIX_ENABLED", ("_FILE_OFFSET_BITS", 64)])
env.ParseConfig("pkg-config gl --cflags --libs") env.ParseConfig("pkg-config gl --cflags --libs")