-
Notifications
You must be signed in to change notification settings - Fork 2
feat(dragonbox): add LLAR formula #126
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,7 @@ | ||
| diff --git a/a/CMakeLists.txt b/b/CMakeLists.txt | ||
| index a9d80b9..e0417d7 100644 | ||
| --- a/a/CMakeLists.txt | ||
| +++ b/b/CMakeLists.txt | ||
| @@ -61,1 +61,1 @@ | ||
| -set(dragonbox_include_directory "${CMAKE_INSTALL_INCLUDEDIR}/${dragonbox_directory}") | ||
| +set(dragonbox_include_directory "${CMAKE_INSTALL_INCLUDEDIR}") |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,96 @@ | ||
| import ( | ||
| "os" | ||
| "path/filepath" | ||
| "slices" | ||
| "strings" | ||
| ) | ||
|
|
||
| const consumerSource = `#include <cstdlib> | ||
| #include <iostream> | ||
|
|
||
| #include "dragonbox/dragonbox_to_chars.h" | ||
|
|
||
| int main(void) { | ||
| constexpr int buffer_length = 1 + | ||
| jkj::dragonbox::max_output_string_length<jkj::dragonbox::ieee754_binary64>; | ||
| double x = 1.234; | ||
| char buffer[buffer_length]; | ||
| char* end_ptr = jkj::dragonbox::to_chars(x, buffer); | ||
| end_ptr = jkj::dragonbox::to_chars_n(x, buffer); | ||
| return end_ptr == buffer ? EXIT_FAILURE : EXIT_SUCCESS; | ||
| } | ||
| ` | ||
|
|
||
| id "jk-jeon/dragonbox" | ||
|
|
||
| fromVer "1.1.3" | ||
|
|
||
| // The Conan recipe's fPIC=True default changes the static archive, so expose | ||
| // that package-owned choice while keeping the source's subproject disabled. | ||
| defaults { | ||
| "fPIC": "ON", | ||
| } | ||
|
|
||
| filter => { | ||
| for _, value := range target.options["fPIC"] { | ||
| if value != "ON" && value != "OFF" { | ||
| return false | ||
| } | ||
| } | ||
| return true | ||
| } | ||
|
|
||
| onBuild ctx => { | ||
| installDir := ctx.outputDir | ||
| patch := ctx.Proj.readFile("1.1.3/dragonbox_include_directory.patch")! | ||
|
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] Header-flatten patch is a non-obvious deviation with no comment The patch flattens upstream's versioned header install path ( |
||
| patchPath := filepath.join(ctx.SourceDir, "_llar_dragonbox.patch") | ||
| os.writeFile(patchPath, patch, 0o644)! | ||
| git "-C", ctx.SourceDir, "apply", "--unidiff-zero", "-p2", patchPath | ||
| lastErr! | ||
|
Comment on lines
+45
to
+49
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] Patch is non-idempotent; scratch file dropped into CMake source root
|
||
|
|
||
| fPIC := slices.contains(target.options["fPIC"], "ON") | ||
| c := cmake.new(ctx.SourceDir, filepath.join(ctx.SourceDir, "_build"), installDir) | ||
| c.defineBool "CMAKE_POSITION_INDEPENDENT_CODE", fPIC | ||
| c.defineBool "DRAGONBOX_INSTALL_TO_CHARS", true | ||
| c.defineBool "DRAGONBOX_ENABLE_SUBPROJECT", false | ||
| c.configure | ||
| c.build | ||
| c.install | ||
|
|
||
| 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)! | ||
| } | ||
|
Comment on lines
+60
to
+65
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] 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 |
||
|
|
||
| flags := []string{ | ||
| "-I" + filepath.join(installDir, "include"), | ||
| "-L" + filepath.join(installDir, "lib"), | ||
| "-ldragonbox_to_chars", | ||
| } | ||
| ctx.setMetadata strings.join(flags, " ") | ||
| } | ||
|
|
||
| onTest ctx => { | ||
| installDir := ctx.outputDir | ||
| testDir := filepath.join(ctx.SourceDir, "_llar_consumer") | ||
| os.mkdirAll(testDir, 0o755)! | ||
|
|
||
| consumer := filepath.join(testDir, "consumer.cpp") | ||
| os.writeFile(consumer, []byte(consumerSource), 0o644)! | ||
|
|
||
| binary := filepath.join(testDir, "consumer") | ||
| flags := []string{ | ||
| "-std=c++17", | ||
| "-I" + filepath.join(installDir, "include"), | ||
| "-L" + filepath.join(installDir, "lib"), | ||
| "-ldragonbox_to_chars", | ||
| consumer, | ||
| "-o", binary, | ||
| } | ||
| exec "c++", flags... | ||
| lastErr! | ||
| exec binary | ||
| lastErr! | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| { | ||
| "path": "jk-jeon/dragonbox", | ||
|
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] versions.json uses 2-space indent; all siblings use tabs
|
||
| "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.
[P3] Comment conflates two unrelated build choices (fPIC vs subproject)
This comment sits on the
defaultsblock (which only definesfPIC) but ties the fPIC choice toDRAGONBOX_ENABLE_SUBPROJECTvia "so expose ... while keeping the source's subproject disabled." They're independent:fPIC->CMAKE_POSITION_INDEPENDENT_CODE(line 53), whereasDRAGONBOX_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.