-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add marisa recipe * fix patch * add le * add le * remove pc file * Update recipes/marisa/all/conanfile.py Co-authored-by: Chris Mc <[email protected]> Co-authored-by: Chris Mc <[email protected]>
- Loading branch information
1 parent
5253b77
commit 5c33ec9
Showing
8 changed files
with
265 additions
and
0 deletions.
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,7 @@ | ||
cmake_minimum_required(VERSION 3.8) | ||
project(cmake_wrapper) | ||
|
||
include(conanbuildinfo.cmake) | ||
conan_basic_setup(KEEP_RPATHS) | ||
|
||
add_subdirectory(source_subfolder) |
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,8 @@ | ||
sources: | ||
"0.2.6": | ||
url: "https://github.com/s-yata/marisa-trie/archive/refs/tags/v0.2.6.tar.gz" | ||
sha256: "1063a27c789e75afa2ee6f1716cc6a5486631dcfcb7f4d56d6485d2462e566de" | ||
patches: | ||
"0.2.6": | ||
- patch_file: "patches/0001-add-cmake.patch" | ||
base_path: "source_subfolder" |
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,87 @@ | ||
import os | ||
from conan import ConanFile, tools | ||
from conan.tools.files import apply_conandata_patches | ||
from conans import CMake | ||
|
||
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") | ||
exports_sources = "patches/**", "CMakeLists.txt" | ||
settings = "os", "compiler", "build_type", "arch" | ||
options = { | ||
"shared": [True, False], | ||
"fPIC": [True, False], | ||
"tools": [True, False], | ||
} | ||
default_options = { | ||
"shared": False, | ||
"fPIC": True, | ||
"tools": True, | ||
} | ||
|
||
generators = "cmake" | ||
_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 | ||
del self.settings.compiler.libcxx | ||
del self.settings.compiler.cppstd | ||
|
||
def source(self): | ||
tools.files.get(**self.conan_data["sources"][self.version], | ||
conanfile=self, destination=self._source_subfolder, strip_root=True) | ||
|
||
def _configure_cmake(self): | ||
if self._cmake: | ||
return self._cmake | ||
self._cmake = CMake(self) | ||
|
||
self._cmake.definitions["BUILD_TOOLS"] = self.options.tools | ||
|
||
self._cmake.configure(build_folder=self._build_subfolder) | ||
return self._cmake | ||
|
||
def build(self): | ||
apply_conandata_patches(self) | ||
cmake = self._configure_cmake() | ||
cmake.build() | ||
|
||
def package(self): | ||
self.copy(pattern="COPYING.md", dst="licenses", | ||
src=self._source_subfolder) | ||
cmake = self._configure_cmake() | ||
cmake.install() | ||
tools.files.rmdir(self, os.path.join( | ||
self.package_folder, "lib", "pkgconfig")) | ||
|
||
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(f"Appending PATH env var with : '{bin_path}'") | ||
self.env_info.PATH.append(bin_path) |
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,120 @@ | ||
diff --git a/CMakeLists.txt b/CMakeLists.txt | ||
new file mode 100644 | ||
index 0000000..c7e4c0e | ||
--- /dev/null | ||
+++ b/CMakeLists.txt | ||
@@ -0,0 +1,114 @@ | ||
+cmake_minimum_required(VERSION 3.1) | ||
+project(marisa CXX) | ||
+ | ||
+include(GNUInstallDirs) | ||
+ | ||
+option(BUILD_SHARED_LIBS "Build as shared library" OFF) | ||
+option(BUILD_TOOLS "Build tools" ON) | ||
+option(ENABLE_TESTS "Build and run tests" ON) | ||
+ | ||
+if(BUILD_SHARED_LIBS) | ||
+ set(MARISA_LIBRARY_TYPE SHARED) | ||
+else() | ||
+ set(MARISA_LIBRARY_TYPE STATIC) | ||
+endif(BUILD_SHARED_LIBS) | ||
+ | ||
+set(CMAKE_CXX_STANDARD 11) | ||
+ | ||
+if(NOT CMAKE_BUILD_TYPE) | ||
+ set(CMAKE_BUILD_TYPE Debug) | ||
+endif() | ||
+ | ||
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall") | ||
+ | ||
+if(NOT MSVC) | ||
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Weffc++ -Wextra -Wconversion") | ||
+endif() | ||
+ | ||
+if(BUILD_SHARED_LIBS AND MSVC) | ||
+ set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS TRUE) | ||
+endif() | ||
+ | ||
+include_directories("${PROJECT_SOURCE_DIR}/include") | ||
+include_directories("${PROJECT_SOURCE_DIR}/lib") | ||
+ | ||
+set(HDR_COMPAT | ||
+ include/marisa.h) | ||
+ | ||
+set(HDR_PUBLIC | ||
+ include/marisa/agent.h | ||
+ include/marisa/base.h | ||
+ include/marisa/exception.h | ||
+ include/marisa/iostream.h | ||
+ include/marisa/key.h | ||
+ include/marisa/keyset.h | ||
+ include/marisa/query.h | ||
+ include/marisa/scoped-array.h | ||
+ include/marisa/scoped-ptr.h | ||
+ include/marisa/stdio.h | ||
+ include/marisa/trie.h) | ||
+add_library(marisa ${MARISA_LIBRARY_TYPE} | ||
+ "${PROJECT_SOURCE_DIR}/lib/marisa/grimoire/io/mapper.cc" | ||
+ "${PROJECT_SOURCE_DIR}/lib/marisa/grimoire/io/reader.cc" | ||
+ "${PROJECT_SOURCE_DIR}/lib/marisa/grimoire/io/writer.cc" | ||
+ "${PROJECT_SOURCE_DIR}/lib/marisa/grimoire/trie/tail.cc" | ||
+ "${PROJECT_SOURCE_DIR}/lib/marisa/grimoire/trie/louds-trie.cc" | ||
+ "${PROJECT_SOURCE_DIR}/lib/marisa/grimoire/vector/bit-vector.cc" | ||
+ "${PROJECT_SOURCE_DIR}/lib/marisa/keyset.cc" | ||
+ "${PROJECT_SOURCE_DIR}/lib/marisa/trie.cc" | ||
+ "${PROJECT_SOURCE_DIR}/lib/marisa/agent.cc") | ||
+ | ||
+install(TARGETS marisa | ||
+ RUNTIME DESTINATION ${CMAKE_INSTALL_FULL_BINDIR} | ||
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} | ||
+ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) | ||
+ | ||
+if(BUILD_TOOLS) | ||
+ add_library(cmdopt OBJECT "${PROJECT_SOURCE_DIR}/tools/cmdopt.cc") | ||
+ set(TOOLS | ||
+ marisa-benchmark | ||
+ marisa-build | ||
+ marisa-common-prefix-search | ||
+ marisa-dump | ||
+ marisa-lookup | ||
+ marisa-predictive-search | ||
+ marisa-reverse-lookup | ||
+ ) | ||
+ | ||
+ foreach(TOOL ${TOOLS}) | ||
+ add_executable(${TOOL} "${PROJECT_SOURCE_DIR}/tools/${TOOL}.cc") | ||
+ target_link_libraries(${TOOL} PRIVATE marisa cmdopt) | ||
+ install(TARGETS ${TOOL} | ||
+ RUNTIME DESTINATION ${CMAKE_INSTALL_FULL_BINDIR}) | ||
+ endforeach(TOOL) | ||
+endif() | ||
+ | ||
+if(ENABLE_TESTS) | ||
+ enable_testing() | ||
+ set(TESTS | ||
+ base-test | ||
+ io-test | ||
+ trie-test | ||
+ vector-test | ||
+ marisa-test | ||
+ ) | ||
+ | ||
+ foreach(TEST ${TESTS}) | ||
+ add_executable(${TEST} "${PROJECT_SOURCE_DIR}/tests/${TEST}.cc") | ||
+ target_link_libraries(${TEST} PRIVATE marisa) | ||
+ add_test(${TEST} ${TEST}) | ||
+ endforeach(TEST) | ||
+endif() | ||
+ | ||
+configure_file( | ||
+ ${PROJECT_SOURCE_DIR}/marisa.pc.in | ||
+ ${PROJECT_BINARY_DIR}/marisa.pc | ||
+ @ONLY) | ||
+install(FILES ${PROJECT_BINARY_DIR}/marisa.pc | ||
+ DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) | ||
+ | ||
+install(FILES ${HDR_COMPAT} | ||
+ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) | ||
+ | ||
+install(FILES ${HDR_PUBLIC} | ||
+ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/marisa) |
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,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) |
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,18 @@ | ||
import os | ||
from conans import CMake, ConanFile, tools | ||
from conan.tools.build import cross_building | ||
|
||
|
||
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): | ||
if not cross_building(self): | ||
bin_path = os.path.join("bin", "test_package") | ||
self.run(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,12 @@ | ||
#include <cstdlib> | ||
#include "marisa.h" | ||
|
||
|
||
int main() { | ||
int x = 100; | ||
int y = 200; | ||
|
||
marisa::swap(x, y); | ||
|
||
return EXIT_SUCCESS; | ||
} |
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: | ||
"0.2.6": | ||
folder: all |