xmake.lua 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. package("pseudo-double-c")
  2. set_homepage("https://github.com/royward/pseudo-double")
  3. set_description("A relatively fast C and C++ 64 bit floating point library written using only integer operations for cross platform consistency. Tested with gcc/clang/Visual Studio, on x86-64/ARMv8 (64 bit)")
  4. set_license("BSD-3-Clause")
  5. add_urls("https://github.com/royward/pseudo-double.git")
  6. add_versions("2024.01.17", "275b244eee40b987a209927d7942d4bf83d91c95")
  7. add_configs("pseudo_double_exp_bits", {description = "This sets the number of bits in the exponent, defaulting to 16 if not set.", default = "16", type = "string", values = {"8", "16", "32"}})
  8. add_configs("pd_error_check", {description = "This enables error checking in the library, defaulting to true if not set.", default = true, type = "boolean"})
  9. on_install("windows|x64", "linux|x86_64", "macosx", "bsd", "android|arm64*", "wasm", function (package)
  10. local configs = {}
  11. io.replace("pseudo_double.h", "#include <stdint.h>", "#include <stdint.h>\n#include <stdbool.h>", {plain = true})
  12. io.writefile("xmake.lua", [[
  13. add_rules("mode.release", "mode.debug")
  14. target("pseudo-double-c")
  15. set_kind("$(kind)")
  16. set_languages("c99")
  17. if is_plat("windows") then
  18. add_defines("_MSC_VER")
  19. end
  20. add_files("pseudo_double.c")
  21. add_headerfiles("(pseudo_double.h)")
  22. on_config(function (target)
  23. if target:has_tool("gcc", "gxx") then
  24. target:add("defines", "__GNUC__")
  25. elseif target:has_tool("cc", "cxx", "clang", "clangxx") then
  26. target:add("defines", "__clang__")
  27. end
  28. end)
  29. ]])
  30. package:add("defines", "PSEUDO_DOUBLE_EXP_BITS=" .. package:config("pseudo_double_exp_bits"))
  31. package:add("defines", "PD_ERROR_CHECK=" .. (package:config("pd_error_check") and "1" or "0"))
  32. import("package.tools.xmake").install(package)
  33. end)
  34. on_test(function (package)
  35. assert(package:check_cxxsnippets({test = [[
  36. #include <pseudo_double.h>
  37. void test() {
  38. pseudo_double a_1 = int64fixed10_to_pd(3, -1);
  39. }
  40. ]]}))
  41. end)