-
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.
- Loading branch information
1 parent
95be8c2
commit ed01631
Showing
8 changed files
with
255 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,88 @@ | ||
import os | ||
from conans import ConanFile, CMake, tools | ||
|
||
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.get(**self.conan_data["sources"][self.version], | ||
destination=self._source_subfolder, strip_root=True) | ||
|
||
def _patch_sources(self): | ||
for patch in self.conan_data.get("patches", {}).get(self.version, []): | ||
tools.patch(**patch) | ||
|
||
def _configure_cmake(self): | ||
if self._cmake: | ||
return self._cmake | ||
self._cmake = CMake(self) | ||
|
||
self._cmake.definitions["BUILD_SHARED_LIBS"] = self.options.shared | ||
self._cmake.definitions["BUILD_TOOLS"] = self.options.tools | ||
|
||
self._cmake.configure(build_folder=self._build_subfolder) | ||
return self._cmake | ||
|
||
def build(self): | ||
self._patch_sources() | ||
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() | ||
|
||
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) |
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,109 @@ | ||
diff --git a/CMakeLists.txt b/CMakeLists.txt | ||
new file mode 100644 | ||
index 0000000..42d6e1d | ||
--- /dev/null | ||
+++ b/CMakeLists.txt | ||
@@ -0,0 +1,103 @@ | ||
+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") | ||
+ | ||
+add_library(io OBJECT | ||
+ "${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") | ||
+ | ||
+add_library(trie OBJECT | ||
+ "${PROJECT_SOURCE_DIR}/lib/marisa/grimoire/trie/tail.cc" | ||
+ "${PROJECT_SOURCE_DIR}/lib/marisa/grimoire/trie/louds-trie.cc") | ||
+ | ||
+add_library(vector OBJECT | ||
+ "${PROJECT_SOURCE_DIR}/lib/marisa/grimoire/vector/bit-vector.cc") | ||
+ | ||
+add_library(marisa ${MARISA_LIBRARY_TYPE} | ||
+ "${PROJECT_SOURCE_DIR}/lib/marisa/keyset.cc" | ||
+ "${PROJECT_SOURCE_DIR}/lib/marisa/trie.cc" | ||
+ "${PROJECT_SOURCE_DIR}/lib/marisa/agent.cc") | ||
+target_link_libraries(marisa PRIVATE io trie vector) | ||
+install(TARGETS marisa | ||
+ RUNTIME DESTINATION ${CMAKE_INSTALL_FULL_BINDIR} | ||
+ LIBRARY DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR} | ||
+ ARCHIVE DESTINATION ${CMAKE_INSTALL_FULL_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_FULL_LIBDIR}/pkgconfig) | ||
+ | ||
+install(FILES "${PROJECT_SOURCE_DIR}/include/marisa.h" | ||
+ DESTINATION ${CMAKE_INSTALL_FULL_INCLUDEDIR}) | ||
+ | ||
+file(GLOB marisa_other_header_files ${PROJECT_SOURCE_DIR}/include/marisa/*.h) | ||
+install(FILES ${marisa_other_header_files} | ||
+ DESTINATION ${CMAKE_INSTALL_FULL_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 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): | ||
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 |