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

Add the abseil/20200205 #801

Merged
merged 8 commits into from
Mar 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 4 additions & 0 deletions recipes/abseil/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
sources:
"20200205":
sha256: 3c554df4909c5c55a6d251f6eadc2c78ff20db5ad4471fd9cbf8085c51b76797
url: https://github.com/abseil/abseil-cpp/archive/08a7e7bf972c8451855a5022f2faf3d3655db015.tar.gz
151 changes: 151 additions & 0 deletions recipes/abseil/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -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):
Copy link
Member

Choose a reason for hiding this comment

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

I don't like it for all versions. From my experience, Abseil changes the library constantly. I would say you should create one recipe per version. However, creating one recipe version is boring, and only the cpp_info.libs will change. So, we could accept the lib list in conandata.yml, but it requires a filter there is conan-center hook.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

A good idea! The all folder is kinda a placeholder. Shouldn't be a problem to split recipes into different folders later on, isn't it?

Copy link
Member

@danimtb danimtb Feb 12, 2020

Choose a reason for hiding this comment

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

I am not a big fan of the idea of having this information in the conandata.yml file, as it will be harder to read and it is mainly used (in this repo) for things related to sources. But you can always make the libs conditional to the version of the recipe if you want to keep one recipe for all of them (easier to maintain). @Minimonium in case the recipe diverges too much we can always split it to one for each version

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"
13 changes: 13 additions & 0 deletions recipes/abseil/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)
uilianries marked this conversation as resolved.
Show resolved Hide resolved
17 changes: 17 additions & 0 deletions recipes/abseil/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -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)
49 changes: 49 additions & 0 deletions recipes/abseil/all/test_package/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#include <string>
#include <utility>
#include <iostream>
#include <vector>

#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<std::string> set1;
absl::flat_hash_map<int, std::string> map1;
absl::flat_hash_set<std::string> set2 = {
{"huey"},
{"dewey"},
{"louie"},
};
absl::flat_hash_map<int, std::string> map2 = {
{1, "huey"},
{2, "dewey"},
{3, "louie"},
};
absl::flat_hash_set<std::string> set3(set2);
absl::flat_hash_map<int, std::string> map3(map2);

absl::flat_hash_set<std::string> set4;
set4 = set3;
absl::flat_hash_map<int, std::string> map4;
map4 = map3;

absl::flat_hash_set<std::string> set5(std::move(set4));
absl::flat_hash_map<int, std::string> map5(std::move(map4));
absl::flat_hash_set<std::string> set6;
set6 = std::move(set5);
absl::flat_hash_map<int, std::string> map6;
map6 = std::move(map5);

const absl::uint128 big = absl::Uint128Max();
std::cout << absl::StrCat("Arg ", "foo", "\n");
std::vector<std::string> v = absl::StrSplit("a,b,,c", ',');

absl::Time t1 = absl::Now();
absl::Time t2 = absl::Time();
absl::Time t3 = absl::UnixEpoch();
}
3 changes: 3 additions & 0 deletions recipes/abseil/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
versions:
"20200205":
folder: all