feat(ide): export a portable VS Code extension; publish Void/VbsVsCode
This commit is contained in:
1 parent
399b52c31c
commit
12a52bbd0d
9 files changed
+278
-2
No files matched your search
@@ -318,6 +318,10 @@ Stage: VERIFIED — Plans 01–19 + Plan 20 Slices 1–2C + Track A + Track B (B
|
|||||||
|
|
||||||
- **Wave 112 (Migration Tooling: `vbs migrate`)**: `Config::import_cmake_lists` reads a bounded CMakeLists.txt subset (`project`, `set`, `add_library`/`add_executable`, `target_link_libraries`, `target_include_directories`, `target_compile_definitions`, `install(TARGETS)`) with variable expansion (`${...}`, source-dir variables) and reports everything it cannot translate; `vbs migrate --input --output [--force] [--dry-run]` renders a `build.cpp` scaffold. Covered by a unit test, a CLI contract, and a dry run over the project's own CMakeLists.
|
- **Wave 112 (Migration Tooling: `vbs migrate`)**: `Config::import_cmake_lists` reads a bounded CMakeLists.txt subset (`project`, `set`, `add_library`/`add_executable`, `target_link_libraries`, `target_include_directories`, `target_compile_definitions`, `install(TARGETS)`) with variable expansion (`${...}`, source-dir variables) and reports everything it cannot translate; `vbs migrate --input --output [--force] [--dry-run]` renders a `build.cpp` scaffold. Covered by a unit test, a CLI contract, and a dry run over the project's own CMakeLists.
|
||||||
|
|
||||||
|
- **Wave 113 (Editor Plugin Asset Export)**: `vbs ide plugin --editor vscode --output DIR` writes ready-to-use VS Code extension assets (`package.json` with six contributed commands, `extension.js` running `vbs` in a terminal, `README.md`), resolving the current `vbs` executable path; other editor kinds are rejected explicitly. Covered by a unit test and a CLI contract.
|
||||||
|
|
||||||
|
- **Wave 114 (VS Code Extension Repository)**: `vbs ide plugin` now emits a portable extension (workspace-folder based, `VBS_BIN`/`vbs` fallback) and the assets were published to the new [Void/VbsVsCode](https://git.faumaray.com/Void/VbsVsCode) repository (`package.json` with six commands, `extension.js`, README, MIT LICENSE, `.vscodeignore`). Zed/CLion plugin repositories remain.
|
||||||
|
|
||||||
## Remaining future scope
|
## Remaining future scope
|
||||||
|
|
||||||
- **Superiority plan ([22-superiority-and-gaps.md](../roadmap/22-superiority-and-gaps.md), 2026-12-05)**: revised platform strategy - **macOS deferred**, **Windows via MinGW-w64 cross-compilation + Wine execution** (`dev cpp-gcc -p pkgsCross.mingwW64.stdenv.cc`, `dev cpp-gcc -p wine64`), native MSVC deferred; plus packaging parity (ZIP/DEB/RPM), IDE ecosystem, migration tooling, test-runner parity, benchmarks, CI runners, and remote execution in prioritized order.
|
- **Superiority plan ([22-superiority-and-gaps.md](../roadmap/22-superiority-and-gaps.md), 2026-12-05)**: revised platform strategy - **macOS deferred**, **Windows via MinGW-w64 cross-compilation + Wine execution** (`dev cpp-gcc -p pkgsCross.mingwW64.stdenv.cc`, `dev cpp-gcc -p wine64`), native MSVC deferred; plus packaging parity (ZIP/DEB/RPM), IDE ecosystem, migration tooling, test-runner parity, benchmarks, CI runners, and remote execution in prioritized order.
|
||||||
|
|||||||
@@ -116,4 +116,6 @@ Base HEAD: `fe0d1a6`
|
|||||||
| Wave 110 (VoidLibrary Net & Sqlite) | Net and Sqlite in the native table; built in the clone under `-p openssl -p boost -p sqlite`; #61 updated | COMPLETE & VERIFIED IN CLONE (13 actions, no CMake) | `recipes/VoidLibrary/VoidLibraryRecipe.cpp`, `contrib/voidlibrary-migration/`, Void/Library#61 |
|
| Wave 110 (VoidLibrary Net & Sqlite) | Net and Sqlite in the native table; built in the clone under `-p openssl -p boost -p sqlite`; #61 updated | COMPLETE & VERIFIED IN CLONE (13 actions, no CMake) | `recipes/VoidLibrary/VoidLibraryRecipe.cpp`, `contrib/voidlibrary-migration/`, Void/Library#61 |
|
||||||
| Wave 111 (VoidLibrary complete module set) | All 57 modules described; full native build verified in the clone (134 actions) | COMPLETE & VERIFIED IN CLONE | `recipes/VoidLibrary/VoidLibraryRecipe.cpp`, `contrib/voidlibrary-migration/`, Void/Library#61 |
|
| Wave 111 (VoidLibrary complete module set) | All 57 modules described; full native build verified in the clone (134 actions) | COMPLETE & VERIFIED IN CLONE | `recipes/VoidLibrary/VoidLibraryRecipe.cpp`, `contrib/voidlibrary-migration/`, Void/Library#61 |
|
||||||
| Wave 112 (`vbs migrate`) | Bounded CMakeLists importer rendering a build.cpp scaffold, with notes for untranslated constructs | COMPLETE & VERIFIED (GCC 16.2, pin `0002e74`; unit test and CLI contract pass) | `include/Void/Build/Config/CmakeImport.hpp`, `src/Config/CmakeImport.cpp`, `src/Main.cpp`, `tests/{FullV1Tests,CliContracts}.cpp/cmake`, docs |
|
| Wave 112 (`vbs migrate`) | Bounded CMakeLists importer rendering a build.cpp scaffold, with notes for untranslated constructs | COMPLETE & VERIFIED (GCC 16.2, pin `0002e74`; unit test and CLI contract pass) | `include/Void/Build/Config/CmakeImport.hpp`, `src/Config/CmakeImport.cpp`, `src/Main.cpp`, `tests/{FullV1Tests,CliContracts}.cpp/cmake`, docs |
|
||||||
|
| Wave 113 (Editor plugin assets) | `vbs ide plugin --editor vscode --output DIR` emits extension assets; other editors rejected | COMPLETE & VERIFIED (GCC 16.2, pin `0002e74`; unit test and CLI contract pass) | `include/Void/Build/Editor/CompDb.hpp`, `src/Editor/CompDb.cpp`, `src/Main.cpp`, `tests/{FullV1Tests,CliContracts}.cpp/cmake`, docs |
|
||||||
|
| Wave 114 (VS Code extension repo) | Portable `vbs ide plugin` output published to `Void/VbsVsCode` (6 commands, LICENSE, README) | COMPLETE & VERIFIED (unit test and CLI contract pass; repo contents confirmed via the Gitea API) | `src/Editor/CompDb.cpp`, `tests/FullV1Tests.cpp`, [Void/VbsVsCode](https://git.faumaray.com/Void/VbsVsCode), docs |
|
||||||
| Future (Plan 20 Slice 3 / Tracks C, E3 editor extensions) |"}] Live `conan` CLI verification; macOS/Windows/cross-compile; binary-variant signing and key distribution; daemon-side dependency materialization and editor plugins; `Void::Net`/`Void::Sqlite` alignment | PLANNED (unimplemented) | [21-expansion-roadmap.md](../roadmap/21-expansion-roadmap.md), [20-future-translation-platforms.md](../roadmap/20-future-translation-platforms.md) |
|
| Future (Plan 20 Slice 3 / Tracks C, E3 editor extensions) |"}] Live `conan` CLI verification; macOS/Windows/cross-compile; binary-variant signing and key distribution; daemon-side dependency materialization and editor plugins; `Void::Net`/`Void::Sqlite` alignment | PLANNED (unimplemented) | [21-expansion-roadmap.md](../roadmap/21-expansion-roadmap.md), [20-future-translation-platforms.md](../roadmap/20-future-translation-platforms.md) |
|
||||||
@@ -1604,6 +1604,30 @@ vbs build --project /tmp/opencode/vl-migrate --build-dir /tmp/opencode/vl-migrat
|
|||||||
expanded `${CMAKE_CURRENT_SOURCE_DIR}`.
|
expanded `${CMAKE_CURRENT_SOURCE_DIR}`.
|
||||||
- CLI contract covers `--help` and a missing input file (exit 1).
|
- CLI contract covers `--help` and a missing input file (exit 1).
|
||||||
|
|
||||||
|
## Editor Plugin Asset Export (GCC 16.2, pin `0002e74`)
|
||||||
|
|
||||||
|
```sh
|
||||||
|
vbs ide plugin --project <proj> --build-dir <build> --editor vscode --output <dir>
|
||||||
|
```
|
||||||
|
|
||||||
|
- Writes `package.json` (six commands: build, test, install, package, daemon start/status),
|
||||||
|
`extension.js` (spawns the resolved `vbs` executable in a terminal) and `README.md`.
|
||||||
|
- `FullV1Tests.ide_plugin_assets_export_vscode_extension` **passed**: three files written, the
|
||||||
|
manifest parses as strict JSON with six contributed commands, the script embeds the configured
|
||||||
|
`vbs` path and the `vbs.build`/`vbs.package` ids, and a Zed request is rejected explicitly.
|
||||||
|
- CLI contract covers `--help` and the missing `--output` error.
|
||||||
|
|
||||||
|
## VS Code Extension Repository (GCC 16.2, pin `0002e74`)
|
||||||
|
|
||||||
|
- `vbs ide plugin --editor vscode --output DIR` now emits a portable extension: commands are
|
||||||
|
plain `vbs` invocations and `--project` comes from the VS Code workspace folder at runtime;
|
||||||
|
the executable falls back to `VBS_BIN` or `vbs` (no machine-specific paths).
|
||||||
|
- `FullV1Tests.ide_plugin_assets_export_vscode_extension` **passed** (3 files, 6 contributed
|
||||||
|
commands, `workspaceFolders` and `VBS_BIN || "vbs"` present, Zed rejected).
|
||||||
|
- Published to the new [Void/VbsVsCode](https://git.faumaray.com/Void/VbsVsCode) repository
|
||||||
|
(`package.json`, `extension.js`, `README.md`, `LICENSE`, `.vscodeignore`); the contents were
|
||||||
|
read back through the Gitea API.
|
||||||
|
|
||||||
## Limits and Unrun Checks
|
## Limits and Unrun Checks
|
||||||
|
|
||||||
1. **HTTPS git fetch**: the host shell is proxy-restricted, but the Docker container could clone `https://git.faumaray.com/Void/VoidLibrary.git`; the pinned commit `3e254055e081a104f08df68dde39711bc7813518` was fetched directly for the verification above. A separate configure against the local `/home/faumaray/Projects/Library` checkout via `VBS_VOID_SOURCE_DIR` also succeeded (development-only override, checkout unmodified).
|
1. **HTTPS git fetch**: the host shell is proxy-restricted, but the Docker container could clone `https://git.faumaray.com/Void/VoidLibrary.git`; the pinned commit `3e254055e081a104f08df68dde39711bc7813518` was fetched directly for the verification above. A separate configure against the local `/home/faumaray/Projects/Library` checkout via `VBS_VOID_SOURCE_DIR` also succeeded (development-only override, checkout unmodified).
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ Concrete work this implies:
|
|||||||
1. Documentation drift: status tables must match verified reality (this plan updates them).
|
1. Documentation drift: status tables must match verified reality (this plan updates them).
|
||||||
2. Wine-first Windows target support (§2).
|
2. Wine-first Windows target support (§2).
|
||||||
3. Packaging parity: ZIP (stored), DEB, RPM, metadata, signing (`--archive-format` extensions).
|
3. Packaging parity: ZIP (stored), DEB, RPM, metadata, signing (`--archive-format` extensions).
|
||||||
4. IDE ecosystem: File API shim (**done**: `vbs ide generate` emits codemodel-v2), presets import (**done**: `vbs presets`), external plugins.
|
4. IDE ecosystem: File API shim (**done**: `vbs ide generate` emits codemodel-v2), presets import (**done**: `vbs presets`), external plugins (**VS Code extension published** at `Void/VbsVsCode` via `vbs ide plugin`; Zed/CLion plugins remain).
|
||||||
5. Migration tooling (**done**: `vbs migrate` renders a `build.cpp` scaffold from a bounded CMakeLists subset) and migrating VoidLibrary onto VBS (**trial extended**: 25+ pure modules build with VBS in a separate clone; upstream #61 tracks the in-repo build description and the remaining externally dependent modules).
|
5. Migration tooling (**done**: `vbs migrate` renders a `build.cpp` scaffold from a bounded CMakeLists subset) and migrating VoidLibrary onto VBS (**trial extended**: 25+ pure modules build with VBS in a separate clone; upstream #61 tracks the in-repo build description and the remaining externally dependent modules).
|
||||||
6. Test-runner parity.
|
6. Test-runner parity.
|
||||||
7. Benchmarks against CMake/Meson/build2 on documented fixtures (including 10k-target scaling).
|
7. Benchmarks against CMake/Meson/build2 on documented fixtures (including 10k-target scaling).
|
||||||
|
|||||||
@@ -119,6 +119,24 @@ struct CompdbQueryResult {
|
|||||||
[[nodiscard]] Void::Result::Result<CompdbQueryResult, Void::Result::Error>
|
[[nodiscard]] Void::Result::Result<CompdbQueryResult, Void::Result::Error>
|
||||||
query_compdb_entries(const std::filesystem::path &compdb_path, const CompdbQuery &query);
|
query_compdb_entries(const std::filesystem::path &compdb_path, const CompdbQuery &query);
|
||||||
|
|
||||||
|
struct IdePluginOptions {
|
||||||
|
std::filesystem::path project_root;
|
||||||
|
std::filesystem::path build_root;
|
||||||
|
std::filesystem::path vbs_executable{"vbs"};
|
||||||
|
IdeKind editor{IdeKind::VsCode};
|
||||||
|
std::filesystem::path output_dir;
|
||||||
|
bool force{false};
|
||||||
|
};
|
||||||
|
|
||||||
|
struct IdePluginReport {
|
||||||
|
std::vector<std::filesystem::path> written_files;
|
||||||
|
std::vector<std::filesystem::path> skipped_existing_files;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Exports editor-extension assets (currently VS Code: package.json, extension.js, README).
|
||||||
|
[[nodiscard]] Void::Result::Result<IdePluginReport, Void::Result::Error>
|
||||||
|
generate_ide_plugin_assets(const IdePluginOptions &options);
|
||||||
|
|
||||||
// Emits versioned JSON workspace/target metadata for external IDE plugins (`vbs ide query`).
|
// Emits versioned JSON workspace/target metadata for external IDE plugins (`vbs ide query`).
|
||||||
[[nodiscard]] std::string format_ide_query_json(const Graph::BuildGraph &graph,
|
[[nodiscard]] std::string format_ide_query_json(const Graph::BuildGraph &graph,
|
||||||
const std::filesystem::path &compdb_path,
|
const std::filesystem::path &compdb_path,
|
||||||
|
|||||||
@@ -1150,6 +1150,140 @@ query_compdb_entries(const std::filesystem::path &compdb_path, const CompdbQuery
|
|||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
Void::Result::Result<IdePluginReport, Void::Result::Error>
|
||||||
|
export_ide_plugin_assets(const IdePluginOptions &options) {
|
||||||
|
using Util::json_array;
|
||||||
|
using Util::json_quote;
|
||||||
|
|
||||||
|
std::error_code ec;
|
||||||
|
const auto output = options.output_dir.lexically_normal();
|
||||||
|
std::filesystem::create_directories(output, ec);
|
||||||
|
if (ec) {
|
||||||
|
return std::unexpected{Void::System::make_system_error(
|
||||||
|
Void::System::SystemErrorCode::io_error,
|
||||||
|
std::format("cannot create plugin directory '{}': {}", output.string(), ec.message()))};
|
||||||
|
}
|
||||||
|
|
||||||
|
IdePluginReport report;
|
||||||
|
const auto write_asset =
|
||||||
|
[&](const std::filesystem::path &path,
|
||||||
|
std::string_view content) -> Void::Result::Result<void, Void::Result::Error> {
|
||||||
|
if (!options.force && std::filesystem::exists(path, ec)) {
|
||||||
|
report.skipped_existing_files.push_back(path);
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
auto written = Platform::atomic_write_file(path, content, false);
|
||||||
|
if (!written) {
|
||||||
|
return std::unexpected{written.error()};
|
||||||
|
}
|
||||||
|
report.written_files.push_back(path);
|
||||||
|
return {};
|
||||||
|
};
|
||||||
|
|
||||||
|
const std::string project = options.project_root.lexically_normal().string();
|
||||||
|
const std::string build = options.build_root.lexically_normal().string();
|
||||||
|
|
||||||
|
struct PluginCommand {
|
||||||
|
std::string id;
|
||||||
|
std::string title;
|
||||||
|
std::vector<std::string> args;
|
||||||
|
};
|
||||||
|
const std::vector<PluginCommand> commands = {
|
||||||
|
{"vbs.build", "VBS: Build", {"build"}},
|
||||||
|
{"vbs.test", "VBS: Test", {"test"}},
|
||||||
|
{"vbs.install", "VBS: Install", {"install", "--prefix", "build/install"}},
|
||||||
|
{"vbs.package",
|
||||||
|
"VBS: Package (installer)",
|
||||||
|
{"install", "--prefix", "build/install", "--archive", "build/install/installer.sh",
|
||||||
|
"--archive-format", "sh"}},
|
||||||
|
{"vbs.daemonStart", "VBS: Start Daemon", {"daemon", "run"}},
|
||||||
|
{"vbs.daemonStatus", "VBS: Daemon Status", {"daemon", "status"}},
|
||||||
|
};
|
||||||
|
|
||||||
|
const std::string package_json =
|
||||||
|
"{\n"
|
||||||
|
" \"name\": \"vbs-tools\",\n"
|
||||||
|
" \"displayName\": \"VoidBuildSystem\",\n"
|
||||||
|
" \"description\": \"Build, test, install and package with VoidBuildSystem.\",\n"
|
||||||
|
" \"version\": \"0.1.0\",\n"
|
||||||
|
" \"publisher\": \"void\",\n"
|
||||||
|
" \"license\": \"MIT\",\n"
|
||||||
|
" \"engines\": {\"vscode\": \"^1.80.0\"},\n"
|
||||||
|
" \"categories\": [\"Other\"],\n"
|
||||||
|
" \"activationEvents\": [],\n"
|
||||||
|
" \"main\": \"./extension.js\",\n"
|
||||||
|
" \"contributes\": {\n \"commands\": " +
|
||||||
|
json_array(commands,
|
||||||
|
[](const PluginCommand &command) {
|
||||||
|
return "{\"command\":" + json_quote(command.id) +
|
||||||
|
",\"title\":" + json_quote(command.title) + '}';
|
||||||
|
}) +
|
||||||
|
"\n }\n}\n";
|
||||||
|
|
||||||
|
std::string extension_js =
|
||||||
|
"// Generated by `vbs ide plugin`. Requires the `vbs` executable in PATH or VBS_BIN.\n"
|
||||||
|
"const vscode = require('vscode');\n"
|
||||||
|
"const vbs = process.env.VBS_BIN || \"vbs\";\n\n"
|
||||||
|
"function projectArgs() {\n"
|
||||||
|
" const folders = vscode.workspace.workspaceFolders;\n"
|
||||||
|
" return folders && folders.length ? ['--project', folders[0].uri.fsPath] : [];\n"
|
||||||
|
"}\n\n"
|
||||||
|
"function runTerminal(name, args) {\n"
|
||||||
|
" const terminal = vscode.window.createTerminal({ name });\n"
|
||||||
|
" terminal.show(true);\n"
|
||||||
|
" const full = [...args, ...projectArgs()];\n"
|
||||||
|
" terminal.sendText([vbs, ...full].map((a) => (a.includes(' ') ? `'${a}'` : a)).join(' '));\n"
|
||||||
|
"}\n\n"
|
||||||
|
"const commands = [\n";
|
||||||
|
for (const auto &command : commands) {
|
||||||
|
extension_js += " [" + json_quote(command.id) + ", " + json_quote(command.title) + ", " +
|
||||||
|
json_array(command.args, json_quote) + "],\n";
|
||||||
|
}
|
||||||
|
extension_js += "];\n\n"
|
||||||
|
"function activate(context) {\n"
|
||||||
|
" for (const [id, title, args] of commands) {\n"
|
||||||
|
" context.subscriptions.push(vscode.commands.registerCommand(id, () => "
|
||||||
|
"runTerminal(title, args)));\n"
|
||||||
|
" }\n"
|
||||||
|
"}\n\n"
|
||||||
|
"function deactivate() {}\n\n"
|
||||||
|
"module.exports = { activate, deactivate };\n";
|
||||||
|
|
||||||
|
const std::string readme = std::format(
|
||||||
|
"# VoidBuildSystem editor extension\n\n"
|
||||||
|
"Generated by `vbs ide plugin` for the project at `{}`.\n\n"
|
||||||
|
"## Commands\n\n{}\n\n"
|
||||||
|
"## Install\n\n"
|
||||||
|
"```sh\ncd {} && npm install -g @vscode/vsce && vsce package\n"
|
||||||
|
"code --install-extension vbs-tools-0.1.0.vsix\n```\n\n"
|
||||||
|
"Set `VBS_BIN` if `vbs` is not on `PATH`.\n",
|
||||||
|
project,
|
||||||
|
[&] {
|
||||||
|
std::string list;
|
||||||
|
for (const auto &command : commands) {
|
||||||
|
list += "- `" + command.title + "` (`" + command.id + "`)\n";
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}(),
|
||||||
|
output.string());
|
||||||
|
|
||||||
|
if (options.editor != IdeKind::VsCode) {
|
||||||
|
return std::unexpected{Void::System::make_system_error(
|
||||||
|
Void::System::SystemErrorCode::unsupported,
|
||||||
|
"editor plugin assets are currently generated for vscode only")};
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const auto &[name, content] :
|
||||||
|
std::vector<std::pair<std::string, std::string>>{{"package.json", package_json},
|
||||||
|
{"extension.js", extension_js},
|
||||||
|
{"README.md", readme}}) {
|
||||||
|
if (auto written = write_asset(output / name, content); !written) {
|
||||||
|
return std::unexpected{written.error()};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return report;
|
||||||
|
}
|
||||||
|
|
||||||
std::string file_api_target_type(TargetKind kind) {
|
std::string file_api_target_type(TargetKind kind) {
|
||||||
switch (kind) {
|
switch (kind) {
|
||||||
case TargetKind::Executable:
|
case TargetKind::Executable:
|
||||||
@@ -1390,4 +1524,9 @@ std::string format_ide_query_json(const Graph::BuildGraph &graph,
|
|||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Void::Result::Result<IdePluginReport, Void::Result::Error>
|
||||||
|
generate_ide_plugin_assets(const IdePluginOptions &options) {
|
||||||
|
return export_ide_plugin_assets(options);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Void::Build::Editor
|
} // namespace Void::Build::Editor
|
||||||
+39
-1
@@ -2676,12 +2676,13 @@ struct IdeCmdOptions {
|
|||||||
std::string profile_name{"debug"};
|
std::string profile_name{"debug"};
|
||||||
std::optional<std::string> compiler_arg;
|
std::optional<std::string> compiler_arg;
|
||||||
std::string editor_name{"all"};
|
std::string editor_name{"all"};
|
||||||
|
std::optional<std::string> plugin_output_arg;
|
||||||
bool force{false};
|
bool force{false};
|
||||||
};
|
};
|
||||||
|
|
||||||
int execute_ide_command(std::string_view sub, const IdeCmdOptions &opts) {
|
int execute_ide_command(std::string_view sub, const IdeCmdOptions &opts) {
|
||||||
Editor::IdeKind ide_kind = Editor::IdeKind::All;
|
Editor::IdeKind ide_kind = Editor::IdeKind::All;
|
||||||
if (sub == "generate") {
|
if (sub == "generate" || sub == "plugin") {
|
||||||
auto parsed_kind = Editor::parse_ide_kind(opts.editor_name);
|
auto parsed_kind = Editor::parse_ide_kind(opts.editor_name);
|
||||||
if (!parsed_kind) {
|
if (!parsed_kind) {
|
||||||
std::cerr << "vbs ide: " << parsed_kind.error().message() << '\n';
|
std::cerr << "vbs ide: " << parsed_kind.error().message() << '\n';
|
||||||
@@ -2690,6 +2691,37 @@ int execute_ide_command(std::string_view sub, const IdeCmdOptions &opts) {
|
|||||||
ide_kind = *parsed_kind;
|
ide_kind = *parsed_kind;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (sub == "plugin") {
|
||||||
|
if (!opts.plugin_output_arg || opts.plugin_output_arg->empty()) {
|
||||||
|
std::cerr << "vbs ide plugin: --output is required\n";
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
const std::filesystem::path project_root{opts.project_arg};
|
||||||
|
const std::filesystem::path build_root =
|
||||||
|
opts.build_arg ? std::filesystem::path{*opts.build_arg} : (project_root / "build");
|
||||||
|
Editor::IdePluginOptions plugin_opts;
|
||||||
|
plugin_opts.project_root = project_root;
|
||||||
|
plugin_opts.build_root = build_root;
|
||||||
|
plugin_opts.editor = ide_kind;
|
||||||
|
plugin_opts.output_dir = *opts.plugin_output_arg;
|
||||||
|
plugin_opts.force = opts.force;
|
||||||
|
if (auto exe = Platform::current_executable_path(); exe) {
|
||||||
|
plugin_opts.vbs_executable = *exe;
|
||||||
|
}
|
||||||
|
auto report = Editor::generate_ide_plugin_assets(plugin_opts);
|
||||||
|
if (!report) {
|
||||||
|
std::cerr << "vbs ide plugin: " << report.error().message() << '\n';
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
for (const auto &written : report->written_files) {
|
||||||
|
std::cout << "wrote " << written.string() << '\n';
|
||||||
|
}
|
||||||
|
for (const auto &skipped : report->skipped_existing_files) {
|
||||||
|
std::cout << "preserved " << skipped.string() << " (pass --force to overwrite)\n";
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
std::optional<CompilerFamily> compiler_override;
|
std::optional<CompilerFamily> compiler_override;
|
||||||
if (opts.compiler_arg) {
|
if (opts.compiler_arg) {
|
||||||
try {
|
try {
|
||||||
@@ -3318,6 +3350,12 @@ int main(int argc, char **argv) {
|
|||||||
ide_opts.compiler_arg);
|
ide_opts.compiler_arg);
|
||||||
add_log_flags(p);
|
add_log_flags(p);
|
||||||
};
|
};
|
||||||
|
auto &ide_plugin_cmd = ide_cmd.subcommand("plugin", "Export editor extension assets (vscode)");
|
||||||
|
configure_ide_common(ide_plugin_cmd);
|
||||||
|
ide_plugin_cmd
|
||||||
|
.option_default("--editor", "-e", "Editor preset (vscode)", ide_opts.editor_name, "vscode")
|
||||||
|
.option("--output", "-o", "Output directory", ide_opts.plugin_output_arg)
|
||||||
|
.flag("--force", "", "Overwrite existing plugin files", ide_opts.force);
|
||||||
auto &ide_gen_cmd =
|
auto &ide_gen_cmd =
|
||||||
ide_cmd.subcommand("generate", "Generate .clangd, .vscode/, .zed/, and .idea/ IDE configs");
|
ide_cmd.subcommand("generate", "Generate .clangd, .vscode/, .zed/, and .idea/ IDE configs");
|
||||||
configure_ide_common(ide_gen_cmd);
|
configure_ide_common(ide_gen_cmd);
|
||||||
|
|||||||
@@ -196,6 +196,8 @@ message(STATUS "daemon describe response: ${daemon_describe_out}")
|
|||||||
check_process(0 "Usage: vbs ide <command>.*Commands:.*generate.*query" "" ide --help)
|
check_process(0 "Usage: vbs ide <command>.*Commands:.*generate.*query" "" ide --help)
|
||||||
check_process(0 "Usage: vbs ide generate " "" ide generate --help)
|
check_process(0 "Usage: vbs ide generate " "" ide generate --help)
|
||||||
check_process(0 "Usage: vbs ide query " "" ide query --help)
|
check_process(0 "Usage: vbs ide query " "" ide query --help)
|
||||||
|
check_process(0 "Usage: vbs ide plugin .*--editor.*--output" "" ide plugin --help)
|
||||||
|
check_process(2 "" "--output is required" ide plugin)
|
||||||
check_process(2 "" "missing subcommand for 'vbs ide'" ide)
|
check_process(2 "" "missing subcommand for 'vbs ide'" ide)
|
||||||
check_process(2 "" "unknown IDE kind" ide generate --editor invalid_ide)
|
check_process(2 "" "unknown IDE kind" ide generate --editor invalid_ide)
|
||||||
|
|
||||||
|
|||||||
@@ -1083,6 +1083,55 @@ void build(Void::Build::Project &p) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// === Editor plugin asset export ===
|
||||||
|
VOID_TEST(FullV1Tests, ide_plugin_assets_export_vscode_extension) {
|
||||||
|
Void::FileSystem::TempDir tmp{"vbs_plugin_"};
|
||||||
|
Editor::IdePluginOptions options;
|
||||||
|
options.project_root = tmp / "proj";
|
||||||
|
options.build_root = tmp / "build";
|
||||||
|
options.vbs_executable = "/opt/vbs/bin/vbs";
|
||||||
|
options.editor = Editor::IdeKind::VsCode;
|
||||||
|
options.output_dir = tmp / "vbs-tools";
|
||||||
|
options.force = true;
|
||||||
|
|
||||||
|
auto report = Editor::generate_ide_plugin_assets(options);
|
||||||
|
Void::Testing::require(report.has_value());
|
||||||
|
Void::Testing::expect_eq(report->written_files.size(), std::size_t{3});
|
||||||
|
Void::Testing::expect(std::filesystem::exists(options.output_dir / "package.json"));
|
||||||
|
Void::Testing::expect(std::filesystem::exists(options.output_dir / "extension.js"));
|
||||||
|
Void::Testing::expect(std::filesystem::exists(options.output_dir / "README.md"));
|
||||||
|
|
||||||
|
auto manifest_text = Void::FileSystem::read_file(options.output_dir / "package.json");
|
||||||
|
Void::Testing::require(manifest_text.has_value());
|
||||||
|
auto manifest = Void::Json::Strict::parse(*manifest_text);
|
||||||
|
Void::Testing::require(manifest.has_value());
|
||||||
|
const auto *manifest_object = std::get_if<Void::Json::Strict::Value::Object>(&manifest->value);
|
||||||
|
Void::Testing::require(manifest_object != nullptr);
|
||||||
|
const auto contributes_it = manifest_object->find("contributes");
|
||||||
|
Void::Testing::require(contributes_it != manifest_object->end());
|
||||||
|
const auto *contributes =
|
||||||
|
std::get_if<Void::Json::Strict::Value::Object>(&contributes_it->second.value);
|
||||||
|
Void::Testing::require(contributes != nullptr);
|
||||||
|
const auto commands_it = contributes->find("commands");
|
||||||
|
Void::Testing::require(commands_it != contributes->end());
|
||||||
|
const auto *commands =
|
||||||
|
std::get_if<Void::Json::Strict::Value::Array>(&commands_it->second.value);
|
||||||
|
Void::Testing::require(commands != nullptr);
|
||||||
|
Void::Testing::expect_eq(commands->size(), std::size_t{6});
|
||||||
|
|
||||||
|
auto extension_text = Void::FileSystem::read_file(options.output_dir / "extension.js");
|
||||||
|
Void::Testing::require(extension_text.has_value());
|
||||||
|
Void::Testing::expect(extension_text->find("VBS_BIN || \"vbs\"") != std::string::npos);
|
||||||
|
Void::Testing::expect(extension_text->find("workspaceFolders") != std::string::npos);
|
||||||
|
Void::Testing::expect(extension_text->find("vbs.build") != std::string::npos);
|
||||||
|
Void::Testing::expect(extension_text->find("vbs.package") != std::string::npos);
|
||||||
|
|
||||||
|
auto zed_options = options;
|
||||||
|
zed_options.editor = Editor::IdeKind::Zed;
|
||||||
|
auto zed_report = Editor::generate_ide_plugin_assets(zed_options);
|
||||||
|
Void::Testing::expect(!zed_report.has_value());
|
||||||
|
}
|
||||||
|
|
||||||
// === Migration tooling: CMakeLists.txt -> build.cpp scaffold ===
|
// === Migration tooling: CMakeLists.txt -> build.cpp scaffold ===
|
||||||
VOID_TEST(FullV1Tests, cmake_lists_import_renders_build_cpp_scaffold) {
|
VOID_TEST(FullV1Tests, cmake_lists_import_renders_build_cpp_scaffold) {
|
||||||
Void::FileSystem::TempDir tmp{"vbs_migrate_"};
|
Void::FileSystem::TempDir tmp{"vbs_migrate_"};
|
||||||
|
|||||||
Reference in new issue
Block a user