Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add node-addon-api package for linux #4505

Merged
merged 10 commits into from
Jul 15, 2024
49 changes: 49 additions & 0 deletions packages/n/node-addon-api/xmake.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
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", {
enzalito marked this conversation as resolved.
Show resolved Hide resolved
description = "Choose between 'except', 'noexcept' and 'maybe' to specify how errors should be handled.\n" ..
"See https://github.com/nodejs/node-addon-api/blob/main/doc/error_handling.md for more details.",
default = "except",
type = "string"
})
add_configs("disable_deprecated", {
description = "Control the availability of the deprecated APIs.",
default = true,
type = "boolean"
})

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", {kind = 'binary', system = true})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no this package in xmake-repo now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I couldn't find it, removing system = true gives me this error:

error: package(node) not found!

Copy link
Member

@waruqi waruqi Jun 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so you should add node as package first. and add on_fetch to find system node in node package at least. like opengl package.


on_load(function(package)
package:add("defines", "NAPI_VERSION=" .. package:version():major())
if package:config("disable_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)
local include_dir = path.join(package:installdir(), "include")
os.mkdir(include_dir)
os.cp("*.h", include_dir)
end)
enzalito marked this conversation as resolved.
Show resolved Hide resolved
Loading