From 43275990600ba385238871c588a80cb8a7ae9bd1 Mon Sep 17 00:00:00 2001 From: SpaceIm <30052553+SpaceIm@users.noreply.github.com> Date: Sat, 1 Jan 2022 21:56:28 +0100 Subject: [PATCH] add ccache/4.5.1 --- recipes/ccache/all/CMakeLists.txt | 7 ++ recipes/ccache/all/conandata.yml | 8 ++ recipes/ccache/all/conanfile.py | 105 ++++++++++++++++++ .../ccache/all/patches/0001-fix-cmake.patch | 63 +++++++++++ recipes/ccache/all/test_package/conanfile.py | 9 ++ recipes/ccache/config.yml | 3 + 6 files changed, 195 insertions(+) create mode 100644 recipes/ccache/all/CMakeLists.txt create mode 100644 recipes/ccache/all/conandata.yml create mode 100644 recipes/ccache/all/conanfile.py create mode 100644 recipes/ccache/all/patches/0001-fix-cmake.patch create mode 100644 recipes/ccache/all/test_package/conanfile.py create mode 100644 recipes/ccache/config.yml diff --git a/recipes/ccache/all/CMakeLists.txt b/recipes/ccache/all/CMakeLists.txt new file mode 100644 index 0000000000000..bd3083b512cb9 --- /dev/null +++ b/recipes/ccache/all/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.1) +project(cmake_wrapper) + +include(conanbuildinfo.cmake) +conan_basic_setup() + +add_subdirectory(source_subfolder) diff --git a/recipes/ccache/all/conandata.yml b/recipes/ccache/all/conandata.yml new file mode 100644 index 0000000000000..f7b5473e6483f --- /dev/null +++ b/recipes/ccache/all/conandata.yml @@ -0,0 +1,8 @@ +sources: + "4.5.1": + url: "https://github.com/ccache/ccache/releases/download/v4.5.1/ccache-4.5.1.tar.xz" + sha256: "51186ebe0326365f4e6131e1caa8911de7da4aa6718efc00680322d63a759517" +patches: + "4.5.1": + - patch_file: "patches/0001-fix-cmake.patch" + base_path: "source_subfolder" diff --git a/recipes/ccache/all/conanfile.py b/recipes/ccache/all/conanfile.py new file mode 100644 index 0000000000000..b0055145768b7 --- /dev/null +++ b/recipes/ccache/all/conanfile.py @@ -0,0 +1,105 @@ +from conans import ConanFile, CMake, tools +from conans.errors import ConanInvalidConfiguration +import os + +required_conan_version = ">=1.33.0" + + +class CcacheConan(ConanFile): + name = "ccache" + description = ( + "Ccache (or “ccache”) is a compiler cache. It speeds up recompilation " + "by caching previous compilations and detecting when the same " + "compilation is being done again." + ) + license = "GPL-3.0-or-later" + topics = ("ccache", "compiler-cache", "recompilation") + homepage = "https://ccache.dev" + url = "https://github.com/conan-io/conan-center-index" + + settings = "os", "arch", "compiler", "build_type" + options = { + "redis_storage_backend": [True, False], + } + default_options = { + "redis_storage_backend": True, + } + + generators = "cmake", "cmake_find_package_multi" + _cmake = None + + @property + def _source_subfolder(self): + return "source_subfolder" + + @property + def _min_cppstd(self): + return "17" if self.settings.compiler == "Visual Studio" else "14" + + @property + def _compilers_minimum_version(self): + return { + "gcc": "6", + "clang": "6", + "apple-clang": "10", + "Visual Studio": "15.7", + } + + def export_sources(self): + self.copy("CMakeLists.txt") + for patch in self.conan_data.get("patches", {}).get(self.version, []): + self.copy(patch["patch_file"]) + + def requirements(self): + self.requires("zstd/1.5.1") + if self.options.redis_storage_backend: + self.requires("hiredis/1.0.2") + + def validate(self): + if self.settings.compiler.get_safe("cppstd"): + tools.check_min_cppstd(self, self._min_cppstd) + + def lazy_lt_semver(v1, v2): + lv1 = [int(v) for v in v1.split(".")] + lv2 = [int(v) for v in v2.split(".")] + min_length = min(len(lv1), len(lv2)) + return lv1[:min_length] < lv2[:min_length] + + minimum_version = self._compilers_minimum_version.get(str(self.settings.compiler), False) + if minimum_version and lazy_lt_semver(str(self.settings.compiler.version), minimum_version): + raise ConanInvalidConfiguration( + "{} requires C++{}, which your compiler does not support.".format(self.name, self._min_cppstd) + ) + + def package_id(self): + del self.info.settings.compiler + + def source(self): + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) + + def _configure_cmake(self): + if self._cmake: + return self._cmake + self._cmake = CMake(self) + self._cmake.definitions["REDIS_STORAGE_BACKEND"] = self.options.redis_storage_backend + self._cmake.definitions["ENABLE_DOCUMENTATION"] = False + self._cmake.definitions["ENABLE_TESTING"] = False + self._cmake.configure() + return self._cmake + + def build(self): + for patch in self.conan_data.get("patches", {}).get(self.version, []): + tools.patch(**patch) + cmake = self._configure_cmake() + cmake.build() + + def package(self): + self.copy("GPL-*.txt", dst="licenses", src=self._source_subfolder) + cmake = self._configure_cmake() + cmake.install() + + def package_info(self): + bin_path = os.path.join(self.package_folder, "bin") + self.output.info("Appending PATH environment variable: {}".format(bin_path)) + self.env_info.PATH.append(bin_path) diff --git a/recipes/ccache/all/patches/0001-fix-cmake.patch b/recipes/ccache/all/patches/0001-fix-cmake.patch new file mode 100644 index 0000000000000..ba4c4b6a18286 --- /dev/null +++ b/recipes/ccache/all/patches/0001-fix-cmake.patch @@ -0,0 +1,63 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -97,12 +97,12 @@ if(MSVC AND NOT CMAKE_TOOLCHAIN_FILE MATCHES "vcpkg|conan") + endif() + + option(ZSTD_FROM_INTERNET "Download and use libzstd from the Internet" ${ZSTD_FROM_INTERNET_DEFAULT}) +-find_package(zstd 1.1.2 REQUIRED) ++find_package(zstd REQUIRED CONFIG) + + option(REDIS_STORAGE_BACKEND "Enable Redis secondary storage" ON) + if(REDIS_STORAGE_BACKEND) + option(HIREDIS_FROM_INTERNET "Download and use libhiredis from the Internet" ${HIREDIS_FROM_INTERNET_DEFAULT}) +- find_package(hiredis 0.13.3 REQUIRED) ++ find_package(hiredis REQUIRED CONFIG) + endif() + + # +--- a/cmake/GenerateConfigurationFile.cmake ++++ b/cmake/GenerateConfigurationFile.cmake +@@ -104,5 +104,5 @@ if(HAVE_SYS_MMAN_H AND HAVE_PTHREAD_MUTEXATTR_SETPSHARED) + set(INODE_CACHE_SUPPORTED 1) + endif() + +-configure_file(${CMAKE_SOURCE_DIR}/cmake/config.h.in ++configure_file(${PROJECT_SOURCE_DIR}/cmake/config.h.in + ${CMAKE_BINARY_DIR}/config.h @ONLY) +--- a/cmake/GenerateVersionFile.cmake ++++ b/cmake/GenerateVersionFile.cmake +@@ -1,4 +1,4 @@ + configure_file( +- ${CMAKE_SOURCE_DIR}/cmake/version.cpp.in ++ ${PROJECT_SOURCE_DIR}/cmake/version.cpp.in + ${CMAKE_BINARY_DIR}/src/version.cpp + @ONLY) +--- a/src/CMakeLists.txt ++++ b/src/CMakeLists.txt +@@ -27,7 +27,7 @@ set( + execute.cpp + hashutil.cpp + language.cpp +- version.cpp ++ ${CMAKE_BINARY_DIR}/src/version.cpp + ) + + if(INODE_CACHE_SUPPORTED) +@@ -65,7 +65,7 @@ set(THREADS_PREFER_PTHREAD_FLAG ON) + find_package(Threads REQUIRED) + target_link_libraries( + ccache_framework +- PRIVATE standard_settings standard_warnings ZSTD::ZSTD Threads::Threads third_party ++ PRIVATE standard_settings standard_warnings $,zstd::libzstd_shared,zstd::libzstd_static> Threads::Threads third_party + ) + + target_include_directories(ccache_framework PRIVATE ${CMAKE_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}) +@@ -74,7 +74,7 @@ if(REDIS_STORAGE_BACKEND) + target_compile_definitions(ccache_framework PRIVATE -DHAVE_REDIS_STORAGE_BACKEND) + target_link_libraries( + ccache_framework +- PUBLIC standard_settings standard_warnings HIREDIS::HIREDIS third_party ++ PUBLIC standard_settings standard_warnings hiredis::hiredis third_party + ) + endif() + diff --git a/recipes/ccache/all/test_package/conanfile.py b/recipes/ccache/all/test_package/conanfile.py new file mode 100644 index 0000000000000..e357214905abd --- /dev/null +++ b/recipes/ccache/all/test_package/conanfile.py @@ -0,0 +1,9 @@ +from conans import ConanFile, tools + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + + def test(self): + if not tools.cross_building(self): + self.run("ccache --version", run_environment=True) diff --git a/recipes/ccache/config.yml b/recipes/ccache/config.yml new file mode 100644 index 0000000000000..e34add5ca9090 --- /dev/null +++ b/recipes/ccache/config.yml @@ -0,0 +1,3 @@ +versions: + "4.5.1": + folder: all