-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(#18947) libest: migrate to Conan v2
* libest: migrate to Conan v2 * libest: transitive_libs=True * libest: strip binaries for Release builds * libest: run autoreconf To hopefully fix configure: error: cannot run C compiled programs. * libest: fix OpenSSL dependency configuration * libest: OpenSSL flags * libest: use version range for openssl Co-authored-by: Uilian Ries <uilianries@gmail.com> * libest: openssl v3 is not supported * libest: revert openssl dep version --------- Co-authored-by: Uilian Ries <uilianries@gmail.com>
- Loading branch information
1 parent
71e8de4
commit 65da40a
Showing
6 changed files
with
114 additions
and
63 deletions.
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
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) |