xmake.lua 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. package("mplib")
  2. set_homepage("https://motion-planning-lib.readthedocs.io/")
  3. set_description("a Lightweight Motion Planning Package")
  4. set_license("MIT")
  5. add_urls("https://github.com/haosulab/MPlib/archive/refs/tags/$(version).tar.gz",
  6. "https://github.com/haosulab/MPlib.git", {submodules = false})
  7. add_versions("v0.2.1", "ea5b549965994ab7794c73f9c95f49590e473e76513f48e6feb4b37c53e5c4da")
  8. add_configs("python", {description = "Build Python bindings.", default = false, type = "boolean"})
  9. if is_plat("windows") then
  10. add_configs("shared", {description = "Build shared library.", default = false, type = "boolean", readonly = true})
  11. end
  12. add_deps("ompl", "assimp", "orocos-kdl", "urdfdom")
  13. add_deps("pinocchio 2.x", {configs = {urdf = true}})
  14. add_deps("fcl", {configs = {octomap = true}})
  15. if on_check then
  16. on_check(function (package)
  17. if not package:is_plat("windows", "linux", "macosx") then
  18. raise("deps octomap is only supported on windows, macosx and linux")
  19. end
  20. end)
  21. end
  22. on_install(function (package)
  23. if package:has_tool("cxx", "clang", "clang_cl") then
  24. for _, filepath in ipairs(os.files("src/**.cpp") ) do
  25. local content = io.readfile(filepath)
  26. local moved_lines = {}
  27. local found_any = false
  28. local pattern = "([ \t]*DEFINE_TEMPLATE_[%w_]+%s*%b();[\r\n]*)"
  29. local clean_content = content:gsub(pattern, function(match)
  30. found_any = true
  31. table.insert(moved_lines, match:trim())
  32. return ""
  33. end)
  34. if found_any then
  35. local pre_brace, brace, post_brace = clean_content:match("^(.*)(})(.*)$")
  36. if pre_brace and brace then
  37. local insertion = "\n" .. table.concat(moved_lines, "\n") .. "\n"
  38. local new_content = pre_brace .. insertion .. brace .. post_brace
  39. io.writefile(filepath, new_content)
  40. end
  41. end
  42. end
  43. end
  44. os.cp(path.join(package:scriptdir(), "port", "xmake.lua"), "xmake.lua")
  45. import("package.tools.xmake").install(package, {python = package:config("python")})
  46. end)
  47. on_test(function (package)
  48. assert(package:check_cxxsnippets({test = [[
  49. #include <mplib/core/articulated_model.h>
  50. using ArticulatedModel = mplib::ArticulatedModelTpl<double>;
  51. void test() {
  52. std::string urdf_filename = "../data/panda/panda.urdf";
  53. std::string srdf_filename = "../data/panda/panda.srdf";
  54. Eigen::Vector3d gravity = Eigen::Vector3d(0, 0, -9.81);
  55. ArticulatedModel articulated_model(urdf_filename, srdf_filename, {}, gravity, {}, {},
  56. false, false);
  57. }
  58. ]]}, {configs = {languages = "c++17"}}))
  59. end)