add node-addon-api package for linux (#4505)
* add node-addon-api package for linux * add test and shorten configs * remove superfluous whitespace * remove options on node dependency * rename dependency node to nodejs * switch nodejs dep. to node-api-headers and add napi_version option * improve node-addonc-api test * use has_cxxfunc instead of has_cfunc * Update xmake.lua --------- Co-authored-by: ruki <waruqi@gmail.com>pull/4665/head
parent
2a2247530b
commit
915ab720ba
1 changed files with 42 additions and 0 deletions
@ -0,0 +1,42 @@ |
||||
package("node-addon-api") |
||||
set_kind("library", {headeronly = true}) |
||||
set_homepage("https://github.com/nodejs/node-addon-api") |
||||
set_description("Module for using Node-API from C++") |
||||
set_license("MIT") |
||||
|
||||
add_configs("errors", {description = "Choose error handling method.", default = "except", type = "string", values = {"except", "noexcept", "maybe"}}) |
||||
add_configs("deprecated", {description = "Disable deprecated APIs.", default = false, type = "boolean"}) |
||||
add_configs("napi_version", {description = "Target a specific Node-API version.", default = nil, type = "number"}) |
||||
|
||||
set_urls("https://github.com/nodejs/node-addon-api/archive/refs/tags/$(version).tar.gz", |
||||
"https://github.com/nodejs/node-addon-api.git") |
||||
add_versions("v8.0.0", "42424c5206b9d67b41af4fcff5d6e3cb22074168035a03b8467852938a281d47") |
||||
|
||||
add_deps("node-api-headers") |
||||
|
||||
on_load(function(package) |
||||
package:add("defines", "NAPI_VERSION=" .. package:config("napi_version") or package:version():major()) |
||||
if not package:config("deprecated") then |
||||
package:add("defines", "NODE_ADDON_API_DISABLE_DEPRECATED") |
||||
end |
||||
|
||||
local errors = package:config("errors") |
||||
if errors == "noexcept" or errors == "maybe" then |
||||
package:add("cxxflags", "-fno-exceptions") |
||||
package:add("defines", "NAPI_DISABLE_CPP_EXCEPTIONS") |
||||
end |
||||
if errors == "maybe" then |
||||
package:add("defines", "NODE_ADDON_API_ENABLE_MAYBE") |
||||
end |
||||
if errors == "except" then |
||||
package:add("defines", "NAPI_CPP_EXCEPTIONS") |
||||
end |
||||
end) |
||||
|
||||
on_install("linux" ,function(package) |
||||
os.cp("*.h", package:installdir("include")) |
||||
end) |
||||
|
||||
on_test(function (package) |
||||
assert(package:has_cxxfuncs("Napi::Just(0)", {includes = "napi.h"})) |
||||
end) |
Loading…
Reference in new issue