-
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
Add the abseil/20200205 #801
Merged
Merged
Changes from 2 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
0275a75
Add the abseil/20200205
Minimonium ca110d7
Use conan_basic_setup for magic injections
Minimonium b7d8026
Remove the LICENSE file check
Minimonium fd555cb
Remove a redundant line
Minimonium 5176598
Raise an exception if the default compiler version is less than C++11
Minimonium a690131
Try to fix the order of libs
Minimonium 01e8c6b
Use a different link order
Minimonium ff1643d
Move along
Minimonium 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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
sources: | ||
"20200205": | ||
sha256: 3c554df4909c5c55a6d251f6eadc2c78ff20db5ad4471fd9cbf8085c51b76797 | ||
url: https://github.com/abseil/abseil-cpp/archive/08a7e7bf972c8451855a5022f2faf3d3655db015.tar.gz |
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,158 @@ | ||
import os | ||
import glob | ||
from conans import ConanFile, CMake, tools | ||
from conans.errors import ConanInvalidConfiguration | ||
|
||
|
||
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" | ||
if self.settings.compiler.cppstd: | ||
tools.check_min_cppstd(self, minimal_cpp_standard) | ||
|
||
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_spinlock_wait", | ||
"absl_dynamic_annotations", | ||
"absl_malloc_internal", | ||
"absl_raw_logging_internal", | ||
"absl_base", | ||
"absl_throw_delegate", | ||
"absl_scoped_set_env", | ||
"absl_hashtablez_sampler", | ||
"absl_raw_hash_set", | ||
"absl_stacktrace", | ||
"absl_symbolize", | ||
"absl_examine_stack", | ||
"absl_failure_signal_handler", | ||
"absl_debugging_internal", | ||
"absl_demangle_internal", | ||
"absl_leak_check", | ||
"absl_leak_check_disable", | ||
"absl_flags_internal", | ||
"absl_flags_config", | ||
"absl_flags_marshalling", | ||
"absl_flags_registry", | ||
"absl_flags", | ||
"absl_flags_usage_internal", | ||
"absl_flags_usage", | ||
"absl_flags_parse", | ||
"absl_hash", | ||
"absl_city ", | ||
"absl_int128", | ||
"absl_strings", | ||
"absl_strings_internal", | ||
"absl_str_format_internal", | ||
"absl_graphcycles_internal", | ||
"absl_synchronization", | ||
"absl_time absl_civil_time", | ||
"absl_time_zone", | ||
"absl_bad_any_cast_impl", | ||
"absl_bad_optional_access", | ||
"absl_bad_variant_access", | ||
"absl_bad_variant_access", | ||
"absl_hashtablez_sampler", | ||
"absl_examine_stack", | ||
"absl_leak_check", | ||
"absl_flags_usage", | ||
"absl_flags_usage_internal", | ||
"absl_flags", | ||
"absl_flags_registry", | ||
"absl_flags_config", | ||
"absl_flags_internal", | ||
"absl_flags_marshalling", | ||
"absl_str_format_internal", | ||
"absl_bad_optional_access", | ||
"absl_synchronization", | ||
"absl_stacktrace", | ||
"absl_symbolize", | ||
"absl_debugging_internal", | ||
"absl_demangle_internal", | ||
"absl_graphcycles_internal", | ||
"absl_malloc_internal", | ||
"absl_time absl_strings", | ||
"absl_throw_delegate", | ||
"absl_strings_internal", | ||
"absl_civil_time", | ||
"absl_time_zone", | ||
"absl_int128", | ||
"absl_base ", | ||
"absl_spinlock_wait", | ||
"absl_dynamic_annotations", | ||
"absl_exponential_biased" | ||
] | ||
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" |
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,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
|
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,19 @@ | ||
# -*- 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): | ||
assert os.path.isfile(os.path.join( | ||
self.deps_cpp_info["abseil"].rootpath, "licenses", "LICENSE")) | ||
Minimonium marked this conversation as resolved.
Show resolved
Hide resolved
|
||
bin_path = os.path.join("bin", "test_package") | ||
self.run("%s -s" % 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 |
---|---|---|
@@ -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(); | ||
} |
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,3 @@ | ||
versions: | ||
"20200205": | ||
folder: all |
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.
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.
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.
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?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.
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