Skip to content

feat(libschrift): add LLAR formula - #143

Open
MeteorsLiu wants to merge 1 commit into
mainfrom
issue/94-libschrift
Open

feat(libschrift): add LLAR formula#143
MeteorsLiu wants to merge 1 commit into
mainfrom
issue/94-libschrift

Conversation

@MeteorsLiu

Copy link
Copy Markdown
Collaborator

Adds a LLAR Formula for tomolt/libschrift.

  • Supports upstream tags v0.10.1 and v0.10.2 from the Conan Center recipe.
  • Builds and installs the C library with the verified CMake wrapper.
  • Publishes consumer flags and tests sft_version() against the installed artifact.

Validation: git diff --cached --check passed. Local formula tests and CI were intentionally not run per request.

@fennoai fennoai Bot left a comment

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.

Review: tomolt/libschrift recipe

A clean, well-structured new recipe that closely follows sibling conventions (cglm's defaults/filter/matrix pattern, json-c's CMAKE_INSTALL_LIBDIR "lib" layout, and a separate _llar_consumer test tree that correctly survives cache hits). Verified good: sft_version() matches upstream schrift.h v0.10.1, upstream ships a root LICENSE (ISC), and versions.json matches the sibling format.

The main theme across findings is that consumer link flags are hand-built and duplicated rather than derived from installed package metadata. formula-semantics.md prefers installing a .pc file and driving both metadata and the consumer test through a pkg-config lookup. Since this recipe already injects its own CMakeLists.txt, it is well positioned to configure_file-generate a schrift.pc; doing so would collapse the three flag-related findings below into one fix and remove the drift-prone OS/-lm logic.

Two smaller notes:

  • CMakeLists.txt:9WINDOWS_EXPORT_ALL_SYMBOLS ON auto-exports every non-static symbol rather than the curated sft_* API. Acceptable for a build recipe, but a .def/explicit export list would be tighter.
  • Comments/docs — unlike its siblings (cglm lines 35-48, json-c lines 14-34), this recipe has no explanatory comments. The single most surprising aspect — injecting a CMakeLists.txt because upstream ships only a Makefile with no CMake support — is entirely undocumented, as are the shared/fPIC option and -lm rationale. A short build-contract comment block would match repo convention. (The lowercase libschrift_llar.gox filename is correct per current docs; don't "fix" it to match the older Cglm_llar.gox-style siblings.)

Inline findings below. All are non-blocking.

if osName == "linux" || osName == "freebsd" {
metadata += " -lm"
}
ctx.setMetadata metadata

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.

Metadata is hand-built rather than derived from an installed pkg-config file. formula-semantics.md states that for C/C++ library metadata you should install a valid .pc under lib/pkgconfig and set metadata from the full pkg-config lookup, treating hand-built -I/-L/-l fragments as a fallback (see how cglm documents its fallback at lines 74-89). Since this recipe injects its own CMakeLists.txt, it can configure_file-generate a schrift.pc and use the pkg-config helper for metadata — that keeps the consumer flags synchronized with the actual install and removes the duplicated OS/-lm logic. If a hand-built string is kept intentionally (upstream ships no pkg-config), add a one-line comment saying so, as the sibling recipe does.

osName = osValues[0]
}
metadata := "-I" + filepath.join(installDir, "include") + " -L" + filepath.join(installDir, "lib") + " -lschrift"
if osName == "linux" || osName == "freebsd" {

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.

The -lm decision here is gated on osName == "linux" || "freebsd", while CMakeLists.txt:14-15 links libm whenever find_library(LIBM m) succeeds (any platform). These are two independent encodings of "does this platform need libm." For the default static build the consumer-side -lm is the load-bearing one (static archives don't record their deps), so on another Unix where libm exists but isn't in this list, the static library would build but consumers would fail to link. Deriving metadata from pkg-config (see the note at setMetadata) would keep these in sync automatically; otherwise consider aligning the two conditions and adding a comment on the intended platform contract.

}
if osName == "linux" || osName == "freebsd" {
args = append(args, "-lm")
}

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.

onTest reconstructs -I/-L/-lschrift/-lm independently (mirroring the onBuild logic at lines 64-72) rather than consuming the published metadata / installed .pc. Per formula-semantics.md, a test that rebuilds the flags does not validate the published metadata — the test can pass while the advertised metadata is wrong, so a real consumer would still break with green CI. Prefer compiling the consumer with the same flags the Formula publishes (ideally via the pkg-config lookup).


if slices.contains(target.options["shared"], "ON") {
os.setenv("LD_LIBRARY_PATH", filepath.join(installDir, "lib"))!
os.setenv("DYLD_LIBRARY_PATH", filepath.join(installDir, "lib"))!

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.

LD_LIBRARY_PATH/DYLD_LIBRARY_PATH are overwritten with only the install dir, dropping any pre-existing value. In this isolated test the risk is low, but if the environment already sets these (e.g. a toolchain lib dir) they'd be clobbered. Prefer prepending: installDir/lib + : + the existing value when one is present.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant