From 8ecce873f337fc0392e19b48fb47fb0e8b825092 Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Thu, 14 Dec 2023 11:43:24 +0200 Subject: [PATCH] (#18844) premake: migrate to Conan v2 * premake: migrate to Conan v2 * premake: add VS 2022 support, fix package_type * premake: fix Linux package() * premake: fix package() * premake: get rid of vs_ide_version use * premake: add 5.0.0-beta2 * premake: add libuuid dependency * premake: add layout to test_package * premake: disable beta2 Fails with premake5: /lib/x86_64-linux-gnu/libm.so.6: version `GLIBC_2.29' not found (required by premake5) premake5: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.25' not found (required by premake5) premake5: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.28' not found (required by premake5) for v1 in CI during test_package. * premake: workaround for Conan v1 debug build failure * premake: tweak comments --- recipes/premake/5.x/conandata.yml | 7 - recipes/premake/5.x/conanfile.py | 154 ++++++++++++------ .../patches/0001-5.0.0-alpha14-mingw.patch | 72 -------- recipes/premake/5.x/test_package/conanfile.py | 14 +- .../premake/5.x/test_v1_package/conanfile.py | 9 + recipes/premake/config.yml | 4 +- 6 files changed, 125 insertions(+), 135 deletions(-) delete mode 100644 recipes/premake/5.x/patches/0001-5.0.0-alpha14-mingw.patch create mode 100644 recipes/premake/5.x/test_v1_package/conanfile.py diff --git a/recipes/premake/5.x/conandata.yml b/recipes/premake/5.x/conandata.yml index d96239dcf6113..91cb25d43c227 100644 --- a/recipes/premake/5.x/conandata.yml +++ b/recipes/premake/5.x/conandata.yml @@ -2,13 +2,6 @@ sources: "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" - "5.0.0-alpha14": - url: "https://github.com/premake/premake-core/releases/download/v5.0.0-alpha14/premake-5.0.0-alpha14-src.zip" - sha256: "7c9fa4488156625c819dd03f2b48bfd4712fbfabdc2b5768e8c7f52dd7d16608" patches: "5.0.0-alpha15": - patch_file: "patches/0001-5.0.0-alpha15-mingw.patch" - base_path: "source_subfolder" - "5.0.0-alpha14": - - patch_file: "patches/0001-5.0.0-alpha14-mingw.patch" - base_path: "source_subfolder" diff --git a/recipes/premake/5.x/conanfile.py b/recipes/premake/5.x/conanfile.py index f0834e0449cd2..d4fa461153f3c 100644 --- a/recipes/premake/5.x/conanfile.py +++ b/recipes/premake/5.x/conanfile.py @@ -1,19 +1,33 @@ -from conans import ConanFile, tools, AutoToolsBuildEnvironment, MSBuild -from conans.errors import ConanInvalidConfiguration import glob import os import re +import shutil + +from conan import ConanFile, conan_version +from conan.errors import ConanInvalidConfiguration +from conan.tools.build import cross_building +from conan.tools.files import apply_conandata_patches, chdir, copy, export_conandata_patches, get, replace_in_file +from conan.tools.gnu import Autotools, AutotoolsToolchain, AutotoolsDeps +from conan.tools.layout import basic_layout +from conan.tools.microsoft import MSBuild, MSBuildToolchain, is_msvc, check_min_vs + +required_conan_version = ">=1.53.0" class PremakeConan(ConanFile): name = "premake" - topics = ("conan", "premake", "build", "build-systems") - description = "Describe your software project just once, using Premake's simple and easy to read syntax, and build it everywhere" + description = ( + "Describe your software project just once, " + "using Premake's simple and easy to read syntax, " + "and build it everywhere" + ) + license = "BSD-3-Clause" url = "https://github.com/conan-io/conan-center-index" homepage = "https://premake.github.io" - license = "BSD-3-Clause" + topics = ("build", "build-systems") + + package_type = "application" settings = "os", "arch", "compiler", "build_type" - exports_sources = "patches/**" options = { "lto": [True, False], } @@ -21,35 +35,53 @@ class PremakeConan(ConanFile): "lto": False, } - @property - def _source_subfolder(self): - return "source_subfolder" - - def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = self.name + "-" + self.version - os.rename(extracted_dir, self._source_subfolder) + def export_sources(self): + export_conandata_patches(self) def config_options(self): - if self.settings.os != "Windows" or self.settings.compiler == "Visual Studio": - del self.options.lto + if self.settings.os != "Windows" or is_msvc(self): + self.options.rm_safe("lto") + + def layout(self): + basic_layout(self, src_folder="src") + + def package_id(self): + del self.info.settings.compiler + + def requirements(self): + if self.settings.os != "Windows": + self.requires("util-linux-libuuid/2.39") def validate(self): - if hasattr(self, 'settings_build') and tools.cross_building(self, skip_x64_x86=True): + if hasattr(self, "settings_build") and cross_building(self, skip_x64_x86=True): raise ConanInvalidConfiguration("Cross-building not implemented") + if conan_version.major == 1 and self.settings.build_type == "Debug": + # This configuration fails without any error messages in C3I. + # https://c3i.jfrog.io/artifactory/misc/logs/pr/18844/15-linux-clang/premake/5.0.0-alpha15/ + raise ConanInvalidConfiguration("Debug build not supported with Conan 1.x") + + def source(self): + get(self, **self.conan_data["sources"][self.version], strip_root=True) @property - def _msvc_version(self): - return { - "12": "2013", - "14": "2015", - "15": "2017", - "16": "2019", - }.get(str(self.settings.compiler.version), "2017") + def _ide_version(self): + compiler_version = str(self.settings.compiler.version) + if str(self.settings.compiler) == "Visual Studio": + return {"17": "2022", + "16": "2019", + "15": "2017", + "14": "2015", + "12": "2013"}.get(compiler_version) + else: + return {"193": "2022", + "192": "2019", + "191": "2017", + "190": "2015", + "180": "2013"}.get(compiler_version) @property - def _msvc_build_dirname(self): - return "vs{}".format(self._msvc_version) + def _msvc_build_dir(self): + return os.path.join(self.source_folder, "build", f"vs{self._ide_version}") def _version_info(self, version): res = [] @@ -63,13 +95,6 @@ def _version_info(self, version): res.append(p) return tuple(res) - @property - def _gmake_directory_name_prefix(self): - if self._version_info(self.version) <= self._version_info("5.0.0-alpha14"): - return "gmake" - else: - return "gmake2" - @property def _gmake_platform(self): return { @@ -80,8 +105,8 @@ def _gmake_platform(self): }[str(self.settings.os)] @property - def _gmake_build_dirname(self): - return "{}.{}".format(self._gmake_directory_name_prefix, self._gmake_platform) + def _gmake_build_dir(self): + return os.path.join(self.source_folder, "build", f"gmake2.{self._gmake_platform}") @property def _gmake_config(self): @@ -91,35 +116,62 @@ def _gmake_config(self): "x86": "x86", "x86_64": "x64", }[str(self.settings.arch)] - config = "{}_{}".format(build_type, arch) + config = f"{build_type}_{arch}" else: config = build_type return config + def generate(self): + if is_msvc(self): + tc = MSBuildToolchain(self) + tc.generate() + else: + tc = AutotoolsToolchain(self) + tc.make_args = ["verbose=1", f"config={self._gmake_config}"] + tc.generate() + deps = AutotoolsDeps(self) + deps.generate() + def _patch_sources(self): - for patch in self.conan_data.get("patches", {}).get(self.version, []): - tools.patch(**patch) - if self.options.get_safe("lto", None) == False: - for fn in glob.glob(os.path.join(self._source_subfolder, "build", self._gmake_build_dirname, "*.make")): - tools.replace_in_file(fn, "-flto", "", strict=False) + apply_conandata_patches(self) + if self.options.get_safe("lto", None) is False: + for fn in glob.glob(os.path.join(self._gmake_build_dir, "*.make")): + replace_in_file(self, fn, "-flto", "", strict=False) + if check_min_vs(self, 193, raise_invalid=False): + # Create VS 2022 project directory based on VS 2019 one + if "alpha" in str(self.version): + shutil.move(os.path.join(self.source_folder, "build", "vs2019"), + os.path.join(self.source_folder, "build", "vs2022")) + for vcxproj in glob.glob(os.path.join(self.source_folder, "build", "vs2022", "*.vcxproj")): + replace_in_file(self, vcxproj, "v142", "v143") def build(self): self._patch_sources() - if self.settings.compiler == "Visual Studio": - with tools.chdir(os.path.join(self._source_subfolder, "build", self._msvc_build_dirname)): + if is_msvc(self): + with chdir(self, self._msvc_build_dir): msbuild = MSBuild(self) - msbuild.build("Premake5.sln", platforms={"x86": "Win32", "x86_64": "x64"}) + msbuild.build(sln="Premake5.sln") else: - with tools.chdir(os.path.join(self._source_subfolder, "build", self._gmake_build_dirname)): - env_build = AutoToolsBuildEnvironment(self) - env_build.make(target="Premake5", args=["verbose=1", "config={}".format(self._gmake_config)]) + with chdir(self, self._gmake_build_dir): + autotools = Autotools(self) + autotools.make(target="Premake5") def package(self): - self.copy(pattern="LICENSE.txt", dst="licenses", src=self._source_subfolder) - self.copy(pattern="*premake5.exe", dst="bin", keep_path=False) - self.copy(pattern="*premake5", dst="bin", keep_path=False) + copy(self, "LICENSE.txt", + dst=os.path.join(self.package_folder, "licenses"), + src=self.source_folder) + suffix = ".exe" if self.settings.os == "Windows" else "" + copy(self, f"*/premake5{suffix}", + dst=os.path.join(self.package_folder, "bin"), + src=os.path.join(self.source_folder, "bin"), + keep_path=False) def package_info(self): + self.cpp_info.frameworkdirs = [] + self.cpp_info.libdirs = [] + self.cpp_info.resdirs = [] + self.cpp_info.includedirs = [] + + # TODO: Legacy, to be removed on Conan 2.0 bindir = os.path.join(self.package_folder, "bin") - self.output.info("Appending PATH environment variable: {}".format(bindir)) self.env_info.PATH.append(bindir) diff --git a/recipes/premake/5.x/patches/0001-5.0.0-alpha14-mingw.patch b/recipes/premake/5.x/patches/0001-5.0.0-alpha14-mingw.patch deleted file mode 100644 index 0dd121be8b2ae..0000000000000 --- a/recipes/premake/5.x/patches/0001-5.0.0-alpha14-mingw.patch +++ /dev/null @@ -1,72 +0,0 @@ ---- a/contrib/curl/lib/select.h -+++ b/contrib/curl/lib/select.h -@@ -36,7 +36,8 @@ - - #if !defined(HAVE_STRUCT_POLLFD) && \ - !defined(HAVE_SYS_POLL_H) && \ -- !defined(HAVE_POLL_H) -+ !defined(HAVE_POLL_H) && \ -+ !defined(POLLIN) - - #define POLLIN 0x01 - #define POLLPRI 0x02 ---- src/host/os_isdir.c -+++ src/host/os_isdir.c -@@ -9,7 +9,7 @@ - #include "premake.h" - - #ifdef _WIN32 --#include -+#include - #endif - - int os_isdir(lua_State* L) ---- src/host/os_uuid.c -+++ src/host/os_uuid.c -@@ -7,7 +7,7 @@ - #include "premake.h" - - #if PLATFORM_WINDOWS --#include -+#include - #endif - - ---- build/gmake.windows/Premake5.make -+++ build/gmake.windows/Premake5.make -@@ -22,7 +22,7 @@ - ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -m32 -flto -O3 -Wall -Wextra - ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -m32 -flto -O3 -Wall -Wextra -fno-stack-protector - ALL_RESFLAGS += $(RESFLAGS) $(DEFINES) $(INCLUDES) -- LIBS += bin/x86/Release/lua-lib.lib bin/x86/Release/zip-lib.lib bin/x86/Release/zlib-lib.lib bin/x86/Release/curl-lib.lib -lole32 -lws2_32 -ladvapi32 -+ LIBS += bin/x86/Release/lua-lib.lib bin/x86/Release/zip-lib.lib bin/x86/Release/zlib-lib.lib bin/x86/Release/curl-lib.lib -lole32 -lws2_32 -ladvapi32 -lversion -lcrypt32 - LDDEPS += bin/x86/Release/lua-lib.lib bin/x86/Release/zip-lib.lib bin/x86/Release/zlib-lib.lib bin/x86/Release/curl-lib.lib - ALL_LDFLAGS += $(LDFLAGS) -L/usr/lib32 -m32 -flto -s - LINKCMD = $(CC) -o "$@" $(OBJECTS) $(RESOURCES) $(ALL_LDFLAGS) $(LIBS) -@@ -49,7 +49,7 @@ ifeq ($(config),release_x64) - ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -m64 -flto -O3 -Wall -Wextra - ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -m64 -flto -O3 -Wall -Wextra -fno-stack-protector - ALL_RESFLAGS += $(RESFLAGS) $(DEFINES) $(INCLUDES) -- LIBS += bin/x64/Release/lua-lib.lib bin/x64/Release/zip-lib.lib bin/x64/Release/zlib-lib.lib bin/x64/Release/curl-lib.lib -lole32 -lws2_32 -ladvapi32 -+ LIBS += bin/x64/Release/lua-lib.lib bin/x64/Release/zip-lib.lib bin/x64/Release/zlib-lib.lib bin/x64/Release/curl-lib.lib -lole32 -lws2_32 -ladvapi32 -lversion -lcrypt32 - LDDEPS += bin/x64/Release/lua-lib.lib bin/x64/Release/zip-lib.lib bin/x64/Release/zlib-lib.lib bin/x64/Release/curl-lib.lib - ALL_LDFLAGS += $(LDFLAGS) -L/usr/lib64 -m64 -flto -s - LINKCMD = $(CC) -o "$@" $(OBJECTS) $(RESOURCES) $(ALL_LDFLAGS) $(LIBS) -@@ -76,7 +76,7 @@ - ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -m32 -g -Wall -Wextra - ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -m32 -g -Wall -Wextra - ALL_RESFLAGS += $(RESFLAGS) $(DEFINES) $(INCLUDES) -- LIBS += bin/x86/Debug/lua-lib.lib bin/x86/Debug/zip-lib.lib bin/x86/Debug/zlib-lib.lib bin/x86/Debug/curl-lib.lib -lole32 -lws2_32 -ladvapi32 -+ LIBS += bin/x86/Debug/lua-lib.lib bin/x86/Debug/zip-lib.lib bin/x86/Debug/zlib-lib.lib bin/x86/Debug/curl-lib.lib -lole32 -lws2_32 -ladvapi32 -lversion -lcrypt32 - LDDEPS += bin/x86/Debug/lua-lib.lib bin/x86/Debug/zip-lib.lib bin/x86/Debug/zlib-lib.lib bin/x86/Debug/curl-lib.lib - ALL_LDFLAGS += $(LDFLAGS) -L/usr/lib32 -m32 - LINKCMD = $(CC) -o "$@" $(OBJECTS) $(RESOURCES) $(ALL_LDFLAGS) $(LIBS) -@@ -103,7 +103,7 @@ - ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -m64 -g -Wall -Wextra - ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -m64 -g -Wall -Wextra - ALL_RESFLAGS += $(RESFLAGS) $(DEFINES) $(INCLUDES) -- LIBS += bin/x64/Debug/lua-lib.lib bin/x64/Debug/zip-lib.lib bin/x64/Debug/zlib-lib.lib bin/x64/Debug/curl-lib.lib -lole32 -lws2_32 -ladvapi32 -+ LIBS += bin/x64/Debug/lua-lib.lib bin/x64/Debug/zip-lib.lib bin/x64/Debug/zlib-lib.lib bin/x64/Debug/curl-lib.lib -lole32 -lws2_32 -ladvapi32 -lversion -lcrypt32 - LDDEPS += bin/x64/Debug/lua-lib.lib bin/x64/Debug/zip-lib.lib bin/x64/Debug/zlib-lib.lib bin/x64/Debug/curl-lib.lib - ALL_LDFLAGS += $(LDFLAGS) -L/usr/lib64 -m64 - LINKCMD = $(CC) -o "$@" $(OBJECTS) $(RESOURCES) $(ALL_LDFLAGS) $(LIBS) diff --git a/recipes/premake/5.x/test_package/conanfile.py b/recipes/premake/5.x/test_package/conanfile.py index c300eaeb0abb7..d2d508976967c 100644 --- a/recipes/premake/5.x/test_package/conanfile.py +++ b/recipes/premake/5.x/test_package/conanfile.py @@ -1,9 +1,17 @@ -from conans import ConanFile, tools +from conan import ConanFile +from conan.tools.cmake import cmake_layout class TestPackageConan(ConanFile): settings = "os", "arch", "compiler", "build_type" + generators = "VirtualBuildEnv" + test_type = "explicit" + + def build_requirements(self): + self.tool_requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def test(self): - if not tools.cross_building(self.settings): - self.run("premake5 --version", run_environment=True) + self.run("premake5 --version") diff --git a/recipes/premake/5.x/test_v1_package/conanfile.py b/recipes/premake/5.x/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..c300eaeb0abb7 --- /dev/null +++ b/recipes/premake/5.x/test_v1_package/conanfile.py @@ -0,0 +1,9 @@ +from conans import ConanFile, tools + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + + def test(self): + if not tools.cross_building(self.settings): + self.run("premake5 --version", run_environment=True) diff --git a/recipes/premake/config.yml b/recipes/premake/config.yml index e529cc98c1a62..95e71fee0aa88 100644 --- a/recipes/premake/config.yml +++ b/recipes/premake/config.yml @@ -1,5 +1,5 @@ versions: - "5.0.0-alpha14": - folder: "5.x" + # "5.0.0-beta2": + # folder: "5.x" "5.0.0-alpha15": folder: "5.x"