Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Build toolchains
run: ./pleasew build //third_party/node:node //third_party/bun:bun //third_party/oxlint:oxlint
run: ./pleasew build //third_party/node:node //third_party/bun:bun
- name: Test toolchains
run: ./pleasew test //test/...
- name: Format
Expand Down
6 changes: 0 additions & 6 deletions .plzconfig
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,5 @@ DefaultValue = ///node//third_party/bun:bun|bun
Help = Build label for the Bun binary, from bun_toolchain.
Inherit = true

[PluginConfig "oxlint_tool"]
ConfigKey = OxlintTool
DefaultValue = ///node//third_party/oxlint:oxlint|oxlint
Help = Build label for the OXLint binary, from oxlint_toolchain.
Inherit = true

[Plugin "node"]
Target = //plugins:node
36 changes: 12 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# node-rules

A Node.js, Bun and OXLint toolchain for the [Please](https://please.build) build system.
A Node.js and Bun toolchain for the [Please](https://please.build) build system.

This plugin fetches pinned native executables for the host platform. It exposes
`node`, `npm`, `npx`, `corepack`, `bun` and `oxlint` as entry points. It has no
`node`, `npm`, `npx`, `corepack` and `bun` as entry points. It has no
opinions about how JavaScript is built, checked or linted.

## Install
Expand Down Expand Up @@ -44,14 +44,6 @@ subinclude("///node//build_defs:bun")
bun_toolchain(name = "bun", version = "1.4.4")
```

Declare OXLint in `third_party/oxlint/BUILD`:

```python
subinclude("///node//build_defs:oxlint")

oxlint_toolchain(name = "oxlint", version = "1.91.0")
```

Then point the plugin config at it, so rules can find it:

```ini
Expand All @@ -60,7 +52,6 @@ Target = //plugins:node
NodeTool = //third_party/node:node|node
NpmTool = //third_party/node:node|npm
BunTool = //third_party/bun:bun|bun
OxlintTool = //third_party/oxlint:oxlint|oxlint
```

## Using it in a rule
Expand Down Expand Up @@ -93,8 +84,8 @@ The Node.js tarball ships `bin/npm` as a symlink to a `.js` file carrying a
there is not. The entry points therefore name the scripts themselves, and the
downloaded tree is left byte-identical to what nodejs.org shipped.

`bun` and `oxlint` are native binaries. Declare them as tools and invoke them
directly; no host Node.js executable or package installation is needed:
`bun` is a native binary. Declare it as a tool and invoke it directly; no host
Node.js executable or package installation is needed:

```python
subinclude("///node//build_defs:bun")
Expand All @@ -108,9 +99,8 @@ build_rule(
)
```

Subinclude `///node//build_defs:bun` or `///node//build_defs:oxlint` in each
BUILD file that reads the respective config key. The default targets live in
`third_party/bun/BUILD` and `third_party/oxlint/BUILD` within this plugin.
Subinclude `///node//build_defs:bun` in each BUILD file that reads the config
key. The default target lives in `third_party/bun/BUILD` within this plugin.

## Configuration

Expand All @@ -120,7 +110,6 @@ BUILD file that reads the respective config key. The default targets live in
| `NpmTool` | `///node//third_party/node:node\|npm` | Build label for the npm CLI |
| `DefaultVersion` | `22.23.2` | Version used when `node_toolchain` is called without one |
| `BunTool` | `///node//third_party/bun:bun\|bun` | Build label for the Bun binary |
| `OxlintTool` | `///node//third_party/oxlint:oxlint\|oxlint` | Build label for the OXLint binary |

## Versions

Expand All @@ -140,10 +129,9 @@ that is not pinned, pass `hashes` explicitly.

Supported platforms: `linux-x64`, `linux-arm64`, `darwin-x64`, `darwin-arm64`.

`bun_toolchain` and `oxlint_toolchain` carry SHA256 hashes of their official
release archives in `build_defs/bun.build_defs` and
`build_defs/oxlint.build_defs`. Each rule requires an explicit version. The
same four platforms are supported. Bun's x64 baseline archives work on CPUs
without AVX2. Linux OXLint uses the glibc archives. Unsupported platforms and
versions fail during rule evaluation. The exact version, archive URL and digest
are in the action command, so a pin change invalidates its cache key.
`bun_toolchain` carries SHA256 hashes of its official release archives in
`build_defs/bun.build_defs`. It requires an explicit version and supports the
same four platforms. Bun's x64 baseline archives work on CPUs without AVX2.
Unsupported platforms and versions fail during rule evaluation. The exact
version, archive URL and digest are in the action command, so a pin change
invalidates its cache key.
6 changes: 0 additions & 6 deletions build_defs/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,3 @@ filegroup(
srcs = ["bun.build_defs"],
visibility = ["PUBLIC"],
)

filegroup(
name = "oxlint",
srcs = ["oxlint.build_defs"],
visibility = ["PUBLIC"],
)
61 changes: 0 additions & 61 deletions build_defs/oxlint.build_defs

This file was deleted.

10 changes: 5 additions & 5 deletions test/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ build_rule(
)

build_rule(
name = "native_tools_test",
srcs = ["native_tools_test.sh"],
data = ["//third_party/bun:bun", "//third_party/oxlint:oxlint"],
outs = ["native_tools_test"],
name = "bun_toolchain_test",
srcs = ["bun_toolchain_test.sh"],
data = ["//third_party/bun:bun"],
outs = ["bun_toolchain_test"],
cmd = "cp $SRCS $OUT",
binary = True,
test = True,
no_test_output = True,
test_cmd = "$TEST third_party/bun/bun 1.4.4 third_party/oxlint/oxlint 1.91.0",
test_cmd = "$TEST third_party/bun/bun 1.4.4",
)
8 changes: 8 additions & 0 deletions test/bun_toolchain_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/sh
set -eu

BUN="$(pwd)/$1/bun"
got=$(env -i PATH=/usr/bin:/bin "$BUN" --version)
[ "$got" = "$2" ] || { echo "Bun: expected $2, got $got" >&2; exit 1; }

echo "Bun tool entry point is hermetic"
16 changes: 0 additions & 16 deletions test/native_tools_test.sh

This file was deleted.

6 changes: 0 additions & 6 deletions third_party/oxlint/BUILD

This file was deleted.

Loading