diff --git a/recipes/marisa/all/conandata.yml b/recipes/marisa/all/conandata.yml new file mode 100644 index 00000000000000..02bba2c8ef3196 --- /dev/null +++ b/recipes/marisa/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "0.2.6": + url: "https://github.com/s-yata/marisa-trie/archive/refs/tags/v0.2.6.tar.gz" + sha256: "1063a27c789e75afa2ee6f1716cc6a5486631dcfcb7f4d56d6485d2462e566de" diff --git a/recipes/marisa/all/conanfile.py b/recipes/marisa/all/conanfile.py new file mode 100644 index 00000000000000..281b49869ef219 --- /dev/null +++ b/recipes/marisa/all/conanfile.py @@ -0,0 +1,149 @@ +import os +import functools +from contextlib import contextmanager +from conans import ConanFile, tools, AutoToolsBuildEnvironment +from conan.tools.microsoft import is_msvc +from conan.tools.build import cross_building + +required_conan_version = ">=1.45.0" + + +class MarisaConan(ConanFile): + name = "marisa" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/s-yata/marisa-trie" + description = "Matching Algorithm with Recursively Implemented StorAge " + license = ("BSD-2-Clause", "LGPL-2.1") + topics = ("algorithm", "dictionary", "marisa") + settings = "os", "compiler", "build_type", "arch" + options = {"shared": [True, False], "fPIC": [True, False]} + default_options = {"shared": False, "fPIC": True} + + _autotools = None + + @property + def _source_subfolder(self): + return "source_subfolder" + + @property + def _use_winbash(self): + return self.settings.os == "Windows" and (self.settings.compiler == "gcc" or cross_building(self)) + + @property + def _is_clang_cl(self): + return self.settings.compiler == "clang" and self.settings.os == "Windows" + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + del self.options.fPIC + del self.settings.compiler.libcxx + del self.settings.compiler.cppstd + + def build_requirements(self): + if self._settings_build.os == "Windows" and not tools.get_env("CONAN_BASH_PATH"): + self.build_requires("msys2/cci.latest") + self.build_requires("libtool/2.4.6") + self.build_requires("automake/1.16.5") + + def source(self): + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) + + @contextmanager + def _build_context(self): + env_vars = {} + if is_msvc(self) or self._is_clang_cl: + cc = "cl" if is_msvc(self) else os.environ.get("CC", "clang-cl") + cxx = "cl" if is_msvc(self) else os.environ.get("CXX", "clang-cl") + lib = "lib" if is_msvc(self) else os.environ.get("AR", "llvm-lib") + build_aux_path = os.path.join( + self.build_folder, self._source_subfolder) + lt_compile = tools.unix_path( + os.path.join(build_aux_path, "compile")) + lt_ar = tools.unix_path(os.path.join(build_aux_path, "ar-lib")) + env_vars.update({ + "CC": "{} {} -nologo".format(lt_compile, cc), + "CXX": "{} {} -nologo".format(lt_compile, cxx), + "LD": "link", + "STRIP": ":", + "AR": "{} {}".format(lt_ar, lib), + "RANLIB": ":", + "NM": "dumpbin -symbols" + }) + env_vars["win32_target"] = "_WIN32_WINNT_VISTA" + + if not cross_building(self) or is_msvc(self) or self._is_clang_cl: + rc = None + if self.settings.arch == "x86": + rc = "windres --target=pe-i386" + elif self.settings.arch == "x86_64": + rc = "windres --target=pe-x86-64" + if rc: + env_vars["RC"] = rc + env_vars["WINDRES"] = rc + if self._use_winbash: + env_vars["RANLIB"] = ":" + + with tools.vcvars(self.settings) if (is_msvc(self) or self._is_clang_cl) else tools.no_op(): + with tools.chdir(self._source_subfolder): + with tools.environment_append(env_vars): + yield + + @functools.lru_cache(1) + def _configure_autotools(self): + host = None + build = None + if is_msvc(self) or self._is_clang_cl: + build = False + if self.settings.arch == "x86": + host = "i686-w64-mingw32" + elif self.settings.arch == "x86_64": + host = "x86_64-w64-mingw32" + + if self._autotools: + return self._autotools + self.run("{} -fiv".format(tools.get_env("AUTORECONF")), + win_bash=self.settings.os == "Windows") + self._autotools = AutoToolsBuildEnvironment( + self, win_bash=self.settings.os == "Windows") + conf_args = [ + ("--enable-shared" if self.options.shared else "--enable-static"), + ("--disable-static" if self.options.shared else "--disable-shared"), + ] + if (self.settings.compiler == "Visual Studio" and tools.Version(self.settings.compiler.version) >= "12") or \ + self.settings.compiler == "msvc": + self._autotools.flags.append("-FS") + + self._autotools.configure(args=conf_args, host=host, build=build) + return self._autotools + + def build(self): + with self._build_context(): + autotools = self._configure_autotools() + autotools.make() + + def package(self): + self.copy("COPYING.md", src=self._source_subfolder, dst="licenses") + with tools.chdir(self._source_subfolder): + with self._build_context(): + autotools = self._configure_autotools() + autotools.install() + tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) + tools.remove_files_by_mask(os.path.join( + self.package_folder, "lib"), "*.la") + + def package_info(self): + self.cpp_info.names["cmake_find_package"] = "marisa" + self.cpp_info.names["cmake_find_package_multi"] = "marisa" + self.cpp_info.names["pkgconfig"] = "marisa" + self.cpp_info.libs = ["marisa"] + if self.settings.os == "Linux": + self.cpp_info.system_libs = ["m"] + + bin_path = os.path.join(self.package_folder, "bin") + self.output.info("Appending PATH env var with : {}".format(bin_path)) + self.env_info.PATH.append(bin_path) diff --git a/recipes/marisa/all/test_package/CMakeLists.txt b/recipes/marisa/all/test_package/CMakeLists.txt new file mode 100644 index 00000000000000..9bae1c0958b767 --- /dev/null +++ b/recipes/marisa/all/test_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup() + +find_package(marisa REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} marisa::marisa) diff --git a/recipes/marisa/all/test_package/conanfile.py b/recipes/marisa/all/test_package/conanfile.py new file mode 100644 index 00000000000000..6b1c13f2d930c5 --- /dev/null +++ b/recipes/marisa/all/test_package/conanfile.py @@ -0,0 +1,18 @@ +import os +from conans import CMake, ConanFile, tools +from conan.tools.build import cross_building + + +class LibrdkafkaTestConan(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): + if not cross_building(self.settings): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/marisa/all/test_package/test_package.cpp b/recipes/marisa/all/test_package/test_package.cpp new file mode 100644 index 00000000000000..ba90951dd5e1b0 --- /dev/null +++ b/recipes/marisa/all/test_package/test_package.cpp @@ -0,0 +1,12 @@ +#include +#include "marisa.h" + + +int main() { + int x = 100; + int y = 200; + + marisa::swap(x, y); + + return EXIT_SUCCESS; +} diff --git a/recipes/marisa/config.yml b/recipes/marisa/config.yml new file mode 100644 index 00000000000000..070a32463b25e0 --- /dev/null +++ b/recipes/marisa/config.yml @@ -0,0 +1,3 @@ +versions: + "0.2.6": + folder: all