-
Notifications
You must be signed in to change notification settings - Fork 2
formula: dougbinks/enkiTS #201
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,11 @@ | ||
| import "strings" | ||
|
|
||
| // Complete tag set: v1.0 .. v1.12. GNU compares the first digit after "v1.", | ||
| // so v1.9 > v1.12. Strip the prefix, then compare the remainder as semver. | ||
| func normalize(version string) string { | ||
| return strings.trimPrefix(version, "v") | ||
| } | ||
|
|
||
| compareVer (a, b) => { | ||
| return semver.Compare("v"+normalize(a.Version), "v"+normalize(b.Version)) | ||
| } | ||
|
Comment on lines
+5
to
+11
Collaborator
Author
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. Seems like LLM got dumb |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,130 @@ | ||
| import ( | ||
| "os" | ||
| "path/filepath" | ||
| "slices" | ||
| "strings" | ||
| ) | ||
|
|
||
| const consumerSource = `#include <enkiTS/TaskScheduler_c.h> | ||
|
|
||
| int main(void) { | ||
| enkiTaskScheduler* pTS = enkiNewTaskScheduler(); | ||
| enkiInitTaskScheduler(pTS); | ||
| enkiDeleteTaskScheduler(pTS); | ||
| return 0; | ||
| } | ||
| ` | ||
|
|
||
| id "dougbinks/enkiTS" | ||
|
|
||
| fromVer "v1.12" | ||
|
|
||
| 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" | ||
|
Comment on lines
+43
to
+44
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. [P2] Unsafe [0] index on target.options may panic
|
||
|
|
||
| cmakeLists := filepath.join(ctx.SourceDir, "CMakeLists.txt") | ||
| source := string(os.readFile(cmakeLists)!) | ||
|
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. [P3] Magic -DENKITS_TASK_PRIORITIES_NUM=3 is unexplained The |
||
| // v1.12 names only ARCHIVE, so ELF shared objects and Windows DLLs are | ||
| // omitted from install. Keep the export while installing every artifact. | ||
| source = strings.replace(source, " ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})", " ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}\n LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}\n RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})", 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. [P3] Brittle CMakeLists replace can silently no-op This |
||
| os.writeFile(cmakeLists, []byte(source), 0o644)! | ||
|
|
||
| c := cmake.new(ctx.SourceDir, filepath.join(ctx.SourceDir, "_build"), installDir) | ||
| c.define "CMAKE_INSTALL_LIBDIR", "lib" | ||
| c.defineBool "ENKITS_INSTALL", true | ||
| c.defineBool "ENKITS_BUILD_EXAMPLES", false | ||
| c.defineBool "ENKITS_BUILD_SHARED", shared | ||
| c.defineBool "CMAKE_POSITION_INDEPENDENT_CODE", fPIC | ||
| c.configure | ||
| c.build | ||
| c.install | ||
|
|
||
| licenseDir := filepath.join(installDir, "licenses") | ||
| os.mkdirAll(licenseDir, 0o755)! | ||
| os.writeFile(filepath.join(licenseDir, "License.txt"), os.readFile(filepath.join(ctx.SourceDir, "License.txt"))!, 0o644)! | ||
|
|
||
| version := "" | ||
| for line in string(os.readFile(filepath.join(ctx.SourceDir, "CMakeLists.txt"))!).split("\n") { | ||
|
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. [P3] CMakeLists.txt read twice (second read is post-mutation)
|
||
| trimmed := line.trimSpace | ||
| if trimmed.hasPrefix("VERSION ") { | ||
| version = strings.trim(trimmed.trimPrefix("VERSION "), `"`) | ||
| break | ||
| } | ||
| } | ||
| if version == "" { | ||
| panic "enkiTS CMakeLists.txt has no project version" | ||
| } | ||
|
|
||
| libs := "-L$${libdir} -lenkiTS" | ||
| if slices.contains(target.require["os"], "linux") || slices.contains(target.require["os"], "freebsd") { | ||
| libs += " -lm -lpthread -lstdc++" | ||
| } else { | ||
| libs += " -lc++" | ||
| } | ||
|
|
||
| cflags := "-I$${includedir} -DENKITS_TASK_PRIORITIES_NUM=3" | ||
| if shared { | ||
| cflags += " -DENKITS_DLL=1" | ||
| } | ||
|
|
||
| pcDir := filepath.join(installDir, "lib", "pkgconfig") | ||
| os.mkdirAll(pcDir, 0o755)! | ||
| pc := `prefix=$${pcfiledir}/../.. | ||
| exec_prefix=$${prefix} | ||
| libdir=$${prefix}/lib | ||
| includedir=$${prefix}/include | ||
|
|
||
| Name: enkiTS | ||
| Description: A C and C++ task scheduler for creating parallel programs | ||
| Version: ` + version + ` | ||
| Libs: ` + libs + ` | ||
| Cflags: ` + cflags + ` | ||
| ` | ||
| os.writeFile(filepath.join(pcDir, "enkiTS.pc"), []byte(pc), 0o644)! | ||
|
|
||
| pkgconfig.use installDir | ||
| ctx.setMetadata pkgconfig.lookup("enkiTS")! | ||
| } | ||
|
|
||
| onTest ctx => { | ||
| installDir := ctx.outputDir | ||
| testDir := filepath.join(ctx.SourceDir, "_llar_consumer") | ||
| os.mkdirAll(testDir, 0o755)! | ||
|
|
||
| sourcePath := filepath.join(testDir, "consumer.c") | ||
| os.writeFile(sourcePath, []byte(consumerSource), 0o644)! | ||
|
|
||
| pkgconfig.use installDir | ||
| flagsFile := filepath.join(testDir, "enkiTS.flags") | ||
| os.writeFile(flagsFile, []byte(pkgconfig.lookup("enkiTS")!), 0o644)! | ||
|
|
||
| binary := filepath.join(testDir, "consumer") | ||
| cc! sourcePath, "-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 | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| { | ||
| "path": "dougbinks/enkiTS", | ||
| "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.
[P2] Comparator is a no-op and its comment is inaccurate
normalizestrips thevprefix, andcompareVerimmediately re-adds it ("v"+normalize(...)), so forv1.12the round-trip returns the input unchanged — this comparator is behaviorally identical to the defaultsemver.Compare(a.Version, b.Version).The comment's premise is also wrong:
semver.Compareparses1.12as minor 12 and1.9as minor 9, so it already ordersv1.12 > v1.9correctly. The described "GNU compares the first digit" failure does not apply here. UnlikeCglm_cmp.gox(addsvonly when missing) orchaiscript_cmp.gox(remaps alias tags), enkiTS has a uniformv1.0 .. v1.12tag set with no irregularity.Consider removing
enkits_cmp.goxentirely (rely on the default comparator), or if a custom one is required, drop the strip/re-add and fix the comment.