From dd41144ccad6065c9579a338d52b7242a755fd84 Mon Sep 17 00:00:00 2001 From: Rick Guo Date: Wed, 9 Sep 2026 21:34:30 +0800 Subject: [PATCH 1/3] formula: add s-yata/marisa-trie --- .../marisa-trie/v0.2.6/0001-add-cmake.patch | 120 ++++++++++++++++ s-yata/marisa-trie/v0.2.6/marisa_llar.gox | 128 ++++++++++++++++++ s-yata/marisa-trie/versions.json | 4 + 3 files changed, 252 insertions(+) create mode 100644 s-yata/marisa-trie/v0.2.6/0001-add-cmake.patch create mode 100644 s-yata/marisa-trie/v0.2.6/marisa_llar.gox create mode 100644 s-yata/marisa-trie/versions.json diff --git a/s-yata/marisa-trie/v0.2.6/0001-add-cmake.patch b/s-yata/marisa-trie/v0.2.6/0001-add-cmake.patch new file mode 100644 index 0000000..4635c52 --- /dev/null +++ b/s-yata/marisa-trie/v0.2.6/0001-add-cmake.patch @@ -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) diff --git a/s-yata/marisa-trie/v0.2.6/marisa_llar.gox b/s-yata/marisa-trie/v0.2.6/marisa_llar.gox new file mode 100644 index 0000000..0c930a4 --- /dev/null +++ b/s-yata/marisa-trie/v0.2.6/marisa_llar.gox @@ -0,0 +1,128 @@ +import ( + "os" + "path/filepath" +) + +const consumerSource = `#include "marisa.h" + +#include + +int main() { + int x = 100; + int y = 200; + + marisa::swap(x, y); + + return EXIT_SUCCESS; +} +` + +id "s-yata/marisa-trie" + +// v0.2.6 is the first Conan-served tag with the verified CMake patch. The +// same patch applies to v0.2.7; 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") + needsCMakePolicy := false + + // v0.2.6 and v0.2.7 need the exact Conan CMake patch; v0.3.0 and newer + // already carry their own CMake build, so apply it only when absent. + if _, err := os.stat(cmakeLists); os.isNotExist(err) { + needsCMakePolicy = true + patch := ctx.Proj.readFile("v0.2.6/0001-add-cmake.patch")! + patchPath := filepath.join(ctx.SourceDir, "_llar_add_cmake.patch") + os.writeFile(patchPath, patch, 0o644)! + git! "-C", ctx.SourceDir, "apply", "--unidiff-zero", patchPath + } else if err != nil { + panic err + } + + 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) + if needsCMakePolicy { + c.define "CMAKE_POLICY_VERSION_MINIMUM", "3.5" + } + 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"] + osName := target.require["os"][0] + 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 +} diff --git a/s-yata/marisa-trie/versions.json b/s-yata/marisa-trie/versions.json new file mode 100644 index 0000000..a22b4a4 --- /dev/null +++ b/s-yata/marisa-trie/versions.json @@ -0,0 +1,4 @@ +{ + "path": "s-yata/marisa-trie", + "deps": {} +} From eb7ee031a4e7d2ad4de9d0b2c521f4ec90f7a62a Mon Sep 17 00:00:00 2001 From: Rick Guo Date: Thu, 10 Sep 2026 13:45:05 +0800 Subject: [PATCH 2/3] fix(marisa): use upstream autotools for legacy tags --- .../marisa-trie/v0.2.6/0001-add-cmake.patch | 120 ------------------ s-yata/marisa-trie/v0.2.6/marisa_llar.gox | 93 ++++++++++---- 2 files changed, 65 insertions(+), 148 deletions(-) delete mode 100644 s-yata/marisa-trie/v0.2.6/0001-add-cmake.patch diff --git a/s-yata/marisa-trie/v0.2.6/0001-add-cmake.patch b/s-yata/marisa-trie/v0.2.6/0001-add-cmake.patch deleted file mode 100644 index 4635c52..0000000 --- a/s-yata/marisa-trie/v0.2.6/0001-add-cmake.patch +++ /dev/null @@ -1,120 +0,0 @@ -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) diff --git a/s-yata/marisa-trie/v0.2.6/marisa_llar.gox b/s-yata/marisa-trie/v0.2.6/marisa_llar.gox index 0c930a4..c865770 100644 --- a/s-yata/marisa-trie/v0.2.6/marisa_llar.gox +++ b/s-yata/marisa-trie/v0.2.6/marisa_llar.gox @@ -19,8 +19,8 @@ int main() { id "s-yata/marisa-trie" -// v0.2.6 is the first Conan-served tag with the verified CMake patch. The -// same patch applies to v0.2.7; v0.3.0 and later provide CMake upstream. +// 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 { @@ -46,38 +46,75 @@ filter => { onBuild ctx => { installDir := ctx.outputDir cmakeLists := filepath.join(ctx.SourceDir, "CMakeLists.txt") - needsCMakePolicy := false - // v0.2.6 and v0.2.7 need the exact Conan CMake patch; v0.3.0 and newer - // already carry their own CMake build, so apply it only when absent. + // 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) { - needsCMakePolicy = true - patch := ctx.Proj.readFile("v0.2.6/0001-add-cmake.patch")! - patchPath := filepath.join(ctx.SourceDir, "_llar_add_cmake.patch") - os.writeFile(patchPath, patch, 0o644)! - git! "-C", ctx.SourceDir, "apply", "--unidiff-zero", patchPath + 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 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)) + } + } } 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 } - 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) - if needsCMakePolicy { - c.define "CMAKE_POLICY_VERSION_MINIMUM", "3.5" - } - 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)! From 48738176382a90b8a636e1f4a02d1fb4ff0e9929 Mon Sep 17 00:00:00 2001 From: Rick Guo Date: Thu, 10 Sep 2026 15:42:43 +0800 Subject: [PATCH 3/3] fix(marisa): make staged Darwin dylib relocatable --- s-yata/marisa-trie/v0.2.6/marisa_llar.gox | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/s-yata/marisa-trie/v0.2.6/marisa_llar.gox b/s-yata/marisa-trie/v0.2.6/marisa_llar.gox index c865770..e248a90 100644 --- a/s-yata/marisa-trie/v0.2.6/marisa_llar.gox +++ b/s-yata/marisa-trie/v0.2.6/marisa_llar.gox @@ -46,6 +46,7 @@ filter => { 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. @@ -89,13 +90,30 @@ onBuild ctx => { 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 { @@ -120,7 +138,6 @@ onBuild ctx => { os.writeFile(filepath.join(licenseDir, "COPYING.md"), os.readFile(filepath.join(ctx.SourceDir, "COPYING.md"))!, 0o644)! libs := ["-L$${libdir}", "-lmarisa"] - osName := target.require["os"][0] if osName == "linux" || osName == "freebsd" { libs <- "-lm" }