mirror of
https://github.com/NoRedInk/noredink-ui.git
synced 2024-09-17 10:17:09 +03:00
add a rule to get a binary, and get browserify
This commit is contained in:
parent
ce93ff9ecd
commit
60dc11f2a9
7
BUCK
7
BUCK
@ -1,6 +1,6 @@
|
||||
# A list of available rules and their signatures can be found here: https://buck2.build/docs/api/rules/
|
||||
load("@prelude-nri//:elm.bzl", "elm_docs")
|
||||
load("@prelude-nri//:node.bzl", "node_modules")
|
||||
load("@prelude-nri//:node.bzl", "node_modules", "npm_bin")
|
||||
|
||||
elm_docs(
|
||||
name = "docs.json",
|
||||
@ -19,3 +19,8 @@ node_modules(
|
||||
package = "package.json",
|
||||
package_lock = "package-lock.json",
|
||||
)
|
||||
|
||||
npm_bin(
|
||||
name = "browserify",
|
||||
node_modules = ":node_modules",
|
||||
)
|
||||
|
@ -35,3 +35,43 @@ node_modules = rule(
|
||||
),
|
||||
}
|
||||
)
|
||||
|
||||
def _npm_bin_impl(ctx: "context") -> [[DefaultInfo.type, RunInfo.type]]:
|
||||
bin_name = ctx.attrs.bin_name or ctx.attrs.name
|
||||
|
||||
out = ctx.actions.declare_output(bin_name)
|
||||
|
||||
node_toolchain = ctx.attrs._node_toolchain[NodeToolchainInfo]
|
||||
|
||||
ctx.actions.run(
|
||||
[
|
||||
ctx.attrs._python_toolchain[PythonToolchainInfo].interpreter,
|
||||
node_toolchain.build_npm_bin[DefaultInfo].default_outputs,
|
||||
ctx.attrs.node_modules,
|
||||
bin_name,
|
||||
out.as_output(),
|
||||
"--bin-dir", node_toolchain.bin_dir[DefaultInfo].default_outputs,
|
||||
],
|
||||
category = "build_npm_bin",
|
||||
)
|
||||
|
||||
return [
|
||||
DefaultInfo(default_output = out),
|
||||
RunInfo(out),
|
||||
]
|
||||
|
||||
npm_bin = rule(
|
||||
impl = _npm_bin_impl,
|
||||
attrs = {
|
||||
"bin_name": attrs.option(attrs.string(), default=None),
|
||||
"node_modules": attrs.source(),
|
||||
"_node_toolchain": attrs.toolchain_dep(
|
||||
default="toolchains//:node",
|
||||
providers=[NodeToolchainInfo]
|
||||
),
|
||||
"_python_toolchain": attrs.toolchain_dep(
|
||||
default="toolchains//:python",
|
||||
providers=[PythonToolchainInfo]
|
||||
),
|
||||
}
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user