Skip to content
This repository was archived by the owner on Sep 20, 2026. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
115 changes: 115 additions & 0 deletions Cyan4973/xxHash/v0.8.0/xxhash_llar.gox
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"

Copy link
Copy Markdown
Contributor

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_MINIMUM is ignored there (the focused build emits the unused-variable warning). With shared=ON on Darwin this disables the @rpath install 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 sets CMAKE_POLICY_DEFAULT_CMP0042=NEW for 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).

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
}
118 changes: 118 additions & 0 deletions Cyan4973/xxHash/v0.8.1/xxhash_llar.gox
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"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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 find_changed_modules.gsh collect four Formula directories for Cyan4973/xxHash; that script explicitly panics whenever a module changes more than one directory because CI can test only one fromVer range. Consequently the required Find changed modules job cannot produce a test matrix for this diff. Please either land the thresholds in sequential PRs or first extend the validation workflow so every changed range is exercised.


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
}
108 changes: 108 additions & 0 deletions Cyan4973/xxHash/v0.8.2/xxhash_llar.gox
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
}
Loading
Loading