Skip to content

feat(dragonbox): add LLAR formula - #126

Open
MeteorsLiu wants to merge 1 commit into
xgo-dev:mainfrom
MeteorsLiu:issue/111-dragonbox
Open

feat(dragonbox): add LLAR formula#126
MeteorsLiu wants to merge 1 commit into
xgo-dev:mainfrom
MeteorsLiu:issue/111-dragonbox

Conversation

@MeteorsLiu

Copy link
Copy Markdown
Collaborator

Add an LLAR Formula for jk-jeon/dragonbox version 1.1.3.

The implementation includes:

  • Install the upstream header through the verified Conan include-directory patch.
  • Build the static library with the evidenced fPIC option and publish its link metadata.
  • Add an independent C++ consumer test covering dragonbox::dragonbox_to_chars.
  • Validate exact-version selection, the lower unsupported boundary, option rejection, and cache-hit consumer behavior.

This completes the closed Dragonbox translation issue with a source-backed Formula and reproducible consumer validation.

Closes #111

@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: jk-jeon/dragonbox 1.1.3 formula

Solid, well-scoped formula that closely follows the sibling patterns (recp/cglm, json-c/json-c). Verified as correct:

  • The include-directory patch is right: upstream 1.1.3 installs headers under include/dragonbox-1.1.3/...; the patch flattens that to include/dragonbox/..., matching the consumer's #include "dragonbox/dragonbox_to_chars.h" and the -Iinclude flag. The a/a b/b prefixes strip correctly under git apply -p2, and --unidiff-zero matches the zero-context hunk.
  • dragonbox_to_chars is genuinely a static library, so fPIC legitimately changes installed object code — the option dimension and the defaults/filter pattern (mirroring cglm) are justified.
  • The consumer test builds in _llar_consumer, separate from the _build scratch tree, and derives flags from installDir rather than build metadata — correct cache-hit-safe pattern.
  • Error propagation uses idiomatic ! / lastErr!, and versions.json correctly declares no deps.
  • Security review found nothing: permissions, path construction (all from trusted ctx.* + literals), and license handling are all sound.

The inline notes below are minor/consistency items. A couple (the patch idempotency and the misleading comment) are worth addressing before merge.

Minor, not inlined:

  • DRAGONBOX_ENABLE_SUBPROJECT=false (line 55) already matches the upstream default (OFF); it's harmless as documented intent but is a non-source-required flag per the formula-semantics guidance.
  • The metadata flags (lines 67–72) and the test flags (lines 84–91) are hand-maintained duplicates and must be kept in sync manually. Acceptable since upstream ships only dragonboxConfig.cmake (no .pc), matching the cglm fallback pattern.

Comment on lines +28 to +29
// The Conan recipe's fPIC=True default changes the static archive, so expose
// that package-owned choice while keeping the source's subproject disabled.

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] Comment conflates two unrelated build choices (fPIC vs subproject)

This comment sits on the defaults block (which only defines fPIC) but ties the fPIC choice to DRAGONBOX_ENABLE_SUBPROJECT via "so expose ... while keeping the source's subproject disabled." They're independent: fPIC -> CMAKE_POSITION_INDEPENDENT_CODE (line 53), whereas DRAGONBOX_ENABLE_SUBPROJECT (line 55) only controls building the upstream subproject/benchmark/test and is never set by the Conan recipe. Suggest stopping the comment at the fPIC rationale and moving any subproject note next to line 55.

@@ -0,0 +1,4 @@
{
"path": "jk-jeon/dragonbox",

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] versions.json uses 2-space indent; all siblings use tabs

jk-jeon/dragonbox/versions.json is 2-space indented, whereas json-c/json-c/versions.json, recp/cglm/versions.json, and madler/zlib/versions.json all use tabs. Match the sibling convention (tabs) for consistency and to avoid noise in any format check.

@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 (inline notes, part 2)

Additional inline findings from the dragonbox 1.1.3 review; the summary is in the preceding review.

Comment on lines +45 to +49
patch := ctx.Proj.readFile("1.1.3/dragonbox_include_directory.patch")!
patchPath := filepath.join(ctx.SourceDir, "_llar_dragonbox.patch")
os.writeFile(patchPath, patch, 0o644)!
git "-C", ctx.SourceDir, "apply", "--unidiff-zero", "-p2", patchPath
lastErr!

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] Patch is non-idempotent; scratch file dropped into CMake source root

onBuild writes _llar_dragonbox.patch into ctx.SourceDir (the CMake source dir passed to cmake.new on line 52) and runs git apply --unidiff-zero -p2 on every build. Two concerns:

  1. Not idempotent: git apply has no --forward/reverse guard here, so if the source tree is ever reused without a clean re-extraction (e.g. an interrupted prior build that already applied the patch), the second apply fails on the already-patched tree. Consider git apply --reverse --check (skip if already applied) or git apply --check first.
  2. Scratch file at source root: writing the patch into ctx.SourceDir can perturb CMake configure on generators that file(GLOB ... CONFIGURE_DEPENDS). Siblings keep scratch under subdirectories and don't drop loose files at the source root — writing the patch into _build (or a temp path) avoids this.


onBuild ctx => {
installDir := ctx.outputDir
patch := ctx.Proj.readFile("1.1.3/dragonbox_include_directory.patch")!

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] Header-flatten patch is a non-obvious deviation with no comment

The patch flattens upstream's versioned header install path (include/dragonbox-1.1.3/...) to include/dragonbox/... so the plain -Iinclude flag and the consumer's #include "dragonbox/dragonbox_to_chars.h" resolve. This is deliberate but unexplained at the application site. Sibling formulas document their install-layout assumptions inline (e.g. Cglm_llar.gox, Jsonc_llar.gox); a one-line comment here would keep a future maintainer from mistaking the patch for cruft.

Comment on lines +60 to +65
licenseDir := filepath.join(installDir, "licenses")
os.mkdirAll(licenseDir, 0o755)!
for name in []string{"LICENSE-Apache2-LLVM", "LICENSE-Boost"} {
license := os.readFile(filepath.join(ctx.SourceDir, name))!
os.writeFile(filepath.join(licenseDir, name), license, 0o644)!
}

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] Hardcoded license filenames hard-fail if upstream renames them

This is the only formula in the repo doing manual license copying, and the two names are hardcoded. If either is renamed across any future fromVer range extension, os.readFile(...)! aborts the build with an opaque error. Names are correct for 1.1.3, so this is fine as-is — but confirm this licenses/ layout is a required store convention (siblings copy none); if nothing consumes it, consider dropping the block, and if it stays, note the tight coupling to exact upstream filename spelling.

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.

Translate Conan Center dragonbox recipe to LLAR

1 participant