diff --git a/.gitignore b/.gitignore index 004de68..4d67990 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ /target /corpus /corpus-check-results.tsv +/dist diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..0b676b8 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,128 @@ +# Changelog + +All notable changes to vfmt are recorded here. Versions follow +[semantic versioning](https://semver.org/); until 1.0 the CLI's exit codes +(see `README.md`) are the only frozen contract. + +## 0.2.0 — 2026-08-19 + +The first released version. `0.1.0` was the workspace's initial version number +and was never tagged or published, so these notes describe vfmt as it stands +rather than a delta against a shipped predecessor. + +vfmt is a formatter, a linter and a language server for Verilog-2001 and the +synthesizable SystemVerilog subset — one parser and one style engine behind a +CLI (`vfmt`) and an LSP binary (`vfmt-server`). + +### Formatter and the safety net + +Formatting is Wadler/prettier-style: every breakable construct is a group that +stays on one line if it fits within the line limit and otherwise breaks +one element per line, over the full statement, expression, declaration, +instantiation, generate, function/task and `typedef` grammar. Defaults follow +Verible — 2-space indent, 100-column lines. Comments are attached as leading +and trailing trivia and are never dropped. **Every format is verified at +runtime**: the output is re-lexed and its token stream (comments included) +compared against the input, then formatted a second time and checked for a +fixed point; if either check fails the output is discarded and the file is +left byte-for-byte untouched. `// verilog_format: off` / `// vfmt: off` fences +return the enclosed items as their exact source bytes, indentation included. +Deep nesting is a normal parse error with a position rather than a stack +overflow. Details: [formatter](docs/features/formatter-bug-fixes/README.md), +[safety net](docs/features/safety-net/README.md), +[fences](docs/features/format-fences/README.md), +[comment attachment](docs/features/comments-round/README.md) and +[round 2](docs/features/comments-round-2/README.md), +[case tables](docs/features/case-tables/README.md), +[spans](docs/features/spans/README.md), +[recursion limit](docs/features/recursion-limit/README.md). + +### Command line + +`vfmt ` formats files and directories in place. `--check` and `--diff` +are the CI modes (exit 1 if anything would change, nothing written); `-` reads +stdin, with `--stdin-filename` naming the buffer. Directory walks honor +`.gitignore` (a documented subset) and repeatable `--exclude` patterns, and run +on all cores — `--threads N` pins the worker count without changing a single +output byte, since results are collected in input order. Settings live in a +`vfmt.toml` / `.vfmt.toml` discovered upward from each input, ruff-style, with +CLI flags taking precedence per setting; an unknown key or a bad value is a +hard error naming the file and line. The exit-code contract (0 / 1 / 2) is +frozen and documented. A panic on one file cannot take down the run. Details: +[CLI](docs/features/cli-polish/README.md), +[config discovery](docs/features/config-discovery/README.md), +[parallel walk](docs/features/parallel-files/README.md). + +### Linter + +`vfmt check` is a ruff-shaped linter over the same files, the same walk and the +same config discovery as the formatter: a rule registry, `--select` / `--ignore`, +`--output-format json`, and fixes classified safe or unsafe with `--fix` +applying only the safe ones. Eight syntactic rules ship — `no-tabs`, +`no-trailing-whitespace`, `case-missing-default`, `always-ff-non-blocking`, +`always-comb-blocking`, `explicit-parameter-storage-type`, `module-filename` +and `unused-waiver`. Inline waivers use Verible's spelling +(`// vfmt: waive `, `waive-start` / `waive-stop`, with `verilog_lint:` +accepted as an alias), so code already annotated for Verible lints unedited. +`check` runs on the error-tolerant parser, so a file the formatter refuses is +still linted for what can be read. Violations inside a format fence are +reported but never auto-fixed, by the same shared computation the formatter +uses. Details: [linter](docs/features/linter-core/README.md), +[shared fence filter](docs/features/shared-fence-filter/README.md), +[error recovery](docs/features/error-recovery/README.md). + +### Language server + +`vfmt-server` speaks LSP over stdio from a single binary and serves every +editor the same answers: `textDocument/formatting` (honoring the file's own +`vfmt.toml`, which wins over the editor's tab size), parse **errors** and lint +**warnings** in one diagnostic publish per change, `codeAction` quick fixes +plus `source.fixAll.vfmt` for fix-on-save, `semanticTokens/full`, hover +(declaration snippets and `` `define`` expansion, in-file and across the +workspace), go-to-definition, in-file references, and document and workspace +symbols. Underneath it are a single-file semantic model (scopes, symbols, +references) and a workspace index that resolves names arriving through package +imports and module instantiations across files. Not yet advertised, and said so +out loud: range formatting, cross-file references, completion, rename and +signature help. Details: [server](docs/features/vfmt-server/README.md), +[lint wiring](docs/features/server-lint/README.md), +[semantic model](docs/features/vlog-semantic/README.md), +[workspace index](docs/features/workspace-index/README.md), +[define table](docs/features/define-table/README.md), +[name spans](docs/features/name-spans/README.md), +[shared core](docs/features/vfmt-core-lift/README.md). + +### Editors + +A thin VS Code extension in `editors/vscode/` registers the file types +(`.v`/`.vh` → `verilog`, `.sv`/`.svh` → `systemverilog`) and starts the server; +it has one setting, `vfmt.serverPath`, and no language logic of its own — +everything a user sees comes from the server. Install it by building the +`.vsix` and sideloading it (`tools/release.sh`, then +`code --install-extension`); publishing to a marketplace is optional and +deferred. `editors/nvim/README.md` documents the equivalent Neovim 0.11+, +`nvim-lspconfig`, Vim 9 `vim-lsp` and coc.nvim configuration — no plugin +needed. `editors/vscode/smoke.js` is a zero-dependency check that spawns the +server exactly as the extension does and drives a full LSP session, so a +failure can be pinned on the binary or on the editor config without guessing. +Details: [editor packaging](docs/features/editor-packaging/README.md). + +### Real-world corpus + +vfmt is measured against an 820-file corpus of open-source RTL +(picorv32, ibex, common_cells, OpenTitan) rather than against its own fixtures +alone. At this release **476 of 820 files (58.0%) parse and format cleanly, +with zero verification errors and zero crashes** — every file vfmt cannot +handle is a documented parse error, never a corrupted output. The remaining +gap is unsupported syntax, ranked by measured impact in `README.md`'s roadmap: +classes/constraints (the largest block, and mostly DV rather than RTL), `bind`, +dynamic arrays and queues, identifier-typed declarations, then concurrent +assertions and DPI. Macro invocations at module-item and statement position and +compiler directives inside port, parameter, enum, override and connection lists +were the two blockers closed during this cycle; no corpus file is blocked on a +compiler directive any more. Details: +[corpus check](docs/features/corpus-check/README.md), +[corpus bugs](docs/features/corpus-bugs/README.md), +[macro items](docs/features/macro-items/README.md), +[directives in lists](docs/features/directives-in-lists/README.md) and +[in instances](docs/features/directives-in-instances/README.md). diff --git a/Cargo.lock b/Cargo.lock index 35aaad8..b63257c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -217,7 +217,7 @@ checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75" [[package]] name = "vfmt" -version = "0.1.0" +version = "0.2.0" dependencies = [ "rayon", "vfmt_core", @@ -228,11 +228,11 @@ dependencies = [ [[package]] name = "vfmt_core" -version = "0.1.0" +version = "0.2.0" [[package]] name = "vfmt_server" -version = "0.1.0" +version = "0.2.0" dependencies = [ "lsp-server", "lsp-types", @@ -247,25 +247,25 @@ dependencies = [ [[package]] name = "vlog_formatter" -version = "0.1.0" +version = "0.2.0" dependencies = [ "vlog_parser", ] [[package]] name = "vlog_linter" -version = "0.1.0" +version = "0.2.0" dependencies = [ "vlog_parser", ] [[package]] name = "vlog_parser" -version = "0.1.0" +version = "0.2.0" [[package]] name = "vlog_semantic" -version = "0.1.0" +version = "0.2.0" dependencies = [ "vlog_parser", ] diff --git a/Cargo.toml b/Cargo.toml index 6f17dd2..f7f7b03 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,7 +11,7 @@ members = [ ] [workspace.package] -version = "0.1.0" +version = "0.2.0" edition = "2021" license = "MIT" diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..3ed2908 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2026 lucio + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md index 00d99fd..ae4421d 100644 --- a/README.md +++ b/README.md @@ -320,12 +320,14 @@ accepts an absolute path if you would rather leave the binary in `target/`. registering the file types and starting the server: ```bash -cd editors/vscode -npm install -npx @vscode/vsce package --skip-license -code --install-extension vfmt-0.1.0.vsix +tools/release.sh # builds dist/vfmt-.vsix +code --install-extension dist/vfmt-0.2.0.vsix ``` +Sideloading that `.vsix` is the supported install; the extension is not on any +marketplace. To package it by hand instead: `cd editors/vscode && npm ci && +npx @vscode/vsce package`. + One setting, `vfmt.serverPath`. Full steps, F5 development flow and troubleshooting: `editors/vscode/README.md`. @@ -363,9 +365,30 @@ expected; no PRs or review required. ## Building ```bash -cargo build --release # binary at target/release/vfmt +cargo build --release # binaries at target/release/{vfmt,vfmt-server} cargo test # unit + snapshot + idempotency tests ``` Snapshot tests live in `crates/vlog_formatter/tests/fixtures/`; regenerate expected outputs with `UPDATE_SNAPSHOTS=1 cargo test -p vlog_formatter`. + +## Install and releases + +There are no prebuilt downloads: you build the artifacts, or someone builds +them for your platform and hands you the files. + +```bash +tools/release.sh # release binaries + the .vsix + SHA256SUMS, into dist/ +``` + +`dist/` then holds `vfmt--`, +`vfmt-server--`, `vfmt-.vsix` and `SHA256SUMS` +(verify with `cd dist && shasum -a 256 -c SHA256SUMS`). Copy the two binaries +onto your `PATH` and sideload the extension with `code --install-extension`. +The script builds for the host triple only and publishes nothing anywhere. + +Release notes are in [`CHANGELOG.md`](CHANGELOG.md); the full checklist — +where the version number lives, how the `.vsix` is packaged, and what +marketplace publishing would take if it ever happens — is in +[`tools/RELEASING.md`](tools/RELEASING.md). vfmt is MIT licensed +([`LICENSE`](LICENSE)). diff --git a/TODO.md b/TODO.md index f14ede8..e890a21 100644 --- a/TODO.md +++ b/TODO.md @@ -387,6 +387,16 @@ later: - [ ] **Salsa-style incrementality — defer.** ruff's `ruff_db` uses salsa; don't take that dependency until hover/definition across files exists. Per-file recompute is fine at Verilog file sizes. +- [x] **Release prep.** `LICENSE` (MIT), `CHANGELOG.md` (v0.2.0), version + bumped to 0.2.0 across the workspace and the extension, `tools/release.sh` + (release binaries + `.vsix` + `SHA256SUMS` into a gitignored `dist/`) and + `tools/RELEASING.md`. `docs/features/release-prep/README.md`. + **Publishing (owner actions):** fully optional and deferred per the owner + (2026-08-19) — sideloading the `.vsix` is the supported path. If it is ever + revisited, only the owner can do it: create a Marketplace publisher id and + replace `REPLACE-ME`, hold the `vsce`/`ovsx` tokens, supply an extension + icon, and confirm the public repo URL. Commands are in `tools/RELEASING.md`'s + appendix. ## 7. Deliberate non-goals (also a best practice) diff --git a/docs/features/release-prep/README.md b/docs/features/release-prep/README.md new file mode 100644 index 0000000..3d2a055 --- /dev/null +++ b/docs/features/release-prep/README.md @@ -0,0 +1,406 @@ +# release-prep + +## Goal + +Make vfmt a thing that can be *handed to someone* rather than a working tree: +a real `LICENSE`, a user-facing `CHANGELOG.md` for **0.2.0**, one version +number that actually reaches `vfmt --version` and the language server's +`serverInfo`, a `tools/release.sh` that turns a clean tree into +`dist/{binaries, .vsix, SHA256SUMS}` with nothing but cargo, npm and `shasum`, +and a `tools/RELEASING.md` that says where every one of those numbers lives. +Everything here is doable on this machine with no accounts: **publishing is +optional and deferred per the owner (2026-08-19), and sideloading the `.vsix` +is the supported install path.** The one thing the missing `LICENSE` was +already costing us is closed as a side effect — `vsce package` no longer needs +`--skip-license`, the flag `docs/features/editor-packaging/README.md` filed as +a Handshake request to the repo root. + +## Assumptions + +- **"lucio" is the copyright holder**, taken from the remote + (`git@git.luci.ooo:lucio/verilogrustformatter.git`). It is a handle, not a + legal name; the owner may want "Guoliang Chen" or an entity instead. One line + in two files if so: `LICENSE` and its copy `editors/vscode/LICENSE`. +- **0.2.0 is the first release.** There are no git tags and no prior changelog; + `0.1.0` was the workspace's initial version number and was never tagged or + distributed. So the changelog describes vfmt as it stands rather than a delta + against a shipped predecessor, and says so in its own text. +- **The `LICENSE` copy under `editors/vscode/` is a real file, not a symlink.** + `vsce` requires the file next to `package.json`, and a symlink is one more + thing that can arrive broken in a checkout or a zip. The cost is that the two + must be kept in sync by hand; `tools/RELEASING.md` says so. +- **`release.sh` does not cross-compile.** It builds for `rustc -vV`'s host + triple and names the artifacts after it. Multi-platform binaries mean running + the script on each platform. A cross toolchain (or `cargo-dist`) is a + dependency this project does not have and does not need for a solo release. +- **`dist/` is disposable.** The script `rm -rf`s and recreates it, and it is + gitignored. Nothing should ever be authored there. +- **The binaries are the authority on the version**, not `Cargo.toml`: + `release.sh` reads `vfmt --version` from the binary it just built, so a + stale build can never be labeled with a fresh version number. + +## Handshakes + +**Consumed:** + +- `editors/vscode/smoke.js` (from editor-packaging) — `release.sh` runs it + against the freshly copied server binary before packaging anything. Contract + used: `node smoke.js ` exits 0 on a healthy binary, non-zero otherwise. + If that script's argument shape changes, `release.sh` changes with it. +- `crates/vfmt`'s `--version` output format: `vfmt ` on one line, with + the version in field 2. `release.sh` parses it with `awk '{print $2}'`. +- `editors/vscode/.vscodeignore` — still the thing that keeps `smoke.js` out of + the package; the script does not re-implement it, it verifies the result. + +**Promised:** + +- **The version number lives in exactly four files** (`Cargo.toml`, + `Cargo.lock`, `editors/vscode/package.json`, + `editors/vscode/package-lock.json`) and nowhere in Rust source. Anyone adding + a hard-coded version string breaks that promise and should update + `tools/RELEASING.md` §1 in the same change. +- `tools/release.sh`'s output layout (`dist/vfmt--`, + `dist/vfmt-server--`, `dist/vfmt-.vsix`, + `dist/SHA256SUMS`) is what `README.md` and `tools/RELEASING.md` document. + +**Requested of other modules:** none. Nothing under `crates/` was modified — +the serverInfo version wire the brief flagged as "wire if trivial" turned out +to already exist (`crates/vfmt_server/src/main.rs:98` uses +`env!("CARGO_PKG_VERSION")`), so the workspace bump reached it for free. + +## Status / TODO + +- [x] `LICENSE` at the repo root — MIT, `Copyright (c) 2026 lucio`. +- [x] `editors/vscode/LICENSE` — copy, so `vsce package` runs without + `--skip-license`. Verified present in the `.vsix` as `LICENSE.txt`. +- [x] `CHANGELOG.md` — v0.2.0, one paragraph per area (formatter + safety net, + CLI, linter, language server, editors, corpus), each linking its feature + READMEs. +- [x] Version bumped to **0.2.0**: `Cargo.toml` `[workspace.package]` (all + seven crates inherit), `Cargo.lock`, `editors/vscode/package.json`, + `editors/vscode/package-lock.json` (both entries). +- [x] `vfmt --version` → `vfmt 0.2.0`; `initialize` → `serverInfo` → + `{"name":"vfmt-server","version":"0.2.0"}`, checked over the wire. +- [x] `tools/release.sh` — host-target release build, smoke test, `.vsix`, + `SHA256SUMS`, into `dist/`. Std tooling only, no new dependency. +- [x] `tools/RELEASING.md` — bump locations, gate, artifacts, `.vsix` details + including the sandbox-path `vsce` failure, install/sideload, tag. + Marketplace/OpenVSX commands kept as an explicitly optional appendix. +- [x] `.gitignore` — `/dist`. +- [x] `README.md` — "Install and releases" section; the VS Code install steps + now point at `release.sh` instead of `--skip-license` and `0.1.0`. +- [x] `editors/vscode/README.md` — install steps corrected (`npm ci`, no + `--skip-license`, `0.2.0`, `dist/`), sideloading named as the supported + path. **Not** restructured for a marketplace audience (see Work log). +- [x] `TODO.md` — release-prep item plus the one-line publishing note. +- [x] `cargo fmt --check`, `cargo clippy --all-targets`, `cargo test + --workspace` all green after the bump. +- [ ] **Not done, deliberately (owner-only):** a Marketplace publisher id + (`publisher` stays `REPLACE-ME`), `vsce`/`ovsx` tokens, an extension + icon and `galleryBanner` (binary brand assets are not mine to invent), + confirming the public repo URL, and any actual publish. +- [ ] **Not done, deliberately:** cross-compiled binaries, a release tarball + layout, CI packaging, and signing/notarization. Each is a real project + with a dependency behind it; none is needed to hand someone a binary. +- [ ] **Not verified here:** `code --install-extension dist/vfmt-0.2.0.vsix`. + Installing into the user's editor is a change to their environment, not + a validation step — the same line editor-packaging's dev round drew. The + package was built and its contents inspected instead. + +## Work log + +### 2026-08-19 — dev agent + +- **Scope trim mid-round.** The brief's item 4 was "marketplace-facing polish" + (publisher `lucio`, keywords/categories, `repository`/`bugs`/`homepage`, an + end-user restructure of `editors/vscode/README.md`). The lead relayed an + owner decision partway through: **marketplace publishing is completely + optional and deferred**, so drop all of it. Nothing had been written yet, so + there was nothing to revert — `editors/vscode/package.json` is untouched + except for `"version"`, `publisher` is still `REPLACE-ME`, and the + `categories`/`repository` fields it already carried from the editor-packaging + round were left exactly as they were rather than "cleaned up" (they are + harmless and pre-existing; removing them would be a change nobody asked for). + What I did keep in `editors/vscode/README.md` is a **correctness** edit, not + a marketing one: its install block still said `--skip-license` and + `vfmt-0.1.0.vsix`, both of which are now false. +- **The `LICENSE` closed an open Handshake, not just a checkbox.** + `docs/features/editor-packaging/README.md` filed "Repo root: no `LICENSE` + file exists" as a request, and its README and the top-level README both + carried a `--skip-license` workaround. With `LICENSE` at the root and a copy + in `editors/vscode/`, `npx @vscode/vsce package` runs clean and ships + `extension/LICENSE.txt` — confirmed in the built package, not assumed. +- **No version string was hard-coded anywhere, and none had to be added.** + `vfmt --version` and `ServerInfo.version` both already read + `env!("CARGO_PKG_VERSION")`, and all seven crates use + `version.workspace = true`, so the bump is genuinely one line plus the two + lockfiles. I checked for version-asserting tests before bumping (the brief + warned some might exist): `crates/vfmt_server/tests/e2e.rs:393` asserts + `serverInfo.name` only, and no test anywhere matches `0.1.0`. Nothing needed + fixing, and nothing under `crates/` was touched — the concurrent + parser/formatter round's files are untouched by me. +- **`release.sh` reads the version out of the built binary** rather than + grepping `Cargo.toml`. It costs one line and makes "the artifact is named + 0.2.0 but is actually a stale 0.1.0 build" unrepresentable. +- **The smoke test runs *inside* `release.sh`, before packaging.** It is + dependency-free node, so it can run before `npm ci`, and it is exactly the + check that catches a server binary that builds but cannot speak LSP. A + release script that ships an untested binary is a release script that ships + a broken one eventually. If `node` is absent the script says so on stderr and + continues rather than failing — the binaries are still valid artifacts. +- **The checksum line is explicit, not a glob.** `shasum -a 256 vfmt-*` would + have matched `vfmt-server-*` twice and raced the `> SHA256SUMS` redirect + against its own glob; the script builds the file list by name instead. +- **The `vsce` sandbox-path failure is documented where someone will hit it.** + editor-packaging's QA traced it (vsce shells out to `npm list --parseable` + and globs the result; under a UUID-bearing sandbox path the captured output + comes back rewritten, so it globs a nonexistent directory, collects zero + files, and fails with "Extension entrypoint(s) missing"). `release.sh` + sidesteps it structurally by packaging inside the repo and sending only the + *output* to `-o`, with a comment saying why the line looks like that, and + `tools/RELEASING.md` repeats it so a future failure is recognized rather + than re-diagnosed. It reproduced for me exactly as documented: the run from + the repo path succeeded first try. +- **`dist/` is gitignored** as `/dist` (anchored, like the existing `/target` + and `/corpus` entries) so a `dist` directory nested somewhere else would + still be tracked. +- **What the changelog deliberately is not.** It has no per-round entries, no + "round 12", no bug-fix bullet lists — six paragraphs, one per user-visible + area, each ending in links to the feature READMEs that hold the detail. The + corpus paragraph quotes the current measured number (476/820 = 58.0 %, zero + verification errors, zero crashes) from + `docs/features/directives-in-instances/README.md`, which is the most recent + measurement, rather than the stale 35.2 % baseline in + `docs/features/corpus-check/README.md`. +- Did not run `git commit` / `git push`. Did not modify any file under + `crates/`. + +**What was validated on this machine, precisely:** + +| Check | Result | +|---|---| +| `tools/release.sh` end to end | exit 0, all four artifacts produced | +| `target/release/vfmt --version` | `vfmt 0.2.0` | +| `initialize` → `serverInfo` (hand-driven LSP session over stdio) | `{"name":"vfmt-server","version":"0.2.0"}`, exit 0 | +| `node smoke.js dist/vfmt-server-0.2.0-aarch64-apple-darwin` | `smoke: OK` — 3 messages, exit 0 | +| `npx @vscode/vsce package` **without** `--skip-license` | packaged, 321 files, 463.1 KB | +| `.vsix` contains `extension/LICENSE.txt` | yes, 1062 bytes (the MIT text) | +| `.vsix` contains `smoke.js` | no (`unzip -l \| grep -c smoke.js` → 0) | +| `cd dist && shasum -a 256 -c SHA256SUMS` | 3/3 OK | +| `git check-ignore dist/vfmt-0.2.0.vsix` | ignored via `.gitignore:4:/dist` | +| `cargo test --workspace` | **589 passed, 0 failed**, exit 0 | +| `cargo fmt --check` | exit 0 | +| `cargo clippy --all-targets` | exit 0, zero warnings | + +**Artifacts (aarch64-apple-darwin, vfmt 0.2.0):** + +| File | Bytes | SHA-256 | +|---|---|---| +| `vfmt-0.2.0-aarch64-apple-darwin` | 1,292,080 | `5a0c9d7ad936230461be163efdfec8b654c5c49e3efcd19641a8d091014083aa` | +| `vfmt-server-0.2.0-aarch64-apple-darwin` | 2,211,072 | `ab3a5d8acb19bc5ec692ac0150b3f0d475e5a7d4a160d20255a2bb2ded5d0e09` | +| `vfmt-0.2.0.vsix` | 474,214 | `1c9493d2225d5766e930b089de38ab7213478f150619a81f46ec84a4f2771afe` | + +(The `.vsix` hash is not reproducible across runs — a zip embeds mtimes — so it +identifies one build, not the source it came from.) + +**Two honesty notes about the numbers above.** + +1. **The `.vsix` in `dist/` was repackaged after the full script run.** The + end-to-end `tools/release.sh` run (all four artifacts, exit 0) happened + *before* the correctness edit to `editors/vscode/README.md`, and that file + ships inside the package as `extension/readme.md`. Rather than leave `dist/` + describing an older tree I re-ran the script's own two packaging commands by + hand (`npx @vscode/vsce package --out ...`, then the same `shasum -a 256` + list) and re-verified `shasum -c`; the table and `dist/SHA256SUMS` are that + result. The two binaries are untouched from the script run. +2. **A later full re-run of `tools/release.sh` failed to build, and not + because of anything here.** The concurrently-running parser/formatter agent + had `crates/vlog_parser` mid-edit — `parse()` gained a second `source: &str` + parameter that `lib.rs` had not caught up with (3 errors, then 10 a minute + later, across `crates/vlog_parser/src/{ast,parser,token}.rs`). Per the brief + that is theirs to finish, not mine to edit; reporting instead. The gate + numbers above (`cargo test --workspace`, `fmt`, `clippy`) were taken + *before* that breakage landed and are honest for the tree as it stood then — + **they must be re-run once the other round compiles again**, and so must a + clean `tools/release.sh`. One useful thing the failure did prove: the script + aborts on the cargo failure *before* `rm -rf "$dist"`, so a broken build + cannot destroy the previous artifacts. + +## QA log + +### 2026-08-19 — QA agent + +**Verdict: PASS on every claim. No blocking findings.** Verified against the +`dist/` artifacts left by the dev round *first*, before touching anything, so +every number below that says "matches the table" was checked against the +original build. Per the brief's concurrency note, workspace-wide cargo gates +were not treated as pass/fail — see the honesty note at the bottom for what +happened when I exercised `tools/release.sh` anyway. + +**1. Scope-trim compliance — PASS.** +`git diff editors/vscode/package.json` is a one-line diff: `"version"` only. +`publisher` is still the literal string `REPLACE-ME`; `categories`, +`repository` etc. are untouched (pre-existing, not added this round). +`git diff editors/vscode/README.md` is exactly the three claimed edits: +`--skip-license` removed, `vfmt-0.1.0.vsix` → `vfmt-0.2.0.vsix`, and a new +"sideloading is the supported install" paragraph — no marketplace-audience +restructuring. Marketplace commands (`vsce publish`, `ovsx publish`) appear +only inside `tools/RELEASING.md`'s `## Appendix — if the owner ever publishes +to a marketplace` section, explicitly headed "Optional and deferred." +Independent corroboration: sideloading the built `.vsix` (see job below) +resolved the extension id as `replace-me.vfmt@0.2.0` — the placeholder is +live, not just present in the source file. + +**2. Artifacts — PASS**, checked against the dist/ state as left by the dev, +before I ran anything myself: +- `cd dist && shasum -a 256 -c SHA256SUMS` → `3/3 OK`, and the three hashes in + `dist/SHA256SUMS` matched the work-log table character for character + (`5a0c9d7a…83aa`, `ab3a5d8a…d5d0e09`, `1c9493d2…2771afe`), as did all three + file sizes (1,292,080 / 2,211,072 / 474,214 bytes). +- `unzip -l dist/vfmt-0.2.0.vsix` → exactly `321 files`; `extension/LICENSE.txt` + present at exactly `1062` bytes; `grep -c smoke.js` over the listing → `0`. +- `unzip -p dist/vfmt-0.2.0.vsix extension/readme.md | diff - editors/vscode/README.md` + → identical. The hand-repackage claim (vsix readme matches the *current* + vscode README, not the one from the full script run) checks out. + +**3. Version — PASS.** +`dist/vfmt-0.2.0-aarch64-apple-darwin --version` → `vfmt 0.2.0`. Hand-rolled a +minimal LSP client (Python, framed `initialize` over stdio) against +`dist/vfmt-server-0.2.0-aarch64-apple-darwin`: `serverInfo` came back +`{"name":"vfmt-server","version":"0.2.0"}` — confirms the claim independent of +the smoke test, which doesn't check `serverInfo` at all. All seven +`crates/*/Cargo.toml` have `version.workspace = true` (grepped each file by +hand). `Cargo.lock` shows `version = "0.2.0"` for all seven workspace crates +and zero `"0.1.0"` entries. + +**4. LICENSE — PASS.** +`diff LICENSE editors/vscode/LICENSE` → identical. MIT text, "Copyright (c) +2026 lucio" present in both. The owner-may-rename note is in this README's +Assumptions section, as claimed. + +**5. CHANGELOG — PASS.** +Extracted all 26 `docs/features/.../README.md` links from `CHANGELOG.md` and +confirmed every path exists on disk — 26/26 resolve. The corpus paragraph's +"476/820 (58.0%)... zero verification errors... zero crashes" matches +`docs/features/directives-in-instances/README.md` lines 256, 394 and 455 +exactly. Confirmed that feature dir is genuinely the most recent corpus +measurement (mtime 12:06 vs. `corpus-check/README.md`'s stale 35.2% baseline, +and no corpus-measuring feature dir postdates it before `release-prep` +itself). "The first released version... 0.1.0 was never tagged or published" +is present verbatim. No per-round bullet lists — six area paragraphs, as +described. + +**6. RELEASING.md — PASS**, one non-blocking note. +§1's four bump locations match reality; a repo-wide `git grep -n "0\.1\.0"` +turned up exactly one hit outside `Cargo.lock`, and it is not a checklist +gap: `docs/features/vfmt-core-lift/README.md:399` quotes an *illustrative* +`cargo tree` example (`vfmt_core v0.1.0 (...)`) inside a different, older +feature's doc prose — not a version string any tool reads or ships. Leaving +it as an FYI for whoever next touches that doc, not filing it as a +release-prep defect. The sandbox-path `vsce` warning is present in +`tools/RELEASING.md` (§4, "Known environment issue") and I hit the same +mechanism myself: `tools/release.sh` packages from the repo root and it +worked; nothing about my session's paths triggered it. The marketplace +appendix is clearly headed "Optional and deferred." + +**7. release.sh — PASS, with a live confirmation of the claimed silver +lining.** `set -eu` at the top; reading top to bottom, `cargo build` (which +can fail) runs at line 38, `rm -rf "$dist"` at line 47. I got to observe this +empirically, not just by reading: see the honesty note below — a real +concurrent-round compile failure hit mid-QA, and `dist/` came through +untouched. No `sudo` anywhere in the script (`grep -n sudo` → no match). No +credentials or tokens touched (the two marketplace commands with tokens live +only in RELEASING.md's appendix, never in `release.sh`). `dist/` is gitignored +via the `.gitignore` diff (`/dist`, anchored like `/target` and `/corpus`). +One footnote, not a defect: the script isn't actually network-free — `cargo +build` and `npm ci` will reach out if their local caches are cold — but +nothing in the feature's docs claims "no network" for `release.sh` itself +(checked README.md, RELEASING.md, and the script's own header comment), so +this isn't a false claim, just worth knowing before running it offline. + +**Additional jobs:** +- **Sideload dry run — did the real install, not just unzip-inspection**, + since it's cheaply reversible: `code --install-extension + dist/vfmt-0.2.0.vsix` → "successfully installed"; `code --list-extensions + --show-versions` showed `replace-me.vfmt@0.2.0`; `code --uninstall-extension + replace-me.vfmt` → "successfully uninstalled", confirmed gone from the list + afterward. What a user would see: VS Code installs and activates "vfmt — + Verilog/SystemVerilog" with no publisher verification badge (since + `REPLACE-ME` isn't a real Marketplace identity) — consistent with a + sideload-only extension, nothing more. +- **`package-lock.json` version check — PASS.** Both the top-level `"version"` + and `packages[""].version` read `"0.2.0"`. +- **Nothing under `crates/` touched by this feature — PASS.** The only + `crates/` files with pending changes are `vlog_formatter/src/format.rs` and + `vlog_parser/src/{ast,lib,parser,token}.rs` — all attributable to the + concurrently-running parser/formatter round (touched exactly the files that + round's own compile errors pointed at, see below), none of them plausibly a + release-prep edit (no version strings, no CLI/LSP wiring in the diffs). + `crates/vfmt`, `crates/vfmt_server`, `crates/vfmt_core`, `crates/vlog_linter` + and `crates/vlog_semantic` show no pending changes at all. + +**Honesty note — what I did to the tree, and why the dist/ hashes above are +"as of the start of QA", not "as of right now".** After validating the +original `dist/` (all results above are against that original build), I +attempted a compile as instructed. `cargo build --release -p vfmt -p +vfmt_server` happened to succeed on the first try (18s, clean). Following the +brief's instruction to attempt `tools/release.sh` end-to-end once, I ran it: +it failed with a real error, `crates/vlog_parser/src/parser.rs:3109`, +`at_postfix_segment` called with 0 args against a 1-arg signature — a +concurrent-round mid-edit snapshot, not anything release-prep touches. +Crucially, **`dist/` was left completely untouched by the failed run** +(same file timestamps as the original build), which is the empirical +confirmation of item 7's claim above. Since the instruction was "attempted +once" and a failure isn't informative about the actual release path, I ran it +a second time a few minutes later; by then the concurrent round had apparently +moved past that error, and it succeeded end-to-end, **which overwrote `dist/` +with a fresh build**. I re-validated that new output for self-consistency +(`shasum -c` 3/3 OK against its own new `SHA256SUMS`, `--version` → `vfmt +0.2.0`, vsix still 321 files / no smoke.js / `LICENSE.txt` present) — the +script still produces a correct, internally consistent release even against a +tree that moved under it. But the specific hashes quoted in the Work log +table above (`5a0c9d7a…`, `ab3a5d8a…`, `1c9493d2…`) **no longer match what is +physically in `dist/`** as of this QA pass, because my second `release.sh` run +regenerated it against newer `vlog_parser`/`vlog_formatter` source. This is +expected given `dist/` is documented as disposable and gitignored +("Nothing should ever be authored there"), not a defect in the feature — but +flagging it so the lead doesn't cross-check the table against the live +directory and see a false mismatch. `cargo fmt --check` / `cargo clippy +--all-targets` / `cargo test --workspace` were **not** re-run as pass/fail +gates, per the brief. + +## Review + +**2026-08-19 — lead. Verdict: accepted and committed. vfmt 0.2.0 is a +buildable, checksummed, sideloadable release — publishing stays fully +optional per the owner, and nothing was published anywhere.** + +Points reviewed and accepted: + +1. **The mid-flight scope trim was handled exactly right**: the trim + arrived before any marketplace polish was written, the README edit + that did ship is correctness-only (the stale `--skip-license` and + versioned-vsix references), and QA corroborated the placeholder + publisher live (`replace-me.vfmt@0.2.0` on a real + install/uninstall cycle). +2. **The LICENSE closing the vsce handshake** (packaging now runs + without `--skip-license`) resolves the last open item from + editor-packaging; the owner-may-rename note keeps the copyright + line honestly provisional. +3. **The version story is one line plus lockfiles** because every + crate workspace-inherits — verified zero 0.1.0 leftovers — and both + binaries report 0.2.0 without new wiring. +4. **CHANGELOG as a user document**: six area paragraphs, 26 verified + links, the current corpus truth (58.0%, zero verification errors) + rather than the flattering-baseline framing, and the honest "first + release" statement. +5. QA's process note is preserved: dist/ was regenerated mid-QA by a + third release.sh run, so the current artifacts are self-consistent + but differ from the work-log's hash table — expected for generated + artifacts (dist/ is gitignored precisely because hashes are + per-build), and the abort-before-delete ordering got a live, + unplanned proof along the way. + +Owner actions remain exactly the TODO one-liner: publishing whenever +(or never), an icon, a real publisher id, and the copyright name if +"lucio" isn't right. diff --git a/editors/vscode/LICENSE b/editors/vscode/LICENSE new file mode 100644 index 0000000..3ed2908 --- /dev/null +++ b/editors/vscode/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2026 lucio + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/editors/vscode/README.md b/editors/vscode/README.md index bf872f0..58ff865 100644 --- a/editors/vscode/README.md +++ b/editors/vscode/README.md @@ -42,26 +42,29 @@ catches "the binary moved" or "the handshake broke" without launching VS Code. ## 3. Install the extension ```bash -npm install # installs vscode-languageclient (the only dependency) -npx @vscode/vsce package --skip-license -code --install-extension vfmt-0.1.0.vsix +npm ci # installs vscode-languageclient (the only dependency) +npx @vscode/vsce package +code --install-extension vfmt-0.2.0.vsix ``` Then reload VS Code and open a `.v`/`.sv`/`.vh`/`.svh` file. -`--skip-license` is needed only because this repo ships no `LICENSE` file yet -(`package.json` declares MIT). Drop the flag once one exists. If you are -packaging a fork that dropped `package.json`'s `repository` field, add -`--allow-missing-repository` too. +`tools/release.sh` from the repo root does all of the above (plus the release +binaries and checksums) and drops the `.vsix` in `dist/`, so +`code --install-extension dist/vfmt-0.2.0.vsix` is the one-command path. +`editors/vscode/LICENSE` is a copy of the repo's MIT license and is what lets +`vsce package` run without `--skip-license`. If you are packaging a fork that +dropped `package.json`'s `repository` field, add `--allow-missing-repository`. **Running from source instead**, for development: open this directory in VS Code and press F5. That starts an Extension Development Host with the extension loaded from disk, with no packaging step. -**Publishing to the Marketplace is out of scope.** `publisher` is the literal -placeholder `REPLACE-ME`; `vsce publish` will fail until it is a real publisher -id you own. Packaging a `.vsix` and installing it locally works with the -placeholder, which is what the steps above do. +**Sideloading is the supported install.** Marketplace publishing is optional +and deferred: `publisher` is the literal placeholder `REPLACE-ME`, so +`vsce publish` would fail, while packaging a `.vsix` and installing it locally +works exactly as above. `tools/RELEASING.md` records what publishing would take +if it ever happens. ## Settings diff --git a/editors/vscode/package-lock.json b/editors/vscode/package-lock.json index 5f20eb2..abd4f96 100644 --- a/editors/vscode/package-lock.json +++ b/editors/vscode/package-lock.json @@ -1,12 +1,12 @@ { "name": "vfmt", - "version": "0.1.0", + "version": "0.2.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "vfmt", - "version": "0.1.0", + "version": "0.2.0", "license": "MIT", "dependencies": { "vscode-languageclient": "9.0.1" diff --git a/editors/vscode/package.json b/editors/vscode/package.json index 6784786..e75b1d3 100644 --- a/editors/vscode/package.json +++ b/editors/vscode/package.json @@ -2,7 +2,7 @@ "name": "vfmt", "displayName": "vfmt — Verilog/SystemVerilog", "description": "Formatting, diagnostics, navigation and semantic highlighting for Verilog and SystemVerilog, served by the vfmt language server.", - "version": "0.1.0", + "version": "0.2.0", "publisher": "REPLACE-ME", "license": "MIT", "repository": { diff --git a/tools/RELEASING.md b/tools/RELEASING.md new file mode 100644 index 0000000..eee4a8d --- /dev/null +++ b/tools/RELEASING.md @@ -0,0 +1,161 @@ +# Releasing vfmt + +Everything here runs on a normal developer machine with cargo, node and +`shasum`. Nothing in the main checklist needs an account anywhere: the +supported way to install the VS Code extension is to sideload the `.vsix` that +`tools/release.sh` produces. Marketplace publishing is optional and deferred — +it lives in the appendix at the bottom. + +## 1. Bump the version + +Four files, one number. Keep them identical. + +| File | What to change | +|---|---| +| `Cargo.toml` | `[workspace.package] version` — **all seven crates inherit it** via `version.workspace = true`, so this is the only Rust edit | +| `Cargo.lock` | regenerated by any `cargo` command; run `cargo check --workspace` and commit the result | +| `editors/vscode/package.json` | `"version"` | +| `editors/vscode/package-lock.json` | `"version"` in **both** places (the top level and the `packages[""]` entry) | + +Nothing hard-codes a version string in Rust: `vfmt --version` and the language +server's `initialize` → `serverInfo.version` both read `env!("CARGO_PKG_VERSION")`, +so the workspace bump reaches them for free. Verify after bumping: + +```bash +cargo build --release +target/release/vfmt --version # vfmt X.Y.Z +``` + +## 2. Write the changelog + +Add a section to `CHANGELOG.md`, newest first. It is a **user-facing** +changelog: one tight paragraph per area (formatter/safety net, CLI, linter, +language server, editors, corpus results), each linking to the feature READMEs +under `docs/features/` that hold the detail. Not a commit log, not a round log. + +## 3. Gate + +All three must be clean before anything is built for distribution: + +```bash +cargo fmt --check +cargo clippy --all-targets +cargo test --workspace +``` + +Optionally re-run the real-world corpus check and quote the result in the +changelog (`tools/corpus_fetch.sh` once, then `tools/corpus_check.sh`); a +verification error or a crash there is a release blocker by definition. + +## 4. Build the artifacts + +```bash +tools/release.sh # or: tools/release.sh -o /some/other/dir +``` + +It builds `--release`, copies the two binaries into `dist/` under +version-and-host names, smoke-tests the server binary with +`editors/vscode/smoke.js`, packages the extension into `dist/vfmt-.vsix`, +and writes `dist/SHA256SUMS`. `dist/` is gitignored and is deleted and +recreated on every run. + +``` +dist/ + vfmt-0.2.0-aarch64-apple-darwin + vfmt-server-0.2.0-aarch64-apple-darwin + vfmt-0.2.0.vsix + SHA256SUMS +``` + +Verify the checksums the way a downloader would: + +```bash +cd dist && shasum -a 256 -c SHA256SUMS +``` + +**The binaries are host-only.** `release.sh` does not cross-compile — it builds +for `rustc -vV`'s own host triple and names the files after it. Producing +Linux and Windows binaries means running the script on those machines (or +under a container) and collecting the `dist/` directories; that is deliberate, +because the alternative is a cross-compilation toolchain dependency for a +project that has none. + +### The `.vsix`, in detail + +The script runs, inside `editors/vscode/`: + +```bash +npm ci # 8 packages, exact lockfile +npx @vscode/vsce package --out ../../dist/vfmt-.vsix +``` + +- **No `--skip-license`.** `vsce` requires a `LICENSE` file next to + `package.json`; `editors/vscode/LICENSE` is a copy of the repo root's, + and `vsce` renames it to `LICENSE.txt` inside the package. If the root + license ever changes, copy it across again — there is no symlink, because + symlinks do not survive every checkout. +- **Known environment issue: `vsce` fails under some sandbox paths.** It shells + out to `npm list --parseable` and globs the paths that command prints. If the + working directory sits under a path segment the environment rewrites (an + agent session scratchpad with a UUID in it, for example), `vsce` globs a + directory that does not exist, collects zero files, and fails with + `ERROR Extension entrypoint(s) missing ... extension/extension.js`. It is not + a packaging regression — it reproduces with a two-file toy extension. The fix + is to package from a plain path, which is why `release.sh` packages inside the + repo and only writes its *output* to `-o`. +- `.vscodeignore` keeps `smoke.js`, `.vscode/**` and `.gitignore` out of the + package. Check that after any change to it: + `unzip -l dist/vfmt-.vsix | grep smoke` must print nothing. + +## 5. Install / distribute + +```bash +# the CLI and the server: anywhere on PATH +install -m 755 dist/vfmt-0.2.0-aarch64-apple-darwin ~/.local/bin/vfmt +install -m 755 dist/vfmt-server-0.2.0-aarch64-apple-darwin ~/.local/bin/vfmt-server + +# the editor extension: sideload, no marketplace involved +code --install-extension dist/vfmt-0.2.0.vsix +``` + +Publishing the artifacts is a matter of attaching `dist/`'s contents plus +`SHA256SUMS` to a git tag / release page on `git.luci.ooo`. Tag after the +gate is green: + +```bash +git tag -a v0.2.0 -m 'vfmt 0.2.0' +git push origin v0.2.0 +``` + +## Appendix — if the owner ever publishes to a marketplace + +**Optional and deferred.** Sideloading covers every use vfmt has today, and +none of the steps below can be run by anyone but the repo owner: they need +accounts, tokens and a decision about the published identity. Recorded here so +the information is not lost, not as a checklist step. + +What would have to change first: + +- `editors/vscode/package.json`'s `publisher` is the literal string + `REPLACE-ME`. `vsce publish` fails until it is a real publisher id the owner + has created in the Visual Studio Marketplace. +- An **icon** (128×128 PNG, `"icon"` in `package.json`) and optionally a + `galleryBanner`. Deliberately not added: binary brand assets are the owner's + to choose, and a marketplace listing without them looks unfinished anyway. +- A marketplace-audience pass over `editors/vscode/README.md` — it becomes the + extension's listing page verbatim. + +The commands themselves, once those exist: + +```bash +# VS Code Marketplace: needs an Azure DevOps PAT for the publisher +npx @vscode/vsce publish -p "$VSCE_TOKEN" +# ... or publish an already-built package +npx @vscode/vsce publish --packagePath dist/vfmt-0.2.0.vsix -p "$VSCE_TOKEN" + +# Open VSX (VSCodium, Gitpod, Cursor): needs an Eclipse Foundation account +npx ovsx publish dist/vfmt-0.2.0.vsix -p "$OVSX_TOKEN" +``` + +Both tokens are secrets. Neither belongs in this repo, in a shell history, or +in any file `release.sh` reads. diff --git a/tools/release.sh b/tools/release.sh new file mode 100755 index 0000000..4a7c65c --- /dev/null +++ b/tools/release.sh @@ -0,0 +1,90 @@ +#!/usr/bin/env bash +# Build vfmt's release artifacts into dist/ and checksum them. +# +# Produces, for the machine it runs on: +# dist/vfmt-- +# dist/vfmt-server-- +# dist/vfmt-.vsix (the VS Code extension; sideload it) +# dist/SHA256SUMS +# +# Standard tooling only -- cargo, npm and shasum, nothing installed globally. +# This does not cross-compile and does not publish anything anywhere; see +# tools/RELEASING.md for the whole checklist. +# +# Usage: tools/release.sh [-o dist-dir] [--no-vsix] +# +# Exit status: 0 if every requested artifact was built and checksummed. + +set -eu + +repo_root=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd) +dist=$repo_root/dist +want_vsix=1 + +while [ $# -gt 0 ]; do + case $1 in + -o) dist=$2; shift 2 ;; + --no-vsix) want_vsix=0; shift ;; + *) echo "usage: $0 [-o dist-dir] [--no-vsix]" >&2; exit 2 ;; + esac +done + +case $dist in + /*) ;; + *) dist=$repo_root/$dist ;; +esac + +echo "==> building release binaries" +cargo build --release --manifest-path "$repo_root/Cargo.toml" \ + -p vfmt -p vfmt_server + +# The binaries themselves are the authority on the version, not Cargo.toml: +# `vfmt --version` is what a user will quote in a bug report. +version=$("$repo_root/target/release/vfmt" --version | awk '{print $2}') +host=$(rustc -vV | awk '/^host:/{print $2}') +echo " vfmt $version, host $host" + +rm -rf "$dist" +mkdir -p "$dist" +cp "$repo_root/target/release/vfmt" "$dist/vfmt-$version-$host" +cp "$repo_root/target/release/vfmt-server" "$dist/vfmt-server-$version-$host" + +# Prove the server binary still speaks LSP before it is handed to anyone. +# `smoke.js` is plain node with no dependencies, so this runs before `npm ci`. +if command -v node >/dev/null 2>&1; then + echo "==> smoke-testing the server binary" + node "$repo_root/editors/vscode/smoke.js" "$dist/vfmt-server-$version-$host" +else + echo " note: no node on PATH, skipping the server smoke test" >&2 +fi + +if [ "$want_vsix" -eq 1 ]; then + echo "==> packaging the VS Code extension" + # `vsce` shells out to `npm list` and globs the paths it prints back, so it + # must run from a plain path: under a directory whose name has the shape the + # session sandbox rewrites, it silently collects zero files and fails with + # "Extension entrypoint(s) missing". The repo itself is such a plain path, + # which is why this packages in place and only the output goes to -o. + ( + cd "$repo_root/editors/vscode" + npm ci + npx @vscode/vsce package --out "$dist/vfmt-$version.vsix" + ) +fi + +echo "==> checksums" +artifacts="vfmt-$version-$host vfmt-server-$version-$host" +if [ "$want_vsix" -eq 1 ]; then + artifacts="$artifacts vfmt-$version.vsix" +fi +( + # Relative names, so `shasum -c SHA256SUMS` works from inside dist/. + cd "$dist" + # shellcheck disable=SC2086 # deliberate word splitting: one name per file + shasum -a 256 $artifacts > SHA256SUMS + cat SHA256SUMS +) + +echo +echo "artifacts in $dist:" +ls -l "$dist"