Skip to content
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
134 changes: 134 additions & 0 deletions Auburn/FastNoise2/v1.1.1/fastnoise2_llar.gox
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
import (
"os"
"path/filepath"
"slices"
)

const consumerSource = `#include "FastNoise/FastNoise.h"

int main() {
auto gen = FastNoise::New<FastNoise::Simplex>();
if (!gen) {
return 1;
}
(void)gen->GenSingle2D(0.5f, 0.5f, 1337);
return 0;
}
`

id "Auburn/FastNoise2"

fromVer "v1.1.1"

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"

c := cmake.new(ctx.SourceDir, filepath.join(ctx.SourceDir, "_build"), installDir)

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] No CMake build type set — ships an unoptimized SIMD library

The build never sets a build type (no c.buildType "Release"), and upstream's CMakeLists.txt does not default CMAKE_BUILD_TYPE. On single-config generators (Make/Ninja) that means the compiler runs at -O0 with no -DNDEBUG. For FastNoise2 — a template/SIMD library whose entire value is runtime performance — this ships a dramatically slower artifact. Sibling recipes such as Amanieu/asyncplusplus/v1.0/asyncplusplus_llar.gox:42 set c.buildType "Release" right after cmake.new. Recommend adding c.buildType "Release" here.

c.define "CMAKE_INSTALL_LIBDIR", "lib"
c.define "CMAKE_CXX_STANDARD", "17"
c.defineBool "BUILD_SHARED_LIBS", shared
c.defineBool "CMAKE_POSITION_INDEPENDENT_CODE", fPIC
c.defineBool "FASTNOISE2_TOOLS", false
c.defineBool "FASTNOISE2_TESTS", false
c.defineBool "FASTNOISE2_UTILITY", false
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)!

version := ""
for line in string(os.readFile(filepath.join(ctx.SourceDir, "CMakeLists.txt"))!).split("\n") {
if line.hasPrefix("project(FastNoise2 VERSION ") {
version = line.trimPrefix("project(FastNoise2 VERSION ").split(")")[0]

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.

[P3] Fragile version parse via split(")")[0]

For the exact v1.1.1 line project(FastNoise2 VERSION 1.1.1) this yields 1.1.1 correctly. But it assumes nothing follows the version before ). A future tag like project(FastNoise2 VERSION 1.1.1 LANGUAGES CXX) would capture 1.1.1 LANGUAGES CXX into the Version: field. intel/libipt tokenizes with strings.fields for robustness. Low risk while fromVer pins a single version — worth hardening or adding a note on the assumption.

break
}
}
if version == "" {
panic "FastNoise2 CMakeLists.txt has no project version"
}

libName := "FastNoise"
for entry in os.readDir(filepath.join(installDir, "lib"))! {
if entry.isDir {
continue
}
name := entry.name
if name.hasPrefix("libFastNoiseD.") || name.hasPrefix("FastNoiseD.") {
libName = "FastNoiseD"
break
}
}
Comment on lines +74 to +84

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.

[P2] FastNoiseD debug-suffix detection is effectively dead code

Upstream applies the D suffix via set_target_properties(... DEBUG_POSTFIX D), which only takes effect for a Debug configuration. Because this recipe never selects a Debug build type, the installed library is always libFastNoise.*, so this loop can never match and libName stays "FastNoise". As written it reads as if it handles a real case but is unreachable. Either drop the loop for simplicity, or — if Debug is meant to be supported — drive the build type from an option and add a comment explaining when this branch triggers. (Closely tied to the missing-build-type finding above.)


cflags := "-I$${includedir}"
if !shared {
cflags += " -DFASTNOISE_STATIC_LIB"
}
libs := "-L$${libdir} -l" + libName
if slices.contains(target.require["os"], "linux") {
libs += " -lm"
}

pcDir := filepath.join(installDir, "lib", "pkgconfig")
os.mkdirAll(pcDir, 0o755)!
pc := `prefix=$${pcfiledir}/../..
exec_prefix=$${prefix}
libdir=$${prefix}/lib
includedir=$${prefix}/include

Name: FastNoise2
Description: Modular node graph based noise generation library using SIMD, C++17 and templates

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.

[P2] pkg-config Description misstates the upstream tagline

Upstream describes itself as "Modular node based noise generation library using SIMD, focused on performance, modern C++17...". This line invents "node graph based" and appends "and templates," wording upstream does not use. The Description: field is operator-facing (pkg-config --description). Recommend matching the upstream README tagline verbatim.

Version: ` + version + `
Libs: ` + libs + `
Cflags: ` + cflags + `
`
os.writeFile(filepath.join(pcDir, "FastNoise2.pc"), []byte(pc), 0o644)!

pkgconfig.use installDir
ctx.setMetadata pkgconfig.lookup("FastNoise2")!
}

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, "FastNoise2.flags")
os.writeFile(flagsFile, []byte(pkgconfig.lookup("FastNoise2")!), 0o644)!

binary := filepath.join(testDir, "consumer")
exec! "c++", "-std=c++17", 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
}
4 changes: 4 additions & 0 deletions Auburn/FastNoise2/versions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"path": "Auburn/FastNoise2",
"deps": {}
}
Loading