diff --git a/jk-jeon/dragonbox/1.1.3/dragonbox_include_directory.patch b/jk-jeon/dragonbox/1.1.3/dragonbox_include_directory.patch new file mode 100644 index 0000000..5414693 --- /dev/null +++ b/jk-jeon/dragonbox/1.1.3/dragonbox_include_directory.patch @@ -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}") diff --git a/jk-jeon/dragonbox/1.1.3/dragonbox_llar.gox b/jk-jeon/dragonbox/1.1.3/dragonbox_llar.gox new file mode 100644 index 0000000..2f37b15 --- /dev/null +++ b/jk-jeon/dragonbox/1.1.3/dragonbox_llar.gox @@ -0,0 +1,96 @@ +import ( + "os" + "path/filepath" + "slices" + "strings" +) + +const consumerSource = `#include +#include + +#include "dragonbox/dragonbox_to_chars.h" + +int main(void) { + constexpr int buffer_length = 1 + + jkj::dragonbox::max_output_string_length; + 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")! + patchPath := filepath.join(ctx.SourceDir, "_llar_dragonbox.patch") + os.writeFile(patchPath, patch, 0o644)! + git "-C", ctx.SourceDir, "apply", "--unidiff-zero", "-p2", patchPath + lastErr! + + 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)! + } + + 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! +} diff --git a/jk-jeon/dragonbox/versions.json b/jk-jeon/dragonbox/versions.json new file mode 100644 index 0000000..f85ca19 --- /dev/null +++ b/jk-jeon/dragonbox/versions.json @@ -0,0 +1,4 @@ +{ + "path": "jk-jeon/dragonbox", + "deps": {} +}