Skip to content

Commit 15a7479

Browse files
authored
Merge pull request #1073 from microsoft/main
Merge 'main' into 'release-cpptools'
2 parents 1fea306 + aaedf79 commit 15a7479

File tree

4 files changed

+53
-16
lines changed

4 files changed

+53
-16
lines changed

src/MICore/JsonLaunchOptions.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,12 @@ public abstract partial class BaseOptions
8989
/// </summary>
9090
[JsonProperty("symbolLoadInfo", DefaultValueHandling = DefaultValueHandling.Ignore)]
9191
public SymbolLoadInfo SymbolLoadInfo { get; set; }
92+
93+
/// <summary>
94+
/// One or more GDB/LLDB commands to execute in order to setup the underlying debugger. Example: "setupCommands": [ { "text": "-enable-pretty-printing", "description": "Enable GDB pretty printing", "ignoreFailures": true }].
95+
/// </summary>
96+
[JsonProperty("setupCommands", DefaultValueHandling = DefaultValueHandling.Ignore)]
97+
public List<SetupCommand> SetupCommands { get; protected set; }
9298
}
9399

94100
public partial class AttachOptions : BaseOptions
@@ -220,12 +226,6 @@ public partial class LaunchOptions : BaseOptions
220226
[JsonProperty("cwd", DefaultValueHandling = DefaultValueHandling.Ignore)]
221227
public string Cwd { get; set; }
222228

223-
/// <summary>
224-
/// One or more GDB/LLDB commands to execute in order to setup the underlying debugger. Example: "setupCommands": [ { "text": "-enable-pretty-printing", "description": "Enable GDB pretty printing", "ignoreFailures": true }].
225-
/// </summary>
226-
[JsonProperty("setupCommands", DefaultValueHandling = DefaultValueHandling.Ignore)]
227-
public List<SetupCommand> SetupCommands { get; private set; }
228-
229229
/// <summary>
230230
/// If provided, this replaces the default commands used to launch a target with some other commands. For example, this can be "-target-attach" in order to attach to a target process. An empty command list replaces the launch commands with nothing, which can be useful if the debugger is being provided launch options as command line options. Example: "customLaunchSetupCommands": [ { "text": "target-run", "description": "run target", "ignoreFailures": false }].
231231
/// </summary>

src/MICore/LaunchOptions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1711,6 +1711,8 @@ protected void InitializeCommonOptions(Json.LaunchOptions.BaseOptions options)
17111711
}
17121712
}
17131713

1714+
this.SetupCommands = LaunchCommand.CreateCollection(options.SetupCommands);
1715+
17141716
}
17151717

17161718
protected void InitializeCommonOptions(Xml.LaunchOptions.BaseLaunchOptions source)
@@ -1886,8 +1888,6 @@ public void InitializeLaunchOptions(Json.LaunchOptions.LaunchOptions launch)
18861888

18871889
this.CoreDumpPath = launch.CoreDumpPath;
18881890

1889-
this.SetupCommands = LaunchCommand.CreateCollection(launch.SetupCommands);
1890-
18911891
if (launch.CustomLaunchSetupCommands.Any())
18921892
{
18931893
this.CustomLaunchSetupCommands = LaunchCommand.CreateCollection(launch.CustomLaunchSetupCommands);

tools/Setup.csx

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class Setup {
4040

4141
private void PrintHelp()
4242
{
43-
Console.WriteLine("USAGE: dotnet script Setup.csx -- <Target-Path> [-vs|-vscode] [-debug|-release]");
43+
Console.WriteLine("USAGE: Setup.[sh|cmd] -- <Target-Path> [-vs|-vscode] [-debug|-release]");
4444
Console.WriteLine("");
4545
Console.WriteLine("\t<Target-Path> is the path to the VS Code C/C++ Extension or root path of Visual Studio.");
4646
Console.WriteLine("\tFor Example:");
@@ -58,7 +58,7 @@ class Setup {
5858

5959
foreach (string arg in args)
6060
{
61-
if (arg.StartsWith("-") || arg.StartsWith("/"))
61+
if (arg.StartsWith("-"))
6262
{
6363
switch(arg.Substring(1).ToLower())
6464
{
@@ -69,6 +69,10 @@ class Setup {
6969
break;
7070
case "vs":
7171
Client = Client.VS;
72+
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
73+
{
74+
throw new InvalidOperationException("Patching MIEngine with VS bits is not applicable for non-Windows Platforms.");
75+
}
7276
break;
7377
case "vscode":
7478
Client = Client.VSCode;
@@ -182,7 +186,15 @@ class Setup {
182186
{
183187
if (Client == Client.VSCode)
184188
{
185-
string vscodeExtensionPath = Environment.ExpandEnvironmentVariables("%USERPROFILE%\\.vscode\\extensions");
189+
string vscodeExtensionPath = string.Empty;
190+
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
191+
{
192+
vscodeExtensionPath = Environment.ExpandEnvironmentVariables("%USERPROFILE%\\.vscode\\extensions");
193+
}
194+
else
195+
{
196+
vscodeExtensionPath = Path.Join(Environment.GetEnvironmentVariable("HOME"), ".vscode/extensions");
197+
}
186198
IEnumerable<string> extensions = Directory.EnumerateDirectories(vscodeExtensionPath);
187199

188200
foreach (string extension in extensions)
@@ -237,18 +249,25 @@ class Setup {
237249
}
238250
string destPath = Path.Join(TargetPath, lff.InstallDir, lff.FileName);
239251

252+
// Normalize Paths for OS
253+
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
254+
{
255+
srcPath = srcPath.Replace('/', '\\');
256+
destPath = destPath.Replace('/', '\\');
257+
}
258+
else
259+
{
260+
srcPath = srcPath.Replace('\\', '/');
261+
destPath = destPath.Replace('\\', '/');
262+
}
263+
240264
Console.WriteLine(string.Format("Copying {0} to {1}.", srcPath, destPath));
241265

242266
// TODO: Support symlinking
243267
File.Copy(srcPath, destPath, overwrite: true);
244268
}
245269
}
246270

247-
}
248-
249-
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
250-
{
251-
throw new InvalidOperationException("This script is only supported for Windows.");
252271
}
253272

254273
Setup setup = new Setup();

tools/Setup.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/bash
2+
3+
if ! hash dotnet 2>/dev/null; then
4+
echo "ERROR: The dotnet is not installed. see: https://dotnet.microsoft.com/download/dotnet-core"
5+
exit 1
6+
fi
7+
8+
if ! dotnet script -v &> /dev/null; then
9+
echo "dotnet script needs to be installed. Run 'dotnet tool install -g dotnet-script'".
10+
echo "More Information: https://github.com/filipw/dotnet-script#net-core-global-tool"
11+
exit 1
12+
fi
13+
14+
ScriptDir=$(dirname "$0")
15+
16+
"$ScriptDir/Setup.csx" "${@:1}"
17+
18+
exit 0

0 commit comments

Comments
 (0)