diff --git a/hunspell/hunspell/hunspell_cmp.gox b/hunspell/hunspell/hunspell_cmp.gox new file mode 100644 index 0000000..16b0741 --- /dev/null +++ b/hunspell/hunspell/hunspell_cmp.gox @@ -0,0 +1,14 @@ +import "strings" + +// The complete tag set contains the historical hunspell-1.4.0 alias and +// v1.3.4 through v1.7.3. Normalize the alias before semver ordering. +func normalize(version string) string { + if version == "hunspell-1.4.0" { + return "v1.4.0" + } + return "v" + strings.trimPrefix(version, "v") +} + +compareVer (a, b) => { + return semver.Compare(normalize(a.Version), normalize(b.Version)) +} diff --git a/hunspell/hunspell/v1.7.0/CMakeLists.txt b/hunspell/hunspell/v1.7.0/CMakeLists.txt new file mode 100644 index 0000000..8fb4e22 --- /dev/null +++ b/hunspell/hunspell/v1.7.0/CMakeLists.txt @@ -0,0 +1,69 @@ +cmake_minimum_required(VERSION 3.15) + +project(hunspell VERSION "${CONAN_hunspell_VERSION}" LANGUAGES CXX) + +set(src "${CMAKE_CURRENT_SOURCE_DIR}/src/src/hunspell") + +# ---- Configure hunvisapi.h ---- + +include(CheckCXXCompilerFlag) +check_cxx_compiler_flag(-fvisibility=hidden HAVE_VISIBILITY) +configure_file("${src}/hunvisapi.h.in" hunvisapi.h @ONLY) + +# ---- Library target ---- + +add_library( + hunspell + "${src}/affentry.cxx" + "${src}/affixmgr.cxx" + "${src}/csutil.cxx" + "${src}/filemgr.cxx" + "${src}/hashmgr.cxx" + "${src}/hunspell.cxx" + "${src}/hunzip.cxx" + "${src}/phonet.cxx" + "${src}/replist.cxx" + "${src}/suggestmgr.cxx" +) + +target_compile_features(hunspell PRIVATE cxx_std_11) + +if(MSVC) + target_compile_options(hunspell PRIVATE /wd4267 /wd4996) +endif() + +if(NOT BUILD_SHARED_LIBS) + target_compile_definitions(hunspell PRIVATE HUNSPELL_STATIC) +endif() +target_compile_definitions(hunspell PRIVATE BUILDING_LIBHUNSPELL) + +target_include_directories(hunspell PRIVATE "${src}" "${PROJECT_BINARY_DIR}") + +set_target_properties( + hunspell PROPERTIES + CXX_VISIBILITY_PRESET hidden + VISIBILITY_INLINES_HIDDEN YES + VERSION "${PROJECT_VERSION}" + SOVERSION "${PROJECT_VERSION_MAJOR}" +) + +# ---- Install ---- + +include(GNUInstallDirs) + +install( + TARGETS hunspell + RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" + LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" + ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" +) + +install( + FILES + "${src}/hunspell.hxx" + "${src}/hunspell.h" + "${src}/w_char.hxx" + "${src}/atypes.hxx" + "${PROJECT_BINARY_DIR}/hunvisapi.h" + DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/hunspell" +) diff --git a/hunspell/hunspell/v1.7.0/hunspell_llar.gox b/hunspell/hunspell/v1.7.0/hunspell_llar.gox new file mode 100644 index 0000000..38a4b69 --- /dev/null +++ b/hunspell/hunspell/v1.7.0/hunspell_llar.gox @@ -0,0 +1,165 @@ +import ( + "os" + "path/filepath" + "slices" + "strings" +) + +const consumerSource = `#include +#include + +int main(int argc, char const* argv[]) +{ + (void)argc; + (void)argv; + + Hunspell_destroy(NULL); + + return 0; +} +` + +id "hunspell/hunspell" + +fromVer "v1.7.0" + +defaults { + "shared": "OFF", + "fPIC": "ON", +} + +filter => { + for name, values in target.options { + if name != "shared" && name != "fPIC" { + return false + } + for value in values { + if value != "ON" && value != "OFF" { + return false + } + } + } + return true +} + +onBuild ctx => { + installDir := ctx.outputDir + shared := target.options["shared"][0] == "ON" + fPIC := target.options["fPIC"][0] == "ON" + osName := target.require["os"][0] + + libName := "hunspell-1.7" + if osName == "windows" { + // Windows keeps the module's existing CMake adapter. The upstream tag + // provides Visual Studio projects, while the adapter supplies the + // install layout used by this formula. + cmakeLists := string(ctx.Proj.readFile("v1.7.0/CMakeLists.txt")!) + cmakeLists = strings.replace(cmakeLists, "src/src/hunspell", "src/hunspell", 1) + os.writeFile(filepath.join(ctx.SourceDir, "CMakeLists.txt"), []byte(cmakeLists), 0o644)! + + hunvisapi := filepath.join(ctx.SourceDir, "src", "hunspell", "hunvisapi.h") + os.remove(hunvisapi)! + + c := cmake.new(ctx.SourceDir, filepath.join(ctx.SourceDir, "_build"), installDir) + c.define "CMAKE_INSTALL_LIBDIR", "lib" + c.define "CONAN_hunspell_VERSION", "1.7.0" + c.defineBool "BUILD_SHARED_LIBS", shared + c.defineBool "CMAKE_POSITION_INDEPENDENT_CODE", fPIC + c.configure + c.build + c.install + + libName = "hunspell" + } else { + os.chdir(ctx.SourceDir)! + if exec("libtoolize", "--copy", "--force") != nil { + glibtoolize! "--copy", "--force" + } + autoreconf! "-fi" + + picFlag := "--without-pic" + if fPIC { + picFlag = "--with-pic" + } + // The validator and LLAR matrix encode option values in outputDir with + // '|', which libtool treats as a shell pipeline in its -rpath command. + // Install to a source-local staging path, then copy only the library + // payload into LLAR's output directory. + stagingDir := filepath.join(ctx.SourceDir, "_llar_autotools_install") + a := autotools.new(ctx.SourceDir, filepath.join(ctx.SourceDir, "_build"), stagingDir) + if shared { + a.configure "--enable-shared", "--disable-static", picFlag + } else { + a.configure "--disable-shared", "--enable-static", picFlag + } + a.build + a.install + os.mkdirAll(filepath.join(installDir, "include"), 0o755)! + os.mkdirAll(filepath.join(installDir, "lib"), 0o755)! + exec! "cp", "-R", filepath.join(stagingDir, "include")+"/.", filepath.join(installDir, "include") + exec! "cp", "-R", filepath.join(stagingDir, "lib")+"/.", filepath.join(installDir, "lib") + for path in filepath.glob(filepath.join(installDir, "lib", "*.la"))! { + os.remove(path)! + } + if shared && osName == "darwin" { + // libtool records the temporary staging prefix in the Darwin install + // name; make the published dylib relocatable for package consumers. + dylib := filepath.join(installDir, "lib", "libhunspell-1.7.0.dylib") + exec! "install_name_tool", "-id", "@rpath/libhunspell-1.7.0.dylib", dylib + } + os.removeAll(stagingDir)! + } + + licenseDir := filepath.join(installDir, "licenses") + os.mkdirAll(licenseDir, 0o755)! + for name in ["COPYING", "COPYING.LESSER", "COPYING.MPL", "license.hunspell"] { + os.writeFile(filepath.join(licenseDir, name), os.readFile(filepath.join(ctx.SourceDir, name))!, 0o644)! + } + + cflags := ["-I$${includedir}"] + if !shared { + cflags <- "-DHUNSPELL_STATIC" + } + + pcDir := filepath.join(installDir, "lib", "pkgconfig") + os.mkdirAll(pcDir, 0o755)! + pc := pkgconfig.new( + name = "hunspell", + description = "Hunspell spellchecking library", + version = "v1.7.0", + libs = ["-L$${libdir}", "-l"+libName], + cflags = cflags, + )! + out := os.create(filepath.join(pcDir, "hunspell.pc"))! + pc.writeTo(out)! + out.close()! + + pkgconfig.use installDir + ctx.setMetadata pkgconfig.lookup("hunspell")! +} + +onTest ctx => { + installDir := ctx.outputDir + testDir := filepath.join(ctx.SourceDir, "_llar_consumer") + os.mkdirAll(testDir, 0o755)! + + consumer := filepath.join(testDir, "consumer.cxx") + os.writeFile(consumer, []byte(consumerSource), 0o644)! + + pkgconfig.use installDir + flagsFile := filepath.join(testDir, "hunspell.flags") + os.writeFile(flagsFile, []byte(pkgconfig.lookup("hunspell")!), 0o644)! + + binary := filepath.join(testDir, "consumer") + exec! "c++", 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"))! + if slices.contains(target.require["os"], "windows") { + path := os.getenv("PATH") + os.setenv("PATH", filepath.join(installDir, "bin")+";"+path)! + } + } + exec! binary +} diff --git a/hunspell/hunspell/versions.json b/hunspell/hunspell/versions.json new file mode 100644 index 0000000..dc6abbb --- /dev/null +++ b/hunspell/hunspell/versions.json @@ -0,0 +1,4 @@ +{ + "path": "hunspell/hunspell", + "deps": {} +}