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
11 changes: 11 additions & 0 deletions dougbinks/enkiTS/enkits_cmp.gox
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.",

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] Comparator is a no-op and its comment is inaccurate

normalize strips the v prefix, and compareVer immediately re-adds it ("v"+normalize(...)), so for v1.12 the round-trip returns the input unchanged — this comparator is behaviorally identical to the default semver.Compare(a.Version, b.Version).

The comment's premise is also wrong: semver.Compare parses 1.12 as minor 12 and 1.9 as minor 9, so it already orders v1.12 > v1.9 correctly. The described "GNU compares the first digit" failure does not apply here. Unlike Cglm_cmp.gox (adds v only when missing) or chaiscript_cmp.gox (remaps alias tags), enkiTS has a uniform v1.0 .. v1.12 tag set with no irregularity.

Consider removing enkits_cmp.gox entirely (rely on the default comparator), or if a custom one is required, drop the strip/re-add and fix the comment.

// 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

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like LLM got dumb

130 changes: 130 additions & 0 deletions dougbinks/enkiTS/v1.12/enkits_llar.gox
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

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] Unsafe [0] index on target.options may panic

target.options["shared"][0] / target.options["fPIC"][0] index element [0] directly, which panics if the option slice is ever empty. Every sibling formula (streamvbyte, neco) uses the panic-safe slices.contains(target.options["shared"], "ON") instead — and this file already imports slices. Same pattern recurs in onTest (line 125). defaults guarantees a value in the normal flow, but the slices.contains form is the safer, consistent convention.


cmakeLists := filepath.join(ctx.SourceDir, "CMakeLists.txt")
source := string(os.readFile(cmakeLists)!)

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] Magic -DENKITS_TASK_PRIORITIES_NUM=3 is unexplained

The .pc Cflags hardcode -DENKITS_TASK_PRIORITIES_NUM=3, but this value is not passed to the library build via c.define. If the built library used a different (default) value, consumers compiling with =3 risk a compile-time-constant/ABI mismatch. Add a brief comment explaining why 3, and confirm it matches the value the installed library was built with.

// 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)

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] Brittle CMakeLists replace can silently no-op

This strings.replace(..., 1) matches an exact literal with hardcoded 8-space indentation. If upstream reformats the install rule, the replace silently no-ops and shared objects / DLLs are omitted from the install with no error. streamvbyte guards its equivalent mutation with a strings.contains(...) check. Consider asserting the replacement actually occurred (compare pre/post and panic if unchanged) so an upstream format change fails loudly.

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") {

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] CMakeLists.txt read twice (second read is post-mutation)

CMakeLists.txt is read into source (line 47), mutated, and written back (line 51); then re-read here to extract the version. The version line (project(... VERSION ...)) is untouched by the ARCHIVE/LIBRARY replace, so you can iterate over the already-in-memory source (for line in source.split("\n")) and drop the second os.readFile. streamvbyte reads once and reuses.

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
}
4 changes: 4 additions & 0 deletions dougbinks/enkiTS/versions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"path": "dougbinks/enkiTS",
"deps": {}
}
Loading