@gjsify/oxfmt-native 0.53.0 → 0.55.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.
Files changed (2) hide show
  1. package/meson.build +48 -7
  2. package/package.json +6 -6
package/meson.build CHANGED
@@ -52,16 +52,52 @@ if host_system == 'darwin'
52
52
  lib_rpath = '@loader_path'
53
53
  # Normalise the cdylib's LC_ID_DYLIB to @rpath/<leaf> BEFORE the Vala
54
54
  # library links against it: ld64 copies the dependency's install name
55
- # verbatim into the dependent's LC_LOAD_DYLIB. rustc's own install name has
56
- # varied across releases (absolute build path in older rustc, @rpath/<leaf>
57
- # in current ones); pinning it here makes the recorded dependency
58
- # rustc-version-independent, and @rpath/ is never longer than an absolute
59
- # path so install_name_tool can always rewrite in place.
60
- rust_cdylib_post = ' && install_name_tool -id "@rpath/' + rust_cdylib_name + '" "$3"'
55
+ # verbatim into the dependent's LC_LOAD_DYLIB. Pinning it here makes the
56
+ # recorded dependency rustc-version-independent, and @rpath/ is never
57
+ # longer than an absolute path so install_name_tool can always rewrite in
58
+ # place.
59
+ #
60
+ # The cdylib must be a FUNCTION OF ITS SOURCES, and on darwin that takes
61
+ # TWO steps, only the first of which `install_name_tool` could do.
62
+ # MEASURED with rustc 1.98.1 / ld64-27037.1 (macOS 27, arm64); the whole
63
+ # measurement and the reasoning behind each step: scripts/macho-set-uuid.mjs.
64
+ #
65
+ # 1. THE INSTALL NAME, at the LINK. rustc still gives a cdylib the ABSOLUTE
66
+ # path of its own output as `LC_ID_DYLIB`
67
+ # (`<builddir>/cargo-target/release/deps/<leaf>`), so the build
68
+ # directory's name and LENGTH reach the artifact: the recorded name, the
69
+ # load-command block's size, and therefore every section address after it.
70
+ # Without this, two builds from `build/` and `builddir/` differ by 8 bytes
71
+ # of pure layout before any content is compared. ld64 takes the LAST
72
+ # `-install_name` (verified), and a `-C link-arg` lands after rustc's own,
73
+ # so this one wins. `install_name_tool` then keeps the recorded dependency
74
+ # rustc-version-independent.
75
+ # 2. THE UUID, after every other edit (the script, which re-signs). ld64
76
+ # computed that field over the image it emitted and `install_name_tool`
77
+ # recomputes neither it nor the signature — and it is not a function of
78
+ # the emitted bytes even so, so pinning the name above still leaves 48
79
+ # moving bytes (16 `LC_UUID` + 32 of the signature hashing it). It is
80
+ # derived from the image instead, so if the CODE ever stops being a
81
+ # function of the sources the UUID moves with it and
82
+ # `check-prebuild-reproducible.mjs` still reds; nothing here hides
83
+ # content drift.
84
+ rust_cargo_link_args = ' -- -C link-arg=-Wl,-install_name,@rpath/' + rust_cdylib_name
85
+ rust_cargo_cmd = 'cargo rustc --lib'
86
+ # The repo's OWN script, from the package's own meson.build — so a bridge
87
+ # built outside the workspace has to say so itself rather than silently
88
+ # skipping the step that makes its artifact reproducible.
89
+ set_uuid_tool = meson.current_source_dir() / '..' / '..' / '..' / 'scripts' / 'macho-set-uuid.mjs'
90
+ rust_cdylib_post = ' && install_name_tool -id "@rpath/' + rust_cdylib_name + '" "$3"' \
91
+ + ' && ' + find_program('node').full_path() + ' "' + set_uuid_tool + '" "$3"'
61
92
  else
62
93
  rust_cdylib_name = 'libgjsify_oxfmt.so'
63
94
  shared_lib_name = 'libgjsifyoxfmt.so'
64
95
  lib_rpath = '$ORIGIN'
96
+ # ELF records a bare SONAME and no UUID load command, and its link line is
97
+ # already a function of the sources: the darwin branch's steps have no ELF
98
+ # spelling, so this one is left exactly as it was.
99
+ rust_cargo_link_args = ''
100
+ rust_cargo_cmd = 'cargo build'
65
101
  rust_cdylib_post = ''
66
102
  endif
67
103
 
@@ -72,6 +108,10 @@ endif
72
108
  # cdylib into the meson build dir under the expected name, so meson tracks
73
109
  # it as a build artifact and serializes the Vala link step behind it.
74
110
  # ----------------------------------------------------------------------------
111
+ # `cargo rustc --lib -- <args>` rather than `cargo build`, so the link args reach
112
+ # the FINAL crate's rustc and no other: the dependency rlibs and any build
113
+ # script are linked without them, and a pinned `-install_name` on an executable
114
+ # is not a thing ld64 wants.
75
115
  cargo = find_program('cargo')
76
116
 
77
117
  rust_sources = files(
@@ -93,7 +133,8 @@ rust_cdylib = custom_target('gjsify-oxfmt-rust',
93
133
  input: rust_sources,
94
134
  output: rust_cdylib_name,
95
135
  command: ['sh', '-c',
96
- 'cargo build --release ${CI:+--locked} --manifest-path "$1" --target-dir "$2" && cp "$2/release/'
136
+ rust_cargo_cmd + ' --release ${CI:+--locked} --manifest-path "$1" --target-dir "$2"'
137
+ + rust_cargo_link_args + ' && cp "$2/release/'
97
138
  + rust_cdylib_name + '" "$3"' + rust_cdylib_post,
98
139
  'sh',
99
140
  meson.current_source_dir() / 'src/rust/Cargo.toml',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gjsify/oxfmt-native",
3
- "version": "0.53.0",
3
+ "version": "0.55.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",
@@ -67,7 +67,7 @@
67
67
  "@girs/gobject-2.0": "5.4.0"
68
68
  },
69
69
  "devDependencies": {
70
- "@gjsify/cli": "^0.53.0",
70
+ "@gjsify/cli": "^0.55.0",
71
71
  "@types/node": "^25.9.2",
72
72
  "typescript": "^6.0.3"
73
73
  },
@@ -83,9 +83,9 @@
83
83
  },
84
84
  "homepage": "https://github.com/gjsify/gjsify/tree/main/packages/infra/oxfmt-native#readme",
85
85
  "optionalDependencies": {
86
- "@gjsify/oxfmt-native-darwin-arm64": "0.53.0",
87
- "@gjsify/oxfmt-native-darwin-x64": "0.53.0",
88
- "@gjsify/oxfmt-native-linux-arm64": "0.53.0",
89
- "@gjsify/oxfmt-native-linux-x64": "0.53.0"
86
+ "@gjsify/oxfmt-native-darwin-arm64": "0.55.0",
87
+ "@gjsify/oxfmt-native-darwin-x64": "0.55.0",
88
+ "@gjsify/oxfmt-native-linux-arm64": "0.55.0",
89
+ "@gjsify/oxfmt-native-linux-x64": "0.55.0"
90
90
  }
91
91
  }