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: Cyan4973/xxHash #511
Open
MeteorsLiu
wants to merge
1
commit into
xgo-dev:main
Choose a base branch
from
MeteorsLiu:issue/244-xxhash-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
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,115 @@ | ||
| import ( | ||
| "os" | ||
| "path/filepath" | ||
| "slices" | ||
| ) | ||
|
|
||
| const consumerSource = `#include "xxhash.h" | ||
|
|
||
| #include <stdio.h> | ||
| #include <stdlib.h> | ||
|
|
||
|
|
||
| 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 | ||
| } | ||
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,118 @@ | ||
| import ( | ||
| "os" | ||
| "path/filepath" | ||
| "slices" | ||
| "strings" | ||
| ) | ||
|
|
||
| const consumerSource = `#include "xxhash.h" | ||
|
|
||
| #include <stdio.h> | ||
| #include <stdlib.h> | ||
|
|
||
|
|
||
| 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" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [P1] Avoid changing multiple Formula directories in one PR Adding this second threshold (together with v0.8.2 and v0.8.3) makes the repository's |
||
|
|
||
| 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 <assert.h>\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 | ||
| } | ||
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,108 @@ | ||
| import ( | ||
| "os" | ||
| "path/filepath" | ||
| "slices" | ||
| "strings" | ||
| ) | ||
|
|
||
| const consumerSource = `#include "xxhash.h" | ||
|
|
||
| #include <stdio.h> | ||
| #include <stdlib.h> | ||
|
|
||
|
|
||
| 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 | ||
| } |
Oops, something went wrong.
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] Preserve CMP0042 for pre-0.8.3 shared Darwin builds
For v0.8.0 through v0.8.2, upstream declares CMake 2.8.12, so under CMake 3.x CMP0042 remains OLD;
CMAKE_POLICY_VERSION_MINIMUMis ignored there (the focused build emits the unused-variable warning). Withshared=ONon Darwin this disables the@rpathinstall name and embeds the build machine's absolute install prefix in the dylib. LLAR archives that output and restores it under another user's workspace, so cached/shared consumers can no longer load the library. The pinned Conan recipe setsCMAKE_POLICY_DEFAULT_CMP0042=NEWfor this reason; add that definition to the v0.8.0, v0.8.1, and v0.8.2 recipes (v0.8.3's CMake 3.10 minimum already selects NEW behavior).