clion debugger driver provider
This commit is contained in:
parent
9e65bcc639
commit
fc760497a9
8 changed files with 135 additions and 20 deletions
|
@ -0,0 +1,67 @@
|
||||||
|
/*
|
||||||
|
* This file is part of ZigBrains.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2023-2024 FalsePattern
|
||||||
|
* All Rights Reserved
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included
|
||||||
|
* in all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* ZigBrains is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, only version 3 of the License.
|
||||||
|
*
|
||||||
|
* ZigBrains is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with ZigBrains. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.falsepattern.zigbrains.clion
|
||||||
|
|
||||||
|
import com.falsepattern.zigbrains.debugger.ZigDebuggerDriverConfigurationProvider
|
||||||
|
import com.falsepattern.zigbrains.debugger.settings.ZigDebuggerSettings
|
||||||
|
import com.intellij.openapi.diagnostic.Logger
|
||||||
|
import com.intellij.openapi.diagnostic.logger
|
||||||
|
import com.intellij.openapi.project.Project
|
||||||
|
import com.intellij.openapi.util.SystemInfo
|
||||||
|
import com.jetbrains.cidr.cpp.execution.debugger.backend.CLionGDBDriverConfiguration
|
||||||
|
import com.jetbrains.cidr.cpp.execution.debugger.backend.CLionLLDBDriverConfiguration
|
||||||
|
import com.jetbrains.cidr.cpp.toolchains.CPPDebugger
|
||||||
|
import com.jetbrains.cidr.cpp.toolchains.CPPToolchains
|
||||||
|
import com.jetbrains.cidr.execution.debugger.backend.DebuggerDriverConfiguration
|
||||||
|
|
||||||
|
class ZigClionDebuggerDriverConfigurationProvider: ZigDebuggerDriverConfigurationProvider() {
|
||||||
|
override suspend fun getDebuggerConfiguration(
|
||||||
|
project: Project,
|
||||||
|
isElevated: Boolean,
|
||||||
|
emulateTerminal: Boolean
|
||||||
|
): DebuggerDriverConfiguration? {
|
||||||
|
if (SystemInfo.isWindows)
|
||||||
|
return null
|
||||||
|
|
||||||
|
if (!ZigDebuggerSettings.instance.useClion)
|
||||||
|
return null
|
||||||
|
|
||||||
|
val toolchains = CPPToolchains.getInstance()
|
||||||
|
var toolchain = toolchains.getToolchainByNameOrDefault("Zig")
|
||||||
|
if (toolchain == null || !toolchain.isDebuggerSupported) {
|
||||||
|
LOG.info("Couldn't find debug-compatible C++ toolchain with name \"Zig\"")
|
||||||
|
toolchain = toolchains.defaultToolchain
|
||||||
|
}
|
||||||
|
if (toolchain == null || !toolchain.isDebuggerSupported) {
|
||||||
|
LOG.info("Couldn't find debug-compatible C++ default toolchain")
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
return when(toolchain.debuggerKind) {
|
||||||
|
CPPDebugger.Kind.BUNDLED_GDB,
|
||||||
|
CPPDebugger.Kind.CUSTOM_GDB -> CLionGDBDriverConfiguration(project, toolchain)
|
||||||
|
CPPDebugger.Kind.BUNDLED_LLDB -> CLionLLDBDriverConfiguration(project, toolchain)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private val LOG = logger<ZigClionDebuggerDriverConfigurationProvider>()
|
|
@ -25,9 +25,9 @@ package com.falsepattern.zigbrains.debugbridge
|
||||||
import com.intellij.openapi.extensions.ExtensionPointName
|
import com.intellij.openapi.extensions.ExtensionPointName
|
||||||
import com.intellij.openapi.project.Project
|
import com.intellij.openapi.project.Project
|
||||||
|
|
||||||
interface ZigDebuggerDriverConfigurationProvider {
|
interface ZigDebuggerDriverConfigurationProviderBase {
|
||||||
companion object {
|
companion object {
|
||||||
val EXTENSION_POINT_NAME = ExtensionPointName.create<ZigDebuggerDriverConfigurationProvider>("com.falsepattern.zigbrains.debuggerDriverProvider")
|
val EXTENSION_POINT_NAME = ExtensionPointName.create<ZigDebuggerDriverConfigurationProviderBase>("com.falsepattern.zigbrains.debuggerDriverProvider")
|
||||||
}
|
}
|
||||||
suspend fun <T> getDebuggerConfiguration(project: Project, isElevated: Boolean, emulateTerminal: Boolean, klass: Class<T>): T?
|
suspend fun <T> getDebuggerConfiguration(project: Project, isElevated: Boolean, emulateTerminal: Boolean, klass: Class<T>): T?
|
||||||
}
|
}
|
|
@ -0,0 +1,42 @@
|
||||||
|
/*
|
||||||
|
* This file is part of ZigBrains.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2023-2024 FalsePattern
|
||||||
|
* All Rights Reserved
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included
|
||||||
|
* in all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* ZigBrains is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, only version 3 of the License.
|
||||||
|
*
|
||||||
|
* ZigBrains is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with ZigBrains. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.falsepattern.zigbrains.debugger
|
||||||
|
|
||||||
|
import com.falsepattern.zigbrains.debugbridge.ZigDebuggerDriverConfigurationProviderBase
|
||||||
|
import com.intellij.openapi.project.Project
|
||||||
|
import com.jetbrains.cidr.execution.debugger.backend.DebuggerDriverConfiguration
|
||||||
|
|
||||||
|
abstract class ZigDebuggerDriverConfigurationProvider: ZigDebuggerDriverConfigurationProviderBase {
|
||||||
|
final override suspend fun <T> getDebuggerConfiguration(
|
||||||
|
project: Project,
|
||||||
|
isElevated: Boolean,
|
||||||
|
emulateTerminal: Boolean,
|
||||||
|
klass: Class<T>
|
||||||
|
): T? {
|
||||||
|
if (klass != DebuggerDriverConfiguration::class.java)
|
||||||
|
return null
|
||||||
|
@Suppress("UNCHECKED_CAST")
|
||||||
|
return getDebuggerConfiguration(project, isElevated, emulateTerminal) as T
|
||||||
|
}
|
||||||
|
protected abstract suspend fun getDebuggerConfiguration(project: Project, isElevated: Boolean, emulateTerminal: Boolean): DebuggerDriverConfiguration?
|
||||||
|
}
|
|
@ -22,7 +22,6 @@
|
||||||
|
|
||||||
package com.falsepattern.zigbrains.debugger
|
package com.falsepattern.zigbrains.debugger
|
||||||
|
|
||||||
import com.falsepattern.zigbrains.debugbridge.ZigDebuggerDriverConfigurationProvider
|
|
||||||
import com.falsepattern.zigbrains.debugger.settings.ZigDebuggerSettings
|
import com.falsepattern.zigbrains.debugger.settings.ZigDebuggerSettings
|
||||||
import com.falsepattern.zigbrains.debugger.toolchain.*
|
import com.falsepattern.zigbrains.debugger.toolchain.*
|
||||||
import com.falsepattern.zigbrains.debugger.win.MSVCDriverConfiguration
|
import com.falsepattern.zigbrains.debugger.win.MSVCDriverConfiguration
|
||||||
|
@ -39,15 +38,8 @@ import com.jetbrains.cidr.execution.debugger.backend.lldb.LLDBDriverConfiguratio
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import kotlin.io.path.pathString
|
import kotlin.io.path.pathString
|
||||||
|
|
||||||
class ZigDefaultDebuggerDriverConfigurationProvider: ZigDebuggerDriverConfigurationProvider {
|
class ZigDefaultDebuggerDriverConfigurationProvider: ZigDebuggerDriverConfigurationProvider() {
|
||||||
override suspend fun <T> getDebuggerConfiguration(project: Project, isElevated: Boolean, emulateTerminal: Boolean, klass: Class<T>): T? {
|
override suspend fun getDebuggerConfiguration(project: Project, isElevated: Boolean, emulateTerminal: Boolean): DebuggerDriverConfiguration? {
|
||||||
if (klass != DebuggerDriverConfiguration::class.java)
|
|
||||||
return null
|
|
||||||
@Suppress("UNCHECKED_CAST")
|
|
||||||
return getDebuggerConfiguration(project, isElevated, emulateTerminal) as T
|
|
||||||
}
|
|
||||||
|
|
||||||
private suspend fun getDebuggerConfiguration(project: Project, isElevated: Boolean, emulateTerminal: Boolean): DebuggerDriverConfiguration? {
|
|
||||||
val settings = ZigDebuggerSettings.instance
|
val settings = ZigDebuggerSettings.instance
|
||||||
val service = zigDebuggerToolchainService
|
val service = zigDebuggerToolchainService
|
||||||
val kind = settings.debuggerKind
|
val kind = settings.debuggerKind
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
package com.falsepattern.zigbrains.debugger.runner.base
|
package com.falsepattern.zigbrains.debugger.runner.base
|
||||||
|
|
||||||
import com.falsepattern.zigbrains.debugbridge.ZigDebuggerDriverConfigurationProvider
|
import com.falsepattern.zigbrains.debugbridge.ZigDebuggerDriverConfigurationProviderBase
|
||||||
import com.falsepattern.zigbrains.debugger.ZigLocalDebugProcess
|
import com.falsepattern.zigbrains.debugger.ZigLocalDebugProcess
|
||||||
import com.falsepattern.zigbrains.project.execution.base.ZigProfileState
|
import com.falsepattern.zigbrains.project.execution.base.ZigProfileState
|
||||||
import com.falsepattern.zigbrains.project.run.ZigProgramRunner
|
import com.falsepattern.zigbrains.project.run.ZigProgramRunner
|
||||||
|
@ -55,7 +55,7 @@ abstract class ZigDebugRunnerBase<ProfileState : ZigProfileState<*>> : ZigProgra
|
||||||
environment: ExecutionEnvironment
|
environment: ExecutionEnvironment
|
||||||
): RunContentDescriptor? {
|
): RunContentDescriptor? {
|
||||||
val project = environment.project
|
val project = environment.project
|
||||||
val driverProviders = ZigDebuggerDriverConfigurationProvider.EXTENSION_POINT_NAME.extensionList
|
val driverProviders = ZigDebuggerDriverConfigurationProviderBase.EXTENSION_POINT_NAME.extensionList
|
||||||
for (provider in driverProviders) {
|
for (provider in driverProviders) {
|
||||||
val driver = provider.getDebuggerConfiguration(project, isElevated = false, emulateTerminal = false, DebuggerDriverConfiguration::class.java) ?: continue
|
val driver = provider.getDebuggerConfiguration(project, isElevated = false, emulateTerminal = false, DebuggerDriverConfiguration::class.java) ?: continue
|
||||||
return executeWithDriver(state, toolchain, environment, driver) ?: continue
|
return executeWithDriver(state, toolchain, environment, driver) ?: continue
|
||||||
|
|
|
@ -30,8 +30,11 @@ import com.falsepattern.zigbrains.debugger.toolchain.zigDebuggerToolchainService
|
||||||
import com.falsepattern.zigbrains.shared.coroutine.launchWithEDT
|
import com.falsepattern.zigbrains.shared.coroutine.launchWithEDT
|
||||||
import com.falsepattern.zigbrains.shared.coroutine.runModalOrBlocking
|
import com.falsepattern.zigbrains.shared.coroutine.runModalOrBlocking
|
||||||
import com.falsepattern.zigbrains.shared.zigCoroutineScope
|
import com.falsepattern.zigbrains.shared.zigCoroutineScope
|
||||||
|
import com.intellij.ide.plugins.PluginManager
|
||||||
|
import com.intellij.openapi.extensions.PluginId
|
||||||
import com.intellij.openapi.observable.util.whenItemSelected
|
import com.intellij.openapi.observable.util.whenItemSelected
|
||||||
import com.intellij.openapi.ui.ComboBox
|
import com.intellij.openapi.ui.ComboBox
|
||||||
|
import com.intellij.openapi.util.SystemInfo
|
||||||
import com.intellij.platform.ide.progress.ModalTaskOwner
|
import com.intellij.platform.ide.progress.ModalTaskOwner
|
||||||
import com.intellij.platform.ide.progress.TaskCancellation
|
import com.intellij.platform.ide.progress.TaskCancellation
|
||||||
import com.intellij.platform.ide.progress.withModalProgress
|
import com.intellij.platform.ide.progress.withModalProgress
|
||||||
|
@ -103,11 +106,11 @@ class ZigDebuggerToolchainConfigurableUi : ZigDebuggerUiComponent {
|
||||||
row {
|
row {
|
||||||
cell(downloadAutomaticallyCheckBox)
|
cell(downloadAutomaticallyCheckBox)
|
||||||
}
|
}
|
||||||
// if (PluginManager.isPluginInstalled(PluginId.getId("com.intellij.modules.clion")) && !SystemInfo.isWindows) {
|
if (PluginManager.isPluginInstalled(PluginId.getId("com.intellij.modules.clion")) && !SystemInfo.isWindows) {
|
||||||
// row {
|
row {
|
||||||
// cell(useClion)
|
cell(useClion)
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
zigCoroutineScope.launchWithEDT {
|
zigCoroutineScope.launchWithEDT {
|
||||||
update()
|
update()
|
||||||
}
|
}
|
||||||
|
|
10
cidr/src/main/resources/META-INF/zigbrains-clion.xml
Normal file
10
cidr/src/main/resources/META-INF/zigbrains-clion.xml
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
<idea-plugin package="com.falsepattern.zigbrains.clion">
|
||||||
|
<depends>com.intellij.clion</depends>
|
||||||
|
<extensions defaultExtensionNs="com.falsepattern.zigbrains">
|
||||||
|
<debuggerDriverProvider
|
||||||
|
id="CLionProvider"
|
||||||
|
implementation="com.falsepattern.zigbrains.clion.ZigClionDebuggerDriverConfigurationProvider"
|
||||||
|
order="before DefaultProvider"
|
||||||
|
/>
|
||||||
|
</extensions>
|
||||||
|
</idea-plugin>
|
|
@ -7,6 +7,7 @@
|
||||||
<depends config-file="zigbrains-lsp.xml">com.redhat.devtools.lsp4ij</depends>
|
<depends config-file="zigbrains-lsp.xml">com.redhat.devtools.lsp4ij</depends>
|
||||||
<depends config-file="zigbrains-debugger.xml" optional="true">com.intellij.nativeDebug</depends>
|
<depends config-file="zigbrains-debugger.xml" optional="true">com.intellij.nativeDebug</depends>
|
||||||
<depends config-file="zigbrains-cidr.xml" optional="true">com.intellij.cidr.base</depends>
|
<depends config-file="zigbrains-cidr.xml" optional="true">com.intellij.cidr.base</depends>
|
||||||
|
<depends config-file="zigbrains-clion.xml" optional="true">com.intellij.clion</depends>
|
||||||
|
|
||||||
<resource-bundle>zigbrains.Bundle</resource-bundle>
|
<resource-bundle>zigbrains.Bundle</resource-bundle>
|
||||||
|
|
||||||
|
@ -27,7 +28,7 @@
|
||||||
name="featureProvider"
|
name="featureProvider"
|
||||||
/>
|
/>
|
||||||
<extensionPoint
|
<extensionPoint
|
||||||
interface="com.falsepattern.zigbrains.debugbridge.ZigDebuggerDriverConfigurationProvider"
|
interface="com.falsepattern.zigbrains.debugbridge.ZigDebuggerDriverConfigurationProviderBase"
|
||||||
dynamic="true"
|
dynamic="true"
|
||||||
name="debuggerDriverProvider"
|
name="debuggerDriverProvider"
|
||||||
/>
|
/>
|
||||||
|
|
Loading…
Add table
Reference in a new issue