@gjsify/oxfmt-native 0.21.0 → 0.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +21 -1
- package/meson.build +51 -4
- package/package.json +9 -4
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @gjsify/oxfmt-native
|
|
2
2
|
|
|
3
|
-
A native Rust cdylib + Vala/GObject bridge that wraps oxc's formatter ([oxfmt](https://oxc.rs/docs/guide/usage/formatter)) and exposes it to GJS via `gi://`. This is the formatter engine used by `gjsify format` / `gjsify fix` under GJS — npm's `oxfmt` is a Rust N-API binary that cannot load in GJS, so this bridge is how gjsify formats without a Node runtime. The bridge links oxfmt's pure-Rust CLI core, so the full CLI surface runs in-process: `.oxfmtrc(.json)` + `.editorconfig` resolution, ignore handling, parallel file walking, `--write` / `--check` / `--list-different`. Ships prebuilt
|
|
3
|
+
A native Rust cdylib + Vala/GObject bridge that wraps oxc's formatter ([oxfmt](https://oxc.rs/docs/guide/usage/formatter)) and exposes it to GJS via `gi://`. This is the formatter engine used by `gjsify format` / `gjsify fix` under GJS — npm's `oxfmt` is a Rust N-API binary that cannot load in GJS, so this bridge is how gjsify formats without a Node runtime. The bridge links oxfmt's pure-Rust CLI core, so the full CLI surface runs in-process: `.oxfmtrc(.json)` + `.editorconfig` resolution, ignore handling, parallel file walking, `--write` / `--check` / `--list-different`. Ships prebuilt native libraries + `.gir` + `.typelib` for Linux and macOS — see [Platform coverage](#platform-coverage).
|
|
4
4
|
|
|
5
5
|
Part of the [gjsify](https://github.com/gjsify/gjsify) project — Node.js and Web APIs for GJS (GNOME JavaScript).
|
|
6
6
|
|
|
@@ -40,6 +40,26 @@ git submodule update --init refs/oxc
|
|
|
40
40
|
gjsify workspace @gjsify/oxfmt-native build:prebuilds # needs meson + vala + cargo
|
|
41
41
|
```
|
|
42
42
|
|
|
43
|
+
## Platform coverage
|
|
44
|
+
|
|
45
|
+
| Platform | Prebuild | Built by |
|
|
46
|
+
|---|---|---|
|
|
47
|
+
| `linux-x86_64` | ✅ `.so` + `.gir` + `.typelib` | native runner |
|
|
48
|
+
| `linux-aarch64` | ✅ | native runner |
|
|
49
|
+
| `linux-ppc64`, `linux-s390x`, `linux-riscv64` | ❌ | not built — the `refs/oxc` crate graph is too slow under QEMU |
|
|
50
|
+
| `darwin-arm64` (macOS, Apple silicon) | ✅ `.dylib` + `.gir` + `.typelib` | `macos-latest` runner |
|
|
51
|
+
| `darwin-x64` (macOS, Intel) | ❌ | — no runner leg yet |
|
|
52
|
+
| Windows | ❌ | — no Vala/GI bridge in this repo targets Windows |
|
|
53
|
+
|
|
54
|
+
All prebuilds are produced by [`.github/workflows/prebuilds.yml`](../../../.github/workflows/prebuilds.yml)
|
|
55
|
+
and committed back to the repository.
|
|
56
|
+
|
|
57
|
+
**Known gap — a `darwin-arm64` prebuild is built and shipped, but the CLI does not
|
|
58
|
+
load it yet.** `detectNativePackages()` (`packages/infra/cli/src/utils/detect-native-packages.ts`)
|
|
59
|
+
hardcodes a `linux-` directory prefix, and `buildNativeEnv()` exports `LD_LIBRARY_PATH`,
|
|
60
|
+
which macOS `dyld` ignores in favour of `DYLD_LIBRARY_PATH`. Both are CLI-side fixes;
|
|
61
|
+
until they land, `gjsify format` on macOS falls back to spawning the npm `oxfmt` Node launcher.
|
|
62
|
+
|
|
43
63
|
## License
|
|
44
64
|
|
|
45
65
|
MIT
|
package/meson.build
CHANGED
|
@@ -17,6 +17,48 @@ vala_deps = [
|
|
|
17
17
|
dependency('gobject-2.0'),
|
|
18
18
|
]
|
|
19
19
|
|
|
20
|
+
# ----------------------------------------------------------------------------
|
|
21
|
+
# Host-dependent naming + runtime-lookup conventions
|
|
22
|
+
#
|
|
23
|
+
# Three things differ per host and MUST agree, or the prebuild loads on one
|
|
24
|
+
# platform and silently fails on the other (mirrors @gjsify/napi's meson
|
|
25
|
+
# branch):
|
|
26
|
+
#
|
|
27
|
+
# 1. cargo's cdylib leaf — libgjsify_oxfmt.{so,dylib}
|
|
28
|
+
# 2. meson's library() leaf — libgjsifyoxfmt.{so,dylib}; the typelib records
|
|
29
|
+
# this name and gjs' g_module_open() resolves exactly it at load.
|
|
30
|
+
# 3. how the Vala library finds its sibling Rust cdylib at runtime. Both
|
|
31
|
+
# files ship side by side in prebuilds/<platform>-<arch>/, so the lookup
|
|
32
|
+
# must be relative to the loading binary: $ORIGIN on ELF, @loader_path on
|
|
33
|
+
# Mach-O. On macOS this is load-bearing — unlike Linux (where the CLI
|
|
34
|
+
# exports LD_LIBRARY_PATH for the prebuild dir) nothing sets
|
|
35
|
+
# DYLD_LIBRARY_PATH, so the rpath is the ONLY way the cdylib is found.
|
|
36
|
+
#
|
|
37
|
+
# Windows is deliberately absent: no Vala bridge here has had any Windows
|
|
38
|
+
# portability work, so `else` (ELF naming) is the honest fallback rather than a
|
|
39
|
+
# .dll branch that would imply support that does not exist.
|
|
40
|
+
# ----------------------------------------------------------------------------
|
|
41
|
+
host_system = host_machine.system()
|
|
42
|
+
|
|
43
|
+
if host_system == 'darwin'
|
|
44
|
+
rust_cdylib_name = 'libgjsify_oxfmt.dylib'
|
|
45
|
+
shared_lib_name = 'libgjsifyoxfmt.dylib'
|
|
46
|
+
lib_rpath = '@loader_path'
|
|
47
|
+
# Normalise the cdylib's LC_ID_DYLIB to @rpath/<leaf> BEFORE the Vala
|
|
48
|
+
# library links against it: ld64 copies the dependency's install name
|
|
49
|
+
# verbatim into the dependent's LC_LOAD_DYLIB. rustc's own install name has
|
|
50
|
+
# varied across releases (absolute build path in older rustc, @rpath/<leaf>
|
|
51
|
+
# in current ones); pinning it here makes the recorded dependency
|
|
52
|
+
# rustc-version-independent, and @rpath/ is never longer than an absolute
|
|
53
|
+
# path so install_name_tool can always rewrite in place.
|
|
54
|
+
rust_cdylib_post = ' && install_name_tool -id "@rpath/' + rust_cdylib_name + '" "$3"'
|
|
55
|
+
else
|
|
56
|
+
rust_cdylib_name = 'libgjsify_oxfmt.so'
|
|
57
|
+
shared_lib_name = 'libgjsifyoxfmt.so'
|
|
58
|
+
lib_rpath = '$ORIGIN'
|
|
59
|
+
rust_cdylib_post = ''
|
|
60
|
+
endif
|
|
61
|
+
|
|
20
62
|
# ----------------------------------------------------------------------------
|
|
21
63
|
# Rust cdylib (cargo)
|
|
22
64
|
#
|
|
@@ -35,9 +77,10 @@ rust_target_dir = meson.current_build_dir() / 'cargo-target'
|
|
|
35
77
|
|
|
36
78
|
rust_cdylib = custom_target('gjsify-oxfmt-rust',
|
|
37
79
|
input: rust_sources,
|
|
38
|
-
output:
|
|
80
|
+
output: rust_cdylib_name,
|
|
39
81
|
command: ['sh', '-c',
|
|
40
|
-
'cargo build --release --manifest-path "$1" --target-dir "$2" && cp "$2/release/
|
|
82
|
+
'cargo build --release --manifest-path "$1" --target-dir "$2" && cp "$2/release/'
|
|
83
|
+
+ rust_cdylib_name + '" "$3"' + rust_cdylib_post,
|
|
41
84
|
'sh',
|
|
42
85
|
meson.current_source_dir() / 'src/rust/Cargo.toml',
|
|
43
86
|
rust_target_dir,
|
|
@@ -68,7 +111,11 @@ libGjsifyOxfmt = library('gjsifyoxfmt', sources,
|
|
|
68
111
|
link_depends: rust_cdylib,
|
|
69
112
|
install: true,
|
|
70
113
|
install_dir: [true, true, true, true],
|
|
71
|
-
install_rpath:
|
|
114
|
+
# `build_rpath` (not just `install_rpath`) is what matters for the prebuild:
|
|
115
|
+
# the artifact shipped in prebuilds/ is copied straight out of the build
|
|
116
|
+
# dir, never through `meson install`, so only the build-tree rpath survives.
|
|
117
|
+
build_rpath: lib_rpath,
|
|
118
|
+
install_rpath: lib_rpath,
|
|
72
119
|
)
|
|
73
120
|
|
|
74
121
|
g_ir_compiler = find_program('g-ir-compiler')
|
|
@@ -76,7 +123,7 @@ g_ir_compiler = find_program('g-ir-compiler')
|
|
|
76
123
|
custom_target(meson.project_name() + '-1.0.typelib',
|
|
77
124
|
command: [
|
|
78
125
|
g_ir_compiler,
|
|
79
|
-
'--shared-library',
|
|
126
|
+
'--shared-library', shared_lib_name,
|
|
80
127
|
'--output', '@OUTPUT@',
|
|
81
128
|
meson.current_build_dir() / meson.project_name() + '-1.0.gir',
|
|
82
129
|
],
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gjsify/oxfmt-native",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.23.0",
|
|
4
4
|
"description": "Vala/GObject + Rust cdylib bridge to oxc's formatter (oxfmt) for GJS. Formats JavaScript/TypeScript/JSX under GJS without a Node runtime — the Node-free counterpart to the npm `oxfmt` native napi binary, backing `gjsify format` under GJS. Wraps oxc_formatter (Prettier-compatible) via a single-shot FFI; the embedded CSS/HTML/Markdown ExternalFormatter (Prettier-NAPI) is out of scope.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/esm/index.js",
|
|
@@ -20,6 +20,11 @@
|
|
|
20
20
|
"src/vala"
|
|
21
21
|
],
|
|
22
22
|
"gjsify": {
|
|
23
|
+
"platforms": [
|
|
24
|
+
"linux-x86_64",
|
|
25
|
+
"linux-aarch64",
|
|
26
|
+
"darwin-arm64"
|
|
27
|
+
],
|
|
23
28
|
"prebuilds": "prebuilds",
|
|
24
29
|
"runtimes": {
|
|
25
30
|
"gjs": "polyfill",
|
|
@@ -36,9 +41,9 @@
|
|
|
36
41
|
"init:meson:wipe": "gjsify run init:meson --wipe",
|
|
37
42
|
"build": "gjsify run build:gjsify && gjsify run build:types",
|
|
38
43
|
"build:gjsify": "gjsify build --library 'src/ts/**/*.{ts,js}'",
|
|
39
|
-
"build:meson": "gjsify run init:meson && meson compile -C build",
|
|
44
|
+
"build:meson": "node ../../../scripts/check-refs-pin.mjs . && gjsify run init:meson && meson compile -C build",
|
|
40
45
|
"build:types": "gjsify tsc",
|
|
41
|
-
"build:prebuilds": "gjsify run build:meson &&
|
|
46
|
+
"build:prebuilds": "gjsify run build:meson && node ../../../scripts/stage-prebuild.mjs ."
|
|
42
47
|
},
|
|
43
48
|
"keywords": [
|
|
44
49
|
"gjs",
|
|
@@ -57,7 +62,7 @@
|
|
|
57
62
|
"@girs/gobject-2.0": "^4.1.0"
|
|
58
63
|
},
|
|
59
64
|
"devDependencies": {
|
|
60
|
-
"@gjsify/cli": "^0.
|
|
65
|
+
"@gjsify/cli": "^0.23.0",
|
|
61
66
|
"@types/node": "^25.9.2",
|
|
62
67
|
"typescript": "^6.0.3"
|
|
63
68
|
},
|