Skip to content

Commit

Permalink
Merge pull request #1073 from microsoft/main
Browse files Browse the repository at this point in the history
Merge 'main' into 'release-cpptools'
  • Loading branch information
WardenGnaw authored Oct 30, 2020
2 parents 1fea306 + aaedf79 commit 15a7479
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 16 deletions.
12 changes: 6 additions & 6 deletions src/MICore/JsonLaunchOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,12 @@ public abstract partial class BaseOptions
/// </summary>
[JsonProperty("symbolLoadInfo", DefaultValueHandling = DefaultValueHandling.Ignore)]
public SymbolLoadInfo SymbolLoadInfo { get; set; }

/// <summary>
/// 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 }].
/// </summary>
[JsonProperty("setupCommands", DefaultValueHandling = DefaultValueHandling.Ignore)]
public List<SetupCommand> SetupCommands { get; protected set; }
}

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

/// <summary>
/// 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 }].
/// </summary>
[JsonProperty("setupCommands", DefaultValueHandling = DefaultValueHandling.Ignore)]
public List<SetupCommand> SetupCommands { get; private set; }

/// <summary>
/// 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 }].
/// </summary>
Expand Down
4 changes: 2 additions & 2 deletions src/MICore/LaunchOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1711,6 +1711,8 @@ protected void InitializeCommonOptions(Json.LaunchOptions.BaseOptions options)
}
}

this.SetupCommands = LaunchCommand.CreateCollection(options.SetupCommands);

}

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

this.CoreDumpPath = launch.CoreDumpPath;

this.SetupCommands = LaunchCommand.CreateCollection(launch.SetupCommands);

if (launch.CustomLaunchSetupCommands.Any())
{
this.CustomLaunchSetupCommands = LaunchCommand.CreateCollection(launch.CustomLaunchSetupCommands);
Expand Down
35 changes: 27 additions & 8 deletions tools/Setup.csx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class Setup {

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

foreach (string arg in args)
{
if (arg.StartsWith("-") || arg.StartsWith("/"))
if (arg.StartsWith("-"))
{
switch(arg.Substring(1).ToLower())
{
Expand All @@ -69,6 +69,10 @@ class Setup {
break;
case "vs":
Client = Client.VS;
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
throw new InvalidOperationException("Patching MIEngine with VS bits is not applicable for non-Windows Platforms.");
}
break;
case "vscode":
Client = Client.VSCode;
Expand Down Expand Up @@ -182,7 +186,15 @@ class Setup {
{
if (Client == Client.VSCode)
{
string vscodeExtensionPath = Environment.ExpandEnvironmentVariables("%USERPROFILE%\\.vscode\\extensions");
string vscodeExtensionPath = string.Empty;
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
vscodeExtensionPath = Environment.ExpandEnvironmentVariables("%USERPROFILE%\\.vscode\\extensions");
}
else
{
vscodeExtensionPath = Path.Join(Environment.GetEnvironmentVariable("HOME"), ".vscode/extensions");
}
IEnumerable<string> extensions = Directory.EnumerateDirectories(vscodeExtensionPath);

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

// Normalize Paths for OS
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
srcPath = srcPath.Replace('/', '\\');
destPath = destPath.Replace('/', '\\');
}
else
{
srcPath = srcPath.Replace('\\', '/');
destPath = destPath.Replace('\\', '/');
}

Console.WriteLine(string.Format("Copying {0} to {1}.", srcPath, destPath));

// TODO: Support symlinking
File.Copy(srcPath, destPath, overwrite: true);
}
}

}

if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
throw new InvalidOperationException("This script is only supported for Windows.");
}

Setup setup = new Setup();
Expand Down
18 changes: 18 additions & 0 deletions tools/Setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash

if ! hash dotnet 2>/dev/null; then
echo "ERROR: The dotnet is not installed. see: https://dotnet.microsoft.com/download/dotnet-core"
exit 1
fi

if ! dotnet script -v &> /dev/null; then
echo "dotnet script needs to be installed. Run 'dotnet tool install -g dotnet-script'".
echo "More Information: https://github.com/filipw/dotnet-script#net-core-global-tool"
exit 1
fi

ScriptDir=$(dirname "$0")

"$ScriptDir/Setup.csx" "${@:1}"

exit 0

0 comments on commit 15a7479

Please sign in to comment.