feat(ide): export CLion plugin assets; publish Void/VbsCLion
This commit is contained in:
1 parent
3577ba69b7
commit
4f581d1b51
4 files changed
+103
-1
No files matched your search
+84
-1
@@ -1303,10 +1303,93 @@ export_ide_plugin_assets(const IdePluginOptions &options) {
|
||||
}
|
||||
return report;
|
||||
}
|
||||
if (options.editor == IdeKind::CLion) {
|
||||
const std::string plugin_xml =
|
||||
"<idea-plugin>\n"
|
||||
" <id>com.faumaray.vbs</id>\n"
|
||||
" <name>VoidBuildSystem</name>\n"
|
||||
" <vendor>Void</vendor>\n"
|
||||
" <description>Build, test, install and package with VoidBuildSystem (VBS).</description>\n"
|
||||
" <depends>com.intellij.modules.platform</depends>\n"
|
||||
" <depends>com.intellij.modules.cidr.lang</depends>\n"
|
||||
" <actions>\n"
|
||||
" <action id=\"Vbs.Build\" class=\"com.faumaray.vbs.BuildAction\"\n"
|
||||
" text=\"VBS: Build\" description=\"Run vbs build in the project root\">\n"
|
||||
" <add-to-group group-id=\"ToolsMenu\" anchor=\"first\"/>\n"
|
||||
" </action>\n"
|
||||
" <action id=\"Vbs.Install\" class=\"com.faumaray.vbs.InstallAction\"\n"
|
||||
" text=\"VBS: Install\" description=\"Stage an install prefix\">\n"
|
||||
" <add-to-group group-id=\"ToolsMenu\" anchor=\"after\" relative-to-action=\"Vbs.Build\"/>\n"
|
||||
" </action>\n"
|
||||
" </actions>\n"
|
||||
"</idea-plugin>\n";
|
||||
const std::string gradle =
|
||||
"plugins {\n"
|
||||
" kotlin(\"jvm\") version \"2.0.21\"\n"
|
||||
" id(\"org.jetbrains.intellij.platform\") version \"2.1.0\"\n"
|
||||
"}\n\n"
|
||||
"group = \"com.faumaray\"\n"
|
||||
"version = \"0.1.0\"\n\n"
|
||||
"repositories {\n"
|
||||
" mavenCentral()\n"
|
||||
" intellijPlatform { defaultRepositories() }\n"
|
||||
"}\n\n"
|
||||
"dependencies {\n"
|
||||
" intellijPlatform { create(\"CL\", \"2024.2\") }\n"
|
||||
"}\n\n"
|
||||
"intellijPlatform {\n"
|
||||
" pluginConfiguration { ideaVersion { sinceBuild = \"242\" } }\n"
|
||||
"}\n";
|
||||
const std::string action_kt =
|
||||
"package com.faumaray.vbs\n\n"
|
||||
"import com.intellij.execution.configurations.GeneralCommandLine\n"
|
||||
"import com.intellij.execution.process.OSProcessHandler\n"
|
||||
"import com.intellij.openapi.actionSystem.AnAction\n"
|
||||
"import com.intellij.openapi.actionSystem.AnActionEvent\n"
|
||||
"import com.intellij.openapi.project.Project\n\n"
|
||||
"private fun runVbs(project: Project, title: String, args: List<String>) {\n"
|
||||
" val command = GeneralCommandLine(listOf(System.getenv(\"VBS_BIN\") ?: \"vbs\") + "
|
||||
"args)\n"
|
||||
" .withWorkDirectory(project.basePath)\n"
|
||||
" val handler = OSProcessHandler(command)\n"
|
||||
" handler.startNotify()\n"
|
||||
" println(\"[$title] ${command.commandLineString}\")\n"
|
||||
"}\n\n"
|
||||
"class BuildAction : AnAction(\"VBS: Build\") {\n"
|
||||
" override fun actionPerformed(event: AnActionEvent) {\n"
|
||||
" event.project?.let { runVbs(it, \"build\", listOf(\"build\")) }\n"
|
||||
" }\n"
|
||||
"}\n\n"
|
||||
"class InstallAction : AnAction(\"VBS: Install\") {\n"
|
||||
" override fun actionPerformed(event: AnActionEvent) {\n"
|
||||
" event.project?.let {\n"
|
||||
" runVbs(it, \"install\", listOf(\"install\", \"--prefix\", \"build/install\"))\n"
|
||||
" }\n"
|
||||
" }\n"
|
||||
"}\n";
|
||||
const std::string clion_readme =
|
||||
"# VbsCLion\n\nCLion (JetBrains) plugin assets for VoidBuildSystem, generated by "
|
||||
"`vbs ide plugin --editor clion`.\n\nCLion can also read the CMake File API document "
|
||||
"emitted by `vbs ide generate`, so this plugin is complementary: it adds Tools-menu "
|
||||
"actions for `vbs build` and `vbs install`.\n\n```sh\n./gradlew buildPlugin\n```\n\nSet "
|
||||
"`VBS_BIN` if `vbs` is not on `PATH`.\n";
|
||||
|
||||
for (const auto &[name, content] :
|
||||
std::vector<std::pair<std::string, std::string>>{
|
||||
{"src/main/resources/META-INF/plugin.xml", plugin_xml},
|
||||
{"build.gradle.kts", gradle},
|
||||
{"src/main/kotlin/com/faumaray/vbs/VbsActions.kt", action_kt},
|
||||
{"README.md", clion_readme}}) {
|
||||
if (auto written = write_asset(output / name, content); !written) {
|
||||
return std::unexpected{written.error()};
|
||||
}
|
||||
}
|
||||
return report;
|
||||
}
|
||||
if (options.editor != IdeKind::VsCode) {
|
||||
return std::unexpected{Void::System::make_system_error(
|
||||
Void::System::SystemErrorCode::unsupported,
|
||||
"editor plugin assets are generated for vscode and zed only")};
|
||||
"editor plugin assets are generated for vscode, zed and clion only")};
|
||||
}
|
||||
|
||||
for (const auto &[name, content] :
|
||||
|
||||
Reference in new issue
Block a user