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
23 changes: 23 additions & 0 deletions ChaiScript/ChaiScript/chaiscript_cmp.gox
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import "strings"

// Stable releases use v-prefixed semantic versions, while the repository
// also keeps Release-* aliases and two named snapshots. The snapshots are
// mapped to their source-tree release lines so every visible tag is accepted
// without letting the WebAssembly-only snapshot become the default native
// build.
func normalize(version string) string {
if strings.hasPrefix(version, "Release-") {
return "v" + strings.trimPrefix(version, "Release-")

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.

Distinct tags collapse to equality — comparator is not a total order.

Upstream has both Release-X.Y.Z and vX.Y.Z for 21 versions (e.g. Release-1.0.0 and v1.0.0, up through Release-5.2.0/v5.2.0). Stripping the Release- prefix maps each Release-X.Y.Z onto the identical string vX.Y.Z, so semver.Compare(normalize(a), normalize(b)) returns 0 for each of those 21 pairs.

Per references/contract-discovery.md:63 ("distinct ordered releases do not collapse to equality") and SKILL.md:98-101, the comparator must impose a total order over the complete tag set. Ties here make selection at any threshold landing on such a pair (including fromVer "v5.0.0", which collides with Release-5.0.0) nondeterministic. Consider a stable tie-break so the two spellings order consistently rather than comparing equal, and validate against fromVer and the version immediately below it.

}
if version == "Test_Release" {
return "v5.7.2"

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.

Test_Release normalizes to a non-existent version. v5.7.2 (and Release-5.7.2) does not exist in the upstream tag set — Release-* stops at 5.3.0 and the v* line jumps from 5.8.x to 6.x. So this is a synthetic ordinal wedged between the 5.x and 6.x lines, not the "source-tree release line" the file comment (lines 4-5) claims. Please either back the mapping with evidence of the source line this snapshot actually points at, or handle/exclude the snapshot explicitly rather than assigning a fabricated semver.

}
if version == "wasm-latest" {
return "v6.1.0-0"
}
return version
}

compareVer (a, b) => {
return semver.Compare(normalize(a.Version), normalize(b.Version))
}
91 changes: 91 additions & 0 deletions ChaiScript/ChaiScript/v5.0.0/chaiscript_llar.gox
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
import (
"os"
"path/filepath"
"strings"
)

const consumerSource = `#include <chaiscript/chaiscript.hpp>
#include <iostream>
#include <cassert>

double chai_add(double i, double j)
{
return i + j;
}

int main()
{
chaiscript::ChaiScript chai({CHAI_MODULE_PATH});
chai.add(chaiscript::fun(&chai_add), "add");
const auto answer = chai.eval<double>("add(38.8, 3.2);");
assert(static_cast<int>(answer) == 42);
std::cout << "The answer is: " << answer << '\n';
}
`

id "ChaiScript/ChaiScript"

fromVer "v5.0.0"

onBuild ctx => {
installDir := ctx.outputDir

c := cmake.new(ctx.SourceDir, filepath.join(ctx.SourceDir, "_build"), installDir)
// The supported release line declares CMake 2.8; current CMake rejects
// that policy floor unless the minimum policy version is made explicit.
c.define "CMAKE_POLICY_VERSION_MINIMUM", "3.5"
c.defineBool "BUILD_TESTING", false
c.defineBool "BUILD_SAMPLES", false
c.defineBool "BUILD_MODULES", true
c.defineBool "MULTITHREAD_SUPPORT_ENABLED", true
c.configure
c.build
c.install

// v5.0.0 builds the standard-library module but omits it from the CMake
// install target; the installed `chai` executable and consumers load it
// from lib/chaiscript at runtime.
stdlib := os.readFile(filepath.join(ctx.SourceDir, "_build", "libchaiscript_stdlib.so"))!
os.writeFile(filepath.join(installDir, "lib", "chaiscript", "libchaiscript_stdlib.so"), stdlib, 0o755)!

// Keep the license published by the Conan package.

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.

Comment/code mismatch: this says "published by the Conan package," but the code reads license.txt from the upstream source tree (ctx.SourceDir) — nothing here involves Conan. Please reword to reflect the actual source.

licenseDir := filepath.join(installDir, "licenses")
os.mkdirAll(licenseDir, 0o755)!
license := os.readFile(filepath.join(ctx.SourceDir, "license.txt"))!
os.writeFile(filepath.join(licenseDir, "license.txt"), license, 0o644)!

// The upstream file embeds the build output path. Make it relocatable
// before using the installed pkg-config contract for Formula metadata.
pcPath := filepath.join(installDir, "lib", "pkgconfig", "chaiscript.pc")
pc := string(os.readFile(pcPath)!)
pc = strings.replace(pc, "prefix="+installDir, `prefix=$${pcfiledir}/../..`, 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.

Verify the $$ in the .pc prefix produces a single literal $. pkg-config expects single-dollar ${pcfiledir} in the .pc file, and it treats $$ in a .pc as an escape for a literal $ — so if the bytes written to disk are $${pcfiledir}, pkg-config collapses them to the literal text ${pcfiledir} (never expanded), leaving a broken, non-relocatable prefix.

Whether the written bytes are $$ or $ depends on how XGo/ixgo treats $ inside a backtick raw string (the style reference documents $NAME env-expansion in gsh contexts, so $$ may be the intended escape to emit one $). Please confirm by inspecting the installed chaiscript.pc after a build and running the pkg-config lookup: if the file contains prefix=${pcfiledir}/../.. and resolves correctly, this is fine; if it contains prefix=$${pcfiledir}/../.., drop one $. (The ../.. depth is correct for lib/pkgconfig/.)

os.writeFile(pcPath, []byte(pc), 0o644)!

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

onTest ctx => {
installDir := ctx.outputDir
testDir := filepath.join(ctx.SourceDir, "_llar_consumer")
os.mkdirAll(testDir, 0o755)!

consumer := filepath.join(testDir, "consumer.cpp")
modulePath := "\"" + filepath.join(installDir, "lib", "chaiscript") + "/\""
source := strings.replace(consumerSource, "CHAI_MODULE_PATH", modulePath, 1)
os.writeFile(consumer, []byte(source), 0o644)!

// Resolve the complete installed cflags-and-libs query so this test checks
// the same metadata that downstream consumers receive, including on cache
// hits where onBuild is skipped.
pkgconfig.use installDir
flags := pkgconfig.lookup("chaiscript")!
flagsFile := filepath.join(testDir, "chaiscript.flags")
os.writeFile(flagsFile, []byte(flags), 0o644)!

binary := filepath.join(testDir, "consumer")
exec "c++", "-std=c++17", "@"+flagsFile, consumer, "-o", binary
lastErr!
exec binary
lastErr!
}
4 changes: 4 additions & 0 deletions ChaiScript/ChaiScript/versions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"path": "ChaiScript/ChaiScript",

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.

Indentation nit: existing versions.json files in the store use tabs (see recp/cglm/versions.json, madler/zlib/versions.json); this one uses 2 spaces. Convert to tabs for consistency.

"deps": {}
}
Loading