Skip to content

feat(drmp3): add LLAR formula - #133

Open
MeteorsLiu wants to merge 1 commit into
xgo-dev:mainfrom
MeteorsLiu:issue/105-drmp3
Open

feat(drmp3): add LLAR formula#133
MeteorsLiu wants to merge 1 commit into
xgo-dev:mainfrom
MeteorsLiu:issue/105-drmp3

Conversation

@MeteorsLiu

Copy link
Copy Markdown
Collaborator

Summary

  • add the mackron/dr_libs LLAR Formula from the Conan drmp3 recipe
  • support Conan refs 0.6.32, 0.6.34, and 0.6.38 plus current mp3 tags with verified comparator ordering
  • publish relocatable drmp3.pc metadata and validate an installed C consumer

Validation

  • llar test -v ./mackron/dr_libs@9497270f581f43e6b795ce5d98d8764861fb6a50
  • cache-hit rerun of the same command
  • llar test -v ./mackron/dr_libs@01d23df76776faccee3bc456f685900dcc273b4c
  • llar test -v ./mackron/dr_libs@mp3-0.7.3
  • installed pkg-config --cflags --libs drmp3 lookup

@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.

Code Review: dr_mp3 recipe

Overall this is a clean, well-documented recipe. The version-normalization logic, header-macro parsing, relocatable .pc generation, and the build/test separation all look correct, and it improves on the sibling cglm recipe by validating the published pkg-config metadata in onTest. The hash→version mappings and their comments were cross-checked and are internally consistent (9497270…=0.6.32, dd762b…=0.6.34, 01d23d…=0.6.38).

A few non-blocking observations are inline below. None block merge.

c := cmake.new(ctx.SourceDir, filepath.join(ctx.SourceDir, "_build"), installDir)
c.define "DRMP3_SRC_DIR", ctx.SourceDir
c.defineBool "BUILD_SHARED_LIBS", shared
c.defineBool "CMAKE_POSITION_INDEPENDENT_CODE", fPIC

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.

fPIC and shared overlap. CMAKE_POSITION_INDEPENDENT_CODE is set from fPIC unconditionally, but when BUILD_SHARED_LIBS=ON the library is always built PIC. So (shared=ON, fPIC=OFF) and (shared=ON, fPIC=ON) produce identical output — an overlapping option combination. Conan's convention is to remove/force fPIC when shared is set. Consider constraining this in filter/defaults or documenting that fPIC is a no-op when shared, to avoid two dimensions selecting the same artifact.

cflags += " -DDRMP3_DLL"
}
if noSimd {
cflags += " -DDR_MP3_NO_SIMD"

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.

Confirm -DDR_MP3_NO_SIMD belongs in consumer Cflags. In upstream dr_mp3.h, DR_MP3_NO_SIMD appears to only affect code inside the DR_MP3_IMPLEMENTATION section — it does not guard any public declarations — whereas DR_MP3_NO_STDIO does gate public APIs (e.g. drmp3_init_file). If that holds, consumers don't need -DDR_MP3_NO_SIMD to match the compiled library, and it could be dropped from the .pc Cflags (and made a PRIVATE define in CMakeLists). Worth verifying against the pinned header before changing. Harmless if left as-is.

return "v2." + strings.trimPrefix(strings.trimPrefix(version, "wav-"), "0.")
}
if strings.hasPrefix(version, "mp3-") {
return "v3." + strings.trimPrefix(strings.trimPrefix(version, "mp3-"), "0.")

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.

trimPrefix(version, "0.") is fragile for a future non-0.x line. This is correct today because every dr_libs tag is 0.x.y. But if upstream ever ships e.g. mp3-1.0.0, trimPrefix("1.0.0", "0.") is a no-op and yields v3.1.0.0, which is invalid semver and would break semver.Compare for the whole set. A guarding comment or a more robust transform would future-proof this. (Applies to the flac/wav/mp3 branches on lines 19/22/25.)

exec "cc", "-std=c99", "@"+flagsFile, consumer, "-o", binary
lastErr!

os.setenv("LD_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.

Minor: os.setenv overwrites rather than prepends. Setting LD_LIBRARY_PATH / DYLD_LIBRARY_PATH to installDir/lib replaces any pre-existing value, which could drop other library directories the shared-library test needs. Prepending to the existing value would be more robust. The value itself is recipe-controlled, so this is robustness, not security.

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