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 ab3fe4a
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 14 deletions.
6 changes: 3 additions & 3 deletions recipes/premake/5.x/conandata.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
sources:
"5.0.0-beta2":
url: "https://github.com/premake/premake-core/releases/download/v5.0.0-beta2/premake-5.0.0-beta2-src.zip"
sha256: "4c1100f5170ae1c3bd1b4fd9458b3b02ae841aefbfc41514887b80996436dee2"
# "5.0.0-beta2":

Check failure on line 2 in recipes/premake/5.x/conandata.yml

View workflow job for this annotation

GitHub Actions / Lint changed files (YAML files)

comment not indented like content
# url: "https://github.com/premake/premake-core/releases/download/v5.0.0-beta2/premake-5.0.0-beta2-src.zip"
# sha256: "4c1100f5170ae1c3bd1b4fd9458b3b02ae841aefbfc41514887b80996436dee2"
"5.0.0-alpha15":
url: "https://github.com/premake/premake-core/releases/download/v5.0.0-alpha15/premake-5.0.0-alpha15-src.zip"
sha256: "880f56e7cb9f4945d1cb879f059189462c1b7bf62ef43ac7d25842dfb177dd53"
Expand Down
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 ab3fe4a

Please sign in to comment.