From 15a40d8e22505547cad52d538ac8cfec39e61f5f Mon Sep 17 00:00:00 2001 From: "andrei.malashkin" Date: Fri, 2 Jul 2021 13:30:47 +0400 Subject: [PATCH] add effcee recipe --- recipes/effcee/all/CMakeLists.txt | 9 +++ recipes/effcee/all/conandata.yml | 8 +++ recipes/effcee/all/conanfile.py | 68 +++++++++++++++++++ .../patches/0001-substitute-conan-libs.patch | 12 ++++ .../effcee/all/test_package/CMakeLists.txt | 11 +++ recipes/effcee/all/test_package/conanfile.py | 16 +++++ recipes/effcee/all/test_package/main.cc | 64 +++++++++++++++++ recipes/effcee/config.yml | 3 + 8 files changed, 191 insertions(+) create mode 100644 recipes/effcee/all/CMakeLists.txt create mode 100644 recipes/effcee/all/conandata.yml create mode 100644 recipes/effcee/all/conanfile.py create mode 100644 recipes/effcee/all/patches/0001-substitute-conan-libs.patch create mode 100644 recipes/effcee/all/test_package/CMakeLists.txt create mode 100644 recipes/effcee/all/test_package/conanfile.py create mode 100644 recipes/effcee/all/test_package/main.cc create mode 100644 recipes/effcee/config.yml diff --git a/recipes/effcee/all/CMakeLists.txt b/recipes/effcee/all/CMakeLists.txt new file mode 100644 index 00000000000000..5286f8a2277b91 --- /dev/null +++ b/recipes/effcee/all/CMakeLists.txt @@ -0,0 +1,9 @@ +cmake_minimum_required(VERSION 2.8.11) +project(cmake_wrapper) + +include(conanbuildinfo.cmake) +conan_basic_setup() + +find_package(re2 REQUIRED CONFIG) + +add_subdirectory(source_subfolder/) diff --git a/recipes/effcee/all/conandata.yml b/recipes/effcee/all/conandata.yml new file mode 100644 index 00000000000000..616ed0f0725972 --- /dev/null +++ b/recipes/effcee/all/conandata.yml @@ -0,0 +1,8 @@ +sources: + "v2019.1": + sha256: 332586221ef53a615cc6595cc54643610b1f9f77acd2862860a1eda6f03de8b9 + url: https://github.com/google/effcee/archive/refs/tags/v2019.1.zip +patches: + "v2019.1": + - base_path: "source_subfolder" + patch_file: "patches/0001-substitute-conan-libs.patch" diff --git a/recipes/effcee/all/conanfile.py b/recipes/effcee/all/conanfile.py new file mode 100644 index 00000000000000..eb260282b704ec --- /dev/null +++ b/recipes/effcee/all/conanfile.py @@ -0,0 +1,68 @@ +import os +from conans import ConanFile, CMake, tools + + +class EffceeConan(ConanFile): + name = "effcee" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/google/effcee/" + description = "Zstandard - Fast real-time compression algorithm" + topics = ("conan", "effcee", "strings", "algorithm", "matcher") + license = "Apache 2.0" + exports_sources = ["CMakeLists.txt", "patches/**"] + generators = "cmake", "cmake_find_package_multi" + settings = "os", "arch", "compiler", "build_type" + options = {"shared": [True, False], "fPIC": [True, False]} + default_options = {"shared": False, "fPIC": True} + + _cmake = None + + @property + def _source_subfolder(self): + return "source_subfolder" + + @property + def _build_subfolder(self): + return "build_subfolder" + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + del self.options.fPIC + + 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["EFFCEE_BUILD_TESTING"] = False + self._cmake.definitions["EFFCEE_BUILD_SAMPLES"] = False + self._cmake.configure(build_folder=self._build_subfolder) + return self._cmake + + def _patch_sources(self): + for patch in self.conan_data.get("patches", {}).get(self.version, []): + tools.patch(**patch) + + def requirements(self): + self.requires('re2/20210601') + + def build(self): + self._patch_sources() + cmake = self._configure_cmake() + cmake.build() + + def package(self): + self.copy(pattern="LICENSE", dst="licenses", src=self._source_subfolder) + cmake = self._configure_cmake() + cmake.install() + + def package_info(self): + self.cpp_info.libs = tools.collect_libs(self) + diff --git a/recipes/effcee/all/patches/0001-substitute-conan-libs.patch b/recipes/effcee/all/patches/0001-substitute-conan-libs.patch new file mode 100644 index 00000000000000..4daf354b1426f9 --- /dev/null +++ b/recipes/effcee/all/patches/0001-substitute-conan-libs.patch @@ -0,0 +1,12 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index d96e44a..6268fe3 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -33,7 +33,6 @@ include(cmake/setup_build.cmake) + include(cmake/utils.cmake) + include(GNUInstallDirs) + +-add_subdirectory(third_party) + add_subdirectory(effcee) + add_subdirectory(fuzzer) + diff --git a/recipes/effcee/all/test_package/CMakeLists.txt b/recipes/effcee/all/test_package/CMakeLists.txt new file mode 100644 index 00000000000000..c4f6a225321770 --- /dev/null +++ b/recipes/effcee/all/test_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup() + +find_package(effcee REQUIRED) + +add_executable(effcee-example main.cc) + +target_link_libraries(effcee-example ${CONAN_LIBS}) diff --git a/recipes/effcee/all/test_package/conanfile.py b/recipes/effcee/all/test_package/conanfile.py new file mode 100644 index 00000000000000..44398186e86f33 --- /dev/null +++ b/recipes/effcee/all/test_package/conanfile.py @@ -0,0 +1,16 @@ +import os +from conans import ConanFile, CMake, tools + + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake", "cmake_find_package" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + pass + diff --git a/recipes/effcee/all/test_package/main.cc b/recipes/effcee/all/test_package/main.cc new file mode 100644 index 00000000000000..ea0a3436de6fb4 --- /dev/null +++ b/recipes/effcee/all/test_package/main.cc @@ -0,0 +1,64 @@ +// Copyright 2017 The Effcee Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include +#include + +#include "effcee/effcee.h" + +// Checks standard input against the list of checks provided as command line +// arguments. +// +// Example: +// cat <sample_data.txt +// Bees +// Make +// Delicious Honey +// EOF +// effcee-example > input_stream.rdbuf(); + + // Attempt to match. The input and checks arguments can be provided as + // std::string or pointer to char. + auto result = effcee::Match(input_stream.str(), checks_stream.str(), + effcee::Options().SetChecksName("checks")); + + // Successful match result converts to true. + if (result) { + std::cout << "The input matched your check list!" << std::endl; + } else { + // Otherwise, you can get a status code and a detailed message. + switch (result.status()) { + case effcee::Result::Status::NoRules: + std::cout << "error: Expected check rules as command line arguments\n"; + break; + case effcee::Result::Status::Fail: + std::cout << "The input failed to match your check rules:\n"; + break; + default: + break; + } + std::cout << result.message() << std::endl; + return 1; + } + return 0; +} diff --git a/recipes/effcee/config.yml b/recipes/effcee/config.yml new file mode 100644 index 00000000000000..97d49d4ebd089b --- /dev/null +++ b/recipes/effcee/config.yml @@ -0,0 +1,3 @@ +versions: + "2019.1": + folder: all