From 058cb1fb675c8d15937acec0a6a7920fa07630b5 Mon Sep 17 00:00:00 2001 From: memsharded Date: Thu, 15 Jul 2021 17:51:31 +0200 Subject: [PATCH 01/10] wip --- recipes/zlib/1.2.11/CMakeLists.txt | 9 -- recipes/zlib/1.2.11/conandata.yml | 2 - recipes/zlib/1.2.11/conanfile.py | 87 +++++++++---------- recipes/zlib/1.2.11/test_package/conanfile.py | 14 ++- .../test_package/{ => src}/CMakeLists.txt | 5 +- .../zlib/1.2.11/test_package/{ => src}/test.c | 0 6 files changed, 55 insertions(+), 62 deletions(-) delete mode 100644 recipes/zlib/1.2.11/CMakeLists.txt rename recipes/zlib/1.2.11/test_package/{ => src}/CMakeLists.txt (55%) rename recipes/zlib/1.2.11/test_package/{ => src}/test.c (100%) diff --git a/recipes/zlib/1.2.11/CMakeLists.txt b/recipes/zlib/1.2.11/CMakeLists.txt deleted file mode 100644 index 9ca0774a41f3a..0000000000000 --- a/recipes/zlib/1.2.11/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -cmake_minimum_required(VERSION 2.8) -project(conanzlib) - -message(STATUS "Conan CMake Wrapper") -include(conanbuildinfo.cmake) -conan_basic_setup() - -include_directories(${CMAKE_SOURCE_DIR}/source_subfolder) -add_subdirectory("source_subfolder") diff --git a/recipes/zlib/1.2.11/conandata.yml b/recipes/zlib/1.2.11/conandata.yml index 7624bd5968faa..f11c4a33f5a60 100644 --- a/recipes/zlib/1.2.11/conandata.yml +++ b/recipes/zlib/1.2.11/conandata.yml @@ -8,6 +8,4 @@ sources: patches: "1.2.11": - patch_file: "patches/0002-gzguts-xcode12-compile-fix.patch" - base_path: "source_subfolder" - patch_file: "patches/0003-cmake-fix-msys2-subsystem.patch" - base_path: "source_subfolder" diff --git a/recipes/zlib/1.2.11/conanfile.py b/recipes/zlib/1.2.11/conanfile.py index 1a06fdb6bde7f..76d7efbe22d18 100644 --- a/recipes/zlib/1.2.11/conanfile.py +++ b/recipes/zlib/1.2.11/conanfile.py @@ -1,5 +1,7 @@ import os -from conans import ConanFile, tools, CMake +from conans import ConanFile, tools +from conan.tools.cmake import CMake +from conan.tools.layout import cmake_layout from conans.errors import ConanException @@ -14,17 +16,9 @@ class ZlibConan(ConanFile): settings = "os", "arch", "compiler", "build_type" options = {"shared": [True, False], "fPIC": [True, False], "minizip": [True, False, "deprecated"]} default_options = {"shared": False, "fPIC": True, "minizip": "deprecated"} - exports_sources = ["CMakeLists.txt", "CMakeLists_minizip.txt", "patches/**"] - generators = "cmake" - topics = ("conan", "zlib", "compression") - - @property - def _source_subfolder(self): - return "source_subfolder" - - @property - def _build_subfolder(self): - return "build_subfolder" + exports_sources = ["patches/**"] + generators = "CMakeToolchain", "CMakeDeps" + topics = ("zlib", "compression") def config_options(self): if self.settings.os == "Windows": @@ -44,35 +38,39 @@ def package_id(self): del self.info.options.minizip def source(self): - tools.get(**self.conan_data["sources"][self.version], destination=self._source_subfolder, strip_root=True) + tools.get(**self.conan_data["sources"][self.version], destination=self.source_folder, strip_root=True) def _patch_sources(self): - for patch in self.conan_data["patches"][self.version]: - tools.patch(**patch) - - with tools.chdir(self._source_subfolder): - # https://github.com/madler/zlib/issues/268 - tools.replace_in_file('gzguts.h', - '#if defined(_WIN32) || defined(__CYGWIN__)', - '#if defined(_WIN32) || defined(__MINGW32__)') - - is_apple_clang12 = self.settings.compiler == "apple-clang" and tools.Version(self.settings.compiler.version) >= "12.0" - if not is_apple_clang12: - for filename in ['zconf.h', 'zconf.h.cmakein', 'zconf.h.in']: - tools.replace_in_file(filename, - '#ifdef HAVE_UNISTD_H ' - '/* may be set to #if 1 by ./configure */', - '#if defined(HAVE_UNISTD_H) && (1-HAVE_UNISTD_H-1 != 0)') - tools.replace_in_file(filename, - '#ifdef HAVE_STDARG_H ' - '/* may be set to #if 1 by ./configure */', - '#if defined(HAVE_STDARG_H) && (1-HAVE_STDARG_H-1 != 0)') + with tools.chdir(".."): + for patch in self.conan_data["patches"][self.version]: + tools.patch(**patch, base_path=self.source_folder) + + with tools.chdir(self.source_folder): + # https://github.com/madler/zlib/issues/268 + tools.replace_in_file('gzguts.h', + '#if defined(_WIN32) || defined(__CYGWIN__)', + '#if defined(_WIN32) || defined(__MINGW32__)') + + is_apple_clang12 = self.settings.compiler == "apple-clang" and tools.Version(self.settings.compiler.version) >= "12.0" + if not is_apple_clang12: + for filename in ['zconf.h', 'zconf.h.cmakein', 'zconf.h.in']: + tools.replace_in_file(filename, + '#ifdef HAVE_UNISTD_H ' + '/* may be set to #if 1 by ./configure */', + '#if defined(HAVE_UNISTD_H) && (1-HAVE_UNISTD_H-1 != 0)') + tools.replace_in_file(filename, + '#ifdef HAVE_STDARG_H ' + '/* may be set to #if 1 by ./configure */', + '#if defined(HAVE_STDARG_H) && (1-HAVE_STDARG_H-1 != 0)') + + def layout(self): + cmake_layout(self) def build(self): self._patch_sources() make_target = "zlib" if self.options.shared else "zlibstatic" cmake = CMake(self) - cmake.configure(build_folder=self._build_subfolder) + cmake.configure() cmake.build(target=make_target) def _rename_libraries(self): @@ -97,29 +95,29 @@ def _rename_libraries(self): tools.rename(current_lib, os.path.join(lib_path, "zlib.lib")) def _extract_license(self): - with tools.chdir(os.path.join(self.source_folder, self._source_subfolder)): + with tools.chdir(self.source_folder): tmp = tools.load("zlib.h") license_contents = tmp[2:tmp.find("*/", 1)] tools.save("LICENSE", license_contents) def package(self): self._extract_license() - self.copy("LICENSE", src=self._source_subfolder, dst="licenses") + self.copy("LICENSE", dst="licenses") # Copy headers for header in ["*zlib.h", "*zconf.h"]: - self.copy(pattern=header, dst="include", src=self._source_subfolder, keep_path=False) - self.copy(pattern=header, dst="include", src=self._build_subfolder, keep_path=False) + self.copy(pattern=header, dst="include", keep_path=False) + self.copy(pattern=header, dst="include", keep_path=False) # Copying static and dynamic libs if self.options.shared: - self.copy(pattern="*.dylib*", dst="lib", src=self._build_subfolder, keep_path=False, symlinks=True) - self.copy(pattern="*.so*", dst="lib", src=self._build_subfolder, keep_path=False, symlinks=True) - self.copy(pattern="*.dll", dst="bin", src=self._build_subfolder, keep_path=False) - self.copy(pattern="*.dll.a", dst="lib", src=self._build_subfolder, keep_path=False) + self.copy(pattern="*.dylib*", dst="lib", keep_path=False, symlinks=True) + self.copy(pattern="*.so*", dst="lib", keep_path=False, symlinks=True) + self.copy(pattern="*.dll", dst="bin", keep_path=False) + self.copy(pattern="*.dll.a", dst="lib", keep_path=False) else: - self.copy(pattern="*.a", dst="lib", src=self._build_subfolder, keep_path=False) - self.copy(pattern="*.lib", dst="lib", src=self._build_subfolder, keep_path=False) + self.copy(pattern="*.a", dst="lib", keep_path=False) + self.copy(pattern="*.lib", dst="lib", keep_path=False) self._rename_libraries() @@ -127,3 +125,4 @@ def package_info(self): self.cpp_info.libs.append("zlib" if self.settings.os == "Windows" and not self.settings.os.subsystem else "z") self.cpp_info.names["cmake_find_package"] = "ZLIB" self.cpp_info.names["cmake_find_package_multi"] = "ZLIB" + self.cpp_info.set_property("cmake_file_name", "ZLIB") diff --git a/recipes/zlib/1.2.11/test_package/conanfile.py b/recipes/zlib/1.2.11/test_package/conanfile.py index 093cbddd41a9b..94c523fc6df74 100644 --- a/recipes/zlib/1.2.11/test_package/conanfile.py +++ b/recipes/zlib/1.2.11/test_package/conanfile.py @@ -1,9 +1,11 @@ import os -from conans import ConanFile, CMake, tools +from conans import ConanFile, tools +from conan.tools.cmake import CMake +from conan.tools.layout import cmake_layout class TestZlibConan(ConanFile): settings = "os", "compiler", "arch", "build_type" - generators = "cmake", "pkg_config" + generators = "CMakeDeps", "CMakeToolchain", "PkgConfigDeps" def configure(self): del self.settings.compiler.libcxx @@ -13,8 +15,12 @@ def build(self): cmake.configure() cmake.build() + def layout(self): + cmake_layout(self) + def test(self): assert os.path.exists(os.path.join(self.deps_cpp_info["zlib"].rootpath, "licenses", "LICENSE")) - assert os.path.exists(os.path.join(self.build_folder, "zlib.pc")) + assert os.path.exists(os.path.join(self.generators_folder, "zlib.pc")) if "x86" in self.settings.arch and not tools.cross_building(self.settings): - self.run(os.path.join("bin", "test"), run_environment=True) + # FIXME: Very ugly interface to get the current test executable path + self.run(os.path.join(self.build_folder, self.cpp.build.libdirs[0], "test"), run_environment=True) diff --git a/recipes/zlib/1.2.11/test_package/CMakeLists.txt b/recipes/zlib/1.2.11/test_package/src/CMakeLists.txt similarity index 55% rename from recipes/zlib/1.2.11/test_package/CMakeLists.txt rename to recipes/zlib/1.2.11/test_package/src/CMakeLists.txt index c49f3b49e436a..a2f7363f13f31 100644 --- a/recipes/zlib/1.2.11/test_package/CMakeLists.txt +++ b/recipes/zlib/1.2.11/test_package/src/CMakeLists.txt @@ -1,9 +1,8 @@ cmake_minimum_required(VERSION 3.0) project(test_package C) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup(TARGETS) +find_package(ZLIB REQUIRED) add_executable(test_zlib test.c) -target_link_libraries(test_zlib CONAN_PKG::zlib) +target_link_libraries(test_zlib ZLIB::ZLIB) set_target_properties(test_zlib PROPERTIES OUTPUT_NAME "test") diff --git a/recipes/zlib/1.2.11/test_package/test.c b/recipes/zlib/1.2.11/test_package/src/test.c similarity index 100% rename from recipes/zlib/1.2.11/test_package/test.c rename to recipes/zlib/1.2.11/test_package/src/test.c From beb9ab4d4724782b24f55e6a29f4429c404bc0eb Mon Sep 17 00:00:00 2001 From: memsharded Date: Thu, 15 Jul 2021 19:09:29 +0200 Subject: [PATCH 02/10] wip --- recipes/bzip2/all/CMakeLists.txt | 5 +- recipes/bzip2/all/conanfile.py | 49 ++++++++----------- recipes/bzip2/all/test_package/conanfile.py | 17 +++++-- .../all/test_package/{ => src}/CMakeLists.txt | 3 -- .../all/test_package/{ => src}/test_package.c | 0 recipes/zlib/1.2.11/conanfile.py | 2 +- recipes/zlib/1.2.11/test_package/conanfile.py | 11 +++-- 7 files changed, 44 insertions(+), 43 deletions(-) rename recipes/bzip2/all/test_package/{ => src}/CMakeLists.txt (86%) rename recipes/bzip2/all/test_package/{ => src}/test_package.c (100%) diff --git a/recipes/bzip2/all/CMakeLists.txt b/recipes/bzip2/all/CMakeLists.txt index f030f7a2fa9cd..f4c2f1dd2a877 100644 --- a/recipes/bzip2/all/CMakeLists.txt +++ b/recipes/bzip2/all/CMakeLists.txt @@ -3,15 +3,12 @@ project(bzip2 C) include(GNUInstallDirs) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() - if(MSVC OR MSVC90 OR MSVC10) set(MSVC ON) set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) endif() -set(SOURCE_SUBFOLDER ${CMAKE_CURRENT_SOURCE_DIR}/source_subfolder) +set(SOURCE_SUBFOLDER ${CMAKE_CURRENT_SOURCE_DIR}) set(BZ2_LIBRARY bz2) option(BZ2_BUILD_EXE ON) diff --git a/recipes/bzip2/all/conanfile.py b/recipes/bzip2/all/conanfile.py index f95d8070f7d75..c17f0510d69fb 100644 --- a/recipes/bzip2/all/conanfile.py +++ b/recipes/bzip2/all/conanfile.py @@ -1,6 +1,8 @@ import os import textwrap -from conans import ConanFile, CMake, tools +from conans import ConanFile, tools +from conan.tools.cmake import CMake, CMakeToolchain +from conan.tools.layout import cmake_layout required_conan_version = ">=1.33.0" @@ -11,7 +13,7 @@ class Bzip2Conan(ConanFile): homepage = "http://www.bzip.org" license = "bzip2-1.0.8" description = "bzip2 is a free and open-source file compression program that uses the Burrows Wheeler algorithm." - topics = ("conan", "bzip2", "data-compressor", "file-compression") + topics = ("bzip2", "data-compressor", "file-compression") settings = "os", "compiler", "arch", "build_type" options = { @@ -26,12 +28,6 @@ class Bzip2Conan(ConanFile): } exports_sources = ["CMakeLists.txt", "patches/**"] - generators = "cmake" - _cmake = None - - @property - def _source_subfolder(self): - return "source_subfolder" def config_options(self): if self.settings.os == "Windows": @@ -45,27 +41,29 @@ def configure(self): del self.settings.compiler.cppstd def source(self): - tools.get(**self.conan_data["sources"][self.version], destination=self._source_subfolder, strip_root=True) - - def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) - self._cmake.definitions["BZ2_VERSION_STRING"] = self.version - self._cmake.definitions["BZ2_VERSION_MAJOR"] = tools.Version(self.version).major - self._cmake.definitions["BZ2_BUILD_EXE"] = self.options.build_executable - self._cmake.configure() - return self._cmake + tools.get(**self.conan_data["sources"][self.version], destination=self.source_folder, strip_root=True) + os.rename("CMakeLists.txt", "src/CMakeLists.txt") + + def layout(self): + cmake_layout(self) + + def generate(self): + cmake_toolchain = CMakeToolchain(self) + cmake_toolchain.variables["BZ2_VERSION_STRING"] = self.version + cmake_toolchain.variables["BZ2_VERSION_MAJOR"] = tools.Version(self.version).major + cmake_toolchain.variables["BZ2_BUILD_EXE"] = self.options.build_executable + cmake_toolchain.generate() def build(self): - for patch in self.conan_data.get("patches", {}).get(self.version, []): + for patch in self.conan_data["patches"].get(self.version, []): tools.patch(**patch) - cmake = self._configure_cmake() + cmake = CMake(self) + cmake.configure() cmake.build() def package(self): - self.copy("LICENSE", dst="licenses", src=self._source_subfolder) - cmake = self._configure_cmake() + self.copy("LICENSE", dst="licenses") + cmake = CMake(self) cmake.install() self._create_cmake_module_variables( os.path.join(self.package_folder, self._module_subfolder, self._module_file) @@ -105,8 +103,3 @@ def package_info(self): self.cpp_info.builddirs.append(self._module_subfolder) self.cpp_info.build_modules["cmake_find_package"] = [os.path.join(self._module_subfolder, self._module_file)] self.cpp_info.libs = ["bz2"] - - if self.options.build_executable: - bin_path = os.path.join(self.package_folder, "bin") - self.output.info("Appending PATH environment variable: {}".format(bin_path)) - self.env_info.PATH.append(bin_path) diff --git a/recipes/bzip2/all/test_package/conanfile.py b/recipes/bzip2/all/test_package/conanfile.py index 4df84b70849e5..385718a21aacf 100644 --- a/recipes/bzip2/all/test_package/conanfile.py +++ b/recipes/bzip2/all/test_package/conanfile.py @@ -1,17 +1,26 @@ import os -from conans import ConanFile, CMake, tools +from conans import ConanFile, tools +from conan.tools.cmake import CMake +from conan.tools.layout import cmake_layout class TestPackageConan(ConanFile): settings = "os", "compiler", "arch", "build_type" - generators = "cmake", "cmake_find_package" + generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" def build(self): cmake = CMake(self) cmake.configure() cmake.build() + def configure(self): + del self.settings.compiler.libcxx + + def layout(self): + cmake_layout(self) + def test(self): if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run("%s --help" % bin_path, run_environment=True) + # FIXME: Very ugly interface to get the current test executable path + cmd = os.path.join(self.build_folder, self.cpp.build.libdirs[0], "test_package") + self.run("%s --help" % cmd, env=["conanrunenv"]) diff --git a/recipes/bzip2/all/test_package/CMakeLists.txt b/recipes/bzip2/all/test_package/src/CMakeLists.txt similarity index 86% rename from recipes/bzip2/all/test_package/CMakeLists.txt rename to recipes/bzip2/all/test_package/src/CMakeLists.txt index 8bc0f00ec83b0..f018e6cde6521 100644 --- a/recipes/bzip2/all/test_package/CMakeLists.txt +++ b/recipes/bzip2/all/test_package/src/CMakeLists.txt @@ -1,9 +1,6 @@ cmake_minimum_required(VERSION 3.1) project(test_package C) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup(TARGETS) - find_package(BZip2 REQUIRED) message("BZIP2_FOUND: ${BZIP2_FOUND}") message("BZIP2_NEED_PREFIX: ${BZIP2_NEED_PREFIX}") diff --git a/recipes/bzip2/all/test_package/test_package.c b/recipes/bzip2/all/test_package/src/test_package.c similarity index 100% rename from recipes/bzip2/all/test_package/test_package.c rename to recipes/bzip2/all/test_package/src/test_package.c diff --git a/recipes/zlib/1.2.11/conanfile.py b/recipes/zlib/1.2.11/conanfile.py index 76d7efbe22d18..7b247222f2224 100644 --- a/recipes/zlib/1.2.11/conanfile.py +++ b/recipes/zlib/1.2.11/conanfile.py @@ -41,7 +41,7 @@ def source(self): tools.get(**self.conan_data["sources"][self.version], destination=self.source_folder, strip_root=True) def _patch_sources(self): - with tools.chdir(".."): + with tools.chdir(".."): # FIXME: This need to go to parent folder is not very nice. for patch in self.conan_data["patches"][self.version]: tools.patch(**patch, base_path=self.source_folder) diff --git a/recipes/zlib/1.2.11/test_package/conanfile.py b/recipes/zlib/1.2.11/test_package/conanfile.py index 94c523fc6df74..2feccc895106c 100644 --- a/recipes/zlib/1.2.11/test_package/conanfile.py +++ b/recipes/zlib/1.2.11/test_package/conanfile.py @@ -5,7 +5,7 @@ class TestZlibConan(ConanFile): settings = "os", "compiler", "arch", "build_type" - generators = "CMakeDeps", "CMakeToolchain", "PkgConfigDeps" + generators = "CMakeDeps", "CMakeToolchain", "PkgConfigDeps", "VirtualRunEnv" def configure(self): del self.settings.compiler.libcxx @@ -18,9 +18,14 @@ def build(self): def layout(self): cmake_layout(self) + def generate(self): + # Necessary modernization, as test() doesn't have self.dependencies yet. + assert os.path.exists(os.path.join(self.dependencies["zlib"].package_folder, "licenses", "LICENSE")) + def test(self): - assert os.path.exists(os.path.join(self.deps_cpp_info["zlib"].rootpath, "licenses", "LICENSE")) assert os.path.exists(os.path.join(self.generators_folder, "zlib.pc")) if "x86" in self.settings.arch and not tools.cross_building(self.settings): # FIXME: Very ugly interface to get the current test executable path - self.run(os.path.join(self.build_folder, self.cpp.build.libdirs[0], "test"), run_environment=True) + cmd = os.path.join(self.build_folder, self.cpp.build.libdirs[0], "test") + self.output.info("Running {}".format(cmd)) + self.run(cmd) From af531220e9ec2fbf73c010e5b3783ec51d8c8105 Mon Sep 17 00:00:00 2001 From: memsharded Date: Thu, 15 Jul 2021 19:36:05 +0200 Subject: [PATCH 03/10] wip --- recipes/zlib/1.2.11/conanfile.py | 35 ++++++++++--------- recipes/zlib/1.2.11/test_package/conanfile.py | 2 +- 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/recipes/zlib/1.2.11/conanfile.py b/recipes/zlib/1.2.11/conanfile.py index 7b247222f2224..0a7751fe7f44c 100644 --- a/recipes/zlib/1.2.11/conanfile.py +++ b/recipes/zlib/1.2.11/conanfile.py @@ -45,23 +45,23 @@ def _patch_sources(self): for patch in self.conan_data["patches"][self.version]: tools.patch(**patch, base_path=self.source_folder) - with tools.chdir(self.source_folder): - # https://github.com/madler/zlib/issues/268 - tools.replace_in_file('gzguts.h', - '#if defined(_WIN32) || defined(__CYGWIN__)', - '#if defined(_WIN32) || defined(__MINGW32__)') - - is_apple_clang12 = self.settings.compiler == "apple-clang" and tools.Version(self.settings.compiler.version) >= "12.0" - if not is_apple_clang12: - for filename in ['zconf.h', 'zconf.h.cmakein', 'zconf.h.in']: - tools.replace_in_file(filename, - '#ifdef HAVE_UNISTD_H ' - '/* may be set to #if 1 by ./configure */', - '#if defined(HAVE_UNISTD_H) && (1-HAVE_UNISTD_H-1 != 0)') - tools.replace_in_file(filename, - '#ifdef HAVE_STDARG_H ' - '/* may be set to #if 1 by ./configure */', - '#if defined(HAVE_STDARG_H) && (1-HAVE_STDARG_H-1 != 0)') + with tools.chdir(self.source_folder): + # https://github.com/madler/zlib/issues/268 + tools.replace_in_file('gzguts.h', + '#if defined(_WIN32) || defined(__CYGWIN__)', + '#if defined(_WIN32) || defined(__MINGW32__)') + + is_apple_clang12 = self.settings.compiler == "apple-clang" and tools.Version(self.settings.compiler.version) >= "12.0" + if not is_apple_clang12: + for filename in ['zconf.h', 'zconf.h.cmakein', 'zconf.h.in']: + tools.replace_in_file(filename, + '#ifdef HAVE_UNISTD_H ' + '/* may be set to #if 1 by ./configure */', + '#if defined(HAVE_UNISTD_H) && (1-HAVE_UNISTD_H-1 != 0)') + tools.replace_in_file(filename, + '#ifdef HAVE_STDARG_H ' + '/* may be set to #if 1 by ./configure */', + '#if defined(HAVE_STDARG_H) && (1-HAVE_STDARG_H-1 != 0)') def layout(self): cmake_layout(self) @@ -126,3 +126,4 @@ def package_info(self): self.cpp_info.names["cmake_find_package"] = "ZLIB" self.cpp_info.names["cmake_find_package_multi"] = "ZLIB" self.cpp_info.set_property("cmake_file_name", "ZLIB") + self.cpp_info.set_property("cmake_target_name", "ZLIB") diff --git a/recipes/zlib/1.2.11/test_package/conanfile.py b/recipes/zlib/1.2.11/test_package/conanfile.py index 2feccc895106c..b76f5ca7fb681 100644 --- a/recipes/zlib/1.2.11/test_package/conanfile.py +++ b/recipes/zlib/1.2.11/test_package/conanfile.py @@ -28,4 +28,4 @@ def test(self): # FIXME: Very ugly interface to get the current test executable path cmd = os.path.join(self.build_folder, self.cpp.build.libdirs[0], "test") self.output.info("Running {}".format(cmd)) - self.run(cmd) + self.run(cmd, env="conanrunenv") From 6c8eb21b859656b891b42e9ac8877a18df00d840 Mon Sep 17 00:00:00 2001 From: memsharded Date: Thu, 15 Jul 2021 23:29:02 +0200 Subject: [PATCH 04/10] wip --- recipes/bzip2/all/conanfile.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/recipes/bzip2/all/conanfile.py b/recipes/bzip2/all/conanfile.py index c17f0510d69fb..c689e06f26c1c 100644 --- a/recipes/bzip2/all/conanfile.py +++ b/recipes/bzip2/all/conanfile.py @@ -103,3 +103,5 @@ def package_info(self): self.cpp_info.builddirs.append(self._module_subfolder) self.cpp_info.build_modules["cmake_find_package"] = [os.path.join(self._module_subfolder, self._module_file)] self.cpp_info.libs = ["bz2"] + self.cpp_info.set_property("cmake_file_name", "BZip2") + self.cpp_info.set_property("cmake_target_name", "BZip2") From d114fab1625606cfb897e06ed502e18269b5e512 Mon Sep 17 00:00:00 2001 From: memsharded Date: Fri, 16 Jul 2021 11:35:24 +0200 Subject: [PATCH 05/10] wip --- recipes/zlib/1.2.11/conanfile.py | 18 ++++++++---------- recipes/zlib/1.2.11/test_package/conanfile.py | 2 +- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/recipes/zlib/1.2.11/conanfile.py b/recipes/zlib/1.2.11/conanfile.py index 0a7751fe7f44c..f416054613df1 100644 --- a/recipes/zlib/1.2.11/conanfile.py +++ b/recipes/zlib/1.2.11/conanfile.py @@ -48,20 +48,20 @@ def _patch_sources(self): with tools.chdir(self.source_folder): # https://github.com/madler/zlib/issues/268 tools.replace_in_file('gzguts.h', - '#if defined(_WIN32) || defined(__CYGWIN__)', - '#if defined(_WIN32) || defined(__MINGW32__)') + '#if defined(_WIN32) || defined(__CYGWIN__)', + '#if defined(_WIN32) || defined(__MINGW32__)') is_apple_clang12 = self.settings.compiler == "apple-clang" and tools.Version(self.settings.compiler.version) >= "12.0" if not is_apple_clang12: for filename in ['zconf.h', 'zconf.h.cmakein', 'zconf.h.in']: tools.replace_in_file(filename, - '#ifdef HAVE_UNISTD_H ' - '/* may be set to #if 1 by ./configure */', - '#if defined(HAVE_UNISTD_H) && (1-HAVE_UNISTD_H-1 != 0)') + '#ifdef HAVE_UNISTD_H ' + '/* may be set to #if 1 by ./configure */', + '#if defined(HAVE_UNISTD_H) && (1-HAVE_UNISTD_H-1 != 0)') tools.replace_in_file(filename, - '#ifdef HAVE_STDARG_H ' - '/* may be set to #if 1 by ./configure */', - '#if defined(HAVE_STDARG_H) && (1-HAVE_STDARG_H-1 != 0)') + '#ifdef HAVE_STDARG_H ' + '/* may be set to #if 1 by ./configure */', + '#if defined(HAVE_STDARG_H) && (1-HAVE_STDARG_H-1 != 0)') def layout(self): cmake_layout(self) @@ -123,7 +123,5 @@ def package(self): def package_info(self): self.cpp_info.libs.append("zlib" if self.settings.os == "Windows" and not self.settings.os.subsystem else "z") - self.cpp_info.names["cmake_find_package"] = "ZLIB" - self.cpp_info.names["cmake_find_package_multi"] = "ZLIB" self.cpp_info.set_property("cmake_file_name", "ZLIB") self.cpp_info.set_property("cmake_target_name", "ZLIB") diff --git a/recipes/zlib/1.2.11/test_package/conanfile.py b/recipes/zlib/1.2.11/test_package/conanfile.py index b76f5ca7fb681..e13bb5781ee78 100644 --- a/recipes/zlib/1.2.11/test_package/conanfile.py +++ b/recipes/zlib/1.2.11/test_package/conanfile.py @@ -26,6 +26,6 @@ def test(self): assert os.path.exists(os.path.join(self.generators_folder, "zlib.pc")) if "x86" in self.settings.arch and not tools.cross_building(self.settings): # FIXME: Very ugly interface to get the current test executable path - cmd = os.path.join(self.build_folder, self.cpp.build.libdirs[0], "test") + cmd = os.path.join(self.build_folder, self.cpp.build.bindirs[0], "test") self.output.info("Running {}".format(cmd)) self.run(cmd, env="conanrunenv") From 2a533f0f7bba8da73261f595ce43f05620902cab Mon Sep 17 00:00:00 2001 From: memsharded Date: Fri, 16 Jul 2021 11:35:45 +0200 Subject: [PATCH 06/10] wip --- recipes/bzip2/all/conanfile.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/recipes/bzip2/all/conanfile.py b/recipes/bzip2/all/conanfile.py index c689e06f26c1c..61a9530dae532 100644 --- a/recipes/bzip2/all/conanfile.py +++ b/recipes/bzip2/all/conanfile.py @@ -42,7 +42,11 @@ def configure(self): def source(self): tools.get(**self.conan_data["sources"][self.version], destination=self.source_folder, strip_root=True) - os.rename("CMakeLists.txt", "src/CMakeLists.txt") + # FIXME: this is failing after the export export to "src" in local folder + try: + os.rename("CMakeLists.txt", "src/CMakeLists.txt") + except: + pass def layout(self): cmake_layout(self) @@ -98,8 +102,6 @@ def _module_file(self): return "conan-official-{}-variables.cmake".format(self.name) def package_info(self): - self.cpp_info.names["cmake_find_package"] = "BZip2" - self.cpp_info.names["cmake_find_package_multi"] = "BZip2" self.cpp_info.builddirs.append(self._module_subfolder) self.cpp_info.build_modules["cmake_find_package"] = [os.path.join(self._module_subfolder, self._module_file)] self.cpp_info.libs = ["bz2"] From e700c5ea33668c1ebb84abb7c0ea17088454334b Mon Sep 17 00:00:00 2001 From: memsharded Date: Fri, 16 Jul 2021 11:53:33 +0200 Subject: [PATCH 07/10] wip --- recipes/bzip2/all/test_package/conanfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/bzip2/all/test_package/conanfile.py b/recipes/bzip2/all/test_package/conanfile.py index 385718a21aacf..12ad9d06a5f1e 100644 --- a/recipes/bzip2/all/test_package/conanfile.py +++ b/recipes/bzip2/all/test_package/conanfile.py @@ -22,5 +22,5 @@ def layout(self): def test(self): if not tools.cross_building(self.settings): # FIXME: Very ugly interface to get the current test executable path - cmd = os.path.join(self.build_folder, self.cpp.build.libdirs[0], "test_package") + cmd = os.path.join(self.build_folder, self.cpp.build.bindirs[0], "test_package") self.run("%s --help" % cmd, env=["conanrunenv"]) From 594f74e61b686cad81640da423bf492e874814f4 Mon Sep 17 00:00:00 2001 From: memsharded Date: Fri, 23 Jul 2021 18:09:08 +0200 Subject: [PATCH 08/10] wip --- recipes/bzip2/all/conanfile.py | 2 +- recipes/bzip2/all/test_package/conanfile.py | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/recipes/bzip2/all/conanfile.py b/recipes/bzip2/all/conanfile.py index 61a9530dae532..cb4c208c98c9e 100644 --- a/recipes/bzip2/all/conanfile.py +++ b/recipes/bzip2/all/conanfile.py @@ -4,7 +4,7 @@ from conan.tools.cmake import CMake, CMakeToolchain from conan.tools.layout import cmake_layout -required_conan_version = ">=1.33.0" +required_conan_version = ">=1.38.0" class Bzip2Conan(ConanFile): diff --git a/recipes/bzip2/all/test_package/conanfile.py b/recipes/bzip2/all/test_package/conanfile.py index 12ad9d06a5f1e..a99a50ab8f5d6 100644 --- a/recipes/bzip2/all/test_package/conanfile.py +++ b/recipes/bzip2/all/test_package/conanfile.py @@ -21,6 +21,5 @@ def layout(self): def test(self): if not tools.cross_building(self.settings): - # FIXME: Very ugly interface to get the current test executable path - cmd = os.path.join(self.build_folder, self.cpp.build.bindirs[0], "test_package") + cmd = os.path.join(self.cpp.build.bindirs[0], "test_package") self.run("%s --help" % cmd, env=["conanrunenv"]) From e84b92a2026d0943c9659d9a044e5e7b59ce9d52 Mon Sep 17 00:00:00 2001 From: memsharded Date: Fri, 23 Jul 2021 18:12:40 +0200 Subject: [PATCH 09/10] new recipes for bzip2 and zlib --- recipes/zlib/1.2.11/test_package/conanfile.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/recipes/zlib/1.2.11/test_package/conanfile.py b/recipes/zlib/1.2.11/test_package/conanfile.py index e13bb5781ee78..f1a35ec39834c 100644 --- a/recipes/zlib/1.2.11/test_package/conanfile.py +++ b/recipes/zlib/1.2.11/test_package/conanfile.py @@ -25,7 +25,5 @@ def generate(self): def test(self): assert os.path.exists(os.path.join(self.generators_folder, "zlib.pc")) if "x86" in self.settings.arch and not tools.cross_building(self.settings): - # FIXME: Very ugly interface to get the current test executable path - cmd = os.path.join(self.build_folder, self.cpp.build.bindirs[0], "test") - self.output.info("Running {}".format(cmd)) + cmd = os.path.join(self.cpp.build.bindirs[0], "test") self.run(cmd, env="conanrunenv") From 90bad33e6a32967efb1763bc3184134bb76fdd26 Mon Sep 17 00:00:00 2001 From: James Date: Mon, 26 Jul 2021 13:35:15 +0200 Subject: [PATCH 10/10] Update recipes/bzip2/all/conanfile.py Co-authored-by: ericLemanissier --- recipes/bzip2/all/conanfile.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/recipes/bzip2/all/conanfile.py b/recipes/bzip2/all/conanfile.py index cb4c208c98c9e..3eab16d8bf633 100644 --- a/recipes/bzip2/all/conanfile.py +++ b/recipes/bzip2/all/conanfile.py @@ -59,8 +59,7 @@ def generate(self): cmake_toolchain.generate() def build(self): - for patch in self.conan_data["patches"].get(self.version, []): - tools.patch(**patch) + tools.files.apply_conandata_patches(self) cmake = CMake(self) cmake.configure() cmake.build()