Skip to content

Commit b04d7fc

Browse files
authored
Implement the Debug Run Configuration on Linux (#74)
1 parent b661c20 commit b04d7fc

15 files changed

Lines changed: 322 additions & 12 deletions

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Changelog
22

3+
## 2025.1.2
4+
* Implement the Debug Run Configuration on Linux
5+
36
## 2025.1.1
47
* Fixes an issue with the Rimworld Run Configuration when using multiple parameters
58

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
DotnetPluginId=ReSharperPlugin.RimworldDev
55
DotnetSolution=ReSharperPlugin.RimworldDev.sln
66
RiderPluginId=com.jetbrains.rider.plugins.rimworlddev
7-
PluginVersion=2025.1.1
7+
PluginVersion=2025.1.2
88

99
BuildConfiguration=Release
1010

src/rider/main/kotlin/run/RunConfiguration.kt

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,17 @@ import com.intellij.execution.process.*
99
import com.intellij.execution.runners.ExecutionEnvironment
1010
import com.intellij.openapi.options.SettingsEditor
1111
import com.intellij.openapi.project.Project
12-
import com.intellij.openapi.rd.util.startOnUiAsync
13-
import com.intellij.openapi.rd.util.toPromise
14-
import com.jetbrains.rd.platform.util.lifetime
12+
import com.intellij.util.system.OS
1513
import com.jetbrains.rider.debugger.IRiderDebuggable
1614
import com.jetbrains.rider.plugins.unity.run.configurations.UnityAttachToPlayerFactory
1715
import com.jetbrains.rider.plugins.unity.run.configurations.UnityPlayerDebugConfigurationOptions
1816
import com.jetbrains.rider.run.configurations.AsyncRunConfiguration
19-
import com.jetbrains.rider.run.getProcess
20-
import kotlinx.coroutines.ExperimentalCoroutinesApi
2117
import org.jetbrains.concurrency.Promise
2218
import com.jetbrains.rider.plugins.unity.UnityBundle
2319
import com.jetbrains.rider.plugins.unity.run.configurations.unityExe.UnityExeConfiguration
2420
import com.jetbrains.rider.run.RiderRunBundle
2521
import icons.UnityIcons
22+
import kotlin.io.path.Path
2623

2724

2825
internal class UnityPlayerDebugConfigurationTypeInternal : ConfigurationTypeBase(
@@ -111,7 +108,7 @@ class RunConfiguration(project: Project, factory: ConfigurationFactory, name: St
111108
getScriptName(),
112109
getSaveFilePath(),
113110
getModListPath(),
114-
getRimworldState(environment),
111+
getRimworldState(environment, OS.CURRENT == OS.Linux),
115112
UnityDebugRemoteConfiguration(),
116113
environment,
117114
"CustomPlayer"
@@ -122,11 +119,21 @@ class RunConfiguration(project: Project, factory: ConfigurationFactory, name: St
122119
return RimworldDev.Rider.run.SettingsEditor(project)
123120
}
124121

125-
private fun getRimworldState(environment: ExecutionEnvironment): CommandLineState {
122+
private fun getRimworldState(environment: ExecutionEnvironment, debugInLinux: Boolean = false): CommandLineState {
126123
return object : CommandLineState(environment) {
127124
override fun startProcess(): ProcessHandler {
128-
val commandLine = GeneralCommandLine(getScriptName())
129-
.withParameters(getCommandLineOptions().split(' '))
125+
var pathToRun = getScriptName()
126+
var arguments = getCommandLineOptions()
127+
128+
// If we're debugging in Rimworld, instead of /pwd/RimWorldLinux ...args we want to run /bin/sh /pwd/run.sh /pwd/RimWorldLinux ...args
129+
if (debugInLinux) {
130+
val bashScriptPath = "${Path(pathToRun).parent}/run.sh"
131+
arguments = "$bashScriptPath $pathToRun $arguments"
132+
pathToRun = "/bin/sh"
133+
}
134+
135+
val commandLine = GeneralCommandLine(pathToRun)
136+
.withParameters(arguments.split(' ').filter { it.isNotEmpty() })
130137

131138
EnvironmentVariablesData.create(getEnvData(), true).configureCommandLine(commandLine, true)
132139

src/rider/main/kotlin/run/RunState.kt

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,20 @@ class RunState(
4444
"Doorstop/Mono.CompilerServices.SymbolWriter.dll",
4545
"Doorstop/pdb2mdb.exe",
4646
),
47+
OS.Linux to listOf(
48+
"run.sh",
49+
".doorstop_version",
50+
51+
"Doorstop/0Harmony.dll",
52+
"Doorstop/dnlib.dll",
53+
"Doorstop/Doorstop.dll",
54+
"Doorstop/Doorstop.pdb",
55+
"Doorstop/HotReload.dll",
56+
"Doorstop/libdoorstop.so",
57+
"Doorstop/Mono.Cecil.dll",
58+
"Doorstop/Mono.CompilerServices.SymbolWriter.dll",
59+
"Doorstop/pdb2mdb.exe",
60+
),
4761
OS.macOS to listOf(
4862
".doorstop_version",
4963
".doorstop_config.ini",
@@ -69,7 +83,7 @@ class RunState(
6983

7084
val rimworldResult = rimworldState.execute(executor, runner)
7185
workerProcessHandler.debuggerWorkerRealHandler.addProcessListener(createProcessListener(rimworldResult?.processHandler))
72-
86+
7387
return result
7488
}
7589

@@ -79,7 +93,12 @@ class RunState(
7993
val processHandler = event.processHandler
8094
processHandler.removeProcessListener(this)
8195

82-
siblingProcessHandler?.getProcess()?.destroy()
96+
if (OS.CURRENT == OS.Linux) {
97+
siblingProcessHandler?.getProcess()?.destroyForcibly()
98+
} else {
99+
siblingProcessHandler?.getProcess()?.destroy()
100+
}
101+
83102
QuickStartUtils.tearDown(saveFilePath)
84103
removeDoorstep()
85104
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
4.0.0
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)