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 3 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
136 changes: 65 additions & 71 deletions recipes/isl/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
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, rmdir, apply_conandata_patches
System-Arch marked this conversation as resolved.
Show resolved Hide resolved
from conan.tools.gnu import Autotools, AutotoolsToolchain
from conan.tools.layout import basic_layout
from conan.tools.microsoft import unix_path
System-Arch marked this conversation as resolved.
Show resolved Hide resolved
from conan.tools.scm import Version
from conan.errors import ConanInvalidConfiguration
import os

required_conan_version = ">=1.33.0"

required_conan_version = ">=1.54.0"

class IslConan(ConanFile):
name = "isl"
Expand All @@ -25,21 +28,16 @@ class IslConan(ConanFile):
"with_int": "gmp",
}

_autotools = None

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

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,7 +47,7 @@ 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":
if self.settings.compiler == "msvc" and Version(self.settings.compiler.version) < 16 and self.settings.compiler.runtime == "MDd":
System-Arch marked this conversation as resolved.
Show resolved Hide resolved
# 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")

Expand All @@ -62,72 +60,68 @@ 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.settings.compiler == "msvc":
self.tool_requires("automake/1.16.4")
System-Arch marked this conversation as resolved.
Show resolved Hide resolved

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")
tc.configure_args.append(f'--enable-shared={"yes" if self.options.shared else "no"}')
tc.configure_args.append(f'--enable-static={"yes" if not self.options.shared else "no"}')
System-Arch marked this conversation as resolved.
Show resolved Hide resolved
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 self.settings.compiler == "msvc":
System-Arch marked this conversation as resolved.
Show resolved Hide resolved
if Version(self.settings.compiler.version) >= 15:
tc.extra_cflags = ["-Zf"]
if Version(self.settings.compiler.version) >= 12:
Copy link
Contributor

Choose a reason for hiding this comment

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

Visual Studio & msvc don't follow the same versioning in conan

tc.extra_cflags = ["-FS"]
env = tc.environment()
if self.settings.compiler == "msvc":
System-Arch marked this conversation as resolved.
Show resolved Hide resolved
env.define("AR", f'{unix_path(self, self.dependencies["automake"].ar_lib)} lib')
env.define("CC", f'{unix_path(self, self.dependencies["automake"].compile)} cl -nologo {self.settings.compiler.runtime}')
env.define("CXX", f'{unix_path(self, self.dependencies["automake"].compile)} cl -nologo {self.settings.compiler.runtime}')
System-Arch marked this conversation as resolved.
Show resolved Hide resolved
env.define("NM", "dumpbin -symbols")
env.define("OBJDUMP", ":")
env.define("RANLIB", ":")
env.define("STRIP", ":")
tc.generate(env)

def build(self):
with self._build_context():
autotools = self._configure_autotools()
autotools.make()
# Support building with source from Git reop
with chdir(self, self.source_folder):
command = "./autogen.sh"
if os.path.exists(command) and not os.path.exists("configure"):
self.run(command)
System-Arch marked this conversation as resolved.
Show resolved Hide resolved
apply_conandata_patches(self)
System-Arch marked this conversation as resolved.
Show resolved Hide resolved
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()
copy(self, "LICENSE", self.source_folder, os.path.join(self.package_folder, "licenses"), keep_path=False)
System-Arch marked this conversation as resolved.
Show resolved Hide resolved
autotools = Autotools(self)
autotools.install()

os.unlink(os.path.join(os.path.join(self.package_folder, "lib", "libisl.la")))
System-Arch marked this conversation as resolved.
Show resolved Hide resolved
tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig"))
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("cmake_find_mode", "both")
self.cpp_info.set_property("cmake_file_name", "ISL")
self.cpp_info.set_property("cmake_target_name", "ISL::ISL")
System-Arch marked this conversation as resolved.
Show resolved Hide resolved
self.cpp_info.libs = ["isl"]

self.cpp_info.names["pkg_config"] = "isl"
System-Arch marked this conversation as resolved.
Show resolved Hide resolved
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)
System-Arch marked this conversation as resolved.
Show resolved Hide resolved

add_executable(${PROJECT_NAME} test_package.c)
target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS})
target_link_libraries(${PROJECT_NAME} PRIVATE ISL::ISL)
System-Arch marked this conversation as resolved.
Show resolved Hide resolved
18 changes: 13 additions & 5 deletions recipes/isl/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,25 @@
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

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.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)
9 changes: 9 additions & 0 deletions recipes/isl/all/test_v1_package/test_package.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#include "isl/ctx.h"
Copy link
Contributor

Choose a reason for hiding this comment

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

do not duplicate code please, see recipe templates in conan-center doc



int main() {
isl_ctx *ctx = isl_ctx_alloc();

isl_ctx_free(ctx);
return 0;
}