xmake.lua 1.3 KB

1234567891011121314151617181920212223242526272829303132333435
  1. package("node-api-stub")
  2. set_homepage("https://github.com/napi-bindings/node-api-stub")
  3. set_description("Node-API stub")
  4. set_license("MIT")
  5. add_urls("https://github.com/napi-bindings/node-api-stub/archive/refs/tags/$(version).tar.gz",
  6. "https://github.com/napi-bindings/node-api-stub.git")
  7. add_versions("8.0.0", "7fdf725a3122f4d86443e707227a30c663c7163c6d1b9f883cb2305f18e01740")
  8. on_install(function (package)
  9. if package:has_tool("cxx", "cl") then
  10. io.replace("node_api.c", "void exit() __attribute__((noreturn));", "NAPI_NO_RETURN void exit();", {plain = true})
  11. end
  12. if package:is_plat("windows") then
  13. if package:config("shared") then
  14. package:add("defines", "NAPI_EXTERN=__declspec(dllimport)")
  15. else
  16. io.replace("js_native_api.h", "__declspec(dllexport)", "", {plain = true})
  17. end
  18. end
  19. io.writefile("xmake.lua", [[
  20. add_rules("mode.debug", "mode.release")
  21. target("node-api-stub")
  22. set_kind("$(kind)")
  23. add_files("node_api.c")
  24. add_headerfiles("*.h")
  25. ]])
  26. import("package.tools.xmake").install(package)
  27. end)
  28. on_test(function (package)
  29. assert(package:has_cfuncs("napi_get_undefined", {includes = "node_api.h"}))
  30. end)