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 Conan 2.0 compatibility #14916

Closed
wants to merge 27 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
120a723
ISL Conan 2.0 compatibility
System-Arch Dec 23, 2022
e628faa
Fixed lint errors
System-Arch Dec 23, 2022
cee6b0c
Fixed new lint errors
System-Arch Dec 23, 2022
97058c4
Apply suggestions from code review
System-Arch Dec 26, 2022
1c42d56
Post code review tweaks
System-Arch Dec 26, 2022
27a94b0
Add import for check_min_vs
System-Arch Dec 26, 2022
5010083
Work around vs_ide_version not being part of public API
System-Arch Dec 26, 2022
29cc91b
Fixed improper use of conanfile
System-Arch Dec 26, 2022
2b7527e
Treat version numbers as strings
System-Arch Dec 27, 2022
e2da76e
Tweak msvc env. vars
System-Arch Dec 31, 2022
5c446fd
Update conanfile.py
System-Arch Jan 9, 2023
8a2b47c
Update naming of user.automake:lib-wrapper
System-Arch Jan 16, 2023
c6adc1c
Make gmp a build_requirement
System-Arch Jan 17, 2023
1b672c7
Bump required_conan_version
System-Arch Jan 20, 2023
a97dc24
Make gmp a requirement
System-Arch Jan 21, 2023
bbf710c
Fix build issues on Windows and add support for 0.25 release
System-Arch Feb 11, 2023
a9aafd4
Fixed misplaced bracket
System-Arch Feb 11, 2023
d0f1d37
Export patches
System-Arch Feb 11, 2023
4141271
Eliminate duplicate test file per review feedback
System-Arch Feb 11, 2023
1719bea
UNIX is case sensitive
System-Arch Feb 11, 2023
d80d1bd
Try again
System-Arch Feb 11, 2023
d1a750b
Drop support for older (unused) versions
System-Arch Feb 12, 2023
8357e0b
Added autogen option to shield autoconf workflow
System-Arch Feb 16, 2023
05acd93
Only pass CFLAGS_FOR_BUILD for 0.24 with -MD*
System-Arch Feb 16, 2023
072dacd
Also pass CC_FOR_BUILD to avoid confusion with GCC
System-Arch Feb 16, 2023
60d34e9
Bump required_conan_version
System-Arch Feb 16, 2023
114ac12
Bumped required_conan_version
System-Arch Mar 14, 2023
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
14 changes: 8 additions & 6 deletions recipes/isl/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
sources:
"0.25":
url: "https://libisl.sourceforge.io/isl-0.25.tar.gz"
sha256: "acac270b41f6a533cbe5cf26463877ed5e4107051a5457b9d50b58576a59c6c5"
"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"
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"
149 changes: 76 additions & 73 deletions recipes/isl/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
from conans import AutoToolsBuildEnvironment, ConanFile, tools
from conans.errors import ConanInvalidConfiguration
from contextlib import contextmanager
from conan import ConanFile
from conan.tools.files import chdir, 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
from conan.errors import ConanInvalidConfiguration
import os

required_conan_version = ">=1.33.0"

required_conan_version = ">=1.58.0"

class IslConan(ConanFile):
name = "isl"
Expand All @@ -18,28 +20,30 @@ class IslConan(ConanFile):
"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
def package_id(self):
self.info.options.rm_safe("autogen")

@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:
Expand All @@ -49,9 +53,9 @@ def validate(self):
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":
# 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")
if msvc_runtime_flag(self) == "MDd":
# 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)
check_min_vs(self, "192")

def requirements(self):
if self.options.with_int == "gmp":
Expand All @@ -62,72 +66,71 @@ 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") # Needed for autoreconf
self.tool_requires("automake/1.16.5") # Needed for aclocal called by autoreconf--does Coanan 2.0 need a transitive_run trait?
self.tool_requires("libtool/2.4.7") # Needed for libtool

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, destination=self.source_folder)

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):
compiler_version = self.settings.get_safe("compiler.version")
if compiler_version >= "191":
tc.extra_cflags = ["-Zf"]
if compiler_version >= "180":
tc.extra_cflags = ["-FS"]
# Visual Studio support for Conan 1.x; Can be remvoed when 2.0 is default
if self.settings.get_safe("compiler") == "Visual Studio":
compiler_version = self.settings.get_safe("compiler.version")
if compiler_version >= "15":
tc.extra_cflags = ["-Zf"]
if compiler_version >= "12":
tc.extra_cflags = ["-FS"]
Comment on lines +92 to +104
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if is_msvc(self):
compiler_version = self.settings.get_safe("compiler.version")
if compiler_version >= "191":
tc.extra_cflags = ["-Zf"]
if compiler_version >= "180":
tc.extra_cflags = ["-FS"]
# Visual Studio support for Conan 1.x; Can be remvoed when 2.0 is default
if self.settings.get_safe("compiler") == "Visual Studio":
compiler_version = self.settings.get_safe("compiler.version")
if compiler_version >= "15":
tc.extra_cflags = ["-Zf"]
if compiler_version >= "12":
tc.extra_cflags = ["-FS"]
if is_msvc(self):
compiler_version = self.settings.get_safe("compiler.version")
if compiler_version >= "191":
tc.extra_cflags += ["-Zf"]
if compiler_version >= "180":
tc.extra_cflags += ["-FS"]
# Visual Studio support for Conan 1.x; Can be remvoed when 2.0 is default
if self.settings.get_safe("compiler") == "Visual Studio":
compiler_version = self.settings.get_safe("compiler.version")
if compiler_version >= "15":
tc.extra_cflags += ["-Zf"]
if compiler_version >= "12":
tc.extra_cflags += ["-FS"]

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
with chdir(self, self.source_folder):
command = "./autogen.sh"
if os.path.exists(command):
self.run(command)
autotools = Autotools(self)
if is_msvc(self) and self.version == "0.24" and msvc_runtime_flag(self).startswith("MD"):
# Pass BUILD flags to avoid confusion with GCC and mixing of runtime variants
autotools.configure(args=['CC_FOR_BUILD=cl -nologo', f'CFLAGS_FOR_BUILD=-{msvc_runtime_flag(self)}'])
else:
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()
copy(self, "LICENSE", self.source_folder, os.path.join(self.package_folder, "licenses"))
autotools = Autotools(self)
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"))
rm(self, "*.la", os.path.join(os.path.join(self.package_folder, "lib")))
rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig"))

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"
System-Arch marked this conversation as resolved.
Show resolved Hide resolved
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: 2 additions & 4 deletions recipes/isl/config.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
versions:
"0.24":
folder: "all"
"0.23":
"0.25":
folder: "all"
"0.22":
"0.24":
folder: "all"