From ac97215b77cad3863de089c4540c705ddb20592c Mon Sep 17 00:00:00 2001 From: "Ravi Akella email = raakella@ebay.com" Date: Mon, 28 Aug 2023 10:18:59 -0700 Subject: [PATCH 01/22] use pistache/0.0.5 --- conanfile.py | 6 +++--- src/auth_manager/CMakeLists.txt | 2 +- src/grpc/tests/unit/CMakeLists.txt | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/conanfile.py b/conanfile.py index aa13b392..086b2716 100644 --- a/conanfile.py +++ b/conanfile.py @@ -8,7 +8,7 @@ class SISLConan(ConanFile): name = "sisl" - version = "8.5.4" + version = "8.5.17" homepage = "https://github.com/eBay/sisl" description = "Library for fast data structures, utilities" topics = ("ebay", "components", "core", "efficiency") @@ -41,7 +41,7 @@ def build_requirements(self): self.build_requires("benchmark/1.7.0") self.build_requires("gtest/1.11.0") if self.settings.compiler in ["gcc"]: - self.build_requires("pistache/cci.20201127") + self.build_requires("pistache/0.0.5") def requirements(self): # Custom packages @@ -66,7 +66,7 @@ def requirements(self): self.requires("zmarok-semver/1.1.0") self.requires("fmt/8.1.1", override=True) self.requires("libevent/2.1.12", override=True) - self.requires("openssl/1.1.1q", override=True) + self.requires("openssl/1.1.1s", override=True) self.requires("xz_utils/5.2.5", override=True) self.requires("zlib/1.2.12", override=True) if self.options.malloc_impl == "jemalloc": diff --git a/src/auth_manager/CMakeLists.txt b/src/auth_manager/CMakeLists.txt index aa554c36..ff83dc6d 100644 --- a/src/auth_manager/CMakeLists.txt +++ b/src/auth_manager/CMakeLists.txt @@ -34,7 +34,7 @@ target_link_libraries(test_auth_mgr sisl ${COMMON_DEPS} cpr::cpr - pistache::pistache + Pistache::Pistache flatbuffers::flatbuffers jwt-cpp::jwt-cpp GTest::gmock diff --git a/src/grpc/tests/unit/CMakeLists.txt b/src/grpc/tests/unit/CMakeLists.txt index 1e82a780..bd163d99 100644 --- a/src/grpc/tests/unit/CMakeLists.txt +++ b/src/grpc/tests/unit/CMakeLists.txt @@ -7,7 +7,7 @@ add_executable(auth_test target_link_libraries(auth_test sisl sisl_grpc - pistache::pistache + Pistache::Pistache GTest::gmock ${COMMON_DEPS} ) From 1a90a5ca197d8be8a3b2e4a673111c512a130ced Mon Sep 17 00:00:00 2001 From: "Ravi Akella email = raakella@ebay.com" Date: Mon, 28 Aug 2023 16:04:35 -0700 Subject: [PATCH 02/22] add caching to auth_manager --- include/sisl/auth_manager/auth_manager.hpp | 33 +++++++ src/auth_manager/LRUCache.h | 84 ++++++++++++++++ src/auth_manager/auth_manager.cpp | 106 ++++++++++++++++++--- 3 files changed, 209 insertions(+), 14 deletions(-) create mode 100644 src/auth_manager/LRUCache.h diff --git a/include/sisl/auth_manager/auth_manager.hpp b/include/sisl/auth_manager/auth_manager.hpp index bf5ea957..67857a39 100644 --- a/include/sisl/auth_manager/auth_manager.hpp +++ b/include/sisl/auth_manager/auth_manager.hpp @@ -23,6 +23,31 @@ namespace sisl { ENUM(AuthVerifyStatus, uint8_t, OK, UNAUTH, FORBIDDEN) +template < typename key_t, typename value_t > +class LRUCache; + +/** + * This struct holds information of a token, that can be used as if + * they were extracted from decoded token. + */ +struct CachedToken { + AuthVerifyStatus response_status; + std::string msg; + bool valid; + std::chrono::system_clock::time_point expires_at; + + inline void set_invalid(AuthVerifyStatus code, const std::string& reason) { + valid = false; + response_status = code; + msg = reason; + } + + inline void set_valid() { + valid = true; + response_status = AuthVerifyStatus::OK; + } +}; + class AuthManager { public: AuthManager() {} @@ -33,5 +58,13 @@ class AuthManager { void verify_decoded(const jwt::decoded_jwt& decoded) const; virtual std::string download_key(const std::string& key_url) const; std::string get_app(const jwt::decoded_jwt& decoded) const; + + // the verify method is declared const. We make this mutable + // as these caches are modified in the verify method. md5_sum(raw_token) -> + // DecodedToken + mutable LRUCache< std::string, CachedToken > m_cached_tokens; + + // key_id -> signing public key + mutable LRUCache< std::string, std::string > m_cached_keys; }; } // namespace sisl diff --git a/src/auth_manager/LRUCache.h b/src/auth_manager/LRUCache.h new file mode 100644 index 00000000..6b35fd57 --- /dev/null +++ b/src/auth_manager/LRUCache.h @@ -0,0 +1,84 @@ +#pragma once + +#include +#include +#include +#include +#include +#include + +namespace auth_manager { + +/** + * + * written by @jiankun + * + * A high performance LRU cache implementation. + * + * The cache provides two atomic operations: + * put(key, value): put an object into the cache. + * get(key): returns a optional reference to the value found by key in cache + * + * Important notes: + * 1. The get() method returns a const reference, any change to the reference + * needs to be done by a Put call. + * 2. The put/get methods are thread safe. + */ +template class LRUCache { +public: + using kv_pair_t = std::pair; + using list_iterator_t = typename std::list::iterator; + + explicit LRUCache(size_t capacity) : capacity_(capacity) {} + + template void put(K &&key, V &&value) { + std::unique_lock l{mtx_}; + + auto it = items_map_.find(key); + if (it != items_map_.end()) { + items_list_.erase(it->second); + items_map_.erase(it); + } + + items_list_.emplace_front( + std::make_pair(std::forward(key), std::forward(value))); + items_map_[key] = items_list_.begin(); + + if (items_map_.size() > capacity_) { + auto last = items_list_.rbegin(); + items_map_.erase(last->first); + items_list_.pop_back(); + } + } + + [[nodiscard]] const std::optional> + get(const key_t &key) { + std::shared_lock l{mtx_}; + + auto it = items_map_.find(key); + if (it == items_map_.end()) { + return std::nullopt; + } + + items_list_.splice(items_list_.begin(), items_list_, it->second); + return std::optional(std::cref(it->second->second)); + } + + bool exists(const key_t &key) const { + std::shared_lock l{mtx_}; + return items_map_.find(key) != items_map_.end(); + } + + [[nodiscard]] size_t size() const { + std::shared_lock l{mtx_}; + return items_map_.size(); + } + +private: + std::list items_list_; + std::unordered_map items_map_; + size_t capacity_; + mutable std::shared_mutex mtx_; +}; + +} // namespace auth_manager diff --git a/src/auth_manager/auth_manager.cpp b/src/auth_manager/auth_manager.cpp index 38396cca..06013caa 100644 --- a/src/auth_manager/auth_manager.cpp +++ b/src/auth_manager/auth_manager.cpp @@ -7,46 +7,124 @@ namespace sisl { +static std::string md5_sum(std::string const& b) { + std::array< unsigned char, MD5_DIGEST_LENGTH > result; + uint32_t md_len; + auto mdctx = EVP_MD_CTX_new(); + EVP_DigestInit_ex2(mdctx, EVP_md5(), nullptr); + EVP_DigestUpdate(mdctx, b.c_str(), b.size()); + EVP_DigestFinal_ex(mdctx, result.data(), &md_len); + EVP_MD_CTX_free(mdctx); + if (md_len != MD5_DIGEST_LENGTH) { + LOGERROR("Bad digest length, expected [{}] got [{}]!", MD5_DIGEST_LENGTH, md_len); + return std::string(); + } + + // convert to hex + std::ostringstream ss; + ss << std::hex; + for (auto const c : result) { + ss << static_cast< unsigned >(c); + } + return ss.str(); +} + +struct incomplete_verification_error : std::exception { + explicit incomplete_verification_error(const std::string& error) : error_(error) {} + const char* what() const noexcept { return error_.c_str(); } + +private: + const std::string error_; +}; + AuthVerifyStatus AuthManager::verify(const std::string& token, std::string& msg) const { + // if we have it in cache, just use it to make the decision + auto const token_hash = md5_sum(token); + if (auto const ct = m_cached_tokens.get(token_hash); ct) { + auto const& cached_token = ct->get(); + if (cached_token.valid) { + auto now = std::chrono::system_clock::now(); + if (now > cached_token.expires_at + std::chrono::seconds(SECURITY_DYNAMIC_CONFIG(auth_manager->leeway))) { + m_cached_tokens.put( + token_hash, CachedToken{AuthVerifyStatus::UNAUTH, "token expired", false, cached_token.expires_at}); + } + } + msg = cached_token.msg; + return cached_token.response_status; + } + + // not found in cache + CachedToken cached_token; std::string app_name; - // TODO: cache tokens for better performance try { // this may throw if token is ill formed - const auto decoded{jwt::decode(token)}; + const auto decoded{jwt::decode< traits >(token)}; // for any reason that causes the verification failure, an // exception is thrown. verify_decoded(decoded); app_name = get_app(decoded); - } catch (const std::exception& e) { + cached_token.expires_at = decoded.get_expires_at(); + cached_token.set_valid(); + } catch (const incomplete_verification_error& e) { + // verification incomplete, the token validity is not determined, shouldn't + // cache msg = e.what(); return AuthVerifyStatus::UNAUTH; + } catch (const std::exception& e) { + cached_token.set_invalid(AuthVerifyStatus::UNAUTH, e.what()); + m_cached_tokens.put(token_hash, cached_token); + msg = cached_token.msg; + return cached_token.response_status; } // check client application - if (SECURITY_DYNAMIC_CONFIG(auth_manager->auth_allowed_apps) != "all") { - if (SECURITY_DYNAMIC_CONFIG(auth_manager->auth_allowed_apps).find(app_name) == std::string::npos) { - msg = fmt::format("application '{}' is not allowed to perform the request", app_name); - return AuthVerifyStatus::FORBIDDEN; + if (AUTH_CONFIG(trf_verifier->auth_allowed_apps) != "all") { + if (AUTH_CONFIG(trf_verifier->auth_allowed_apps).find(app_name) == std::string::npos) { + cached_token.set_invalid(AuthVerifyStatus::FORBIDDEN, + fmt::format("application '{}' is not allowed to perform the request", app_name)); } } - return AuthVerifyStatus::OK; + m_cached_tokens.put(token_hash, cached_token); + msg = cached_token.msg; + return cached_token.response_status; } + void AuthManager::verify_decoded(const jwt::decoded_jwt& decoded) const { const auto alg{decoded.get_algorithm()}; if (alg != "RS256") throw std::runtime_error(fmt::format("unsupported algorithm: {}", alg)); - if (!decoded.has_header_claim("x5u")) throw std::runtime_error("no indication of verification key"); + std::string signing_key; + std::string key_id; + auto should_cache_key = true; + + if (decoded.has_key_id()) { + key_id = decoded.get_key_id(); + auto cached_key = m_cached_keys.get(key_id); + if (cached_key) { + signing_key = cached_key->get(); + should_cache_key = false; + } + } else { + should_cache_key = false; + } + + if (signing_key.empty()) { + if (!decoded.has_header_claim("x5u")) throw std::runtime_error("no indication of verification key"); - auto key_url = decoded.get_header_claim("x5u").as_string(); + auto key_url = decoded.get_header_claim("x5u").as_string(); - if (key_url.rfind(SECURITY_DYNAMIC_CONFIG(auth_manager->tf_token_url), 0) != 0) { - throw std::runtime_error(fmt::format("key url {} is not trusted", key_url)); + if (key_url.rfind(AUTH_CONFIG(trf_verifier->tf_token_url), 0) != 0) { + throw std::runtime_error(fmt::format("key url {} is not trusted", key_url)); + } + signing_key = download_key(key_url); } - const std::string signing_key{download_key(key_url)}; - const auto verifier{jwt::verify() + + if (should_cache_key) { m_cached_keys.put(key_id, signing_key); } + + const auto verifier{jwt::verify< traits >() .with_issuer(SECURITY_DYNAMIC_CONFIG(auth_manager->issuer)) .allow_algorithm(jwt::algorithm::rs256(signing_key)) .expires_at_leeway(SECURITY_DYNAMIC_CONFIG(auth_manager->leeway))}; From 57593c4bcf1ffeb4f9dd5d84b2c8bbf1f0b0f896 Mon Sep 17 00:00:00 2001 From: "Ravi Akella email = raakella@ebay.com" Date: Mon, 28 Aug 2023 16:24:23 -0700 Subject: [PATCH 03/22] fix the auth test after caching --- conanfile.py | 2 +- include/sisl/auth_manager/LRUCache.h | 82 +++++++++++++++++++++ include/sisl/auth_manager/auth_manager.hpp | 3 +- src/auth_manager/LRUCache.h | 84 ---------------------- src/auth_manager/auth_manager.cpp | 45 ++++++------ src/auth_manager/security_config.fbs | 4 ++ src/auth_manager/tests/AuthTest.cpp | 4 +- 7 files changed, 113 insertions(+), 111 deletions(-) create mode 100644 include/sisl/auth_manager/LRUCache.h delete mode 100644 src/auth_manager/LRUCache.h diff --git a/conanfile.py b/conanfile.py index 086b2716..3c02c812 100644 --- a/conanfile.py +++ b/conanfile.py @@ -8,7 +8,7 @@ class SISLConan(ConanFile): name = "sisl" - version = "8.5.17" + version = "8.5.18" homepage = "https://github.com/eBay/sisl" description = "Library for fast data structures, utilities" topics = ("ebay", "components", "core", "efficiency") diff --git a/include/sisl/auth_manager/LRUCache.h b/include/sisl/auth_manager/LRUCache.h new file mode 100644 index 00000000..f5eb3cdc --- /dev/null +++ b/include/sisl/auth_manager/LRUCache.h @@ -0,0 +1,82 @@ +#pragma once + +#include +#include +#include +#include +#include +#include + +namespace sisl { + +/** + * + * written by @jiankun + * + * A high performance LRU cache implementation. + * + * The cache provides two atomic operations: + * put(key, value): put an object into the cache. + * get(key): returns a optional reference to the value found by key in cache + * + * Important notes: + * 1. The get() method returns a const reference, any change to the reference + * needs to be done by a Put call. + * 2. The put/get methods are thread safe. + */ +template < typename key_t, typename value_t > +class LRUCache { +public: + using kv_pair_t = std::pair< key_t, value_t >; + using list_iterator_t = typename std::list< kv_pair_t >::iterator; + + explicit LRUCache(size_t capacity) : capacity_(capacity) {} + + template < typename K, typename V > + void put(K&& key, V&& value) { + std::unique_lock< std::shared_mutex > l{mtx_}; + + auto it = items_map_.find(key); + if (it != items_map_.end()) { + items_list_.erase(it->second); + items_map_.erase(it); + } + + items_list_.emplace_front(std::make_pair(std::forward< K >(key), std::forward< V >(value))); + items_map_[key] = items_list_.begin(); + + if (items_map_.size() > capacity_) { + auto last = items_list_.rbegin(); + items_map_.erase(last->first); + items_list_.pop_back(); + } + } + + [[nodiscard]] const std::optional< std::reference_wrapper< value_t const > > get(const key_t& key) { + std::shared_lock< std::shared_mutex > l{mtx_}; + + auto it = items_map_.find(key); + if (it == items_map_.end()) { return std::nullopt; } + + items_list_.splice(items_list_.begin(), items_list_, it->second); + return std::optional(std::cref(it->second->second)); + } + + bool exists(const key_t& key) const { + std::shared_lock< std::shared_mutex > l{mtx_}; + return items_map_.find(key) != items_map_.end(); + } + + [[nodiscard]] size_t size() const { + std::shared_lock< std::shared_mutex > l{mtx_}; + return items_map_.size(); + } + +private: + std::list< kv_pair_t > items_list_; + std::unordered_map< key_t, list_iterator_t > items_map_; + size_t capacity_; + mutable std::shared_mutex mtx_; +}; + +} // namespace sisl diff --git a/include/sisl/auth_manager/auth_manager.hpp b/include/sisl/auth_manager/auth_manager.hpp index 67857a39..01885809 100644 --- a/include/sisl/auth_manager/auth_manager.hpp +++ b/include/sisl/auth_manager/auth_manager.hpp @@ -18,6 +18,7 @@ #include #include "security_config.hpp" +#include "LRUCache.h" namespace sisl { @@ -50,7 +51,7 @@ struct CachedToken { class AuthManager { public: - AuthManager() {} + AuthManager(); virtual ~AuthManager() = default; AuthVerifyStatus verify(const std::string& token, std::string& msg) const; diff --git a/src/auth_manager/LRUCache.h b/src/auth_manager/LRUCache.h deleted file mode 100644 index 6b35fd57..00000000 --- a/src/auth_manager/LRUCache.h +++ /dev/null @@ -1,84 +0,0 @@ -#pragma once - -#include -#include -#include -#include -#include -#include - -namespace auth_manager { - -/** - * - * written by @jiankun - * - * A high performance LRU cache implementation. - * - * The cache provides two atomic operations: - * put(key, value): put an object into the cache. - * get(key): returns a optional reference to the value found by key in cache - * - * Important notes: - * 1. The get() method returns a const reference, any change to the reference - * needs to be done by a Put call. - * 2. The put/get methods are thread safe. - */ -template class LRUCache { -public: - using kv_pair_t = std::pair; - using list_iterator_t = typename std::list::iterator; - - explicit LRUCache(size_t capacity) : capacity_(capacity) {} - - template void put(K &&key, V &&value) { - std::unique_lock l{mtx_}; - - auto it = items_map_.find(key); - if (it != items_map_.end()) { - items_list_.erase(it->second); - items_map_.erase(it); - } - - items_list_.emplace_front( - std::make_pair(std::forward(key), std::forward(value))); - items_map_[key] = items_list_.begin(); - - if (items_map_.size() > capacity_) { - auto last = items_list_.rbegin(); - items_map_.erase(last->first); - items_list_.pop_back(); - } - } - - [[nodiscard]] const std::optional> - get(const key_t &key) { - std::shared_lock l{mtx_}; - - auto it = items_map_.find(key); - if (it == items_map_.end()) { - return std::nullopt; - } - - items_list_.splice(items_list_.begin(), items_list_, it->second); - return std::optional(std::cref(it->second->second)); - } - - bool exists(const key_t &key) const { - std::shared_lock l{mtx_}; - return items_map_.find(key) != items_map_.end(); - } - - [[nodiscard]] size_t size() const { - std::shared_lock l{mtx_}; - return items_map_.size(); - } - -private: - std::list items_list_; - std::unordered_map items_map_; - size_t capacity_; - mutable std::shared_mutex mtx_; -}; - -} // namespace auth_manager diff --git a/src/auth_manager/auth_manager.cpp b/src/auth_manager/auth_manager.cpp index 06013caa..d50b7e7e 100644 --- a/src/auth_manager/auth_manager.cpp +++ b/src/auth_manager/auth_manager.cpp @@ -2,31 +2,26 @@ #include #include +extern "C" { +#include +} #include "sisl/auth_manager/auth_manager.hpp" namespace sisl { -static std::string md5_sum(std::string const& b) { - std::array< unsigned char, MD5_DIGEST_LENGTH > result; - uint32_t md_len; - auto mdctx = EVP_MD_CTX_new(); - EVP_DigestInit_ex2(mdctx, EVP_md5(), nullptr); - EVP_DigestUpdate(mdctx, b.c_str(), b.size()); - EVP_DigestFinal_ex(mdctx, result.data(), &md_len); - EVP_MD_CTX_free(mdctx); - if (md_len != MD5_DIGEST_LENGTH) { - LOGERROR("Bad digest length, expected [{}] got [{}]!", MD5_DIGEST_LENGTH, md_len); - return std::string(); - } +static std::string md5_sum(std::string const& s) { + unsigned char digest[MD5_DIGEST_LENGTH]; - // convert to hex - std::ostringstream ss; - ss << std::hex; - for (auto const c : result) { - ss << static_cast< unsigned >(c); + MD5(reinterpret_cast< unsigned char* >(const_cast< char* >(s.c_str())), s.length(), + reinterpret_cast< unsigned char* >(&digest)); + + std::ostringstream out; + out << std::hex; + for (int i = 0; i < MD5_DIGEST_LENGTH; i++) { + out << std::setfill('0') << std::setw(2) << std::hex << (int)(unsigned char)digest[i]; } - return ss.str(); + return out.str(); } struct incomplete_verification_error : std::exception { @@ -37,6 +32,10 @@ struct incomplete_verification_error : std::exception { const std::string error_; }; +AuthManager::AuthManager() : + m_cached_tokens(SECURITY_DYNAMIC_CONFIG(auth_manager->auth_token_cache_size)), + m_cached_keys(SECURITY_DYNAMIC_CONFIG(auth_manager->auth_key_cache_size)) {} + AuthVerifyStatus AuthManager::verify(const std::string& token, std::string& msg) const { // if we have it in cache, just use it to make the decision auto const token_hash = md5_sum(token); @@ -58,7 +57,7 @@ AuthVerifyStatus AuthManager::verify(const std::string& token, std::string& msg) std::string app_name; try { // this may throw if token is ill formed - const auto decoded{jwt::decode< traits >(token)}; + const auto decoded{jwt::decode(token)}; // for any reason that causes the verification failure, an // exception is thrown. @@ -80,8 +79,8 @@ AuthVerifyStatus AuthManager::verify(const std::string& token, std::string& msg) // check client application - if (AUTH_CONFIG(trf_verifier->auth_allowed_apps) != "all") { - if (AUTH_CONFIG(trf_verifier->auth_allowed_apps).find(app_name) == std::string::npos) { + if (SECURITY_DYNAMIC_CONFIG(auth_manager->auth_allowed_apps) != "all") { + if (SECURITY_DYNAMIC_CONFIG(auth_manager->auth_allowed_apps).find(app_name) == std::string::npos) { cached_token.set_invalid(AuthVerifyStatus::FORBIDDEN, fmt::format("application '{}' is not allowed to perform the request", app_name)); } @@ -116,7 +115,7 @@ void AuthManager::verify_decoded(const jwt::decoded_jwt& decoded) const { auto key_url = decoded.get_header_claim("x5u").as_string(); - if (key_url.rfind(AUTH_CONFIG(trf_verifier->tf_token_url), 0) != 0) { + if (key_url.rfind(SECURITY_DYNAMIC_CONFIG(auth_manager->tf_token_url), 0) != 0) { throw std::runtime_error(fmt::format("key url {} is not trusted", key_url)); } signing_key = download_key(key_url); @@ -124,7 +123,7 @@ void AuthManager::verify_decoded(const jwt::decoded_jwt& decoded) const { if (should_cache_key) { m_cached_keys.put(key_id, signing_key); } - const auto verifier{jwt::verify< traits >() + const auto verifier{jwt::verify() .with_issuer(SECURITY_DYNAMIC_CONFIG(auth_manager->issuer)) .allow_algorithm(jwt::algorithm::rs256(signing_key)) .expires_at_leeway(SECURITY_DYNAMIC_CONFIG(auth_manager->leeway))}; diff --git a/src/auth_manager/security_config.fbs b/src/auth_manager/security_config.fbs index e560455b..20cbec5a 100644 --- a/src/auth_manager/security_config.fbs +++ b/src/auth_manager/security_config.fbs @@ -33,6 +33,10 @@ table AuthManager { // ssl verification for the signing key download url verify: bool = true; + + // LRUCache sizes + auth_token_cache_size: uint32 = 2000; + auth_key_cache_size: uint32 = 100; } table SecuritySettings { diff --git a/src/auth_manager/tests/AuthTest.cpp b/src/auth_manager/tests/AuthTest.cpp index 7447a346..79ba44ac 100644 --- a/src/auth_manager/tests/AuthTest.cpp +++ b/src/auth_manager/tests/AuthTest.cpp @@ -210,12 +210,12 @@ TEST_F(AuthTest, trf_allow_valid_token) { EXPECT_EQ(mock_auth_mgr->verify(mock_trf_client.get_token()), AuthVerifyStatus::OK); // use the acces_token saved from the previous call - EXPECT_CALL(*mock_auth_mgr, download_key(_)).Times(1).WillOnce(Return(rsa_pub_key)); + EXPECT_CALL(*mock_auth_mgr, download_key(_)).Times(0); EXPECT_EQ(mock_auth_mgr->verify(mock_trf_client.get_token()), AuthVerifyStatus::OK); // set token to be expired invoking request_with_grant_token mock_trf_client.set_expiry(std::chrono::system_clock::now() - std::chrono::seconds(100)); - EXPECT_CALL(*mock_auth_mgr, download_key(_)).Times(1).WillOnce(Return(rsa_pub_key)); + EXPECT_CALL(*mock_auth_mgr, download_key(_)).Times(0); EXPECT_EQ(mock_auth_mgr->verify(mock_trf_client.get_token()), AuthVerifyStatus::OK); } From f419b25c5ffaa7cdfbfc80eee121a836b3efc970 Mon Sep 17 00:00:00 2001 From: Brian Szmyd Date: Wed, 21 Jun 2023 08:36:35 -0600 Subject: [PATCH 04/22] Chain builds. --- .github/workflows/merge_conan_build.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/merge_conan_build.yml b/.github/workflows/merge_conan_build.yml index f32b9c8e..0824ec17 100644 --- a/.github/workflows/merge_conan_build.yml +++ b/.github/workflows/merge_conan_build.yml @@ -32,3 +32,9 @@ jobs: malloc-impl: ${{ matrix.malloc-impl }} prerelease: ${{ matrix.prerelease }} testing: 'True' + ChainBuild: + run: | + curl -XPOST -u "eBay:${{secrets.CHAIN_BUILD_TOKEN}}" -H "Accept: application/vnd.github.everest-preview+json" -H "Content-Type: application/json" https://api.github.com/repos/eBay/iomanager/actions/workflows/merge_conan_build.yml/dispatches --data '{"ref": "stable/v3.x"}' + curl -XPOST -u "eBay:${{secrets.CHAIN_BUILD_TOKEN}}" -H "Accept: application/vnd.github.everest-preview+json" -H "Content-Type: application/json" https://api.github.com/repos/eBay/nuraft_mesg/actions/workflows/merge_conan_build.yml/dispatches --data '{"ref": "stable/v3.x"}' + curl -XPOST -u "eBay:${{secrets.CHAIN_BUILD_TOKEN}}" -H "Accept: application/vnd.github.everest-preview+json" -H "Content-Type: application/json" https://api.github.com/repos/eBay/homestore/actions/workflows/merge_conan_build.yml/dispatches --data '{"ref": "stable/v3.x"}' + curl -XPOST -u "eBay:${{secrets.CHAIN_BUILD_TOKEN}}" -H "Accept: application/vnd.github.everest-preview+json" -H "Content-Type: application/json" https://api.github.com/repos/eBay/homereplication/actions/workflows/merge_conan_build.yml/dispatches --data '{"ref": "stable/v3.x"}' From 099491fc2358d2278b964db32ee5ddfca2716ef4 Mon Sep 17 00:00:00 2001 From: Brian Szmyd Date: Wed, 21 Jun 2023 08:39:42 -0600 Subject: [PATCH 05/22] Fix syntax. --- .github/workflows/merge_conan_build.yml | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/.github/workflows/merge_conan_build.yml b/.github/workflows/merge_conan_build.yml index 0824ec17..6c0c2338 100644 --- a/.github/workflows/merge_conan_build.yml +++ b/.github/workflows/merge_conan_build.yml @@ -33,8 +33,11 @@ jobs: prerelease: ${{ matrix.prerelease }} testing: 'True' ChainBuild: - run: | - curl -XPOST -u "eBay:${{secrets.CHAIN_BUILD_TOKEN}}" -H "Accept: application/vnd.github.everest-preview+json" -H "Content-Type: application/json" https://api.github.com/repos/eBay/iomanager/actions/workflows/merge_conan_build.yml/dispatches --data '{"ref": "stable/v3.x"}' - curl -XPOST -u "eBay:${{secrets.CHAIN_BUILD_TOKEN}}" -H "Accept: application/vnd.github.everest-preview+json" -H "Content-Type: application/json" https://api.github.com/repos/eBay/nuraft_mesg/actions/workflows/merge_conan_build.yml/dispatches --data '{"ref": "stable/v3.x"}' - curl -XPOST -u "eBay:${{secrets.CHAIN_BUILD_TOKEN}}" -H "Accept: application/vnd.github.everest-preview+json" -H "Content-Type: application/json" https://api.github.com/repos/eBay/homestore/actions/workflows/merge_conan_build.yml/dispatches --data '{"ref": "stable/v3.x"}' - curl -XPOST -u "eBay:${{secrets.CHAIN_BUILD_TOKEN}}" -H "Accept: application/vnd.github.everest-preview+json" -H "Content-Type: application/json" https://api.github.com/repos/eBay/homereplication/actions/workflows/merge_conan_build.yml/dispatches --data '{"ref": "stable/v3.x"}' + runs-on: "ubuntu-22.04" + steps: + - name: Start IOManager Build + run: | + curl -XPOST -u "eBay:${{secrets.CHAIN_BUILD_TOKEN}}" -H "Accept: application/vnd.github.everest-preview+json" -H "Content-Type: application/json" https://api.github.com/repos/eBay/iomanager/actions/workflows/merge_conan_build.yml/dispatches --data '{"ref": "stable/v8.x"}' + - name: Start IOManager Build + run: | + curl -XPOST -u "eBay:${{secrets.CHAIN_BUILD_TOKEN}}" -H "Accept: application/vnd.github.everest-preview+json" -H "Content-Type: application/json" https://api.github.com/repos/eBay/homestore/actions/workflows/merge_conan_build.yml/dispatches --data '{"ref": "stable/v3.x"}' From e45fb1d8e8984134d7d14f0f06a355af30966e67 Mon Sep 17 00:00:00 2001 From: Brian Szmyd Date: Wed, 21 Jun 2023 08:44:32 -0600 Subject: [PATCH 06/22] Fix curl requests. --- .github/workflows/merge_conan_build.yml | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/.github/workflows/merge_conan_build.yml b/.github/workflows/merge_conan_build.yml index 6c0c2338..3fc157e2 100644 --- a/.github/workflows/merge_conan_build.yml +++ b/.github/workflows/merge_conan_build.yml @@ -37,7 +37,19 @@ jobs: steps: - name: Start IOManager Build run: | - curl -XPOST -u "eBay:${{secrets.CHAIN_BUILD_TOKEN}}" -H "Accept: application/vnd.github.everest-preview+json" -H "Content-Type: application/json" https://api.github.com/repos/eBay/iomanager/actions/workflows/merge_conan_build.yml/dispatches --data '{"ref": "stable/v8.x"}' + curl -L \ + -X POST \ + -H "Accept: application/vnd.github+json" \ + -H "Authorization: Bearer ${{ secrets.CHAIN_BUILD_TOKEN }}"\ + -H "X-GitHub-Api-Version: 2022-11-28" \ + https://api.github.com/repos/eBay/iomanager/actions/workflows/merge_conan_build.yml/dispatches \ + -d '{"ref":"stable/v8.x","inputs":{}}' - name: Start IOManager Build run: | - curl -XPOST -u "eBay:${{secrets.CHAIN_BUILD_TOKEN}}" -H "Accept: application/vnd.github.everest-preview+json" -H "Content-Type: application/json" https://api.github.com/repos/eBay/homestore/actions/workflows/merge_conan_build.yml/dispatches --data '{"ref": "stable/v3.x"}' + curl -L \ + -X POST \ + -H "Accept: application/vnd.github+json" \ + -H "Authorization: Bearer ${{ secrets.CHAIN_BUILD_TOKEN }}"\ + -H "X-GitHub-Api-Version: 2022-11-28" \ + https://api.github.com/repos/eBay/homestore/actions/workflows/merge_conan_build.yml/dispatches \ + -d '{"ref":"stable/v3.x","inputs":{}}' From afd1cbb9d8c0700dd6f2e57f4b6cbb56420a922c Mon Sep 17 00:00:00 2001 From: Brian Szmyd Date: Wed, 21 Jun 2023 08:49:27 -0600 Subject: [PATCH 07/22] Just chain directly. --- .github/workflows/merge_conan_build.yml | 9 --------- 1 file changed, 9 deletions(-) diff --git a/.github/workflows/merge_conan_build.yml b/.github/workflows/merge_conan_build.yml index 3fc157e2..e8b184a4 100644 --- a/.github/workflows/merge_conan_build.yml +++ b/.github/workflows/merge_conan_build.yml @@ -44,12 +44,3 @@ jobs: -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/repos/eBay/iomanager/actions/workflows/merge_conan_build.yml/dispatches \ -d '{"ref":"stable/v8.x","inputs":{}}' - - name: Start IOManager Build - run: | - curl -L \ - -X POST \ - -H "Accept: application/vnd.github+json" \ - -H "Authorization: Bearer ${{ secrets.CHAIN_BUILD_TOKEN }}"\ - -H "X-GitHub-Api-Version: 2022-11-28" \ - https://api.github.com/repos/eBay/homestore/actions/workflows/merge_conan_build.yml/dispatches \ - -d '{"ref":"stable/v3.x","inputs":{}}' From d78bed7ce8b99c8b2c6115f042966edc050f45be Mon Sep 17 00:00:00 2001 From: Brian Szmyd Date: Thu, 22 Jun 2023 14:28:13 -0600 Subject: [PATCH 08/22] Custom actions. (#148) --- .codecov.yml | 3 - .github/actions/load_conan/action.yml | 48 +++++++++ .github/actions/setup_conan/action.yml | 31 ++++++ .github/actions/store_conan/action.yml | 34 ++++++ .github/workflows/build_dependencies.yml | 130 +++++++++-------------- .github/workflows/merge_conan_build.yml | 1 + 6 files changed, 167 insertions(+), 80 deletions(-) create mode 100644 .github/actions/load_conan/action.yml create mode 100644 .github/actions/setup_conan/action.yml create mode 100644 .github/actions/store_conan/action.yml diff --git a/.codecov.yml b/.codecov.yml index ee7370c9..d39809e7 100644 --- a/.codecov.yml +++ b/.codecov.yml @@ -2,9 +2,6 @@ codecov: notify: require_ci_to_pass: no -fixes: - - "deps/sisl/::" - ignore: - "**/*_test.c*" - "**/*_test.h*" diff --git a/.github/actions/load_conan/action.yml b/.github/actions/load_conan/action.yml new file mode 100644 index 00000000..579d27e1 --- /dev/null +++ b/.github/actions/load_conan/action.yml @@ -0,0 +1,48 @@ +name: 'Load Conan Cache' +description: 'Loads Local Conan Cache' +inputs: + testing: + description: 'Support building tests' + required: true + key_prefix: + description: 'Cache prefix' + required: true + default: 'Deps' + fail_on_cache_miss: + description: 'Fail if key missing' + required: false + default: false + path: + description: 'Recipe path' + required: false + default: '.' +outputs: + cache-hit: + description: 'Cache match found' + value: ${{ steps.restore-cache.outputs.cache-hit }} +runs: + using: "composite" + steps: + - name: Calc Hash Key + id: hash-key + shell: bash + run: | + echo "hash-key=${{ inputs.path }}/**/conanfile.py" >> $GITHUB_OUTPUT + + - name: Restore Cache + id: restore-cache + uses: actions/cache/restore@v3 + with: + path: | + ~/.conan/data + key: ${{ inputs.key_prefix }}-${{ hashFiles(steps.hash-key.outputs.hash-key ) }} + fail-on-cache-miss: ${{ inputs.fail_on_cache_miss }} + + - name: Restore Testing Cache + uses: actions/cache/restore@v3 + with: + path: | + ~/.conan/data + key: ${{ inputs.key_prefix }}- + if: ${{ github.event_name == 'pull_request' && inputs.testing == 'True' && steps.restore-cache.outputs.cache-hit != 'true' }} + diff --git a/.github/actions/setup_conan/action.yml b/.github/actions/setup_conan/action.yml new file mode 100644 index 00000000..0d3dfe01 --- /dev/null +++ b/.github/actions/setup_conan/action.yml @@ -0,0 +1,31 @@ +name: 'Setup Conan' +description: 'Sets up Conan for Sisl Builds' +inputs: + platform: + description: 'Platform conan will be building on' + required: true + default: 'ubuntu-22.04' +runs: + using: "composite" + steps: + - name: Setup Python + uses: actions/setup-python@v3 + with: + python-version: "3.8" + + - name: Setup Conan and Export Recipes + shell: bash + run: | + python -m pip install --upgrade pip + python -m pip install conan~=1.0 + python -m pip install gcovr + conan user + conan profile new --detect default + + - name: Fixup libstdc++ + shell: bash + run: | + # Set std::string to non-CoW C++11 version + sed -i 's,compiler.libcxx=libstdc++$,compiler.libcxx=libstdc++11,g' ~/.conan/profiles/default + if: ${{ inputs.platform == 'ubuntu-22.04' }} + diff --git a/.github/actions/store_conan/action.yml b/.github/actions/store_conan/action.yml new file mode 100644 index 00000000..cc4bd8cb --- /dev/null +++ b/.github/actions/store_conan/action.yml @@ -0,0 +1,34 @@ +name: 'Store Conan Cache' +description: 'Cleans Local Conan Cache and Persists Dirty Packages' +inputs: + key_prefix: + description: 'Cache prefix' + required: true + default: 'Deps' +runs: + using: "composite" + steps: + - name: Setup Conan and Export Recipes + shell: bash + run: | + dep_pkgs=$(ls -1d 3rd_party/* 2>/dev/null | cut -d'/' -f2 | paste -sd'|' - -) + if [ -z "${dep_pkgs}" ]; then + dep_pkgs="no_3rd_party" + fi + dirty_pkgs=$(ls -1d ~/.conan/data/*/*/*/*/build 2>/dev/null | sed 's,.*data/,,') + if [ -z "${dirty_pkgs}" ]; then + dirty_pkgs="no_public/0" + fi + dirty_pkgs_d=$(echo "${dirty_pkgs}" | cut -d'/' -f1 | paste -sd'|' - -) + echo "::info:: Caching: ${dirty_pkgs_d}|${dep_pkgs}" + ls -1d ~/.conan/data/* | grep -Ev "(${dirty_pkgs_d}|${dep_pkgs})" | xargs rm -rf + rm -rf ~/.conan/data/*/*/*/*/build + rm -rf ~/.conan/data/*/*/*/*/source + + - name: Save Cache + uses: actions/cache/save@v3 + with: + path: | + ~/.conan/data + key: ${{ inputs.key_prefix }}-${{ hashFiles('**/conanfile.py') }} + diff --git a/.github/workflows/build_dependencies.yml b/.github/workflows/build_dependencies.yml index d3863a02..782173e7 100644 --- a/.github/workflows/build_dependencies.yml +++ b/.github/workflows/build_dependencies.yml @@ -75,43 +75,32 @@ jobs: - name: Retrieve Code uses: actions/checkout@v3 with: - path: deps/sisl ref: ${{ inputs.branch }} if: ${{ inputs.testing == 'True' }} - name: Retrieve Recipe uses: actions/checkout@v3 with: - repository: ebay/sisl - path: deps/sisl + repository: szmyd/sisl ref: ${{ inputs.branch }} if: ${{ inputs.testing == 'False' }} - - name: Restore Sisl Cache - id: restore-cache-sisl - uses: actions/cache/restore@v3 + - name: Load Conan Cache + id: restore-cache + uses: szmyd/sisl/.github/actions/load_conan@test_custom_action with: - path: | - ~/.conan/data - key: SislDeps8-${{ inputs.platform }}-${{ inputs.build-type }}-${{ inputs.malloc-impl }}-${{ inputs.prerelease }}-${{ hashFiles('**/conanfile.py') }} + testing: ${{ inputs.testing }} + key_prefix: SislDeps8-${{ inputs.platform }}-${{ inputs.build-type }}-${{ inputs.malloc-impl }}-${{ inputs.prerelease }} - - name: Restore Testing Cache - id: restore-cache-testing-sisl - uses: actions/cache/restore@v3 + - name: Setup Conan + uses: szmyd/sisl/.github/actions/setup_conan@test_custom_action with: - path: | - ~/.conan/data - key: SislDeps8-${{ inputs.platform }}-${{ inputs.build-type }}-${{ inputs.malloc-impl }}-${{ inputs.prerelease }}- - if: ${{ github.event_name == 'pull_request' && inputs.testing == 'True' && steps.restore-cache-sisl.outputs.cache-hit != 'true' }} + platform: ${{ inputs.platform }} + if: ${{ inputs.testing == 'True' || steps.restore-cache.outputs.cache-hit != 'true' }} - - name: Setup Python - uses: actions/setup-python@v3 - with: - python-version: "3.8" - if: ${{ inputs.testing == 'True' || steps.restore-cache-sisl.outputs.cache-hit != 'true' }} - - - name: Setup Conan and Export Recipes + - name: Export Recipes run: | +<<<<<<< HEAD python -m pip install --upgrade pip python -m pip install conan~=1.0 python -m pip install gcovr @@ -122,15 +111,17 @@ jobs: conan export deps/sisl/3rd_party/jemalloc conan export deps/sisl/3rd_party/prerelease_dummy conan export deps/sisl/3rd_party/pistache pistache/cci.20201127@ +======= + conan export 3rd_party/breakpad breakpad/cci.20230127@ + conan export 3rd_party/folly folly/2022.01.31.00@ + conan export 3rd_party/gperftools + conan export 3rd_party/jemalloc + conan export 3rd_party/prerelease_dummy + conan export 3rd_party/pistache pistache/cci.20201127@ +>>>>>>> 6f4e054... Custom actions. (#148) cached_pkgs=$(ls -1d ~/.conan/data/*/*/*/*/export 2>/dev/null | sed 's,.*data/,,' | cut -d'/' -f1,2 | paste -sd',' - -) echo "::info:: Pre-cached: ${cached_pkgs}" - if: ${{ inputs.testing == 'True' || steps.restore-cache-sisl.outputs.cache-hit != 'true' }} - - - name: Fixup libstdc++ - run: | - # Set std::string to non-CoW C++11 version - sed -i 's,compiler.libcxx=libstdc++$,compiler.libcxx=libstdc++11,g' ~/.conan/profiles/default - if: ${{ inputs.platform == 'ubuntu-22.04' && ( inputs.testing == 'True' || steps.restore-cache-sisl.outputs.cache-hit != 'true' ) }} + if: ${{ inputs.testing == 'True' || steps.restore-cache.outputs.cache-hit != 'true' }} - name: Build Cache run: | @@ -139,60 +130,45 @@ jobs: -o malloc_impl=${{ inputs.malloc-impl }} \ -s build_type=${{ inputs.build-type }} \ --build missing \ - deps/sisl - if: ${{ steps.restore-cache-sisl.outputs.cache-hit != 'true' }} + . + if: ${{ steps.restore-cache.outputs.cache-hit != 'true' }} - - name: Clean Package Cache - run: | - dep_pkgs=$(ls -1d deps/sisl/3rd_party/* 2>/dev/null | cut -d'/' -f4 | paste -sd'|' - -) - if [ -z "${dep_pkgs}" ]; then - dep_pkgs="no_3rd_party" - fi - dirty_pkgs=$(ls -1d ~/.conan/data/*/*/*/*/build 2>/dev/null | sed 's,.*data/,,') - if [ -z "${dirty_pkgs}" ]; then - dirty_pkgs="no_public/0" - fi - dirty_pkgs_d=$(echo "${dirty_pkgs}" | cut -d'/' -f1 | paste -sd'|' - -) - echo "::info:: Caching: ${dirty_pkgs_d}|${dep_pkgs}" - ls -1d ~/.conan/data/* | grep -Ev "(${dirty_pkgs_d}|${dep_pkgs})" | xargs rm -rf - rm -rf ~/.conan/data/*/*/*/*/build - rm -rf ~/.conan/data/*/*/*/*/source - if: ${{ github.event_name != 'pull_request' && steps.restore-cache-sisl.outputs.cache-hit != 'true' }} - - - name: Save Sisl Cache - id: save-cache-sisl - uses: actions/cache/save@v3 + - name: Save Conan Cache + uses: szmyd/sisl/.github/actions/store_conan@test_custom_action with: - path: | - ~/.conan/data - key: SislDeps8-${{ inputs.platform }}-${{ inputs.build-type }}-${{ inputs.malloc-impl }}-${{ inputs.prerelease }}-${{ hashFiles('**/conanfile.py') }} - if: ${{ github.event_name != 'pull_request' && steps.restore-cache-sisl.outputs.cache-hit != 'true' }} + key_prefix: SislDeps8-${{ inputs.platform }}-${{ inputs.build-type }}-${{ inputs.malloc-impl }}-${{ inputs.prerelease }} + if: ${{ github.event_name != 'pull_request' && steps.restore-cache.outputs.cache-hit != 'true' }} - - name: Create and test Package + - name: Code Coverage Run run: | - if [[ "${{ inputs.build-type }}" == "Debug" && "${{ inputs.malloc-impl }}" == "libc" && "${{ inputs.prerelease }}" == "False" ]]; then - conan install \ - -o prerelease=${{ inputs.prerelease }} \ - -o malloc_impl=${{ inputs.malloc-impl }} \ - -o coverage=True \ - -s build_type=${{ inputs.build-type }} \ - --build missing \ - deps/sisl - conan build deps/sisl - else - sanitize=$([[ "${{ inputs.build-type }}" == "Debug" && "${{ inputs.malloc-impl }}" == "libc" && "${{ inputs.prerelease }}" == "True" ]] && echo "True" || echo "False") - conan create \ - -o sisl:prerelease=${{ inputs.prerelease }} \ - -o sisl:malloc_impl=${{ inputs.malloc-impl }} \ - -o sisl:sanitize=${sanitize} \ - -s build_type=${{ inputs.build-type }} \ - --build missing \ - deps/sisl - fi - if: ${{ inputs.testing == 'True' }} + conan install \ + -o prerelease=${{ inputs.prerelease }} \ + -o malloc_impl=${{ inputs.malloc-impl }} \ + -o coverage=True \ + -s build_type=${{ inputs.build-type }} \ + --build missing \ + . + conan build . + if: ${{ inputs.testing == 'True' && inputs.platform == 'ubuntu-22.04' && inputs.build-type == 'Debug' && inputs.malloc-impl == 'libc' && inputs.prerelease == 'False' }} - name: Upload coverage reports to Codecov uses: codecov/codecov-action@v3 with: token: ${{ secrets.CODECOV_TOKEN }} gcov: true + if: ${{ inputs.testing == 'True' && inputs.platform == 'ubuntu-22.04' && inputs.build-type == 'Debug' && inputs.malloc-impl == 'libc' && inputs.prerelease == 'False' }} + + - name: Create and Test Package + run: | + sanitize=$([[ "${{ inputs.build-type }}" == "Debug" && \ + "${{ inputs.malloc-impl }}" == "libc" && \ + "${{ inputs.prerelease }}" == "True" ]] && \ + echo "True" || echo "False") + conan create \ + -o sisl:prerelease=${{ inputs.prerelease }} \ + -o sisl:malloc_impl=${{ inputs.malloc-impl }} \ + -o sisl:sanitize=${sanitize} \ + -s build_type=${{ inputs.build-type }} \ + --build missing \ + . + if: ${{ inputs.testing == 'True' && ( inputs.platform != 'ubuntu-22.04' || inputs.build-type != 'Debug' || inputs.malloc-impl != 'libc' || inputs.prerelease != 'False' ) }} diff --git a/.github/workflows/merge_conan_build.yml b/.github/workflows/merge_conan_build.yml index e8b184a4..65391851 100644 --- a/.github/workflows/merge_conan_build.yml +++ b/.github/workflows/merge_conan_build.yml @@ -44,3 +44,4 @@ jobs: -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/repos/eBay/iomanager/actions/workflows/merge_conan_build.yml/dispatches \ -d '{"ref":"stable/v8.x","inputs":{}}' + if: ${{ github.ref == 'stable/v8.x' }} From 632ae5c96d0d006f16b7b84d1c654d992cfb3ee8 Mon Sep 17 00:00:00 2001 From: "Ravi Akella email = raakella@ebay.com" Date: Thu, 31 Aug 2023 09:58:03 -0700 Subject: [PATCH 09/22] remove breakpad --- .github/workflows/build_dependencies.yml | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/.github/workflows/build_dependencies.yml b/.github/workflows/build_dependencies.yml index 782173e7..54dcdec6 100644 --- a/.github/workflows/build_dependencies.yml +++ b/.github/workflows/build_dependencies.yml @@ -100,25 +100,11 @@ jobs: - name: Export Recipes run: | -<<<<<<< HEAD - python -m pip install --upgrade pip - python -m pip install conan~=1.0 - python -m pip install gcovr - conan user - conan profile new --detect default - conan export deps/sisl/3rd_party/folly folly/2022.01.31.00@ - conan export deps/sisl/3rd_party/gperftools - conan export deps/sisl/3rd_party/jemalloc - conan export deps/sisl/3rd_party/prerelease_dummy - conan export deps/sisl/3rd_party/pistache pistache/cci.20201127@ -======= - conan export 3rd_party/breakpad breakpad/cci.20230127@ conan export 3rd_party/folly folly/2022.01.31.00@ conan export 3rd_party/gperftools conan export 3rd_party/jemalloc conan export 3rd_party/prerelease_dummy conan export 3rd_party/pistache pistache/cci.20201127@ ->>>>>>> 6f4e054... Custom actions. (#148) cached_pkgs=$(ls -1d ~/.conan/data/*/*/*/*/export 2>/dev/null | sed 's,.*data/,,' | cut -d'/' -f1,2 | paste -sd',' - -) echo "::info:: Pre-cached: ${cached_pkgs}" if: ${{ inputs.testing == 'True' || steps.restore-cache.outputs.cache-hit != 'true' }} From 1ec46b83da103d62e3b6a089b6f0855f5b03d8ee Mon Sep 17 00:00:00 2001 From: Brian Szmyd Date: Thu, 22 Jun 2023 13:36:45 -0700 Subject: [PATCH 10/22] Remove alt repo. --- .github/workflows/build_dependencies.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build_dependencies.yml b/.github/workflows/build_dependencies.yml index 54dcdec6..9e97a018 100644 --- a/.github/workflows/build_dependencies.yml +++ b/.github/workflows/build_dependencies.yml @@ -81,19 +81,19 @@ jobs: - name: Retrieve Recipe uses: actions/checkout@v3 with: - repository: szmyd/sisl + repository: eBay/sisl ref: ${{ inputs.branch }} if: ${{ inputs.testing == 'False' }} - name: Load Conan Cache id: restore-cache - uses: szmyd/sisl/.github/actions/load_conan@test_custom_action + uses: eBay/sisl/.github/actions/load_conan@stable/v8.x with: testing: ${{ inputs.testing }} key_prefix: SislDeps8-${{ inputs.platform }}-${{ inputs.build-type }}-${{ inputs.malloc-impl }}-${{ inputs.prerelease }} - name: Setup Conan - uses: szmyd/sisl/.github/actions/setup_conan@test_custom_action + uses: eBay/sisl/.github/actions/setup_conan@stable/v8.x with: platform: ${{ inputs.platform }} if: ${{ inputs.testing == 'True' || steps.restore-cache.outputs.cache-hit != 'true' }} @@ -120,7 +120,7 @@ jobs: if: ${{ steps.restore-cache.outputs.cache-hit != 'true' }} - name: Save Conan Cache - uses: szmyd/sisl/.github/actions/store_conan@test_custom_action + uses: eBay/sisl/.github/actions/store_conan@stable/v8.x with: key_prefix: SislDeps8-${{ inputs.platform }}-${{ inputs.build-type }}-${{ inputs.malloc-impl }}-${{ inputs.prerelease }} if: ${{ github.event_name != 'pull_request' && steps.restore-cache.outputs.cache-hit != 'true' }} From 8d2e143fad47b0ef6aea42fb219397cceea47165 Mon Sep 17 00:00:00 2001 From: Brian Szmyd Date: Thu, 22 Jun 2023 15:18:12 -0700 Subject: [PATCH 11/22] Use specific hash keys. --- .github/actions/load_conan/action.yml | 5 +++-- .github/actions/store_conan/action.yml | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/actions/load_conan/action.yml b/.github/actions/load_conan/action.yml index 579d27e1..23e06e2d 100644 --- a/.github/actions/load_conan/action.yml +++ b/.github/actions/load_conan/action.yml @@ -27,7 +27,8 @@ runs: id: hash-key shell: bash run: | - echo "hash-key=${{ inputs.path }}/**/conanfile.py" >> $GITHUB_OUTPUT + echo "3rd_party=${{ inputs.path }}/3rd_party/**/conanfile.py" >> $GITHUB_OUTPUT + echo "primary=${{ inputs.path }}/conanfile.py" >> $GITHUB_OUTPUT - name: Restore Cache id: restore-cache @@ -35,7 +36,7 @@ runs: with: path: | ~/.conan/data - key: ${{ inputs.key_prefix }}-${{ hashFiles(steps.hash-key.outputs.hash-key ) }} + key: ${{ inputs.key_prefix }}-${{ hashFiles(steps.hash-key.outputs.primary, steps.hash-key.outputs.3rd_party ) }} fail-on-cache-miss: ${{ inputs.fail_on_cache_miss }} - name: Restore Testing Cache diff --git a/.github/actions/store_conan/action.yml b/.github/actions/store_conan/action.yml index cc4bd8cb..906f3b0d 100644 --- a/.github/actions/store_conan/action.yml +++ b/.github/actions/store_conan/action.yml @@ -30,5 +30,5 @@ runs: with: path: | ~/.conan/data - key: ${{ inputs.key_prefix }}-${{ hashFiles('**/conanfile.py') }} + key: ${{ inputs.key_prefix }}-${{ hashFiles('conanfile.py', '3rd_party/**/conanfile.py') }} From 373bcd4f1a3015765d32a2da6dbc20b091ff52e2 Mon Sep 17 00:00:00 2001 From: Brian Szmyd Date: Thu, 22 Jun 2023 15:21:59 -0700 Subject: [PATCH 12/22] Remove underscore. --- .github/actions/load_conan/action.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/actions/load_conan/action.yml b/.github/actions/load_conan/action.yml index 23e06e2d..1b7a1b2d 100644 --- a/.github/actions/load_conan/action.yml +++ b/.github/actions/load_conan/action.yml @@ -27,7 +27,7 @@ runs: id: hash-key shell: bash run: | - echo "3rd_party=${{ inputs.path }}/3rd_party/**/conanfile.py" >> $GITHUB_OUTPUT + echo "3rdparty=${{ inputs.path }}/3rd_party/**/conanfile.py" >> $GITHUB_OUTPUT echo "primary=${{ inputs.path }}/conanfile.py" >> $GITHUB_OUTPUT - name: Restore Cache @@ -36,7 +36,7 @@ runs: with: path: | ~/.conan/data - key: ${{ inputs.key_prefix }}-${{ hashFiles(steps.hash-key.outputs.primary, steps.hash-key.outputs.3rd_party ) }} + key: ${{ inputs.key_prefix }}-${{ hashFiles(steps.hash-key.outputs.primary, steps.hash-key.outputs.3rdparty ) }} fail-on-cache-miss: ${{ inputs.fail_on_cache_miss }} - name: Restore Testing Cache From d2506fd638c02a9df6602d3dc06b8b6ebb996f85 Mon Sep 17 00:00:00 2001 From: Brian Szmyd Date: Thu, 22 Jun 2023 15:29:59 -0700 Subject: [PATCH 13/22] Try compound key. --- .github/actions/load_conan/action.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/actions/load_conan/action.yml b/.github/actions/load_conan/action.yml index 1b7a1b2d..58a5f6f8 100644 --- a/.github/actions/load_conan/action.yml +++ b/.github/actions/load_conan/action.yml @@ -27,8 +27,7 @@ runs: id: hash-key shell: bash run: | - echo "3rdparty=${{ inputs.path }}/3rd_party/**/conanfile.py" >> $GITHUB_OUTPUT - echo "primary=${{ inputs.path }}/conanfile.py" >> $GITHUB_OUTPUT + echo "keys=[${{ inputs.path }}/conanfile.py, ${{ inputs.path }}/3rd_party/**/conanfile.py]" >> $GITHUB_OUTPUT - name: Restore Cache id: restore-cache @@ -36,7 +35,7 @@ runs: with: path: | ~/.conan/data - key: ${{ inputs.key_prefix }}-${{ hashFiles(steps.hash-key.outputs.primary, steps.hash-key.outputs.3rdparty ) }} + key: ${{ inputs.key_prefix }}-${{ hashFiles(steps.hash-key.outputs.keys ) }} fail-on-cache-miss: ${{ inputs.fail_on_cache_miss }} - name: Restore Testing Cache From 3edb0966091b0deb18c9e3d86b80cab8708762a6 Mon Sep 17 00:00:00 2001 From: Brian Szmyd Date: Thu, 22 Jun 2023 15:42:09 -0700 Subject: [PATCH 14/22] Split outputs. --- .github/actions/load_conan/action.yml | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/.github/actions/load_conan/action.yml b/.github/actions/load_conan/action.yml index 58a5f6f8..fa2c0852 100644 --- a/.github/actions/load_conan/action.yml +++ b/.github/actions/load_conan/action.yml @@ -23,11 +23,15 @@ outputs: runs: using: "composite" steps: - - name: Calc Hash Key - id: hash-key + - id: hash-key-primary shell: bash run: | - echo "keys=[${{ inputs.path }}/conanfile.py, ${{ inputs.path }}/3rd_party/**/conanfile.py]" >> $GITHUB_OUTPUT + echo "key=${{ inputs.path }}/conanfile.py" >> $GITHUB_OUTPUT + + - id: hash-key-3rd + shell: bash + run: | + echo "keys=${{ inputs.path }}/3rd_party/**/conanfile.py" >> $GITHUB_OUTPUT - name: Restore Cache id: restore-cache @@ -35,7 +39,7 @@ runs: with: path: | ~/.conan/data - key: ${{ inputs.key_prefix }}-${{ hashFiles(steps.hash-key.outputs.keys ) }} + key: ${{ inputs.key_prefix }}-${{ hashFiles(steps.hash-key-primary.outputs.key, steps.hash-key-3rd.outputs.keys) }} fail-on-cache-miss: ${{ inputs.fail_on_cache_miss }} - name: Restore Testing Cache From 89de03c4f7314372a82506e2a80628fb70254bbf Mon Sep 17 00:00:00 2001 From: Brian Szmyd Date: Thu, 22 Jun 2023 17:10:15 -0700 Subject: [PATCH 15/22] Relax test cache. --- .github/actions/load_conan/action.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/actions/load_conan/action.yml b/.github/actions/load_conan/action.yml index fa2c0852..dfa2f0d9 100644 --- a/.github/actions/load_conan/action.yml +++ b/.github/actions/load_conan/action.yml @@ -47,6 +47,7 @@ runs: with: path: | ~/.conan/data - key: ${{ inputs.key_prefix }}- - if: ${{ github.event_name == 'pull_request' && inputs.testing == 'True' && steps.restore-cache.outputs.cache-hit != 'true' }} + key: ${{ inputs.key_prefix }}-${{ hashFiles(steps.hash-key-primary.outputs.key, steps.hash-key-3rd.outputs.keys) }} + restore-keys: ${{ inputs.key_prefix }}- + if: ${{ inputs.testing == 'True' && steps.restore-cache.outputs.cache-hit != 'true' }} From 3c769cd834fec341405b2b12a934f46f2d40e564 Mon Sep 17 00:00:00 2001 From: Brian Szmyd Date: Thu, 22 Jun 2023 17:15:41 -0700 Subject: [PATCH 16/22] Load any --- .github/actions/load_conan/action.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/actions/load_conan/action.yml b/.github/actions/load_conan/action.yml index dfa2f0d9..bac4ad5f 100644 --- a/.github/actions/load_conan/action.yml +++ b/.github/actions/load_conan/action.yml @@ -16,6 +16,10 @@ inputs: description: 'Recipe path' required: false default: '.' + load_any: + description: 'Load cache miss' + required: false + default: 'False' outputs: cache-hit: description: 'Cache match found' @@ -49,5 +53,5 @@ runs: ~/.conan/data key: ${{ inputs.key_prefix }}-${{ hashFiles(steps.hash-key-primary.outputs.key, steps.hash-key-3rd.outputs.keys) }} restore-keys: ${{ inputs.key_prefix }}- - if: ${{ inputs.testing == 'True' && steps.restore-cache.outputs.cache-hit != 'true' }} + if: ${{ (github.event_name == 'pull_request' || inputs.load_any == 'True') && inputs.testing == 'True' && steps.restore-cache.outputs.cache-hit != 'true' }} From caeff27d0188103785921b7344e124d100b4f4cc Mon Sep 17 00:00:00 2001 From: Brian Szmyd Date: Thu, 22 Jun 2023 17:22:34 -0700 Subject: [PATCH 17/22] Use load_any excl. --- .github/actions/load_conan/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/load_conan/action.yml b/.github/actions/load_conan/action.yml index bac4ad5f..7cea08ed 100644 --- a/.github/actions/load_conan/action.yml +++ b/.github/actions/load_conan/action.yml @@ -53,5 +53,5 @@ runs: ~/.conan/data key: ${{ inputs.key_prefix }}-${{ hashFiles(steps.hash-key-primary.outputs.key, steps.hash-key-3rd.outputs.keys) }} restore-keys: ${{ inputs.key_prefix }}- - if: ${{ (github.event_name == 'pull_request' || inputs.load_any == 'True') && inputs.testing == 'True' && steps.restore-cache.outputs.cache-hit != 'true' }} + if: ${{ steps.restore-cache.outputs.cache-hit != 'true' && (( github.event_name == 'pull_request' && inputs.testing == 'True' && ) || ( inputs.load_any == 'True' )) }} From 9b2269394770c317e415310871763049d36c8d2d Mon Sep 17 00:00:00 2001 From: Brian Szmyd Date: Thu, 22 Jun 2023 17:24:31 -0700 Subject: [PATCH 18/22] Extra && --- .github/actions/load_conan/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/load_conan/action.yml b/.github/actions/load_conan/action.yml index 7cea08ed..22991f83 100644 --- a/.github/actions/load_conan/action.yml +++ b/.github/actions/load_conan/action.yml @@ -53,5 +53,5 @@ runs: ~/.conan/data key: ${{ inputs.key_prefix }}-${{ hashFiles(steps.hash-key-primary.outputs.key, steps.hash-key-3rd.outputs.keys) }} restore-keys: ${{ inputs.key_prefix }}- - if: ${{ steps.restore-cache.outputs.cache-hit != 'true' && (( github.event_name == 'pull_request' && inputs.testing == 'True' && ) || ( inputs.load_any == 'True' )) }} + if: ${{ steps.restore-cache.outputs.cache-hit != 'true' && (( github.event_name == 'pull_request' && inputs.testing == 'True' ) || ( inputs.load_any == 'True' )) }} From 73e4d03e17ff7e15cfd395cff45e77dc36f25063 Mon Sep 17 00:00:00 2001 From: Brian Szmyd Date: Thu, 22 Jun 2023 17:35:39 -0700 Subject: [PATCH 19/22] Support no 3rd_party. --- .github/actions/store_conan/action.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/actions/store_conan/action.yml b/.github/actions/store_conan/action.yml index 906f3b0d..065614fa 100644 --- a/.github/actions/store_conan/action.yml +++ b/.github/actions/store_conan/action.yml @@ -11,7 +11,9 @@ runs: - name: Setup Conan and Export Recipes shell: bash run: | - dep_pkgs=$(ls -1d 3rd_party/* 2>/dev/null | cut -d'/' -f2 | paste -sd'|' - -) + if [ -d 3rd_party ]; then + dep_pkgs=$(ls -1d 3rd_party/* 2>/dev/null | cut -d'/' -f2 | paste -sd'|' - -) + fi if [ -z "${dep_pkgs}" ]; then dep_pkgs="no_3rd_party" fi From 390af80f50e3c9f5b12e8ece2e7ba059572f8082 Mon Sep 17 00:00:00 2001 From: Brian Szmyd Date: Fri, 23 Jun 2023 14:26:09 -0700 Subject: [PATCH 20/22] Fix chain --- .github/workflows/merge_conan_build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/merge_conan_build.yml b/.github/workflows/merge_conan_build.yml index 65391851..884809b7 100644 --- a/.github/workflows/merge_conan_build.yml +++ b/.github/workflows/merge_conan_build.yml @@ -44,4 +44,4 @@ jobs: -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/repos/eBay/iomanager/actions/workflows/merge_conan_build.yml/dispatches \ -d '{"ref":"stable/v8.x","inputs":{}}' - if: ${{ github.ref == 'stable/v8.x' }} + if: ${{ github.ref == 'refs/heads/stable/v8.x' }} From 2c21566da4fea3d027b4d676b78e45a2805f2429 Mon Sep 17 00:00:00 2001 From: raakella1 <114193113+raakella1@users.noreply.github.com> Date: Wed, 30 Aug 2023 11:36:24 -0700 Subject: [PATCH 21/22] add date to 3rd party (#170) Co-authored-by: Ravi Akella email = raakella@ebay.com --- .github/workflows/build_dependencies.yml | 1 + 3rd_party/date/conandata.yml | 29 +++++ 3rd_party/date/conanfile.py | 140 ++++++++++++++++++++++ 3rd_party/date/patches/0001-fix-uwp.patch | 17 +++ 3rd_party/date/patches/cmake-3.0.0.patch | 14 +++ 3rd_party/date/patches/cmake-3.0.1.patch | 14 +++ 3rd_party/date/patches/cmake.patch | 19 +++ 3rd_party/date/patches/string_view.patch | 13 ++ 8 files changed, 247 insertions(+) create mode 100644 3rd_party/date/conandata.yml create mode 100644 3rd_party/date/conanfile.py create mode 100644 3rd_party/date/patches/0001-fix-uwp.patch create mode 100644 3rd_party/date/patches/cmake-3.0.0.patch create mode 100644 3rd_party/date/patches/cmake-3.0.1.patch create mode 100644 3rd_party/date/patches/cmake.patch create mode 100644 3rd_party/date/patches/string_view.patch diff --git a/.github/workflows/build_dependencies.yml b/.github/workflows/build_dependencies.yml index 9e97a018..6bb2a79e 100644 --- a/.github/workflows/build_dependencies.yml +++ b/.github/workflows/build_dependencies.yml @@ -105,6 +105,7 @@ jobs: conan export 3rd_party/jemalloc conan export 3rd_party/prerelease_dummy conan export 3rd_party/pistache pistache/cci.20201127@ + conan export 3rd_party/date date/3.0.1@ cached_pkgs=$(ls -1d ~/.conan/data/*/*/*/*/export 2>/dev/null | sed 's,.*data/,,' | cut -d'/' -f1,2 | paste -sd',' - -) echo "::info:: Pre-cached: ${cached_pkgs}" if: ${{ inputs.testing == 'True' || steps.restore-cache.outputs.cache-hit != 'true' }} diff --git a/3rd_party/date/conandata.yml b/3rd_party/date/conandata.yml new file mode 100644 index 00000000..bed2d768 --- /dev/null +++ b/3rd_party/date/conandata.yml @@ -0,0 +1,29 @@ +sources: + "3.0.1": + url: "https://github.com/HowardHinnant/date/archive/refs/tags/v3.0.1.tar.gz" + sha256: "7a390f200f0ccd207e8cff6757e04817c1a0aec3e327b006b7eb451c57ee3538" + "3.0.0": + url: "https://github.com/HowardHinnant/date/archive/refs/tags/v3.0.0.tar.gz" + sha256: "87bba2eaf0ebc7ec539e5e62fc317cb80671a337c1fb1b84cb9e4d42c6dbebe3" + "2.4.1": + url: "https://github.com/HowardHinnant/date/archive/refs/tags/v2.4.1.tar.gz" + sha256: "98907d243397483bd7ad889bf6c66746db0d7d2a39cc9aacc041834c40b65b98" +patches: + "3.0.1": + - patch_file: "patches/cmake-3.0.1.patch" + patch_description: "Disable string view to workaround clang 5 not having it" + patch_type: "portability" + "3.0.0": + - patch_file: "patches/cmake-3.0.0.patch" + patch_description: "Disable string view to workaround clang 5 not having it" + patch_type: "portability" + "2.4.1": + - patch_file: "patches/0001-fix-uwp.patch" + patch_description: "Fix Universal Windows Platform (UWP) unhandled exception support. See https://github.com/microsoft/vcpkg/pull/8151#issuecomment-531175393." + patch_type: "portability" + - patch_file: "patches/cmake.patch" + patch_description: "Add libcurl target for conan compatibility" + patch_type: "conan" + - patch_file: "patches/string_view.patch" + patch_description: "Disable string view to workaround clang 5 not having it" + patch_type: "portability" diff --git a/3rd_party/date/conanfile.py b/3rd_party/date/conanfile.py new file mode 100644 index 00000000..7c597110 --- /dev/null +++ b/3rd_party/date/conanfile.py @@ -0,0 +1,140 @@ +from conan import ConanFile +from conan.tools.build import check_min_cppstd +from conan.tools.cmake import CMake, CMakeToolchain, CMakeDeps, cmake_layout +from conan.tools.files import get, rmdir, apply_conandata_patches, export_conandata_patches, copy +from conan.tools.scm import Version + +import os + +required_conan_version = ">=1.53.0" + + +class DateConan(ConanFile): + name = "date" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/HowardHinnant/date" + description = "A date and time library based on the C++11/14/17 header" + topics = ("datetime", "timezone", "calendar", "time", "iana-database") + license = "MIT" + + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + "header_only": [True, False], + "use_system_tz_db": [True, False], + "use_tz_db_in_dot": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + "header_only": False, + "use_system_tz_db": False, + "use_tz_db_in_dot": False, + } + + def export_sources(self): + export_conandata_patches(self) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + if self.settings.os in ["iOS", "tvOS", "watchOS", "Android"]: + self.options.use_system_tz_db = True + + def configure(self): + if self.options.shared or self.options.header_only: + self.options.rm_safe("fPIC") + if self.options.header_only: + del self.options.shared + + def layout(self): + cmake_layout(self, src_folder="src") + + def requirements(self): + if not self.options.header_only and not self.options.use_system_tz_db: + self.requires("libcurl/7.86.0") + + def package_id(self): + if self.info.options.header_only: + self.info.clear() + + def validate(self): + if self.settings.compiler.get_safe("cppstd"): + check_min_cppstd(self, 11) + + def source(self): + get(self, **self.conan_data["sources"][self.version], strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["ENABLE_DATE_TESTING"] = False + tc.variables["USE_SYSTEM_TZ_DB"] = self.options.use_system_tz_db + tc.variables["USE_TZ_DB_IN_DOT"] = self.options.use_tz_db_in_dot + tc.variables["BUILD_TZ_LIB"] = not self.options.header_only + # workaround for clang 5 not having string_view + if Version(self.version) >= "3.0.0" and self.settings.compiler == "clang" \ + and Version(self.settings.compiler.version) <= "5.0": + tc.cache_variables["DISABLE_STRING_VIEW"] = True + tc.generate() + + deps = CMakeDeps(self) + deps.generate() + + def build(self): + apply_conandata_patches(self) + if not self.options.header_only: + cmake = CMake(self) + cmake.configure() + cmake.build() + + def package(self): + copy(self, "LICENSE.txt", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder) + if self.options.header_only: + src = os.path.join(self.source_folder, "include", "date") + dst = os.path.join(self.package_folder, "include", "date") + copy(self, "date.h", dst=dst, src=src) + copy(self, "tz.h", dst=dst, src=src) + copy(self, "ptz.h", dst=dst, src=src) + copy(self, "iso_week.h", dst=dst, src=src) + copy(self, "julian.h", dst=dst, src=src) + copy(self, "islamic.h", dst=dst, src=src) + else: + cmake = CMake(self) + cmake.install() + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) + rmdir(self, os.path.join(self.package_folder, "CMake")) + + def package_info(self): + self.cpp_info.set_property("cmake_target_name", "date::date") + # TODO: Remove legacy .names attribute when conan 2.0 is released + self.cpp_info.names["cmake_find_package"] = "date" + self.cpp_info.names["cmake_find_package_multi"] = "date" + + # date-tz + if not self.options.header_only: + self.cpp_info.components["date-tz"].set_property("cmake_target_name", "date::date-tz") + # TODO: Remove legacy .names attribute when conan 2.0 is released + self.cpp_info.components["date-tz"].names["cmake_find_package"] = "date-tz" + self.cpp_info.components["date-tz"].names["cmake_find_package_multi"] = "date-tz" + lib_name = "{}tz".format("date-" if Version(self.version) >= "3.0.0" else "") + self.cpp_info.components["date-tz"].libs = [lib_name] + if self.settings.os == "Linux": + self.cpp_info.components["date-tz"].system_libs.append("pthread") + self.cpp_info.components["date-tz"].system_libs.append("m") + + if not self.options.use_system_tz_db: + self.cpp_info.components["date-tz"].requires.append("libcurl::libcurl") + + if self.options.use_system_tz_db and not self.settings.os == "Windows": + use_os_tzdb = 1 + else: + use_os_tzdb = 0 + + defines = ["USE_OS_TZDB={}".format(use_os_tzdb)] + if self.settings.os == "Windows" and self.options.shared: + defines.append("DATE_USE_DLL=1") + + self.cpp_info.components["date-tz"].defines.extend(defines) + else: + self.cpp_info.defines.append("DATE_HEADER_ONLY") diff --git a/3rd_party/date/patches/0001-fix-uwp.patch b/3rd_party/date/patches/0001-fix-uwp.patch new file mode 100644 index 00000000..f7b5c246 --- /dev/null +++ b/3rd_party/date/patches/0001-fix-uwp.patch @@ -0,0 +1,17 @@ +diff --git a/include/date/date.h b/include/date/date.h +index cb115a9..66d87c2 100644 +--- a/include/date/date.h ++++ b/include/date/date.h +@@ -76,6 +76,12 @@ + # endif + #endif + ++#ifdef _MSC_VER ++# pragma warning(push) ++// warning C4127: conditional expression is constant ++# pragma warning(disable : 4127 4996) ++#endif ++ + namespace date + { + diff --git a/3rd_party/date/patches/cmake-3.0.0.patch b/3rd_party/date/patches/cmake-3.0.0.patch new file mode 100644 index 00000000..583e86e5 --- /dev/null +++ b/3rd_party/date/patches/cmake-3.0.0.patch @@ -0,0 +1,14 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index ad74900..ac390a9 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -127,6 +127,9 @@ if( BUILD_TZ_LIB ) + target_include_directories( date-tz SYSTEM PRIVATE ${CURL_INCLUDE_DIRS} ) + target_link_libraries( date-tz PRIVATE ${CURL_LIBRARIES} ) + endif( ) ++ if( DISABLE_STRING_VIEW ) ++ target_compile_definitions( date-tz PRIVATE -DHAS_STRING_VIEW=0 -DHAS_DEDUCTION_GUIDES=0 ) ++ endif( ) + endif( ) + + #[===================================================================[ diff --git a/3rd_party/date/patches/cmake-3.0.1.patch b/3rd_party/date/patches/cmake-3.0.1.patch new file mode 100644 index 00000000..8edcb309 --- /dev/null +++ b/3rd_party/date/patches/cmake-3.0.1.patch @@ -0,0 +1,14 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index ad74900..ac390a9 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -156,6 +156,9 @@ if( BUILD_TZ_LIB ) + target_include_directories( date-tz SYSTEM PRIVATE ${CURL_INCLUDE_DIRS} ) + target_link_libraries( date-tz PRIVATE ${CURL_LIBRARIES} ) + endif( ) ++ if( DISABLE_STRING_VIEW ) ++ target_compile_definitions( date-tz PRIVATE -DHAS_STRING_VIEW=0 -DHAS_DEDUCTION_GUIDES=0 ) ++ endif( ) + endif( ) + + #[===================================================================[ diff --git a/3rd_party/date/patches/cmake.patch b/3rd_party/date/patches/cmake.patch new file mode 100644 index 00000000..3f9df797 --- /dev/null +++ b/3rd_party/date/patches/cmake.patch @@ -0,0 +1,19 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index f025a3a..7bc93df 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -57,8 +57,12 @@ else( ) + target_compile_definitions( tz PRIVATE -DHAS_REMOTE_API=1 ) + target_compile_definitions( tz PUBLIC -DUSE_OS_TZDB=0 ) + find_package( CURL REQUIRED ) +- include_directories( SYSTEM ${CURL_INCLUDE_DIRS} ) +- set( OPTIONAL_LIBRARIES ${CURL_LIBRARIES} ) ++ set( OPTIONAL_LIBRARIES CURL::libcurl ) ++endif() ++ ++if( BUILD_SHARED_LIBS ) ++ target_compile_definitions( tz PRIVATE -DDATE_BUILD_DLL=1 ) ++ target_compile_definitions( tz PUBLIC -DDATE_USE_DLL=1 ) + endif( ) + + if( USE_TZ_DB_IN_DOT ) diff --git a/3rd_party/date/patches/string_view.patch b/3rd_party/date/patches/string_view.patch new file mode 100644 index 00000000..008dd04c --- /dev/null +++ b/3rd_party/date/patches/string_view.patch @@ -0,0 +1,13 @@ +diff --git a/include/date/date.h b/include/date/date.h +index cb115a9..23cd05a 100644 +--- a/include/date/date.h ++++ b/include/date/date.h +@@ -31,7 +31,7 @@ + // We did not mean to shout. + + #ifndef HAS_STRING_VIEW +-# if __cplusplus >= 201703 ++# if __cplusplus >= 201703 && __has_include() + # define HAS_STRING_VIEW 1 + # else + # define HAS_STRING_VIEW 0 From e7867c0816208bfa86a0d9c1f717e76d994715d4 Mon Sep 17 00:00:00 2001 From: "Ravi Akella email = raakella@ebay.com" Date: Thu, 31 Aug 2023 11:27:22 -0700 Subject: [PATCH 22/22] remove cmake dep for folly 3rd party --- 3rd_party/folly/conanfile.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/3rd_party/folly/conanfile.py b/3rd_party/folly/conanfile.py index 06dc6965..2ed4f619 100755 --- a/3rd_party/folly/conanfile.py +++ b/3rd_party/folly/conanfile.py @@ -145,7 +145,8 @@ def validate(self): # FIXME: Freeze max. CMake version at 3.16.2 to fix the Linux build def build_requirements(self): - self.build_requires("cmake/3.16.9") + pass + # self.build_requires("cmake/3.16.9") def source(self): files.get(self, **self.conan_data["sources"][self.version], destination=self._source_subfolder, strip_root=True)