-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
libest: migrate to Conan v2 #18947
Merged
Merged
libest: migrate to Conan v2 #18947
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
a621e78
libest: migrate to Conan v2
valgur f9b52c9
libest: transitive_libs=True
valgur 5af17d5
libest: strip binaries for Release builds
valgur a43a822
libest: run autoreconf
valgur d134df2
libest: fix OpenSSL dependency configuration
valgur 46790ec
libest: OpenSSL flags
valgur bc821dc
libest: use version range for openssl
valgur b689ad1
libest: openssl v3 is not supported
valgur ad516d7
libest: revert openssl dep version
valgur 797a3ca
Merge branch 'master' into migrate/libest
valgur File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,8 +3,6 @@ | |
url: "https://github.com/cisco/libest/archive/r3.2.0.tar.gz" | ||
sha256: "324b3a2b16cd14ea4234d75fa90f08b29509bac9cd3795c44268e22f906ee0ad" | ||
patches: | ||
"3.2.0": | ||
- patch_file: "patches/0001-examples-are-broken-don-t-build-them.patch" | ||
Check warning on line 7 in recipes/libest/all/conandata.yml GitHub Actions / Lint changed files (YAML files)conandata.yml schema warning
|
||
base_path: "source_subfolder" | ||
- patch_file: "patches/0002-add-extern.patch" | ||
Check warning on line 8 in recipes/libest/all/conandata.yml GitHub Actions / Lint changed files (YAML files)conandata.yml schema warning
|
||
base_path: "source_subfolder" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,80 +1,100 @@ | ||
import os | ||
from conans import ConanFile, tools, AutoToolsBuildEnvironment | ||
from conans.errors import ConanInvalidConfiguration | ||
|
||
from conan import ConanFile | ||
from conan.errors import ConanInvalidConfiguration | ||
from conan.tools.apple import is_apple_os | ||
from conan.tools.build import cross_building | ||
from conan.tools.env import VirtualRunEnv | ||
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 | ||
|
||
required_conan_version = ">=1.53.0" | ||
|
||
|
||
class LibEstConan(ConanFile): | ||
name = "libest" | ||
license = "BSD-3-Clause" | ||
description = "EST is used for secure certificate enrollment" | ||
topics = ("conan", "EST", "RFC 7030", "certificate enrollment") | ||
homepage = "https://github.com/cisco/libest" | ||
license = "BSD-3-Clause" | ||
url = "https://github.com/conan-io/conan-center-index" | ||
settings = "os", "compiler", "build_type", "arch" | ||
exports_sources = "patches/**" | ||
options = {"shared": [True, False], "fPIC": [True, False]} | ||
default_options = {"shared": False, "fPIC": True} | ||
|
||
_autotools = None | ||
homepage = "https://github.com/cisco/libest" | ||
topics = ("EST", "RFC 7030", "certificate enrollment") | ||
|
||
@property | ||
def _source_subfolder(self): | ||
return "source_subfolder" | ||
package_type = "library" | ||
settings = "os", "arch", "compiler", "build_type" | ||
options = { | ||
"shared": [True, False], | ||
"fPIC": [True, False], | ||
} | ||
default_options = { | ||
"shared": False, | ||
"fPIC": True, | ||
} | ||
|
||
@property | ||
def _build_subfolder(self): | ||
return "build_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.settings.os in ("Windows", "Macos"): | ||
raise ConanInvalidConfiguration( | ||
"Platform is currently not supported by this recipe") | ||
if self.settings.os == "Windows" or is_apple_os(self): | ||
raise ConanInvalidConfiguration("Platform is currently not supported by this recipe") | ||
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 layout(self): | ||
basic_layout(self, src_folder="src") | ||
|
||
def requirements(self): | ||
self.requires("openssl/1.1.1q") | ||
self.requires("openssl/1.1.1w", transitive_headers=True, transitive_libs=True) | ||
|
||
def build_requirements(self): | ||
self.tool_requires("libtool/2.4.7") | ||
|
||
def source(self): | ||
tools.get(**self.conan_data["sources"][self.version]) | ||
extracted_dir = self.name + "-r" + self.version | ||
os.rename(extracted_dir, self._source_subfolder) | ||
|
||
def _configure_autotools(self): | ||
if not self._autotools: | ||
self._autotools = AutoToolsBuildEnvironment(self) | ||
# TODO: | ||
# - Static only build: https://github.com/cisco/libest/blob/70824ddc09bee661329b9416082d88566efefb32/intro.txt#L140 | ||
# - Release build: https://github.com/cisco/libest/blob/70824ddc09bee661329b9416082d88566efefb32/intro.txt#L253 | ||
args = [] | ||
if self.options.shared: | ||
args.extend(["--enable-shared", "--disable-static"]) | ||
else: | ||
args.extend(["--disable-shared", "--enable-static"]) | ||
self._autotools.configure(args=args) | ||
return self._autotools | ||
get(self, **self.conan_data["sources"][self.version], strip_root=True) | ||
|
||
def generate(self): | ||
if not cross_building(self): | ||
env = VirtualRunEnv(self) | ||
env.generate(scope="build") | ||
tc = AutotoolsToolchain(self) | ||
tc.generate() | ||
deps = AutotoolsDeps(self) | ||
deps.generate() | ||
|
||
def _patch_sources(self): | ||
apply_conandata_patches(self) | ||
# Remove duplicate AM_INIT_AUTOMAKE | ||
replace_in_file(self, os.path.join(self.source_folder, "configure.ac"), | ||
"AM_INIT_AUTOMAKE\n", "") | ||
|
||
def build(self): | ||
for patch in self.conan_data.get("patches", {}).get(self.version, []): | ||
tools.patch(**patch) | ||
with tools.chdir(self._source_subfolder): | ||
autotools = self._configure_autotools() | ||
self._patch_sources() | ||
with chdir(self, self.source_folder): | ||
autotools = Autotools(self) | ||
autotools.autoreconf() | ||
autotools.configure() | ||
autotools.make() | ||
|
||
def package(self): | ||
self.copy("*LICENSE", src=self._source_subfolder, dst="licenses") | ||
with tools.chdir(self._source_subfolder): | ||
autotools = self._configure_autotools() | ||
autotools.install() | ||
copy(self, "*LICENSE", | ||
src=self.source_folder, | ||
dst=os.path.join(self.package_folder, "licenses")) | ||
with chdir(self, self.source_folder): | ||
autotools = Autotools(self) | ||
if self.settings.build_type in ["Release", "MinSizeRel"]: | ||
# https://github.com/cisco/libest/blob/r3.2.0/intro.txt#L244-L254 | ||
autotools.install(target="install-strip") | ||
else: | ||
autotools.install() | ||
os.unlink(os.path.join(self.package_folder, "lib", "libest.la")) | ||
|
||
def package_info(self): | ||
self.cpp_info.libs = ["est"] | ||
if self.settings.os == "Linux": | ||
if self.settings.os in ["Linux", "FreeBSD"]: | ||
self.cpp_info.system_libs = ["dl", "pthread"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,7 @@ | ||
cmake_minimum_required(VERSION 3.1) | ||
cmake_minimum_required(VERSION 3.15) | ||
project(PackageTest C) | ||
|
||
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) | ||
conan_basic_setup() | ||
find_package(libest REQUIRED CONFIG) | ||
|
||
add_executable(example example.c) | ||
target_link_libraries(example ${CONAN_LIBS}) | ||
target_link_libraries(example PRIVATE libest::libest) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,26 @@ | ||
from conans import ConanFile, CMake, tools | ||
from conan import ConanFile | ||
from conan.tools.build import can_run | ||
from conan.tools.cmake import cmake_layout, CMake | ||
import os | ||
|
||
class CAresTestConan(ConanFile): | ||
settings = "os", "compiler", "build_type", "arch" | ||
generators = "cmake" | ||
|
||
class TestPackageConan(ConanFile): | ||
settings = "os", "arch", "compiler", "build_type" | ||
generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" | ||
test_type = "explicit" | ||
|
||
def requirements(self): | ||
self.requires(self.tested_reference_str) | ||
|
||
def layout(self): | ||
cmake_layout(self) | ||
|
||
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", "example") | ||
self.run(bin_path, run_environment=True) | ||
if can_run(self): | ||
bin_path = os.path.join(self.cpp.build.bindir, "example") | ||
self.run(bin_path, env="conanrun") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
cmake_minimum_required(VERSION 3.15) | ||
project(test_package) | ||
|
||
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) | ||
conan_basic_setup(TARGETS) | ||
|
||
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package/ | ||
${CMAKE_CURRENT_BINARY_DIR}/test_package/) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
from conans import ConanFile, CMake, tools | ||
import os | ||
|
||
class CAresTestConan(ConanFile): | ||
settings = "os", "compiler", "build_type", "arch" | ||
generators = "cmake", "cmake_find_package_multi" | ||
|
||
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", "example") | ||
self.run(bin_path, run_environment=True) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In case it does not support OpenSSL 3.x, you still can use range, but
[>=1.1 <3]
https://github.com/conan-io/conan-center-index/blob/master/docs/adding_packages/dependencies.md#version-ranges
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Using
<2
did not work for some reason.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@uilianries Yeah, this fails on Conan v1 for some reason. Quite annoying.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What error?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ERROR: Version range '>=1.1 <3' from requirement 'openssl/[>=1.1 <3]' required by 'libest/3.2.0' could not be resolved in remote 'conan-center'
Only in Conan v1.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, I'll take a look.