-
Notifications
You must be signed in to change notification settings - Fork 2
feat(chaiscript): add LLAR formula #130
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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-") | ||
| } | ||
| if version == "Test_Release" { | ||
| return "v5.7.2" | ||
|
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.
|
||
| } | ||
| if version == "wasm-latest" { | ||
| return "v6.1.0-0" | ||
| } | ||
| return version | ||
| } | ||
|
|
||
| compareVer (a, b) => { | ||
| return semver.Compare(normalize(a.Version), normalize(b.Version)) | ||
| } | ||
| 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. | ||
|
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. Comment/code mismatch: this says "published by the Conan package," but the code reads |
||
| 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) | ||
|
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. Verify the Whether the written bytes are |
||
| 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! | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| { | ||
| "path": "ChaiScript/ChaiScript", | ||
|
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. Indentation nit: existing |
||
| "deps": {} | ||
| } | ||
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.
Distinct tags collapse to equality — comparator is not a total order.
Upstream has both
Release-X.Y.ZandvX.Y.Zfor 21 versions (e.g.Release-1.0.0andv1.0.0, up throughRelease-5.2.0/v5.2.0). Stripping theRelease-prefix maps eachRelease-X.Y.Zonto the identical stringvX.Y.Z, sosemver.Compare(normalize(a), normalize(b))returns0for 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 (includingfromVer "v5.0.0", which collides withRelease-5.0.0) nondeterministic. Consider a stable tie-break so the two spellings order consistently rather than comparing equal, and validate againstfromVerand the version immediately below it.