Skip to content

Commit d474213

Browse files
committed
Inject path to rust binaries when launching the debugger
1 parent 587696e commit d474213

File tree

1 file changed

+26
-12
lines changed

1 file changed

+26
-12
lines changed

VisualRust.Project/DefaultRustLauncher.cs

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -124,11 +124,20 @@ private void LaunchInGdbDebugger(string file)
124124
{
125125
writer.WriteAttributeString("WorkingDirectory", EscapePath(debugConfig.WorkingDir));
126126
// GDB won't search working directory by default, but this is expected on Windows.
127-
writer.WriteAttributeString("AdditionalSOLibSearchPath", debugConfig.WorkingDir);
127+
string rustBinPath = RustBinPath();
128+
string additionalPath;
129+
if (rustBinPath != null)
130+
additionalPath = rustBinPath + ";" + debugConfig.WorkingDir;
131+
else
132+
additionalPath = debugConfig.WorkingDir;
133+
writer.WriteAttributeString("AdditionalSOLibSearchPath", additionalPath);
128134
}
129135
else
130136
{
131137
writer.WriteAttributeString("WorkingDirectory", EscapePath(Path.GetDirectoryName(file)));
138+
string rustBinPath = RustBinPath();
139+
if(rustBinPath != null)
140+
writer.WriteAttributeString("AdditionalSOLibSearchPath", rustBinPath);
132141
}
133142
// this affects the number of bytes the engine reads when disassembling commands,
134143
// x64 has the largest maximum command size, so it should be safe to use for x86 as well
@@ -243,21 +252,26 @@ private ProcessStartInfo CreateProcessStartInfo(string startupFile)
243252
return startInfo;
244253
}
245254

246-
private void InjectRustBinPath(ProcessStartInfo startInfo)
255+
private string RustBinPath()
247256
{
248257
EnvDTE.Project proj = project.GetAutomationObject() as EnvDTE.Project;
249-
if(proj == null)
250-
return;
258+
if (proj == null)
259+
return null;
251260
string currentConfigName = Utilities.GetActiveConfigurationName(proj);
252-
if(currentConfigName == null)
253-
return;
254-
ProjectConfig currentConfig = project.ConfigProvider.GetProjectConfiguration(currentConfigName);
255-
if(currentConfig == null)
256-
return;
261+
if (currentConfigName == null)
262+
return null;
263+
ProjectConfig currentConfig = project.ConfigProvider.GetProjectConfiguration(currentConfigName);
264+
if (currentConfig == null)
265+
return null;
257266
string currentTarget = currentConfig.GetConfigurationProperty("PlatformTarget", true);
258-
if(currentTarget == null)
259-
currentTarget = Shared.Environment.DefaultTarget;
260-
string installPath = Shared.Environment.FindInstallPath(currentTarget);
267+
if (currentTarget == null)
268+
currentTarget = Shared.Environment.DefaultTarget;
269+
return Shared.Environment.FindInstallPath(currentTarget);
270+
}
271+
272+
private void InjectRustBinPath(ProcessStartInfo startInfo)
273+
{
274+
string installPath = RustBinPath();
261275
if(installPath == null)
262276
return;
263277
string envPath = Environment.GetEnvironmentVariable("PATH");

0 commit comments

Comments
 (0)