From dd460a629661e2bce582ec03da98b4a0d2b8a36d Mon Sep 17 00:00:00 2001 From: Rick Guo Date: Thu, 10 Sep 2026 11:12:52 +0800 Subject: [PATCH] formula: add Cyan4973/xxHash --- Cyan4973/xxHash/v0.8.0/xxhash_llar.gox | 115 ++++++++++++++++++++++++ Cyan4973/xxHash/v0.8.1/xxhash_llar.gox | 118 +++++++++++++++++++++++++ Cyan4973/xxHash/v0.8.2/xxhash_llar.gox | 108 ++++++++++++++++++++++ Cyan4973/xxHash/v0.8.3/xxhash_llar.gox | 107 ++++++++++++++++++++++ Cyan4973/xxHash/versions.json | 4 + 5 files changed, 452 insertions(+) create mode 100644 Cyan4973/xxHash/v0.8.0/xxhash_llar.gox create mode 100644 Cyan4973/xxHash/v0.8.1/xxhash_llar.gox create mode 100644 Cyan4973/xxHash/v0.8.2/xxhash_llar.gox create mode 100644 Cyan4973/xxHash/v0.8.3/xxhash_llar.gox create mode 100644 Cyan4973/xxHash/versions.json diff --git a/Cyan4973/xxHash/v0.8.0/xxhash_llar.gox b/Cyan4973/xxHash/v0.8.0/xxhash_llar.gox new file mode 100644 index 0000000..1ca183c --- /dev/null +++ b/Cyan4973/xxHash/v0.8.0/xxhash_llar.gox @@ -0,0 +1,115 @@ +import ( + "os" + "path/filepath" + "slices" +) + +const consumerSource = `#include "xxhash.h" + +#include +#include + + +int main() +{ + size_t const bufferSize = 10; + void* const buffer = malloc(bufferSize); + XXH64_hash_t hash = XXH64(buffer, bufferSize, 0); + printf("%llu", hash); + free(buffer); + return 0; +} +` + +id "Cyan4973/xxHash" + +fromVer "v0.8.0" + +defaults { + "shared": "OFF", + "fPIC": "ON", + "utility": "ON", +} + +filter => { + if !slices.contains(target.require["os"], "linux") && !slices.contains(target.require["os"], "darwin") { + return false + } + if !slices.contains(target.require["arch"], "amd64") && !slices.contains(target.require["arch"], "arm64") { + return false + } + for name, values in target.options { + if name != "shared" && name != "fPIC" && name != "utility" { + 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" + utility := target.options["utility"][0] == "ON" + + c := cmake.new( + filepath.join(ctx.SourceDir, "cmake_unofficial"), + filepath.join(ctx.SourceDir, "_build"), + installDir, + ) + c.define "CMAKE_INSTALL_LIBDIR", "lib" + c.define "CMAKE_POLICY_VERSION_MINIMUM", "3.5" + c.defineBool "BUILD_SHARED_LIBS", shared + c.defineBool "CMAKE_POSITION_INDEPENDENT_CODE", fPIC + c.defineBool "XXHASH_BUILD_XXHSUM", utility + c.configure + c.build + c.install + + licenseDir := filepath.join(installDir, "licenses") + os.mkdirAll(licenseDir, 0o755)! + os.writeFile(filepath.join(licenseDir, "LICENSE"), os.readFile(filepath.join(ctx.SourceDir, "LICENSE"))!, 0o644)! + + pcDir := filepath.join(installDir, "lib", "pkgconfig") + os.mkdirAll(pcDir, 0o755)! + pc := pkgconfig.new( + name = "xxhash", + description = "extremely fast hash algorithm", + version = "0.8.0", + libs = ["-L$${libdir}", "-lxxhash"], + cflags = ["-I$${includedir}"], + )! + out := os.create(filepath.join(pcDir, "libxxhash.pc"))! + pc.writeTo(out)! + out.close()! + + pkgconfig.use installDir + ctx.setMetadata pkgconfig.lookup("libxxhash")! +} + +onTest ctx => { + installDir := ctx.outputDir + testDir := filepath.join(ctx.SourceDir, "_llar_consumer") + os.mkdirAll(testDir, 0o755)! + + consumer := filepath.join(testDir, "consumer.c") + os.writeFile(consumer, []byte(consumerSource), 0o644)! + + pkgconfig.use installDir + flagsFile := filepath.join(testDir, "libxxhash.flags") + os.writeFile(flagsFile, []byte(pkgconfig.lookup("libxxhash")!), 0o644)! + + binary := filepath.join(testDir, "consumer") + cc! consumer, "@"+flagsFile, "-o", binary + + 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/Cyan4973/xxHash/v0.8.1/xxhash_llar.gox b/Cyan4973/xxHash/v0.8.1/xxhash_llar.gox new file mode 100644 index 0000000..7997540 --- /dev/null +++ b/Cyan4973/xxHash/v0.8.1/xxhash_llar.gox @@ -0,0 +1,118 @@ +import ( + "os" + "path/filepath" + "slices" + "strings" +) + +const consumerSource = `#include "xxhash.h" + +#include +#include + + +int main() +{ + size_t const bufferSize = 10; + void* const buffer = malloc(bufferSize); + XXH64_hash_t hash = XXH64(buffer, bufferSize, 0); + printf("%llu", hash); + free(buffer); + return 0; +} +` + +id "Cyan4973/xxHash" + +fromVer "v0.8.1" + +defaults { + "shared": "OFF", + "fPIC": "ON", + "utility": "ON", +} + +filter => { + if !slices.contains(target.require["os"], "linux") && !slices.contains(target.require["os"], "darwin") { + return false + } + if !slices.contains(target.require["arch"], "amd64") && !slices.contains(target.require["arch"], "arm64") { + return false + } + for name, values in target.options { + if name != "shared" && name != "fPIC" && name != "utility" { + 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, "cmake_unofficial", "CMakeLists.txt") + source := string(os.readFile(cmakeLists)!) + source = strings.replace(source, "install(FILES \"$${XXHASH_DIR}/xxhsum.1\"", "install(FILES \"$${XXHSUM_DIR}/xxhsum.1\"", 1) + os.writeFile(cmakeLists, []byte(source), 0o644)! + + header := filepath.join(ctx.SourceDir, "xxhash.h") + source = string(os.readFile(header)!) + source = strings.replace(source, "# include \n# define XXH_STATIC_ASSERT_WITH_MESSAGE(c,m) do { static_assert((c),m); } while(0)", "# define XXH_STATIC_ASSERT_WITH_MESSAGE(c,m) do { _Static_assert((c),m); } while(0)", 1) + os.writeFile(header, []byte(source), 0o644)! + + shared := target.options["shared"][0] == "ON" + fPIC := target.options["fPIC"][0] == "ON" + utility := target.options["utility"][0] == "ON" + + c := cmake.new( + filepath.join(ctx.SourceDir, "cmake_unofficial"), + filepath.join(ctx.SourceDir, "_build"), + installDir, + ) + c.define "CMAKE_INSTALL_LIBDIR", "lib" + c.define "CMAKE_POLICY_VERSION_MINIMUM", "3.5" + c.defineBool "BUILD_SHARED_LIBS", shared + c.defineBool "CMAKE_POSITION_INDEPENDENT_CODE", fPIC + c.defineBool "XXHASH_BUILD_XXHSUM", utility + c.configure + c.build + c.install + + licenseDir := filepath.join(installDir, "licenses") + os.mkdirAll(licenseDir, 0o755)! + os.writeFile(filepath.join(licenseDir, "LICENSE"), os.readFile(filepath.join(ctx.SourceDir, "LICENSE"))!, 0o644)! + + pcPath := filepath.join(installDir, "lib", "pkgconfig", "libxxhash.pc") + pc := string(os.readFile(pcPath)!) + pc = strings.replace(pc, "prefix="+installDir, "prefix=$${pcfiledir}/../..", 1) + os.writeFile(pcPath, []byte(pc), 0o644)! + + pkgconfig.use installDir + ctx.setMetadata pkgconfig.lookup("libxxhash")! +} + +onTest ctx => { + installDir := ctx.outputDir + testDir := filepath.join(ctx.SourceDir, "_llar_consumer") + os.mkdirAll(testDir, 0o755)! + + consumer := filepath.join(testDir, "consumer.c") + os.writeFile(consumer, []byte(consumerSource), 0o644)! + + pkgconfig.use installDir + flagsFile := filepath.join(testDir, "libxxhash.flags") + os.writeFile(flagsFile, []byte(pkgconfig.lookup("libxxhash")!), 0o644)! + + binary := filepath.join(testDir, "consumer") + cc! consumer, "@"+flagsFile, "-o", binary + + 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/Cyan4973/xxHash/v0.8.2/xxhash_llar.gox b/Cyan4973/xxHash/v0.8.2/xxhash_llar.gox new file mode 100644 index 0000000..0441b7b --- /dev/null +++ b/Cyan4973/xxHash/v0.8.2/xxhash_llar.gox @@ -0,0 +1,108 @@ +import ( + "os" + "path/filepath" + "slices" + "strings" +) + +const consumerSource = `#include "xxhash.h" + +#include +#include + + +int main() +{ + size_t const bufferSize = 10; + void* const buffer = malloc(bufferSize); + XXH64_hash_t hash = XXH64(buffer, bufferSize, 0); + printf("%llu", hash); + free(buffer); + return 0; +} +` + +id "Cyan4973/xxHash" + +fromVer "v0.8.2" + +defaults { + "shared": "OFF", + "fPIC": "ON", + "utility": "ON", +} + +filter => { + if !slices.contains(target.require["os"], "linux") && !slices.contains(target.require["os"], "darwin") { + return false + } + if !slices.contains(target.require["arch"], "amd64") && !slices.contains(target.require["arch"], "arm64") { + return false + } + for name, values in target.options { + if name != "shared" && name != "fPIC" && name != "utility" { + 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" + utility := target.options["utility"][0] == "ON" + + c := cmake.new( + filepath.join(ctx.SourceDir, "cmake_unofficial"), + filepath.join(ctx.SourceDir, "_build"), + installDir, + ) + c.define "CMAKE_INSTALL_LIBDIR", "lib" + c.define "CMAKE_POLICY_VERSION_MINIMUM", "3.5" + c.defineBool "BUILD_SHARED_LIBS", shared + c.defineBool "CMAKE_POSITION_INDEPENDENT_CODE", fPIC + c.defineBool "XXHASH_BUILD_XXHSUM", utility + c.configure + c.build + c.install + + licenseDir := filepath.join(installDir, "licenses") + os.mkdirAll(licenseDir, 0o755)! + os.writeFile(filepath.join(licenseDir, "LICENSE"), os.readFile(filepath.join(ctx.SourceDir, "LICENSE"))!, 0o644)! + + pcPath := filepath.join(installDir, "lib", "pkgconfig", "libxxhash.pc") + pc := string(os.readFile(pcPath)!) + pc = strings.replace(pc, "prefix="+installDir, "prefix=$${pcfiledir}/../..", 1) + os.writeFile(pcPath, []byte(pc), 0o644)! + + pkgconfig.use installDir + ctx.setMetadata pkgconfig.lookup("libxxhash")! +} + +onTest ctx => { + installDir := ctx.outputDir + testDir := filepath.join(ctx.SourceDir, "_llar_consumer") + os.mkdirAll(testDir, 0o755)! + + consumer := filepath.join(testDir, "consumer.c") + os.writeFile(consumer, []byte(consumerSource), 0o644)! + + pkgconfig.use installDir + flagsFile := filepath.join(testDir, "libxxhash.flags") + os.writeFile(flagsFile, []byte(pkgconfig.lookup("libxxhash")!), 0o644)! + + binary := filepath.join(testDir, "consumer") + cc! consumer, "@"+flagsFile, "-o", binary + + 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/Cyan4973/xxHash/v0.8.3/xxhash_llar.gox b/Cyan4973/xxHash/v0.8.3/xxhash_llar.gox new file mode 100644 index 0000000..f0a4c4d --- /dev/null +++ b/Cyan4973/xxHash/v0.8.3/xxhash_llar.gox @@ -0,0 +1,107 @@ +import ( + "os" + "path/filepath" + "slices" + "strings" +) + +const consumerSource = `#include "xxhash.h" + +#include +#include + + +int main() +{ + size_t const bufferSize = 10; + void* const buffer = malloc(bufferSize); + XXH64_hash_t hash = XXH64(buffer, bufferSize, 0); + printf("%llu", hash); + free(buffer); + return 0; +} +` + +id "Cyan4973/xxHash" + +fromVer "v0.8.3" + +defaults { + "shared": "OFF", + "fPIC": "ON", + "utility": "ON", +} + +filter => { + if !slices.contains(target.require["os"], "linux") && !slices.contains(target.require["os"], "darwin") { + return false + } + if !slices.contains(target.require["arch"], "amd64") && !slices.contains(target.require["arch"], "arm64") { + return false + } + for name, values in target.options { + if name != "shared" && name != "fPIC" && name != "utility" { + 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" + utility := target.options["utility"][0] == "ON" + + c := cmake.new( + filepath.join(ctx.SourceDir, "cmake_unofficial"), + filepath.join(ctx.SourceDir, "_build"), + installDir, + ) + c.define "CMAKE_INSTALL_LIBDIR", "lib" + c.defineBool "BUILD_SHARED_LIBS", shared + c.defineBool "CMAKE_POSITION_INDEPENDENT_CODE", fPIC + c.defineBool "XXHASH_BUILD_XXHSUM", utility + c.configure + c.build + c.install + + licenseDir := filepath.join(installDir, "licenses") + os.mkdirAll(licenseDir, 0o755)! + os.writeFile(filepath.join(licenseDir, "LICENSE"), os.readFile(filepath.join(ctx.SourceDir, "LICENSE"))!, 0o644)! + + pcPath := filepath.join(installDir, "lib", "pkgconfig", "libxxhash.pc") + pc := string(os.readFile(pcPath)!) + pc = strings.replace(pc, "prefix="+installDir, "prefix=$${pcfiledir}/../..", 1) + os.writeFile(pcPath, []byte(pc), 0o644)! + + pkgconfig.use installDir + ctx.setMetadata pkgconfig.lookup("libxxhash")! +} + +onTest ctx => { + installDir := ctx.outputDir + testDir := filepath.join(ctx.SourceDir, "_llar_consumer") + os.mkdirAll(testDir, 0o755)! + + consumer := filepath.join(testDir, "consumer.c") + os.writeFile(consumer, []byte(consumerSource), 0o644)! + + pkgconfig.use installDir + flagsFile := filepath.join(testDir, "libxxhash.flags") + os.writeFile(flagsFile, []byte(pkgconfig.lookup("libxxhash")!), 0o644)! + + binary := filepath.join(testDir, "consumer") + cc! consumer, "@"+flagsFile, "-o", binary + + 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/Cyan4973/xxHash/versions.json b/Cyan4973/xxHash/versions.json new file mode 100644 index 0000000..b9b372d --- /dev/null +++ b/Cyan4973/xxHash/versions.json @@ -0,0 +1,4 @@ +{ + "path": "Cyan4973/xxHash", + "deps": {} +}