From f3b33caa1f45a7ff42d6e0e82e8171cb3b03cd54 Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Sun, 24 Mar 2024 01:03:25 +0200 Subject: [PATCH] premake: fix Windows build --- recipes/premake/5.x/conanfile.py | 21 ++++++++++++++----- .../5.0.0-alpha15/0001-use-conan-deps.patch | 7 ++++--- .../5.0.0-beta2/0001-use-conan-deps.patch | 7 ++++--- 3 files changed, 24 insertions(+), 11 deletions(-) diff --git a/recipes/premake/5.x/conanfile.py b/recipes/premake/5.x/conanfile.py index 6e0e6287361bc..1b99ac7ae2e9d 100644 --- a/recipes/premake/5.x/conanfile.py +++ b/recipes/premake/5.x/conanfile.py @@ -6,7 +6,7 @@ from conan.tools.build import cross_building from conan.tools.files import apply_conandata_patches, chdir, copy, export_conandata_patches, get, replace_in_file, rmdir, save from conan.tools.layout import basic_layout -from conan.tools.microsoft import is_msvc, VCVars +from conan.tools.microsoft import is_msvc, VCVars, is_msvc_static_runtime required_conan_version = ">=1.53.0" @@ -74,9 +74,10 @@ def generate(self): libs = ', '.join([f'"{lib}"' for dep in deps for lib in dep.libs + dep.system_libs]) if is_apple_os(self): libs += ''.join(f', "{lib}.framework"' for dep in deps for lib in dep.frameworks) + defines = ', '.join(f'"{d}"' for dep in deps for d in dep.defines) save(self, self._conan_deps_lua, - "conan_includedirs = {%s}\nconan_libdirs = {%s}\nconan_libs = {%s}\n" % - (includedirs, libdirs, libs)) + "conan_includedirs = {%s}\nconan_libdirs = {%s}\nconan_libs = {%s}\nconan_defines = {%s}\n" % + (includedirs, libdirs, libs, defines)) def _patch_sources(self): apply_conandata_patches(self) @@ -99,9 +100,16 @@ def _patch_sources(self): replace_in_file(self, os.path.join(self.source_folder, "premake5.lua"), "@CONAN_DEPS_LUA@", self._conan_deps_lua.replace("\\", "/")) + # Fix mismatching win32 arch name replace_in_file(self, os.path.join(self.source_folder, "Bootstrap.mak"), "$(PLATFORM:x86=win32)", "$(VS_ARCH)") + # Fix runtime library linkage + if not is_msvc_static_runtime(self): + replace_in_file(self, os.path.join(self.source_folder, "premake5.lua"), + '"StaticRuntime", ', "") + + @property def _os_target(self): return { @@ -124,17 +132,20 @@ def _arch(self): def _vs_ide_year(self): compiler_version = str(self.settings.compiler.version) if str(self.settings.compiler) == "Visual Studio": - return {"17": "2022", + year = {"17": "2022", "16": "2019", "15": "2017", "14": "2015", "12": "2013"}.get(compiler_version) else: - return {"193": "2022", + year = {"193": "2022", "192": "2019", "191": "2017", "190": "2015", "180": "2013"}.get(compiler_version) + if self.version == "5.0.0-alpha15" and year == "2022": + year = "2019" + return year def build(self): self._patch_sources() diff --git a/recipes/premake/5.x/patches/5.0.0-alpha15/0001-use-conan-deps.patch b/recipes/premake/5.x/patches/5.0.0-alpha15/0001-use-conan-deps.patch index a8d6012e8e2b8..f80f68533ffe2 100644 --- a/recipes/premake/5.x/patches/5.0.0-alpha15/0001-use-conan-deps.patch +++ b/recipes/premake/5.x/patches/5.0.0-alpha15/0001-use-conan-deps.patch @@ -25,7 +25,7 @@ filter { 'system:windows' } platforms { 'x86', 'x64' } -@@ -139,16 +136,9 @@ +@@ -139,16 +136,10 @@ includedirs { "contrib/lua/src", "contrib/luashim" } links { "lua-lib" } @@ -42,10 +42,11 @@ + includedirs { conan_includedirs } + libdirs { conan_libdirs } + links { conan_libs } ++ defines { conan_defines } files { -@@ -185,11 +175,6 @@ +@@ -185,11 +176,6 @@ filter "system:linux or hurd" links { "dl", "rt" } @@ -57,7 +58,7 @@ filter "system:macosx" defines { "LUA_USE_MACOSX" } links { "CoreServices.framework", "Foundation.framework", "Security.framework", "readline" } -@@ -213,23 +198,6 @@ +@@ -213,23 +199,6 @@ group "contrib" include "contrib/lua" include "contrib/luashim" diff --git a/recipes/premake/5.x/patches/5.0.0-beta2/0001-use-conan-deps.patch b/recipes/premake/5.x/patches/5.0.0-beta2/0001-use-conan-deps.patch index d0ad08e195041..90e511901e177 100644 --- a/recipes/premake/5.x/patches/5.0.0-beta2/0001-use-conan-deps.patch +++ b/recipes/premake/5.x/patches/5.0.0-beta2/0001-use-conan-deps.patch @@ -25,7 +25,7 @@ filter { "system:macosx", "options:arch=ARM or arch=ARM64" } buildoptions { "-arch arm64" } -@@ -197,16 +194,9 @@ +@@ -197,16 +194,10 @@ includedirs { "contrib/lua/src", "contrib/luashim" } links { "lua-lib" } @@ -42,10 +42,11 @@ + includedirs { conan_includedirs } + libdirs { conan_libdirs } + links { conan_libs } ++ defines { conan_defines } files { -@@ -244,11 +234,6 @@ +@@ -244,11 +235,6 @@ filter "system:linux or hurd" links { "dl", "rt" } @@ -57,7 +58,7 @@ filter "system:macosx" defines { "LUA_USE_MACOSX" } links { "CoreServices.framework", "Foundation.framework", "Security.framework", "readline" } -@@ -276,23 +261,6 @@ +@@ -276,23 +262,6 @@ include "contrib/lua" include "contrib/luashim"