Skip to content

Commit

Permalink
premake: fix Windows build
Browse files Browse the repository at this point in the history
  • Loading branch information
valgur committed Mar 23, 2024
1 parent 39b1546 commit f3b33ca
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 11 deletions.
21 changes: 16 additions & 5 deletions recipes/premake/5.x/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from conan.tools.build import cross_building

Check warning on line 6 in recipes/premake/5.x/conanfile.py

View workflow job for this annotation

GitHub Actions / Lint changed conanfile.py (v2 migration)

Unused cross_building imported from conan.tools.build
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"

Expand Down Expand Up @@ -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)
Expand All @@ -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 {
Expand All @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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" }

Expand All @@ -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" }

Expand All @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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" }

Expand All @@ -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" }

Expand All @@ -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"

Expand Down

0 comments on commit f3b33ca

Please sign in to comment.