xmake.lua 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. package("dynareadout")
  2. set_homepage("https://github.com/PucklaJ/dynareadout")
  3. set_description("High-Performance C/C++ library for parsing binary output files and key files of LS Dyna (d3plot, binout, input deck)")
  4. set_license("zlib")
  5. add_urls("https://github.com/xmake-mirror/dynareadout/releases/download/$(version)/$(version).tar.gz")
  6. add_versions("24.07", "11138c1236f44434adf99ad86dc3315fcba17e59dd4b0ae0e6564972e2de12c5")
  7. add_configs("cpp_bind", {description = "Build the C++ bindings", default = true, type = "boolean"})
  8. add_configs("profiling", {description = "Build with profiling features", default = true, type = "boolean"})
  9. if is_plat("mingw") then
  10. add_configs("python_bind", {description = "Build the python bindings", default = false, type = "boolean", readonly = true})
  11. else
  12. add_configs("python_bind", {description = "Build the python bindings", default = true, type = "boolean"})
  13. end
  14. on_check("windows", function (package)
  15. if package:config("python_bind") then
  16. if not package:is_arch("x64", "arm64") or package:is_cross() then
  17. raise("package(dynareadout) python bind is only supported windows x64/arm64 native build")
  18. end
  19. end
  20. end)
  21. on_load(function (package)
  22. wprint("The original repository PucklaJ/dynareadout is no longer public. You are using a mirror of this repository.")
  23. if package:config("cpp_bind") then
  24. package:add("links", "dynareadout_cpp", "dynareadout")
  25. else
  26. package:add("links", "dynareadout")
  27. end
  28. if package:config("python_bind") and not package:is_plat("mingw") then
  29. package:add("deps", "pybind11")
  30. end
  31. if package:is_plat("macosx") then
  32. package:add("deps", "boost", {configs = {filesystem = true}})
  33. end
  34. end)
  35. on_install("windows", "linux", "macosx", "mingw", function (package)
  36. local configs = {}
  37. configs.build_cpp = package:config("cpp_bind")
  38. configs.profiling = package:config("profiling")
  39. configs.build_python = package:config("python_bind")
  40. os.cd("lib/dynareadout")
  41. os.cp(path.join(package:scriptdir(), "port", "xmake.lua"), "xmake.lua")
  42. import("package.tools.xmake").install(package, configs)
  43. end)
  44. on_test(function (package)
  45. assert(package:has_cfuncs("binout_open", {includes = "binout.h", configs = {languages = "ansi"}}))
  46. assert(package:has_cfuncs("d3plot_open", {includes = "d3plot.h", configs = {languages = "ansi"}}))
  47. if package:config("cpp_bind") then
  48. assert(package:has_cxxtypes("dro::Binout", {includes = "binout.hpp", configs = {languages = "cxx17"}}))
  49. assert(package:has_cxxtypes("dro::D3plot", {includes = "d3plot.hpp", configs = {languages = "cxx17"}}))
  50. assert(package:has_cxxtypes("dro::Array<int32_t>", {includes = {"array.hpp", "cstdint"}, configs = {languages = "cxx17"}}))
  51. end
  52. if package:config("profiling") then
  53. assert(package:check_csnippets({test = [[
  54. void test(int argc, char** argv) {
  55. BEGIN_PROFILE_FUNC();
  56. BEGIN_PROFILE_SECTION(mid_section);
  57. END_PROFILE_SECTION(mid_section);
  58. END_PROFILE_FUNC();
  59. END_PROFILING("dynareadout_test_profiling.txt");
  60. }
  61. ]]}, {includes = "profiling.h", configs = {languages = "ansi"}}))
  62. end
  63. assert(package:has_cfuncs("sync_create", {includes = "sync.h", configs = {languages = "ansi"}}))
  64. assert(package:has_cfuncs("sync_lock", {includes = "sync.h", configs = {languages = "ansi"}}))
  65. end)