diff --git a/recipes/abseil/all/conandata.yml b/recipes/abseil/all/conandata.yml new file mode 100644 index 0000000000000..fa1472c162c72 --- /dev/null +++ b/recipes/abseil/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "20200205": + sha256: 3c554df4909c5c55a6d251f6eadc2c78ff20db5ad4471fd9cbf8085c51b76797 + url: https://github.com/abseil/abseil-cpp/archive/08a7e7bf972c8451855a5022f2faf3d3655db015.tar.gz diff --git a/recipes/abseil/all/conanfile.py b/recipes/abseil/all/conanfile.py new file mode 100644 index 0000000000000..243a0b7ca6426 --- /dev/null +++ b/recipes/abseil/all/conanfile.py @@ -0,0 +1,151 @@ +import os +import glob +from conans import ConanFile, CMake, tools +from conans.errors import ConanInvalidConfiguration, ConanException + + +class ConanRecipe(ConanFile): + name = "abseil" + + description = "Abseil Common Libraries (C++) from Google" + topics = ("algorithm", "container", "google", "common", "utility") + + homepage = "https://github.com/abseil/abseil-cpp" + url = "https://github.com/conan-io/conan-center-index" + + license = "Apache-2.0" + + settings = "os", "arch", "compiler", "build_type" + + options = {"fPIC": [True, False]} + default_options = {"fPIC": True} + + generators = "cmake" + short_paths = True + + @property + def _source_subfolder(self): + return "source_subfolder" + + def source(self): + tools.get(**self.conan_data["sources"][self.version]) + extracted_dir = glob.glob('abseil-cpp-*/')[0] + os.rename(extracted_dir, self._source_subfolder) + tools.replace_in_file( + os.path.join(self._source_subfolder, "CMakeLists.txt"), + "project(absl CXX)", """project(absl CXX) +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup()""") + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + minimal_cpp_standard = "11" + + try: + tools.check_min_cppstd(self, minimal_cpp_standard) + except ConanInvalidConfiguration: + raise + except ConanException: + # FIXME: We need to handle the case when Conan doesn't know + # about a user defined compiler's default standard version + self.output.warn( + "Unnable to determine the default standard version of the compiler") + + minimal_version = { + "Visual Studio": "14", + } + + compiler = str(self.settings.compiler) + if compiler not in minimal_version: + self.output.warn( + "%s recipe lacks information about the %s compiler support" % (self.name, compiler)) + self.output.warn( + "%s requires a compiler that supports at least C++%s" % (self.name, minimal_cpp_standard)) + return + + version = tools.Version(self.settings.compiler.version) + if version < minimal_version[compiler]: + raise ConanInvalidConfiguration( + "%s requires at least %s %s" % (self.name, compiler, minimal_version[compiler])) + + def _configure_cmake(self): + cmake = CMake(self) + cmake.definitions["BUILD_TESTING"] = False + cmake.configure( + source_folder=self._source_subfolder + ) + return cmake + + def build(self): + cmake = self._configure_cmake() + cmake.build() + + def package(self): + self.copy("LICENSE", dst="licenses", src=self._source_subfolder) + cmake = self._configure_cmake() + cmake.install() + tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) + + def package_info(self): + self.cpp_info.libs = [ + "absl_flags_parse", + "absl_flags_usage", + "absl_flags_usage_internal", + "absl_flags", + "absl_flags_internal", + "absl_flags_registry", + "absl_flags_config", + "absl_flags_program_name", + "absl_flags_marshalling", + "absl_raw_hash_set", + "absl_random_seed_sequences", + "absl_hashtablez_sampler", + "absl_synchronization", + "absl_time", + "absl_civil_time", + "absl_time_zone", + "absl_failure_signal_handler", + "absl_random_internal_distribution_test_util", + "absl_examine_stack", + "absl_symbolize", + "absl_str_format_internal", + "absl_graphcycles_internal", + "absl_stacktrace", + "absl_malloc_internal", + "absl_demangle_internal", + "absl_debugging_internal", + "absl_periodic_sampler", + "absl_exponential_biased", + "absl_random_internal_pool_urbg", + "absl_random_distributions", + "absl_random_internal_seed_material", + "absl_random_seed_gen_exception", + "absl_hash", + "absl_strings", + "absl_strings_internal", + "absl_bad_variant_access", + "absl_throw_delegate", + "absl_city", + "absl_base", + "absl_dynamic_annotations", + "absl_bad_any_cast_impl", + "absl_scoped_set_env", + "absl_bad_optional_access", + "absl_raw_logging_internal", + "absl_log_severity", + "absl_spinlock_wait", + "absl_random_internal_randen", + "absl_random_internal_randen_hwaes", + "absl_random_internal_randen_slow", + "absl_random_internal_randen_hwaes_impl", + "absl_leak_check", + "absl_leak_check_disable", + "absl_int128" + ] + if self.settings.os == "Linux": + self.cpp_info.system_libs.append("pthread") + self.cpp_info.names["cmake_find_package"] = "absl" + self.cpp_info.names["cmake_find_package_multi"] = "absl" diff --git a/recipes/abseil/all/test_package/CMakeLists.txt b/recipes/abseil/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..58e19858a5148 --- /dev/null +++ b/recipes/abseil/all/test_package/CMakeLists.txt @@ -0,0 +1,13 @@ +cmake_minimum_required(VERSION 3.2.0) +project(test_package CXX) + +# We set it only for the convenience of calling the executable +# in the package test function +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup() + +find_package(absl REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} main.cpp) +# Note: Conan 1.21 doesn't support granular target generation yet. +target_link_libraries(${PROJECT_NAME} absl::absl) diff --git a/recipes/abseil/all/test_package/conanfile.py b/recipes/abseil/all/test_package/conanfile.py new file mode 100644 index 0000000000000..b631a14a79607 --- /dev/null +++ b/recipes/abseil/all/test_package/conanfile.py @@ -0,0 +1,17 @@ +# -*- coding: utf-8 -*- +from conans import ConanFile, CMake +import os + + +class TestPackageConan(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): + bin_path = os.path.join("bin", "test_package") + self.run("%s -s" % bin_path, run_environment=True) diff --git a/recipes/abseil/all/test_package/main.cpp b/recipes/abseil/all/test_package/main.cpp new file mode 100644 index 0000000000000..0cdc47cb3c724 --- /dev/null +++ b/recipes/abseil/all/test_package/main.cpp @@ -0,0 +1,49 @@ +#include +#include +#include +#include + +#include "absl/strings/str_cat.h" +#include "absl/strings/str_split.h" +#include "absl/container/flat_hash_map.h" +#include "absl/container/flat_hash_set.h" +#include "absl/numeric/int128.h" +#include "absl/time/time.h" + +int main() +{ + absl::flat_hash_set set1; + absl::flat_hash_map map1; + absl::flat_hash_set set2 = { + {"huey"}, + {"dewey"}, + {"louie"}, + }; + absl::flat_hash_map map2 = { + {1, "huey"}, + {2, "dewey"}, + {3, "louie"}, + }; + absl::flat_hash_set set3(set2); + absl::flat_hash_map map3(map2); + + absl::flat_hash_set set4; + set4 = set3; + absl::flat_hash_map map4; + map4 = map3; + + absl::flat_hash_set set5(std::move(set4)); + absl::flat_hash_map map5(std::move(map4)); + absl::flat_hash_set set6; + set6 = std::move(set5); + absl::flat_hash_map map6; + map6 = std::move(map5); + + const absl::uint128 big = absl::Uint128Max(); + std::cout << absl::StrCat("Arg ", "foo", "\n"); + std::vector v = absl::StrSplit("a,b,,c", ','); + + absl::Time t1 = absl::Now(); + absl::Time t2 = absl::Time(); + absl::Time t3 = absl::UnixEpoch(); +} diff --git a/recipes/abseil/config.yml b/recipes/abseil/config.yml new file mode 100644 index 0000000000000..d7a82ea6a23bf --- /dev/null +++ b/recipes/abseil/config.yml @@ -0,0 +1,3 @@ +versions: + "20200205": + folder: all