-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* conan v2 support * add missing system libs * drop 1.31.2
- Loading branch information
Showing
8 changed files
with
128 additions
and
104 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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,141 +1,145 @@ | ||
import os | ||
import shutil | ||
from conan import ConanFile | ||
from conan.errors import ConanInvalidConfiguration | ||
from conan.tools.build import check_min_cppstd | ||
from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout | ||
from conan.tools.env import VirtualBuildEnv | ||
from conan.tools.files import collect_libs, copy, get, replace_in_file, rename, rm | ||
from conan.tools.microsoft import is_msvc | ||
from conan.tools.scm import Version | ||
import glob | ||
from conans import ConanFile, CMake, tools | ||
from conans.errors import ConanInvalidConfiguration | ||
|
||
import os | ||
|
||
required_conan_version = ">=1.33.0" | ||
required_conan_version = ">=1.53.0" | ||
|
||
|
||
class AeronConan(ConanFile): | ||
name = "aeron" | ||
description = "Efficient reliable UDP unicast, UDP multicast, and IPC message transport" | ||
topics = ("conan", "aeron", "udp", "messaging", "low-latency") | ||
topics = ("udp", "messaging", "low-latency") | ||
url = "https://github.com/conan-io/conan-center-index" | ||
homepage = "https://github.com/real-logic/aeron/wiki" | ||
license = "Apache-2.0" | ||
exports_sources = "CMakeLists.txt", | ||
|
||
settings = "os", "arch", "compiler", "build_type" | ||
options = { | ||
"shared": [True, False], | ||
"fPIC": [True, False], | ||
"build_aeron_driver": [True, False], | ||
"build_aeron_archive_api": [True, False] | ||
"build_aeron_archive_api": [True, False], | ||
} | ||
default_options = { | ||
"shared": False, | ||
"fPIC": True, | ||
"build_aeron_driver": True, | ||
"build_aeron_archive_api": True | ||
"build_aeron_archive_api": True, | ||
} | ||
generators = "cmake" | ||
|
||
_cmake = None | ||
|
||
@property | ||
def _source_subfolder(self): | ||
return "source_subfolder" | ||
def _min_cppstd(self): | ||
return "11" | ||
|
||
@property | ||
def _build_subfolder(self): | ||
return "build_subfolder" | ||
def _compilers_minimum_version(self): | ||
return { | ||
"Visual Studio": "16", | ||
"msvc": "192", | ||
"gcc": "5", | ||
} | ||
|
||
def config_options(self): | ||
if self.settings.os == 'Windows': | ||
del self.options.fPIC | ||
|
||
def configure(self): | ||
if self.options.shared: | ||
del self.options.fPIC | ||
self.options.rm_safe("fPIC") | ||
|
||
def build_requirements(self): | ||
self.build_requires("zulu-openjdk/11.0.8") | ||
def layout(self): | ||
cmake_layout(self, src_folder="src") | ||
|
||
def validate(self): | ||
if self.settings.compiler.cppstd: | ||
tools.check_min_cppstd(self, 11) | ||
if self.settings.compiler.get_safe("cppstd"): | ||
check_min_cppstd(self, self._min_cppstd) | ||
|
||
compiler = str(self.settings.compiler) | ||
compiler_version = tools.Version(self.settings.compiler.version) | ||
|
||
minimal_version = { | ||
"Visual Studio": "16", | ||
"gcc": "5" | ||
} | ||
|
||
if compiler in minimal_version and compiler_version < minimal_version[compiler]: | ||
minimum_version = self._compilers_minimum_version.get(str(self.settings.compiler), False) | ||
if minimum_version and Version(self.settings.compiler.version) < minimum_version: | ||
raise ConanInvalidConfiguration( | ||
"{} requires {} compiler {} or newer [is: {}]".format(self.name, compiler, minimal_version[compiler], compiler_version) | ||
f"{self.ref} requires C++{self._min_cppstd}, which your compiler does not support." | ||
) | ||
|
||
if self.settings.os == "Macos" and self.settings.arch == "armv8": | ||
raise ConanInvalidConfiguration("This platform (os=Macos arch=armv8) is not yet supported by this recipe") | ||
|
||
def source(self): | ||
tools.get(**self.conan_data["sources"][self.version], | ||
destination=self._source_subfolder, strip_root=True) | ||
|
||
def _configure_cmake(self): | ||
if self._cmake: | ||
return self._cmake | ||
|
||
self._cmake = CMake(self) | ||
self._cmake.definitions["AERON_INSTALL_TARGETS"] = True | ||
self._cmake.definitions["BUILD_AERON_DRIVER"] = self.options.build_aeron_driver | ||
self._cmake.definitions["AERON_TESTS"] = False | ||
self._cmake.definitions["AERON_BUILD_SAMPLES"] = False | ||
self._cmake.definitions["BUILD_AERON_ARCHIVE_API"] = self.options.build_aeron_archive_api | ||
self._cmake.definitions["AERON_ENABLE_NONSTANDARD_OPTIMIZATIONS"] = True | ||
def build_requirements(self): | ||
self.tool_requires("zulu-openjdk/11.0.15") | ||
|
||
self._cmake.configure(build_folder=self._build_subfolder) | ||
return self._cmake | ||
def source(self): | ||
get(self, **self.conan_data["sources"][self.version], strip_root=True) | ||
|
||
def generate(self): | ||
env = VirtualBuildEnv(self) | ||
env.generate() | ||
tc = CMakeToolchain(self) | ||
tc.cache_variables["BUILD_AERON_DRIVER"] = self.options.build_aeron_driver | ||
tc.cache_variables["BUILD_AERON_ARCHIVE_API"] = self.options.build_aeron_archive_api | ||
tc.cache_variables["AERON_TESTS"] = False | ||
tc.cache_variables["AERON_SYSTEM_TESTS"] = False | ||
tc.cache_variables["AERON_SLOW_SYSTEM_TESTS"] = False | ||
tc.cache_variables["AERON_BUILD_SAMPLES"] = False | ||
tc.cache_variables["AERON_BUILD_DOCUMENTATION"] = False | ||
tc.cache_variables["AERON_INSTALL_TARGETS"] = True | ||
tc.cache_variables["AERON_ENABLE_NONSTANDARD_OPTIMIZATIONS"] = True | ||
tc.generate() | ||
|
||
def _patch_sources(self): | ||
tools.replace_in_file(os.path.join(self._source_subfolder, "CMakeLists.txt"), "/MTd", "") | ||
tools.replace_in_file(os.path.join(self._source_subfolder, "CMakeLists.txt"), "/MT", "") | ||
replace_in_file(self, os.path.join(self.source_folder, "CMakeLists.txt"), "/MTd", "") | ||
replace_in_file(self, os.path.join(self.source_folder, "CMakeLists.txt"), "/MT", "") | ||
|
||
def build(self): | ||
self._patch_sources() | ||
cmake = self._configure_cmake() | ||
cmake = CMake(self) | ||
cmake.configure() | ||
cmake.build() | ||
|
||
def package(self): | ||
self.copy(pattern="LICENSE", dst="licenses", src=self._source_subfolder) | ||
cmake = self._configure_cmake() | ||
copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) | ||
cmake = CMake(self) | ||
cmake.install() | ||
|
||
with tools.chdir(self.package_folder): | ||
for dll in glob.glob(os.path.join("lib", "*.dll")): | ||
shutil.move(dll, "bin") | ||
archive_resources_dir = os.path.join(self.source_folder, "aeron-archive", "src", "main", "resources") | ||
copy(self, "*", src=archive_resources_dir, dst=os.path.join(self.package_folder, "res")) | ||
|
||
archive_resources_dir = os.path.join(self._source_subfolder, "aeron-archive", "src", "main", "resources") | ||
self.copy("*", dst="res", src=archive_resources_dir) | ||
archive_include_dir = os.path.join(self.source_folder, "aeron-archive", "src", "main", "cpp", "client") | ||
copy(self, "*.h", src=archive_include_dir, dst=os.path.join(self.package_folder, "include", "aeron-archive")) | ||
|
||
archive_include_dir = os.path.join(self._source_subfolder, "aeron-archive", "src", "main", "cpp", "client") | ||
self.copy("*.h", dst=os.path.join("include", "aeron-archive"), src=archive_include_dir) | ||
lib_folder = os.path.join(self.package_folder, "lib") | ||
bin_folder = os.path.join(self.package_folder, "bin") | ||
for dll in glob.glob(os.path.join(lib_folder, "*.dll")): | ||
rename(self, dll, os.path.join(bin_folder, os.path.basename(dll))) | ||
|
||
libs_folder = os.path.join(self.package_folder, "lib") | ||
if self.options.shared: | ||
tools.remove_files_by_mask(libs_folder, "*.a") | ||
tools.remove_files_by_mask(libs_folder, "*static.lib") | ||
tools.remove_files_by_mask(libs_folder, "aeron_client.lib") | ||
for lib in glob.glob(os.path.join(lib_folder, "*.a")): | ||
if not lib.endswith(".dll.a"): | ||
os.remove(lib) | ||
rm(self, "*static.lib", lib_folder) | ||
rm(self, "aeron_client.lib", lib_folder) | ||
else: | ||
tools.remove_files_by_mask(os.path.join(self.package_folder, "bin"), "*.dll") | ||
tools.remove_files_by_mask(libs_folder, "*.so") | ||
tools.remove_files_by_mask(libs_folder, "*.dylib") | ||
tools.remove_files_by_mask(libs_folder, "*shared.lib") | ||
tools.remove_files_by_mask(libs_folder, "aeron.lib") | ||
rm(self, "*.dll", bin_folder) | ||
rm(self, "*.so*", lib_folder) | ||
rm(self, "*.dylib", lib_folder) | ||
rm(self, "*.dll.a", lib_folder) | ||
rm(self, "*shared.lib", lib_folder) | ||
rm(self, "aeron.lib", lib_folder) | ||
|
||
def package_info(self): | ||
bin_path = os.path.join(self.package_folder, "bin") | ||
self.output.info("Appending PATH environment variable: {}".format(bin_path)) | ||
self.env_info.PATH.append(bin_path) | ||
self.cpp_info.libs = tools.collect_libs(self) | ||
if self.settings.compiler == "Visual Studio": | ||
self.cpp_info.libs = collect_libs(self) | ||
if is_msvc(self): | ||
self.cpp_info.defines.append("_ENABLE_EXTENDED_ALIGNED_STORAGE") | ||
|
||
if self.settings.os == "Linux": | ||
self.cpp_info.system_libs = ["m", "pthread"] | ||
if self.settings.os in ["Linux", "FreeBSD"]: | ||
self.cpp_info.system_libs.extend(["dl", "m", "pthread"]) | ||
elif self.settings.os == "Windows": | ||
self.cpp_info.system_libs = ["wsock32", "ws2_32", "Iphlpapi"] | ||
self.cpp_info.system_libs = ["winmm", "wsock32", "ws2_32", "iphlpapi"] | ||
self.cpp_info.defines.append("HAVE_WSAPOLL") | ||
|
||
# TODO: to remove in conan v2 | ||
self.env_info.PATH.append(os.path.join(self.package_folder, "bin")) |
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,11 +1,8 @@ | ||
cmake_minimum_required(VERSION 3.6.1) | ||
project(test_package) | ||
cmake_minimum_required(VERSION 3.8) | ||
project(test_package LANGUAGES CXX) | ||
|
||
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) | ||
conan_basic_setup(TARGETS) | ||
|
||
find_package(aeron CONFIG REQUIRED) | ||
find_package(aeron REQUIRED CONFIG) | ||
|
||
add_executable(${PROJECT_NAME} test_package.cpp) | ||
target_link_libraries(${PROJECT_NAME} aeron::aeron) | ||
set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) | ||
target_link_libraries(${PROJECT_NAME} PRIVATE aeron::aeron) | ||
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) |
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 conan import ConanFile | ||
from conan.tools.build import can_run | ||
from conan.tools.cmake import CMake, cmake_layout | ||
import os | ||
from conans import ConanFile, CMake, tools, RunEnvironment | ||
|
||
|
||
class TestPackageConan(ConanFile): | ||
settings = "os", "compiler", "build_type", "arch" | ||
generators = "cmake", "cmake_find_package_multi" | ||
settings = "os", "arch", "compiler", "build_type" | ||
generators = "CMakeDeps", "CMakeToolchain", "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): | ||
self.run(os.path.join("bin", "test_package"), run_environment=True) | ||
if can_run(self): | ||
bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") | ||
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.1) | ||
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,17 @@ | ||
from conans import ConanFile, CMake, tools | ||
import os | ||
|
||
|
||
class TestPackageConan(ConanFile): | ||
settings = "os", "arch", "compiler", "build_type" | ||
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): | ||
bin_path = os.path.join("bin", "test_package") | ||
self.run(bin_path, run_environment=True) |
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 |
---|---|---|
|
@@ -7,5 +7,3 @@ versions: | |
folder: all | ||
"1.32.0": | ||
folder: all | ||
"1.31.2": | ||
folder: all |