This repository was archived by the owner on Sep 20, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
formula: s-yata/marisa-trie #505
Open
MeteorsLiu
wants to merge
3
commits into
xgo-dev:main
Choose a base branch
from
MeteorsLiu:issue/252-marisa-luna
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,182 @@ | ||
| import ( | ||
| "os" | ||
| "path/filepath" | ||
| ) | ||
|
|
||
| const consumerSource = `#include "marisa.h" | ||
|
|
||
| #include <cstdlib> | ||
|
|
||
| int main() { | ||
| int x = 100; | ||
| int y = 200; | ||
|
|
||
| marisa::swap(x, y); | ||
|
|
||
| return EXIT_SUCCESS; | ||
| } | ||
| ` | ||
|
|
||
| id "s-yata/marisa-trie" | ||
|
|
||
| // v0.2.6 and v0.2.7 use the upstream Autotools build. v0.3.0 and later | ||
| // provide CMake upstream. | ||
| fromVer "v0.2.6" | ||
|
|
||
| defaults { | ||
| "shared": "OFF", | ||
| "fPIC": "ON", | ||
| "tools": "ON", | ||
| } | ||
|
|
||
| filter => { | ||
| for name, values in target.options { | ||
| if name != "shared" && name != "fPIC" && name != "tools" { | ||
| return false | ||
| } | ||
| for value in values { | ||
| if value != "ON" && value != "OFF" { | ||
| return false | ||
| } | ||
| } | ||
| } | ||
| return true | ||
| } | ||
|
|
||
| onBuild ctx => { | ||
| installDir := ctx.outputDir | ||
| cmakeLists := filepath.join(ctx.SourceDir, "CMakeLists.txt") | ||
| osName := target.require["os"][0] | ||
|
|
||
| // v0.2.6 and v0.2.7 ship Autotools only. Build those tags in-tree after | ||
| // generating their configure script; v0.3.0 and newer provide CMake. | ||
| if _, err := os.stat(cmakeLists); os.isNotExist(err) { | ||
| exec! "autoreconf", "-fi" | ||
| shared := target.options["shared"][0] == "ON" | ||
| fPIC := target.options["fPIC"][0] == "ON" | ||
| tools := target.options["tools"][0] == "ON" | ||
| // The build matrix may contain '|', which libtool would parse as a | ||
| // shell pipeline when embedded in an absolute -rpath. Stage the | ||
| // install at a source-local path and copy its files to LLAR output. | ||
| stageDir := filepath.join(ctx.SourceDir, "_llar_install") | ||
| a := autotools.new(ctx.SourceDir, ctx.SourceDir, stageDir) | ||
| if shared { | ||
| if fPIC { | ||
| a.configure "--enable-shared", "--disable-static", "--enable-pic" | ||
| } else { | ||
| a.configure "--enable-shared", "--disable-static", "--disable-pic" | ||
| } | ||
| } else { | ||
| if fPIC { | ||
| a.configure "--disable-shared", "--enable-static", "--enable-pic" | ||
| } else { | ||
| a.configure "--disable-shared", "--enable-static", "--disable-pic" | ||
| } | ||
| } | ||
| a.build | ||
| a.install | ||
|
|
||
| includeDir := filepath.join(installDir, "include") | ||
| os.mkdirAll(filepath.join(includeDir, "marisa"), 0o755)! | ||
| for path in filepath.glob(filepath.join(stageDir, "include", "*.h"))! { | ||
| cp! path, filepath.join(includeDir, filepath.base(path)) | ||
| } | ||
| for path in filepath.glob(filepath.join(stageDir, "include", "marisa", "*.h"))! { | ||
| cp! path, filepath.join(includeDir, "marisa", filepath.base(path)) | ||
| } | ||
| libDir := filepath.join(installDir, "lib") | ||
| os.mkdirAll(libDir, 0o755)! | ||
| for path in filepath.glob(filepath.join(stageDir, "lib", "libmarisa*"))! { | ||
| cp! path, filepath.join(libDir, filepath.base(path)) | ||
| } | ||
| os.removeAll(filepath.join(libDir, "libmarisa.la"))! | ||
| if shared && osName == "darwin" { | ||
| // Keep the unversioned name as an alias of the real SONAME file. The | ||
| // alias must not acquire a second install ID when staging is copied. | ||
| dylib := filepath.join(libDir, "libmarisa.0.dylib") | ||
| alias := filepath.join(libDir, "libmarisa.dylib") | ||
| os.removeAll(alias)! | ||
| exec! "ln", "-s", "libmarisa.0.dylib", alias | ||
| exec! "install_name_tool", "-id", "@rpath/libmarisa.0.dylib", dylib | ||
| } | ||
| if tools { | ||
| binDir := filepath.join(installDir, "bin") | ||
| os.mkdirAll(binDir, 0o755)! | ||
| for path in filepath.glob(filepath.join(stageDir, "bin", "*"))! { | ||
| cp! path, filepath.join(binDir, filepath.base(path)) | ||
| } | ||
| if shared && osName == "darwin" { | ||
| oldDylib := filepath.join(stageDir, "lib", "libmarisa.0.dylib") | ||
| newDylib := "@loader_path/../lib/libmarisa.0.dylib" | ||
| for path in filepath.glob(filepath.join(binDir, "*"))! { | ||
| exec! "install_name_tool", "-change", oldDylib, newDylib, path | ||
| } | ||
| } | ||
| } | ||
| os.removeAll(stageDir)! | ||
| } else if err != nil { | ||
| panic err | ||
| } else { | ||
| shared := target.options["shared"][0] == "ON" | ||
| fPIC := target.options["fPIC"][0] == "ON" | ||
| tools := target.options["tools"][0] == "ON" | ||
|
|
||
| c := cmake.new(ctx.SourceDir, filepath.join(ctx.SourceDir, "_build"), installDir) | ||
| c.define "CMAKE_INSTALL_LIBDIR", "lib" | ||
| c.define "LIB_INSTALL_DIR", "lib" | ||
| c.defineBool "BUILD_SHARED_LIBS", shared | ||
| c.defineBool "CMAKE_POSITION_INDEPENDENT_CODE", fPIC | ||
| c.defineBool "BUILD_TOOLS", tools | ||
| c.defineBool "ENABLE_TOOLS", tools | ||
| c.configure | ||
| c.build | ||
| c.install | ||
| } | ||
|
|
||
| licenseDir := filepath.join(installDir, "licenses") | ||
| os.mkdirAll(licenseDir, 0o755)! | ||
| os.writeFile(filepath.join(licenseDir, "COPYING.md"), os.readFile(filepath.join(ctx.SourceDir, "COPYING.md"))!, 0o644)! | ||
|
|
||
| libs := ["-L$${libdir}", "-lmarisa"] | ||
| if osName == "linux" || osName == "freebsd" { | ||
| libs <- "-lm" | ||
| } | ||
|
|
||
| pcDir := filepath.join(installDir, "lib", "pkgconfig") | ||
| os.mkdirAll(pcDir, 0o755)! | ||
| pc := pkgconfig.new( | ||
| name = "Marisa", | ||
| description = "Matching Algorithm with Recursively Implemented StorAge", | ||
| version = "v0.2.6", | ||
| libs = libs, | ||
| cflags = ["-I$${includedir}"], | ||
| )! | ||
| out := os.create(filepath.join(pcDir, "marisa.pc"))! | ||
| pc.writeTo(out)! | ||
| out.close()! | ||
|
|
||
| pkgconfig.use installDir | ||
| ctx.setMetadata pkgconfig.lookup("marisa")! | ||
| } | ||
|
|
||
| onTest ctx => { | ||
| installDir := ctx.outputDir | ||
| testDir := filepath.join(ctx.SourceDir, "_llar_consumer") | ||
| os.mkdirAll(testDir, 0o755)! | ||
|
|
||
| consumer := filepath.join(testDir, "consumer.cpp") | ||
| os.writeFile(consumer, []byte(consumerSource), 0o644)! | ||
|
|
||
| pkgconfig.use installDir | ||
| flagsFile := filepath.join(testDir, "marisa.flags") | ||
| os.writeFile(flagsFile, []byte(pkgconfig.lookup("marisa")!), 0o644)! | ||
|
|
||
| binary := filepath.join(testDir, "consumer") | ||
| exec! "c++", "-std=c++11", consumer, "-o", binary, "@"+flagsFile | ||
|
|
||
| if target.options["shared"][0] == "ON" { | ||
| os.setenv("LD_LIBRARY_PATH", filepath.join(installDir, "lib"))! | ||
| os.setenv("DYLD_LIBRARY_PATH", filepath.join(installDir, "lib"))! | ||
| } | ||
| exec! binary | ||
| } | ||
This file contains hidden or 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,4 @@ | ||
| { | ||
| "path": "s-yata/marisa-trie", | ||
| "deps": {} | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[P1] Compile the consumer with C++17 for v0.3.x
The formula applies to
v0.3.0and newer tags, whose installed public headers declarestd::string_view; compiling this consumer with-std=c++11therefore fails withstd::string_view has not been declaredon those versions. As a result, the advertisedv0.3.xvalidation and every non-cache build'sonTestfail even though the library itself builds. Raise the test standard to at least C++17 (or select it by version); C++17 also accepts the v0.2.x headers.