Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

isl: migrate to Conan v2 #21153

Merged
merged 5 commits into from
Feb 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 13 additions & 8 deletions recipes/isl/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
sources:
"0.26":
url: "https://libisl.sourceforge.io/isl-0.26.tar.xz"
sha256: "a0b5cb06d24f9fa9e77b55fabbe9a3c94a336190345c2555f9915bb38e976504"
"0.25":
url: "https://libisl.sourceforge.io/isl-0.25.tar.xz"
sha256: "be7b210647ccadf90a2f0b000fca11a4d40546374a850db67adb32fad4b230d9"
"0.24":
url: "https://libisl.sourceforge.io/isl-0.24.tar.gz"
sha256: "26e6e4d60ad59b3fff9948eb36743f0c874e124e410ef5bab930d0f546bc580d"
"0.23":
url: "https://libisl.sourceforge.io/isl-0.23.tar.gz"
sha256: "19e77cb562ab3da5a37f263208d6f902ae3a9d52c756bf6eb1a6b2f8a74b883c"
"0.22":
url: "https://libisl.sourceforge.io/isl-0.22.tar.gz"
sha256: "d0c6714e4427d3eb964388afe526a8e0f69687da7e944f1ad66ffa639923be46"
url: "https://libisl.sourceforge.io/isl-0.24.tar.xz"
sha256: "043105cc544f416b48736fff8caf077fb0663a717d06b1113f16e391ac99ebad"
patches:
"0.24":
- patch_file: "patches/0.24-0001-fix-ac_test_cflags.patch"
patch_description: "Fix ac_test_CFLAGS logic error"
patch_type: "portability"
153 changes: 74 additions & 79 deletions recipes/isl/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
from conans import AutoToolsBuildEnvironment, ConanFile, tools
from conans.errors import ConanInvalidConfiguration
from contextlib import contextmanager
from conan import ConanFile
from conan.errors import ConanInvalidConfiguration
from conan.tools.apple import is_apple_os, fix_apple_shared_install_name
from conan.tools.build import cross_building
from conan.tools.files import copy, get, rm, rmdir, apply_conandata_patches, export_conandata_patches
from conan.tools.gnu import Autotools, AutotoolsToolchain
from conan.tools.layout import basic_layout
from conan.tools.microsoft import is_msvc, msvc_runtime_flag, check_min_vs, unix_path, is_msvc_static_runtime
import os

required_conan_version = ">=1.33.0"
required_conan_version = ">=1.58.0"


class IslConan(ConanFile):
Expand All @@ -13,121 +18,111 @@ class IslConan(ConanFile):
license = "MIT"
homepage = "https://libisl.sourceforge.io"
url = "https://github.com/conan-io/conan-center-index"

package_type = "library"
settings = "os", "arch", "compiler", "build_type"
options = {
"shared": [True, False],
"fPIC": [True, False],
"with_int": ["gmp", "imath", "imath-32"],
"autogen": [True, False],
}
default_options = {
"shared": False,
"fPIC": True,
"with_int": "gmp",
"autogen": False,
}

_autotools = None

@property
def _source_subfolder(self):
return "source_subfolder"
def export_sources(self):
export_conandata_patches(self)

def config_options(self):
if self.settings.os == "Windows":
del self.options.fPIC

def configure(self):
if self.options.shared:
del self.options.fPIC
del self.settings.compiler.libcxx
del self.settings.compiler.cppstd
self.options.rm_safe("fPIC")
self.settings.rm_safe("compiler.libcxx")
self.settings.rm_safe("compiler.cppstd")

def validate(self):
if self.settings.os == "Windows" and self.options.shared:
raise ConanInvalidConfiguration("Cannot build shared isl library on Windows (due to libtool refusing to link to static/import libraries)")
if self.settings.os == "Macos" and self.settings.arch == "armv8":
raise ConanInvalidConfiguration("Apple M1 is not yet supported. Contributions are welcome")
if self.options.with_int != "gmp":
# FIXME: missing imath recipe
raise ConanInvalidConfiguration("imath is not (yet) available on cci")
if self.settings.compiler == "Visual Studio" and tools.Version(self.settings.compiler.version) < 16 and self.settings.compiler.runtime == "MDd":
if is_apple_os(self) and cross_building(self):
raise ConanInvalidConfiguration("Cross-building with Apple Clang is not supported yet")
if msvc_runtime_flag(self) == "MDd" and not check_min_vs(self, 192, raise_invalid=False):
# isl fails to link with this version of visual studio and MDd runtime:
# gmp.lib(bdiv_dbm1c.obj) : fatal error LNK1318: Unexpected PDB error; OK (0)
raise ConanInvalidConfiguration("isl fails to link with this version of visual studio and MDd runtime")
raise ConanInvalidConfiguration("isl cannot be built with MDd runtime with MSVC < 192")

def requirements(self):
if self.options.with_int == "gmp":
self.requires("gmp/6.2.1")
self.requires("gmp/6.3.0")
elif self.options.with_int == "imath":
self.requires("imath/3.1.9")

@property
def _settings_build(self):
return getattr(self, "settings_build", self.settings)

def build_requirements(self):
if self._settings_build.os == "Windows" and not tools.get_env("CONAN_BASH_PATH"):
self.build_requires("msys2/cci.latest")
if self.settings.compiler == "Visual Studio":
self.build_requires("automake/1.16.4")
if self._settings_build.os == "Windows":
self.win_bash = True
if not self.conf.get("tools.microsoft.bash:path", check_type=str):
self.tool_requires("msys2/cci.latest")
if self.options.autogen:
self.tool_requires("autoconf/2.71")
self.tool_requires("automake/1.16.5")
self.tool_requires("libtool/2.4.7")

def package_id(self):
del self.info.options.autogen

def layout(self):
basic_layout(self, src_folder="src")

def source(self):
tools.get(**self.conan_data["sources"][self.version],
strip_root=True, destination=self._source_subfolder)

@contextmanager
def _build_context(self):
if self.settings.compiler == "Visual Studio":
with tools.vcvars(self.settings):
env = {
"AR": "{} lib".format(tools.unix_path(self.deps_user_info["automake"].ar_lib)),
"CC": "{} cl -nologo -{}".format(tools.unix_path(self.deps_user_info["automake"].compile), self.settings.compiler.runtime),
"CXX": "{} cl -nologo -{}".format(tools.unix_path(self.deps_user_info["automake"].compile), self.settings.compiler.runtime),
"NM": "dumpbin -symbols",
"OBJDUMP": ":",
"RANLIB": ":",
"STRIP": ":",
}
with tools.environment_append(env):
yield
else:
yield

def _configure_autotools(self):
if self._autotools:
return self._autotools
self._autotools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows)
self._autotools.libs = []
yes_no = lambda v: "yes" if v else "no"
conf_args = [
"--with-int={}".format(self.options.with_int),
"--enable-portable-binary",
"--enable-shared={}".format(yes_no(self.options.shared)),
"--enable-static={}".format(yes_no(not self.options.shared)),
]
get(self, **self.conan_data["sources"][self.version], strip_root=True)

def generate(self):
tc = AutotoolsToolchain(self)
tc.configure_args.append(f'--with-int={self.options.with_int}')
tc.configure_args.append("--enable-portable-binary")
if self.options.with_int == "gmp":
conf_args.extend([
"--with-gmp=system",
"--with-gmp-prefix={}".format(self.deps_cpp_info["gmp"].rootpath.replace("\\", "/")),
])
if self.settings.compiler == "Visual Studio":
if tools.Version(self.settings.compiler.version) >= 15:
self._autotools.flags.append("-Zf")
if tools.Version(self.settings.compiler.version) >= 12:
self._autotools.flags.append("-FS")
self._autotools.configure(args=conf_args, configure_dir=self._source_subfolder)
return self._autotools
tc.configure_args.append("--with-gmp=system")
tc.configure_args.append(f'--with-gmp-prefix={unix_path(self, self.dependencies["gmp"].package_folder)}')
if is_msvc(self):
if check_min_vs(self, 191, raise_invalid=False):
tc.extra_cflags = ["-Zf"]
if check_min_vs(self, 180, raise_invalid=False):
tc.extra_cflags = ["-FS"]
if is_msvc(self) and self.version == "0.24" and not is_msvc_static_runtime(self):
# Pass BUILD flags to avoid confusion with GCC and mixing of runtime variants
tc.configure_args += ['CC_FOR_BUILD=cl -nologo', f'CFLAGS_FOR_BUILD=-{msvc_runtime_flag(self)}']
env = tc.environment()
if is_msvc(self):
env.define("CC", "cl -nologo")
env.define("CXX", "cl -nologo")
tc.generate(env)

def build(self):
with self._build_context():
autotools = self._configure_autotools()
autotools.make()
if self.options.autogen:
apply_conandata_patches(self) # Currently, the only patch is for the autogen use case
self.run("./autogen.sh", cwd=self.source_folder)
autotools = Autotools(self)
autotools.configure()
autotools.make()

def package(self):
self.copy("LICENSE", src=self._source_subfolder, dst="licenses")
with self._build_context():
autotools = self._configure_autotools()
autotools.install()

os.unlink(os.path.join(os.path.join(self.package_folder, "lib", "libisl.la")))
tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig"))
copy(self, "LICENSE", self.source_folder, os.path.join(self.package_folder, "licenses"))
autotools = Autotools(self)
autotools.install()
rm(self, "*.la", os.path.join(os.path.join(self.package_folder, "lib")))
rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig"))
fix_apple_shared_install_name(self)

def package_info(self):
self.cpp_info.names["pkg_config"] = "isl"
self.cpp_info.set_property("pkg_config_name", "isl")
self.cpp_info.libs = ["isl"]
11 changes: 11 additions & 0 deletions recipes/isl/all/patches/0.24-0001-fix-ac_test_cflags.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--- m4/ax_cc_maxopt.m4
+++ m4/ax_cc_maxopt.m4
@@ -65,7 +65,7 @@
acx_maxopt_portable=$withval, acx_maxopt_portable=no)

# Try to determine "good" native compiler flags if none specified via CFLAGS
-if test "$ac_test_CFLAGS" != "set"; then
+if test "x$ac_test_CFLAGS" = "x"; then
CFLAGS=""
case $ax_cv_c_compiler_vendor in
dec) CFLAGS="-newc -w0 -O5 -ansi_alias -ansi_args -fp_reorder -tune host"
5 changes: 2 additions & 3 deletions recipes/isl/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
cmake_minimum_required(VERSION 3.1)
project(test_package C)

include("${CMAKE_BINARY_DIR}/conanbuildinfo.cmake")
conan_basic_setup()
find_package(isl REQUIRED CONFIG)

add_executable(${PROJECT_NAME} test_package.c)
target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS})
target_link_libraries(${PROJECT_NAME} PRIVATE isl::isl)
19 changes: 14 additions & 5 deletions recipes/isl/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,26 @@
from conans import ConanFile, CMake, tools
from conan import ConanFile
from conan.tools.cmake import CMake, cmake_layout
from conan.tools.build import cross_building
import os


class TestPackageConan(ConanFile):
settings = "os", "compiler", "build_type", "arch"
generators = "cmake"
generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv"
test_type = "explicit"

def layout(self):
cmake_layout(self)

def requirements(self):
self.requires(self.tested_reference_str)

def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()

def test(self):
if not tools.cross_building(self.settings):
bin_path = os.path.join("bin", "test_package")
self.run(bin_path, run_environment=True)
if not cross_building(self):
bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package")
self.run(bin_path, env="conanrun")
8 changes: 8 additions & 0 deletions recipes/isl/all/test_v1_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
cmake_minimum_required(VERSION 3.1)
project(test_package C)

include("${CMAKE_BINARY_DIR}/conanbuildinfo.cmake")
conan_basic_setup()

add_executable(${PROJECT_NAME} ../test_package/test_package.c)
target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS})
17 changes: 17 additions & 0 deletions recipes/isl/all/test_v1_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from conans import ConanFile, CMake, tools
import os


class TestPackageConan(ConanFile):
settings = "os", "compiler", "build_type", "arch"
generators = "cmake"

def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()

def test(self):
if not tools.cross_building(self.settings):
bin_path = os.path.join("bin", "test_package")
self.run(bin_path, run_environment=True)
6 changes: 3 additions & 3 deletions recipes/isl/config.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
versions:
"0.24":
"0.26":
folder: "all"
"0.23":
"0.25":
folder: "all"
"0.22":
"0.24":
folder: "all"