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
+39
-1
@@ -2676,12 +2676,13 @@ struct IdeCmdOptions {
|
||||
std::string profile_name{"debug"};
|
||||
std::optional<std::string> compiler_arg;
|
||||
std::string editor_name{"all"};
|
||||
std::optional<std::string> plugin_output_arg;
|
||||
bool force{false};
|
||||
};
|
||||
|
||||
int execute_ide_command(std::string_view sub, const IdeCmdOptions &opts) {
|
||||
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);
|
||||
if (!parsed_kind) {
|
||||
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;
|
||||
}
|
||||
|
||||
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;
|
||||
if (opts.compiler_arg) {
|
||||
try {
|
||||
@@ -3318,6 +3350,12 @@ int main(int argc, char **argv) {
|
||||
ide_opts.compiler_arg);
|
||||
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 =
|
||||
ide_cmd.subcommand("generate", "Generate .clangd, .vscode/, .zed/, and .idea/ IDE configs");
|
||||
configure_ide_common(ide_gen_cmd);
|
||||
|
||||
Reference in new issue
Block a user