From 9fa1955f70174a90583a84f9892414028019b45f Mon Sep 17 00:00:00 2001 From: luncliff Date: Sun, 5 Nov 2023 02:03:45 +0900 Subject: [PATCH] [godot] fixing platform/windows/detect.py --- ports/godot/fix-scons.patch | 130 ++++++++++++++++++++++++++++++++++++ ports/godot/portfile.cmake | 15 ++++- ports/godot/vcpkg.json | 1 + 3 files changed, 145 insertions(+), 1 deletion(-) create mode 100644 ports/godot/fix-scons.patch diff --git a/ports/godot/fix-scons.patch b/ports/godot/fix-scons.patch new file mode 100644 index 00000000..c4a508a2 --- /dev/null +++ b/ports/godot/fix-scons.patch @@ -0,0 +1,130 @@ +diff --git a/modules/SCsub b/modules/SCsub +index fcc01e2..56bb473 100644 +--- a/modules/SCsub ++++ b/modules/SCsub +@@ -5,6 +5,17 @@ import os + + Import("env") + ++from os.path import join ++vcpkg_installed_dir = os.environ["VCPKG_INSTALLED_DIR"] ++vcpkg_include_dir = join(vcpkg_installed_dir, "include") ++env.Prepend(CPPPATH=[vcpkg_include_dir]) ++ ++vcpkg_lib_dir = join(vcpkg_installed_dir, "lib") ++env.Prepend(LIBPATH=[vcpkg_lib_dir]) ++ ++vcpkg_bin_dir = join(vcpkg_installed_dir, "bin") ++env.Prepend(RPATH=[vcpkg_bin_dir]) ++ + env_modules = env.Clone() + + Export("env_modules") +diff --git a/platform/windows/detect.py b/platform/windows/detect.py +index 6e56f2a..cf49624 100644 +--- a/platform/windows/detect.py ++++ b/platform/windows/detect.py +@@ -652,6 +652,103 @@ def configure(env: "Environment"): + setup_mingw(env) + env.msvc = False + ++ # 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. And graphite and harfbuzz need freetype. ++ ft_linked_deps = [ ++ env["builtin_freetype"], ++ env["builtin_libpng"], ++ env["builtin_zlib"], ++ env["builtin_graphite"], ++ env["builtin_harfbuzz"], ++ ] ++ if (not all(ft_linked_deps)) and any(ft_linked_deps): # All or nothing. ++ print( ++ "These libraries should be either all builtin, or all system provided:\n" ++ "freetype, libpng, zlib, graphite, harfbuzz.\n" ++ "Please specify `builtin_=no` for all of them, or none." ++ ) ++ sys.exit(255) ++ ++ if not env["builtin_freetype"]: ++ env.ParseConfig("pkg-config freetype2 --cflags --libs") ++ ++ if not env["builtin_graphite"]: ++ env.ParseConfig("pkg-config graphite2 --cflags --libs") ++ ++ if not env["builtin_icu4c"]: ++ env.ParseConfig("pkg-config icu-i18n icu-uc --cflags --libs") ++ ++ if not env["builtin_harfbuzz"]: ++ env.ParseConfig("pkg-config harfbuzz harfbuzz-icu --cflags --libs") ++ ++ if not env["builtin_libpng"]: ++ env.ParseConfig("pkg-config libpng16 --cflags --libs") ++ ++ if not env["builtin_enet"]: ++ env.ParseConfig("pkg-config libenet --cflags --libs") ++ ++ if not env["builtin_squish"]: ++ # libsquish doesn't reliably install its .pc file, so some distros lack it. ++ env.Append(LIBS=["libsquish"]) ++ ++ if not env["builtin_zstd"]: ++ env.ParseConfig("pkg-config libzstd --cflags --libs") ++ ++ if not env["builtin_brotli"]: ++ env.ParseConfig("pkg-config libbrotlicommon libbrotlidec --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") ++ ++ ++ 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_libogg"]: ++ env.ParseConfig("pkg-config ogg --cflags --libs") ++ ++ if not env["builtin_libwebp"]: ++ env.ParseConfig("pkg-config libwebp --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"]: ++ env.Append(LIBS=["miniupnpc"]) ++ ++ # On Linux wchar_t should be 32-bits ++ # 16-bit library shouldn't be required due to compiler optimizations ++ if not env["builtin_pcre2"]: ++ env.ParseConfig("pkg-config libpcre2-32 --cflags --libs") ++ ++ # if not env["builtin_recastnavigation"]: ++ # # No pkgconfig file so far, hardcode default paths. ++ # env.Prepend(CPPPATH=["/usr/include/recastnavigation"]) ++ # env.Append(LIBS=["Recast"]) ++ ++ if not env["builtin_embree"] and env["arch"] in ["x86_64", "arm64"]: ++ # No pkgconfig file so far, hardcode expected lib name. ++ env.Append(LIBS=["embree3"]) ++ ++ # if not env["builtin_openxr"]: ++ # env.ParseConfig("pkg-config openxr --cflags --libs") ++ ++ # Linkflags below this line should typically stay the last ones ++ if not env["builtin_zlib"]: ++ env.ParseConfig("pkg-config zlib --cflags --libs") ++ + # Now set compiler/linker flags + if env.msvc: + configure_msvc(env, vcvars_msvc_config) diff --git a/ports/godot/portfile.cmake b/ports/godot/portfile.cmake index 727c42b5..ccfee858 100644 --- a/ports/godot/portfile.cmake +++ b/ports/godot/portfile.cmake @@ -1,3 +1,4 @@ +# see https://docs.godotengine.org/en/latest/contributing/development/compiling/index.html # see https://github.com/godotengine/godot/blob/master/.github/workflows/ if(VCPKG_TARGET_IS_WINDOWS) vcpkg_check_linkage(ONLY_DYNAMIC_LIBRARY) @@ -12,8 +13,20 @@ vcpkg_from_github( REF 4.1.2-stable SHA512 691a225fbcd5fc242a20b4e49394728ab7db58669e1badfb81d36bad2d4bee3f85d4e99805332d6e97aca48c3f592b1c36bbfc18a3a5a40fb5809f8d8b0f42c7 HEAD_REF master + # PATCHES + # fix-scons.patch ) -# file(REMOVE_RECURSE "${SOURCE_PATH}/thirdparty") + +# todo: move thirdparty to ports +# file(GLOB_RECURSE THIRD_SOURCES +# "${SOURCE_PATH}/thirdparty/*.h" +# "${SOURCE_PATH}/thirdparty/*.c" +# "${SOURCE_PATH}/thirdparty/*.hpp" +# "${SOURCE_PATH}/thirdparty/*.cpp" +# ) +# if(THIRD_SOURCES) +# file(REMOVE ${THIRD_SOURCES}) +# endif() # 1. Prepare required tools: https://scons.org/ vcpkg_find_acquire_program(PKGCONFIG) diff --git a/ports/godot/vcpkg.json b/ports/godot/vcpkg.json index f3ca0704..f7b89204 100644 --- a/ports/godot/vcpkg.json +++ b/ports/godot/vcpkg.json @@ -60,6 +60,7 @@ "host": true }, "zlib", + "pcg", "zstd" ], "features": {