Now freetype, libpng and zlib is always built in.

This commit is contained in:
Relintai 2023-12-17 14:13:26 +01:00
parent b564b6e261
commit c4cb4e366b
6 changed files with 164 additions and 215 deletions

View File

@ -171,12 +171,9 @@ opts.Add(BoolVariable("editor_docs", "Whether to add docs to an editor build or
# Thirdparty libraries # Thirdparty libraries
opts.Add(BoolVariable("builtin_certs", "Use the built-in SSL certificates bundles", True)) 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_enet", "Use the built-in ENet library", True))
opts.Add(BoolVariable("builtin_freetype", "Use the built-in FreeType library", True))
opts.Add(BoolVariable("builtin_libpng", "Use the built-in libpng library", True))
opts.Add(BoolVariable("builtin_mbedtls", "Use the built-in mbedTLS library", True)) opts.Add(BoolVariable("builtin_mbedtls", "Use the built-in mbedTLS library", True))
opts.Add(BoolVariable("builtin_pcre2", "Use the built-in PCRE2 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_pcre2_with_jit", "Use JIT compiler for the built-in PCRE2 library", True))
opts.Add(BoolVariable("builtin_zlib", "Use the built-in zlib library", True))
# Compilation environment setup # Compilation environment setup
opts.Add("CXX", "C++ compiler") opts.Add("CXX", "C++ compiler")

View File

@ -64,30 +64,29 @@ thirdparty_misc_sources = [thirdparty_misc_dir + file for file in thirdparty_mis
env_thirdparty.add_source_files(thirdparty_obj, thirdparty_misc_sources) env_thirdparty.add_source_files(thirdparty_obj, thirdparty_misc_sources)
# Zlib library, can be unbundled # Zlib library, can be unbundled
if env["builtin_zlib"]: thirdparty_zlib_dir = "thirdparty/zlib/"
thirdparty_zlib_dir = "thirdparty/zlib/" thirdparty_zlib_sources = [
thirdparty_zlib_sources = [ "adler32.c",
"adler32.c", "compress.c",
"compress.c", "crc32.c",
"crc32.c", "deflate.c",
"deflate.c", "infback.c",
"infback.c", "inffast.c",
"inffast.c", "inflate.c",
"inflate.c", "inftrees.c",
"inftrees.c", "trees.c",
"trees.c", "uncompr.c",
"uncompr.c", "zutil.c",
"zutil.c", ]
] thirdparty_zlib_sources = [thirdparty_zlib_dir + file for file in thirdparty_zlib_sources]
thirdparty_zlib_sources = [thirdparty_zlib_dir + file for file in thirdparty_zlib_sources]
env_thirdparty.Prepend(CPPPATH=[thirdparty_zlib_dir]) env_thirdparty.Prepend(CPPPATH=[thirdparty_zlib_dir])
# Needs to be available in main env too # Needs to be available in main env too
env.Prepend(CPPPATH=[thirdparty_zlib_dir]) env.Prepend(CPPPATH=[thirdparty_zlib_dir])
if env["target"] == "debug": if env["target"] == "debug":
env_thirdparty.Append(CPPDEFINES=["ZLIB_DEBUG"]) env_thirdparty.Append(CPPDEFINES=["ZLIB_DEBUG"])
env_thirdparty.add_source_files(thirdparty_obj, thirdparty_zlib_sources) env_thirdparty.add_source_files(thirdparty_obj, thirdparty_zlib_sources)
env.core_sources += thirdparty_obj env.core_sources += thirdparty_obj

View File

@ -11,118 +11,116 @@ env_freetype = env_modules.Clone()
thirdparty_obj = [] thirdparty_obj = []
if env["builtin_freetype"]: thirdparty_dir = "freetype/"
thirdparty_dir = "freetype/" thirdparty_sources = [
thirdparty_sources = [ "src/autofit/autofit.c",
"src/autofit/autofit.c", "src/base/ftbase.c",
"src/base/ftbase.c", "src/base/ftbbox.c",
"src/base/ftbbox.c", "src/base/ftbdf.c",
"src/base/ftbdf.c", "src/base/ftbitmap.c",
"src/base/ftbitmap.c", "src/base/ftcid.c",
"src/base/ftcid.c", "src/base/ftdebug.c",
"src/base/ftdebug.c", "src/base/ftfstype.c",
"src/base/ftfstype.c", "src/base/ftgasp.c",
"src/base/ftgasp.c", "src/base/ftglyph.c",
"src/base/ftglyph.c", "src/base/ftgxval.c",
"src/base/ftgxval.c", "src/base/ftinit.c",
"src/base/ftinit.c", "src/base/ftmm.c",
"src/base/ftmm.c", "src/base/ftotval.c",
"src/base/ftotval.c", "src/base/ftpatent.c",
"src/base/ftpatent.c", "src/base/ftpfr.c",
"src/base/ftpfr.c", "src/base/ftstroke.c",
"src/base/ftstroke.c", "src/base/ftsynth.c",
"src/base/ftsynth.c", "src/base/ftsystem.c",
"src/base/ftsystem.c", "src/base/fttype1.c",
"src/base/fttype1.c", "src/base/ftwinfnt.c",
"src/base/ftwinfnt.c", "src/bdf/bdf.c",
"src/bdf/bdf.c", "src/bzip2/ftbzip2.c",
"src/bzip2/ftbzip2.c", "src/cache/ftcache.c",
"src/cache/ftcache.c", "src/cff/cff.c",
"src/cff/cff.c", "src/cid/type1cid.c",
"src/cid/type1cid.c", "src/gxvalid/gxvalid.c",
"src/gxvalid/gxvalid.c", "src/gzip/ftgzip.c",
"src/gzip/ftgzip.c", "src/lzw/ftlzw.c",
"src/lzw/ftlzw.c", "src/otvalid/otvalid.c",
"src/otvalid/otvalid.c", "src/pcf/pcf.c",
"src/pcf/pcf.c", "src/pfr/pfr.c",
"src/pfr/pfr.c", "src/psaux/psaux.c",
"src/psaux/psaux.c", "src/pshinter/pshinter.c",
"src/pshinter/pshinter.c", "src/psnames/psnames.c",
"src/psnames/psnames.c", "src/raster/raster.c",
"src/raster/raster.c", "src/sdf/sdf.c",
"src/sdf/sdf.c", "src/svg/svg.c",
"src/svg/svg.c", "src/smooth/smooth.c",
"src/smooth/smooth.c", "src/truetype/truetype.c",
"src/truetype/truetype.c", "src/type1/type1.c",
"src/type1/type1.c", "src/type42/type42.c",
"src/type42/type42.c", "src/winfonts/winfnt.c",
"src/winfonts/winfnt.c",
] ]
thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources] thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources]
thirdparty_brotli_dir = "brotli/" thirdparty_brotli_dir = "brotli/"
thirdparty_brotli_sources = [ thirdparty_brotli_sources = [
"common/constants.c", "common/constants.c",
"common/context.c", "common/context.c",
"common/dictionary.c", "common/dictionary.c",
"common/platform.c", "common/platform.c",
"common/shared_dictionary.c", "common/shared_dictionary.c",
"common/transform.c", "common/transform.c",
"dec/bit_reader.c", "dec/bit_reader.c",
"dec/decode.c", "dec/decode.c",
"dec/huffman.c", "dec/huffman.c",
"dec/state.c", "dec/state.c",
] ]
thirdparty_sources += [thirdparty_brotli_dir + file for file in thirdparty_brotli_sources] thirdparty_sources += [thirdparty_brotli_dir + file for file in thirdparty_brotli_sources]
env_freetype.Append(CPPDEFINES=["FT_CONFIG_OPTION_USE_BROTLI"]) env_freetype.Append(CPPDEFINES=["FT_CONFIG_OPTION_USE_BROTLI"])
env_freetype.Prepend(CPPPATH=[thirdparty_brotli_dir + "include"]) env_freetype.Prepend(CPPPATH=[thirdparty_brotli_dir + "include"])
if env["platform"] == "uwp": if env["platform"] == "uwp":
# Include header for UWP to fix build issues # Include header for UWP to fix build issues
env_freetype.Append(CCFLAGS=["/FI", '"modules/freetype/uwpdef.h"']) env_freetype.Append(CCFLAGS=["/FI", '"modules/freetype/uwpdef.h"'])
# Globally too, as freetype is used in scene (see bottom) # Globally too, as freetype is used in scene (see bottom)
env.Append(CCFLAGS=["/FI", '"modules/freetype/uwpdef.h"']) env.Append(CCFLAGS=["/FI", '"modules/freetype/uwpdef.h"'])
env_freetype.Prepend(CPPPATH=[thirdparty_dir + "/include"]) env_freetype.Prepend(CPPPATH=[thirdparty_dir + "/include"])
# Also needed in main env for scene/ # Also needed in main env for scene/
env.Prepend(CPPPATH=[thirdparty_dir + "/include"]) env.Prepend(CPPPATH=[thirdparty_dir + "/include"])
env_freetype.Append(CPPDEFINES=["FT2_BUILD_LIBRARY", "FT_CONFIG_OPTION_USE_PNG", "FT_CONFIG_OPTION_SYSTEM_ZLIB"]) env_freetype.Append(CPPDEFINES=["FT2_BUILD_LIBRARY", "FT_CONFIG_OPTION_USE_PNG", "FT_CONFIG_OPTION_SYSTEM_ZLIB"])
if env["target"] == "debug": if env["target"] == "debug":
env_freetype.Append(CPPDEFINES=["ZLIB_DEBUG"]) env_freetype.Append(CPPDEFINES=["ZLIB_DEBUG"])
# Also requires libpng headers # Also requires libpng headers
if env["builtin_libpng"]: env_freetype.Prepend(CPPPATH=["#modules/png/libpng"])
env_freetype.Prepend(CPPPATH=["#modules/png/libpng"])
sfnt = thirdparty_dir + "src/sfnt/sfnt.c" sfnt = thirdparty_dir + "src/sfnt/sfnt.c"
# Must be done after all CPPDEFINES are being set so we can copy them. # Must be done after all CPPDEFINES are being set so we can copy them.
if env["platform"] == "javascript": if env["platform"] == "javascript":
# Forcibly undefine this macro so SIMD is not used in this file, # Forcibly undefine this macro so SIMD is not used in this file,
# since currently unsupported in WASM # since currently unsupported in WASM
tmp_env = env_freetype.Clone() tmp_env = env_freetype.Clone()
tmp_env.disable_warnings() tmp_env.disable_warnings()
tmp_env.Append(CPPFLAGS=["-U__OPTIMIZE__"]) tmp_env.Append(CPPFLAGS=["-U__OPTIMIZE__"])
sfnt = tmp_env.Object(sfnt) sfnt = tmp_env.Object(sfnt)
thirdparty_sources += [sfnt] thirdparty_sources += [sfnt]
env_thirdparty = env_freetype.Clone() env_thirdparty = env_freetype.Clone()
env_thirdparty.disable_warnings() env_thirdparty.disable_warnings()
lib = env_thirdparty.add_library("freetype_builtin", thirdparty_sources) lib = env_thirdparty.add_library("freetype_builtin", thirdparty_sources)
thirdparty_obj += lib thirdparty_obj += lib
# Needs to be appended to arrive after libscene in the linker call, # Needs to be appended to arrive after libscene in the linker call,
# but we don't want it to arrive *after* system libs, so manual hack # but we don't want it to arrive *after* system libs, so manual hack
# LIBS contains first SCons Library objects ("SCons.Node.FS.File object") # LIBS contains first SCons Library objects ("SCons.Node.FS.File object")
# and then plain strings for system library. We insert between the two. # and then plain strings for system library. We insert between the two.
inserted = False inserted = False
for idx, linklib in enumerate(env["LIBS"]): for idx, linklib in enumerate(env["LIBS"]):
if isbasestring(linklib): # first system lib such as "X11", otherwise SCons lib object if isbasestring(linklib): # first system lib such as "X11", otherwise SCons lib object
env["LIBS"].insert(idx, lib) env["LIBS"].insert(idx, lib)
inserted = True inserted = True
break break
if not inserted: if not inserted:
env.Append(LIBS=[lib]) env.Append(LIBS=[lib])
# Pandemonium source files # Pandemonium source files

View File

@ -9,56 +9,55 @@ env_png = env_modules.Clone()
thirdparty_obj = [] thirdparty_obj = []
if env["builtin_libpng"]: thirdparty_dir = "libpng/"
thirdparty_dir = "libpng/" thirdparty_sources = [
thirdparty_sources = [ "png.c",
"png.c", "pngerror.c",
"pngerror.c", "pngget.c",
"pngget.c", "pngmem.c",
"pngmem.c", "pngpread.c",
"pngpread.c", "pngread.c",
"pngread.c", "pngrio.c",
"pngrio.c", "pngrtran.c",
"pngrtran.c", "pngrutil.c",
"pngrutil.c", "pngset.c",
"pngset.c", "pngtrans.c",
"pngtrans.c", "pngwio.c",
"pngwio.c", "pngwrite.c",
"pngwrite.c", "pngwtran.c",
"pngwtran.c", "pngwutil.c",
"pngwutil.c", ]
] thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources]
thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources]
env_png.Prepend(CPPPATH=[thirdparty_dir]) env_png.Prepend(CPPPATH=[thirdparty_dir])
# Needed for drivers includes and in platform/javascript # Needed for drivers includes and in platform/javascript
env.Prepend(CPPPATH=[thirdparty_dir]) env.Prepend(CPPPATH=[thirdparty_dir])
# Currently .ASM filter_neon.S does not compile on NT. # Currently .ASM filter_neon.S does not compile on NT.
import os import os
use_neon = "neon_enabled" in env and env["neon_enabled"] and os.name != "nt" use_neon = "neon_enabled" in env and env["neon_enabled"] and os.name != "nt"
if use_neon: if use_neon:
env_png.Append(CPPDEFINES=[("PNG_ARM_NEON_OPT", 2)]) env_png.Append(CPPDEFINES=[("PNG_ARM_NEON_OPT", 2)])
else: else:
env_png.Append(CPPDEFINES=[("PNG_ARM_NEON_OPT", 0)]) env_png.Append(CPPDEFINES=[("PNG_ARM_NEON_OPT", 0)])
env_thirdparty = env_png.Clone() env_thirdparty = env_png.Clone()
env_thirdparty.disable_warnings() env_thirdparty.disable_warnings()
env_thirdparty.add_source_files(thirdparty_obj, thirdparty_sources) env_thirdparty.add_source_files(thirdparty_obj, thirdparty_sources)
if use_neon: if use_neon:
env_neon = env_thirdparty.Clone() env_neon = env_thirdparty.Clone()
if "S_compiler" in env: if "S_compiler" in env:
env_neon["CC"] = env["S_compiler"] env_neon["CC"] = env["S_compiler"]
neon_sources = [] neon_sources = []
neon_sources.append(env_neon.Object(thirdparty_dir + "/arm/arm_init.c")) neon_sources.append(env_neon.Object(thirdparty_dir + "/arm/arm_init.c"))
neon_sources.append(env_neon.Object(thirdparty_dir + "/arm/filter_neon_intrinsics.c")) neon_sources.append(env_neon.Object(thirdparty_dir + "/arm/filter_neon_intrinsics.c"))
neon_sources.append(env_neon.Object(thirdparty_dir + "/arm/filter_neon.S")) neon_sources.append(env_neon.Object(thirdparty_dir + "/arm/filter_neon.S"))
neon_sources.append(env_neon.Object(thirdparty_dir + "/arm/palette_neon_intrinsics.c")) neon_sources.append(env_neon.Object(thirdparty_dir + "/arm/palette_neon_intrinsics.c"))
thirdparty_obj += neon_sources thirdparty_obj += neon_sources
env.modules_sources += thirdparty_obj env.modules_sources += thirdparty_obj
# Pandemonium source files # Pandemonium source files

View File

@ -178,25 +178,6 @@ def configure(env):
## Dependencies ## Dependencies
# 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"]: if not env["builtin_enet"]:
env.ParseConfig("pkg-config libenet --cflags --libs") env.ParseConfig("pkg-config libenet --cflags --libs")
@ -214,10 +195,6 @@ def configure(env):
## Flags ## Flags
# 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/server"]) env.Prepend(CPPPATH=["#platform/server"])
env.Append(CPPDEFINES=["SERVER_ENABLED", "UNIX_ENABLED"]) env.Append(CPPDEFINES=["SERVER_ENABLED", "UNIX_ENABLED"])

View File

@ -264,23 +264,6 @@ def configure(env):
# FIXME: Check for existence of the libs before parsing their flags with pkg-config # 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"]: if not env["builtin_enet"]:
env.ParseConfig("pkg-config libenet --cflags --libs") env.ParseConfig("pkg-config libenet --cflags --libs")
@ -323,10 +306,6 @@ def configure(env):
else: else:
env["udev"] = False # Linux specific 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", "OPENGL_ENABLED", "GLES_ENABLED", ("_FILE_OFFSET_BITS", 64)])