Product Changes to Work with new argument escaping

This commit is contained in:
Bryan 2016-01-22 14:04:04 -08:00 committed by Bryan Thornbury
parent e794ad6a10
commit 8d0fada156
20 changed files with 318 additions and 257 deletions

View file

@ -119,7 +119,7 @@ Common Commands:
{
if (appArgs.Any())
{
return Command.Create("dotnet-" + appArgs.First(), "--help")
return Command.Create("dotnet-" + appArgs.First(), new string[] { "--help" })
.ForwardStdErr()
.ForwardStdOut()
.Execute()

View file

@ -6,16 +6,16 @@
},
"dependencies": {
"NETStandard.Library": "1.0.0-rc2-23704",
"System.Threading.ThreadPool": "4.0.10-beta-23704",
"System.Threading.ThreadPool": "4.0.10-rc2-23704",
"System.Runtime.Serialization.Primitives": "4.1.0-rc2-23704",
"Microsoft.DotNet.ProjectModel": "1.0.0-*",
"Microsoft.DotNet.Compiler.Common": "1.0.0-*",
"Microsoft.DotNet.ProjectModel": {"target":"project"},
"Microsoft.DotNet.Compiler.Common": {"target":"project"},
"Microsoft.Extensions.CommandLineUtils.Sources": {
"type": "build",
"version": "1.0.0-*"
},
"Microsoft.Extensions.Logging": "1.0.0-rc2-15935",
"Microsoft.Extensions.Logging.Console": "1.0.0-rc2-15935",
"Microsoft.Extensions.Logging": "1.0.0-rc2-16011",
"Microsoft.Extensions.Logging.Console": "1.0.0-rc2-16011",
"Newtonsoft.Json": "7.0.1"
},
"frameworks": {

View file

@ -13,7 +13,7 @@
"System.Xml.XDocument": "4.0.11-rc2-23704",
"NuGet.Packaging": "3.4.0-beta-*",
"Microsoft.Extensions.FileSystemGlobbing": "1.0.0-rc2-15964",
"Microsoft.Extensions.FileSystemGlobbing": "1.0.0-rc2-15975",
"Microsoft.Extensions.JsonParser.Sources": {
"type": "build",
"version": "1.0.0-*"

View file

@ -220,7 +220,7 @@ namespace Microsoft.DotNet.Tools.Build
private void CollectCheckPathProbingPreconditions(ProjectContext project, IncrementalPreconditions preconditions)
{
var pathCommands = CompilerUtil.GetCommandsInvokedByCompile(project)
.Select(commandName => Command.Create(commandName, "", project.TargetFramework))
.Select(commandName => Command.Create(commandName, new string[] { }, project.TargetFramework))
.Where(c => c.ResolutionStrategy.Equals(CommandResolutionStrategy.Path));
foreach (var pathCommand in pathCommands)
@ -257,13 +257,40 @@ namespace Microsoft.DotNet.Tools.Build
private bool InvokeCompileOnDependency(ProjectDescription projectDependency)
{
var compileResult = Command.Create("dotnet-compile",
$"--framework {projectDependency.Framework} " +
$"--configuration {_args.ConfigValue} " +
$"--output \"{_args.OutputValue}\" " +
$"--temp-output \"{_args.IntermediateValue}\" " +
(_args.NoHostValue ? "--no-host " : string.Empty) +
$"\"{projectDependency.Project.ProjectDirectory}\"")
string[] args;
if (_args.NoHostValue)
{
args = new string[]
{
$"--framework",
$"{projectDependency.Framework}",
$"--configuration",
$"{_args.ConfigValue}",
$"--output",
$"{_args.OutputValue}",
$"--temp-output",
$"{_args.IntermediateValue}",
"--no-host",
$"{projectDependency.Project.ProjectDirectory}"
};
}
else
{
args = new string[]
{
$"--framework",
$"{projectDependency.Framework}",
$"--configuration",
$"{_args.ConfigValue}",
$"--output",
$"{_args.OutputValue}",
$"--temp-output",
$"{_args.IntermediateValue}",
$"{projectDependency.Project.ProjectDirectory}"
};
}
var compileResult = Command.Create("dotnet-compile", args)
.ForwardStdOut()
.ForwardStdErr()
.Execute();
@ -274,20 +301,45 @@ namespace Microsoft.DotNet.Tools.Build
private bool InvokeCompileOnRootProject()
{
// todo: add methods to CompilerCommandApp to generate the arg string?
var compileResult = Command.Create("dotnet-compile",
$"--framework {_rootProject.TargetFramework} " +
$"--configuration {_args.ConfigValue} " +
$"--output \"{_args.OutputValue}\" " +
$"--temp-output \"{_args.IntermediateValue}\" " +
(_args.NoHostValue ? "--no-host " : string.Empty) +
//nativeArgs
(_args.IsNativeValue ? "--native " : string.Empty) +
(_args.IsCppModeValue ? "--cpp " : string.Empty) +
(!string.IsNullOrWhiteSpace(_args.ArchValue) ? $"--arch {_args.ArchValue} " : string.Empty) +
(!string.IsNullOrWhiteSpace(_args.IlcArgsValue) ? $"--ilcargs \"{_args.IlcArgsValue}\" " : string.Empty) +
(!string.IsNullOrWhiteSpace(_args.IlcPathValue) ? $"--ilcpath \"{_args.IlcPathValue}\" " : string.Empty) +
(!string.IsNullOrWhiteSpace(_args.IlcSdkPathValue) ? $"--ilcsdkpath \"{_args.IlcSdkPathValue}\" " : string.Empty) +
$"\"{_rootProject.ProjectDirectory}\"")
List<string> args = new List<string>();
args.Add("--framework");
args.Add(_rootProject.TargetFramework.ToString());
args.Add("--configuration");
args.Add(_args.ConfigValue);
args.Add("--output");
args.Add(_args.OutputValue);
args.Add("--temp-output");
args.Add(_args.IntermediateValue);
if (_args.NoHostValue) args.Add("--no-host");
//native args
if (_args.IsNativeValue) args.Add("--native");
if (_args.IsCppModeValue) args.Add("--cpp");
if (!string.IsNullOrWhiteSpace(_args.ArchValue))
{
args.Add("--arch");
args.Add(_args.ArchValue);
}
if (!string.IsNullOrWhiteSpace(_args.IlcArgsValue))
{
args.Add("--ilcargs");
args.Add(_args.IlcArgsValue);
}
if (!string.IsNullOrWhiteSpace(_args.IlcPathValue))
{
args.Add("--ilcpath");
args.Add(_args.IlcPathValue);
}
if (!string.IsNullOrWhiteSpace(_args.IlcSdkPathValue))
{
args.Add("--ilcsdkpath");
args.Add(_args.IlcSdkPathValue);
}
args.Add(_rootProject.ProjectDirectory);
var compileResult = Command.Create("dotnet-compile",args.ToArray())
.ForwardStdOut()
.ForwardStdErr()
.Execute();

View file

@ -79,6 +79,8 @@ namespace Microsoft.DotNet.Tools.Compiler.Csc
return returnCode;
}
sources = sources.Select(s => s.Trim('"')).ToList();
var translated = TranslateCommonOptions(commonOptions, outputName);
var allArgs = new List<string>(translated);
@ -103,7 +105,7 @@ namespace Microsoft.DotNet.Tools.Compiler.Csc
File.WriteAllLines(rsp, allArgs, Encoding.UTF8);
// Execute CSC!
var result = RunCsc($"-noconfig @\"{rsp}\"")
var result = RunCsc(new string[] { $"-noconfig", "@" + $"{rsp}" })
.ForwardStdErr()
.ForwardStdOut()
.Execute();
@ -214,7 +216,7 @@ namespace Microsoft.DotNet.Tools.Compiler.Csc
return languageVersion;
}
private static Command RunCsc(string cscArgs)
private static Command RunCsc(string[] cscArgs)
{
// Locate CoreRun
return Command.Create("csc", cscArgs);

View file

@ -87,7 +87,7 @@ namespace Microsoft.DotNet.Tools.Compiler.Fsc
// Generate assembly info
var assemblyInfo = Path.Combine(tempOutDir, $"dotnet-compile.assemblyinfo.fs");
File.WriteAllText(assemblyInfo, AssemblyInfoFileGenerator.GenerateFSharp(assemblyInfoOptions));
allArgs.Add($"\"{assemblyInfo}\"");
allArgs.Add($"{assemblyInfo}");
//HACK fsc raise error FS0208 if target exe doesnt have extension .exe
bool hackFS0208 = commonOptions.EmitEntryPoint == true;
@ -100,18 +100,32 @@ namespace Microsoft.DotNet.Tools.Compiler.Fsc
outputName = Path.ChangeExtension(outputName, ".exe");
}
allArgs.Add($"--out:\"{outputName}\"");
allArgs.Add($"--out:");
allArgs.Add($"{outputName}");
}
allArgs.AddRange(references.Select(r => $"-r:\"{r}\""));
allArgs.AddRange(resources.Select(resource => $"--resource:{resource}"));
allArgs.AddRange(sources.Select(s => $"\"{s}\""));
foreach (var reference in references)
{
allArgs.Add("-r");
allArgs.Add($"{reference}");
}
foreach (var resource in resources)
{
allArgs.Add("--resource");
allArgs.Add($"{resource}");
}
foreach (var source in sources)
{
allArgs.Add($"{source}");
}
var rsp = Path.Combine(tempOutDir, "dotnet-compile-fsc.rsp");
File.WriteAllLines(rsp, allArgs, Encoding.UTF8);
// Execute FSC!
var result = RunFsc(string.Join(" ", allArgs))
var result = RunFsc(allArgs)
.ForwardStdErr()
.ForwardStdOut()
.Execute();
@ -192,11 +206,16 @@ namespace Microsoft.DotNet.Tools.Compiler.Fsc
return commonArgs;
}
private static Command RunFsc(string fscArgs)
private static Command RunFsc(List<string> fscArgs)
{
var corerun = Path.Combine(AppContext.BaseDirectory, Constants.HostExecutableName);
var fscExe = Path.Combine(AppContext.BaseDirectory, "fsc.exe");
return Command.Create(corerun, $"\"{fscExe}\" {fscArgs}");
List<string> args = new List<string>();
args.Add(fscExe);
args.AddRange(fscArgs);
return Command.Create(corerun, args.ToArray());
}
}
}

View file

@ -1,11 +1,6 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using Microsoft.Dnx.Runtime.Common.CommandLine;
using Microsoft.DotNet.Cli.Utils;
using Microsoft.DotNet.Tools.Common;
namespace Microsoft.DotNet.Tools.Compiler.Native
{
@ -13,15 +8,14 @@ namespace Microsoft.DotNet.Tools.Compiler.Native
{
private readonly string ExecutableName = "corerun" + Constants.ExeSuffix;
private readonly string ILCompiler = "ilc.exe";
private IEnumerable<string> Args;
private NativeCompileSettings config;
private static readonly Dictionary<NativeIntermediateMode, string> ModeOutputExtensionMap = new Dictionary<NativeIntermediateMode, string>
{
{ NativeIntermediateMode.cpp, ".cpp" },
{ NativeIntermediateMode.ryujit, ".obj" }
};
private string ArgStr { get; set; }
private NativeCompileSettings config;
public ILCompilerInvoker(NativeCompileSettings config)
{
@ -39,28 +33,31 @@ namespace Microsoft.DotNet.Tools.Compiler.Native
throw new FileNotFoundException("Unable to find ILCompiler at " + managedPath);
}
argsList.Add($"\"{managedPath}\"");
argsList.Add($"{managedPath}");
// Input File
var inputFilePath = config.InputManagedAssemblyPath;
argsList.Add($"\"{inputFilePath}\"");
argsList.Add($"{inputFilePath}");
// System.Private.* References
var coreLibsPath = Path.Combine(config.IlcSdkPath, "sdk");
foreach (var reference in Directory.EnumerateFiles(coreLibsPath, "*.dll"))
{
argsList.Add($"-r \"{reference}\"");
argsList.Add($"-r");
argsList.Add($"{reference}");
}
// AppDep References
foreach (var reference in config.ReferencePaths)
{
argsList.Add($"-r \"{reference}\"");
argsList.Add($"-r");
argsList.Add($"{reference}");
}
// Set Output DetermineOutFile
var outFile = DetermineOutputFile(config);
argsList.Add($"-out \"{outFile}\"");
argsList.Add($"-out");
argsList.Add($"{outFile}");
// Add Mode Flag TODO
if (config.NativeMode == NativeIntermediateMode.cpp)
@ -74,14 +71,14 @@ namespace Microsoft.DotNet.Tools.Compiler.Native
argsList.Add(config.IlcArgs);
}
this.ArgStr = string.Join(" ", argsList);
Args = argsList;
}
public int Invoke()
{
var executablePath = Path.Combine(config.IlcPath, ExecutableName);
var result = Command.Create(executablePath, ArgStr)
var result = Command.Create(executablePath, Args)
.ForwardStdErr()
.ForwardStdOut()
.Execute();

View file

@ -1,43 +1,35 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using Microsoft.Dnx.Runtime.Common.CommandLine;
using Microsoft.DotNet.Cli.Utils;
using Microsoft.DotNet.Tools.Common;
namespace Microsoft.DotNet.Tools.Compiler.Native
{
public class LinuxCppCompileStep : IPlatformNativeStep
{
private readonly string CompilerName = "clang-3.5";
private readonly string InputExtension = ".cpp";
private const string CompilerName = "clang-3.5";
private const string InputExtension = ".cpp";
// TODO: debug/release support
private readonly string cLibsFlags = "-lm -ldl";
private readonly string cflags = "-g -lstdc++ -lrt -Wno-invalid-offsetof -pthread";
private readonly string [] _cLibsFlags = { "-lm", "-ldl"};
private readonly string [] _cflags = { "-g", "-lstdc++", "-lrt", "-Wno-invalid-offsetof", "-pthread"};
private readonly string[] IlcSdkLibs = new string[]
{
"libbootstrappercpp.a",
"libPortableRuntime.a",
"libSystem.Private.CoreLib.Native.a"
};
public IEnumerable<string> CompilerArgs { get; set; }
private readonly string[] appdeplibs = new string[]
{
"libSystem.Native.a"
};
private readonly string[] _ilcSdkLibs =
{
"libbootstrappercpp.a",
"libPortableRuntime.a",
"libSystem.Private.CoreLib.Native.a"
};
private string CompilerArgStr { get; set; }
private NativeCompileSettings config;
private readonly string[] _appdeplibs =
{
"libSystem.Native.a"
};
public LinuxCppCompileStep(NativeCompileSettings config)
{
this.config = config;
InitializeArgs(config);
}
@ -63,11 +55,11 @@ namespace Microsoft.DotNet.Tools.Compiler.Native
var argsList = new List<string>();
// Flags
argsList.Add(cflags);
argsList.AddRange(_cflags);
var ilcSdkIncPath = Path.Combine(config.IlcSdkPath, "inc");
argsList.Add("-I");
argsList.Add($"\"{ilcSdkIncPath}\"");
argsList.Add($"{ilcSdkIncPath}");
// Input File
var inCppFile = DetermineInFile(config);
@ -80,33 +72,26 @@ namespace Microsoft.DotNet.Tools.Compiler.Native
}
// ILC SDK Libs
var IlcSdkLibPath = Path.Combine(config.IlcSdkPath, "sdk");
foreach (var lib in IlcSdkLibs)
{
var libPath = Path.Combine(IlcSdkLibPath, lib);
argsList.Add(libPath);
}
var ilcSdkLibPath = Path.Combine(config.IlcSdkPath, "sdk");
argsList.AddRange(_ilcSdkLibs.Select(lib => Path.Combine(ilcSdkLibPath, lib)));
// AppDep Libs
var baseAppDeplibPath = Path.Combine(config.AppDepSDKPath, "CPPSdk/ubuntu.14.04/x64");
foreach (var lib in appdeplibs)
{
var appDeplibPath = Path.Combine(baseAppDeplibPath, lib);
argsList.Add(appDeplibPath);
}
argsList.AddRange(_appdeplibs.Select(lib => Path.Combine(baseAppDeplibPath, lib)));
argsList.Add(cLibsFlags);
argsList.AddRange(_cLibsFlags);
// Output
var libOut = DetermineOutputFile(config);
argsList.Add($"-o \"{libOut}\"");
argsList.Add($"-o");
argsList.Add($"{libOut}");
this.CompilerArgStr = string.Join(" ", argsList);
CompilerArgs = argsList;
}
private int InvokeCompiler()
{
var result = Command.Create(CompilerName, CompilerArgStr)
var result = Command.Create(CompilerName, CompilerArgs)
.ForwardStdErr()
.ForwardStdOut()
.Execute();

View file

@ -1,44 +1,34 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Microsoft.Dnx.Runtime.Common.CommandLine;
using Microsoft.DotNet.Cli.Utils;
using Microsoft.DotNet.Tools.Common;
using System.Linq;
namespace Microsoft.DotNet.Tools.Compiler.Native
{
public class LinuxRyuJitCompileStep : IPlatformNativeStep
{
private readonly string CompilerName = "clang-3.5";
private readonly string InputExtension = ".obj";
private const string CompilerName = "clang-3.5";
private const string InputExtension = ".obj";
private const string CompilerOutputExtension = "";
private readonly string CompilerOutputExtension = "";
public List<string> CompilerArgs { get; set; }
// TODO: debug/release support
private readonly string cflags = "-lstdc++ -lpthread -ldl -lm -lrt";
private readonly string[] _cflags = {"-lstdc++", "-lpthread", "-ldl", "-lm", "-lrt"};
private readonly string[] _ilcSdkLibs =
{
"libbootstrapper.a",
"libRuntime.a",
"libSystem.Private.CoreLib.Native.a"
};
private readonly string[] IlcSdkLibs = new string[]
{
"libbootstrapper.a",
"libRuntime.a",
"libSystem.Private.CoreLib.Native.a"
};
private readonly string[] appdeplibs = new string[]
{
"libSystem.Native.a"
};
private string CompilerArgStr { get; set; }
private NativeCompileSettings config;
private readonly string[] _appdeplibs =
{
"libSystem.Native.a"
};
public LinuxRyuJitCompileStep(NativeCompileSettings config)
{
this.config = config;
InitializeArgs(config);
}
@ -64,7 +54,7 @@ namespace Microsoft.DotNet.Tools.Compiler.Native
var argsList = new List<string>();
// Flags
argsList.Add(cflags);
argsList.AddRange(_cflags);
// Input File
var inLibFile = DetermineInFile(config);
@ -77,31 +67,24 @@ namespace Microsoft.DotNet.Tools.Compiler.Native
}
// ILC SDK Libs
var IlcSdkLibPath = Path.Combine(config.IlcSdkPath, "sdk");
foreach (var lib in IlcSdkLibs)
{
var libPath = Path.Combine(IlcSdkLibPath, lib);
argsList.Add(libPath);
}
var ilcSdkLibPath = Path.Combine(config.IlcSdkPath, "sdk");
argsList.AddRange(_ilcSdkLibs.Select(lib => Path.Combine(ilcSdkLibPath, lib)));
// AppDep Libs
var baseAppDepLibPath = Path.Combine(config.AppDepSDKPath, "CPPSdk/ubuntu.14.04", config.Architecture.ToString());
foreach (var lib in appdeplibs)
{
var appDepLibPath = Path.Combine(baseAppDepLibPath, lib);
argsList.Add(appDepLibPath);
}
argsList.AddRange(_appdeplibs.Select(lib => Path.Combine(baseAppDepLibPath, lib)));
// Output
var libOut = DetermineOutputFile(config);
argsList.Add($"-o \"{libOut}\"");
argsList.Add($"-o");
argsList.Add($"{libOut}");
this.CompilerArgStr = string.Join(" ", argsList);
CompilerArgs = argsList;
}
private int InvokeCompiler()
{
var result = Command.Create(CompilerName, CompilerArgStr)
var result = Command.Create(CompilerName, CompilerArgs)
.ForwardStdErr()
.ForwardStdOut()
.Execute();

View file

@ -12,34 +12,32 @@ namespace Microsoft.DotNet.Tools.Compiler.Native
{
public class MacCppCompileStep : IPlatformNativeStep
{
private readonly string CompilerName = "clang";
private readonly string InputExtension = ".cpp";
private const string CompilerName = "clang";
public const string InputExtension = ".cpp";
// TODO: debug/release support
private readonly string cflags = "-g -lstdc++ -Wno-invalid-offsetof -pthread";
private readonly string [] _cflags = { "-g", "-lstdc++", "-Wno-invalid-offsetof", "-pthread"};
// Link to iconv APIs
private readonly string libFlags = "-liconv";
private const string LibFlags = "-liconv";
private readonly string[] IlcSdkLibs = new string[]
{
"libbootstrappercpp.a",
"libPortableRuntime.a",
"libSystem.Private.CoreLib.Native.a"
};
private readonly string[] _ilcSdkLibs =
{
"libbootstrappercpp.a",
"libPortableRuntime.a",
"libSystem.Private.CoreLib.Native.a"
};
private readonly string[] appdeplibs = new string[]
{
"libSystem.Native.a"
};
private readonly string[] _appdeplibs =
{
"libSystem.Native.a"
};
private string CompilerArgStr { get; set; }
private NativeCompileSettings config;
private List<string> CompilerArgs { get; set; }
public MacCppCompileStep(NativeCompileSettings config)
{
this.config = config;
InitializeArgs(config);
}
@ -65,18 +63,18 @@ namespace Microsoft.DotNet.Tools.Compiler.Native
var argsList = new List<string>();
// Flags
argsList.Add(cflags);
argsList.AddRange(_cflags);
var ilcSdkIncPath = Path.Combine(config.IlcSdkPath, "inc");
argsList.Add("-I");
argsList.Add($"\"{ilcSdkIncPath}\"");
argsList.Add($"{ilcSdkIncPath}");
// Input File
var inCppFile = DetermineInFile(config);
argsList.Add(inCppFile);
// Lib flags
argsList.Add(libFlags);
argsList.Add(LibFlags);
// Pass the optional native compiler flags if specified
if (!string.IsNullOrWhiteSpace(config.CppCompilerFlags))
@ -85,11 +83,9 @@ namespace Microsoft.DotNet.Tools.Compiler.Native
}
// ILC SDK Libs
var IlcSdkLibPath = Path.Combine(config.IlcSdkPath, "sdk");
foreach (var lib in IlcSdkLibs)
var ilcSdkLibPath = Path.Combine(config.IlcSdkPath, "sdk");
foreach (var libPath in _ilcSdkLibs.Select(lib => Path.Combine(ilcSdkLibPath, lib)))
{
var libPath = Path.Combine(IlcSdkLibPath, lib);
// Forward the library to linked to the linker
argsList.Add("-Xlinker");
argsList.Add(libPath);
@ -97,23 +93,23 @@ namespace Microsoft.DotNet.Tools.Compiler.Native
// AppDep Libs
var baseAppDeplibPath = Path.Combine(config.AppDepSDKPath, "CPPSdk/osx.10.10/x64");
foreach (var lib in appdeplibs)
foreach (var appDeplibPath in _appdeplibs.Select(lib => Path.Combine(baseAppDeplibPath, lib)))
{
var appDeplibPath = Path.Combine(baseAppDeplibPath, lib);
argsList.Add("-Xlinker");
argsList.Add(appDeplibPath);
}
// Output
var libOut = DetermineOutputFile(config);
argsList.Add($"-o \"{libOut}\"");
argsList.Add($"-o");
argsList.Add($"{libOut}");
this.CompilerArgStr = string.Join(" ", argsList);
CompilerArgs = argsList;
}
private int InvokeCompiler()
{
var result = Command.Create(CompilerName, CompilerArgStr)
var result = Command.Create(CompilerName, CompilerArgs)
.ForwardStdErr()
.ForwardStdOut()
.Execute();

View file

@ -1,44 +1,36 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Microsoft.Dnx.Runtime.Common.CommandLine;
using Microsoft.DotNet.Cli.Utils;
using Microsoft.DotNet.Tools.Common;
using System.Linq;
namespace Microsoft.DotNet.Tools.Compiler.Native
{
public class MacRyuJitCompileStep : IPlatformNativeStep
{
private readonly string CompilerName = "clang";
private readonly string InputExtension = ".obj";
private const string CompilerName = "clang";
private const string InputExtension = ".obj";
private readonly string CompilerOutputExtension = "";
private const string CompilerOutputExtension = "";
private IEnumerable<string> CompilerArgs;
// TODO: debug/release support
private readonly string cflags = "-g -lstdc++ -Wno-invalid-offsetof -pthread -ldl -lm -liconv";
private readonly string [] _cflags = { "-g", "-lstdc++", "-Wno-invalid-offsetof", "-pthread", "-ldl", "-lm", "-liconv" };
private readonly string[] IlcSdkLibs = new string[]
{
"libbootstrapper.a",
"libRuntime.a",
"libSystem.Private.CoreLib.Native.a"
};
private readonly string[] _ilcSdkLibs =
{
"libbootstrapper.a",
"libRuntime.a",
"libSystem.Private.CoreLib.Native.a"
};
private readonly string[] appdeplibs = new string[]
{
"libSystem.Native.a"
};
private string CompilerArgStr { get; set; }
private NativeCompileSettings config;
private readonly string[] appdeplibs =
{
"libSystem.Native.a"
};
public MacRyuJitCompileStep(NativeCompileSettings config)
{
this.config = config;
InitializeArgs(config);
}
@ -64,7 +56,7 @@ namespace Microsoft.DotNet.Tools.Compiler.Native
var argsList = new List<string>();
// Flags
argsList.Add(cflags);
argsList.AddRange(_cflags);
// Pass the optional native compiler flags if specified
if (!string.IsNullOrWhiteSpace(config.CppCompilerFlags))
@ -77,31 +69,24 @@ namespace Microsoft.DotNet.Tools.Compiler.Native
argsList.Add("-Xlinker "+inLibFile);
// ILC SDK Libs
var IlcSdkLibPath = Path.Combine(config.IlcSdkPath, "sdk");
foreach (var lib in IlcSdkLibs)
{
var libPath = Path.Combine(IlcSdkLibPath, lib);
argsList.Add("-Xlinker "+libPath);
}
var ilcSdkLibPath = Path.Combine(config.IlcSdkPath, "sdk");
argsList.AddRange(_ilcSdkLibs.Select(lib => Path.Combine(ilcSdkLibPath, lib)).Select(libPath => "-Xlinker " + libPath));
// AppDep Libs
var baseAppDepLibPath = Path.Combine(config.AppDepSDKPath, "CPPSdk/osx.10.10", config.Architecture.ToString());
foreach (var lib in appdeplibs)
{
var appDepLibPath = Path.Combine(baseAppDepLibPath, lib);
argsList.Add("-Xlinker "+appDepLibPath);
}
argsList.AddRange(appdeplibs.Select(lib => Path.Combine(baseAppDepLibPath, lib)).Select(appDepLibPath => "-Xlinker " + appDepLibPath));
// Output
var libOut = DetermineOutputFile(config);
argsList.Add($"-o \"{libOut}\"");
argsList.Add($"-o");
argsList.Add($"{libOut}");
this.CompilerArgStr = string.Join(" ", argsList);
this.CompilerArgs = argsList;
}
private int InvokeCompiler()
{
var result = Command.Create(CompilerName, CompilerArgStr)
var result = Command.Create(CompilerName, CompilerArgs)
.ForwardStdErr()
.ForwardStdOut()
.Execute();

View file

@ -20,13 +20,13 @@ namespace Microsoft.DotNet.Tools.Compiler.Native
private readonly string CompilerOutputExtension = ".obj";
private static readonly Dictionary<BuildConfiguration, string> ConfigurationCompilerOptionsMap = new Dictionary<BuildConfiguration, string>
private static readonly Dictionary<BuildConfiguration, string[]> ConfigurationCompilerOptionsMap = new Dictionary<BuildConfiguration, string[]>
{
{ BuildConfiguration.debug, "/ZI /nologo /W3 /WX- /sdl /Od /D CPPCODEGEN /D WIN32 /D _CONSOLE /D _LIB /D _UNICODE /D UNICODE /Gm /EHsc /RTC1 /MD /GS /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /Gd /TP /wd4477 /errorReport:prompt" },
{ BuildConfiguration.release, "/Zi /nologo /W3 /WX- /sdl /O2 /Oi /GL /D CPPCODEGEN /D WIN32 /D NDEBUG /D _CONSOLE /D _LIB /D _UNICODE /D UNICODE /Gm- /EHsc /MD /GS /Gy /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /Gd /TP /wd4477 /errorReport:prompt" }
{ BuildConfiguration.debug, new string[] {"/ZI", "/nologo", "/W3", "/WX-", "/sdl", "/Od", "/D", "CPPCODEGEN", "/D", "WIN32", "/D", "_CONSOLE", "/D", "_LIB", "/D", "_UNICODE", "/D", "UNICODE", "/Gm", "/EHsc", "/RTC1", "/MD", "/GS", "/fp:precise", "/Zc:wchar_t", "/Zc:forScope", "/Zc:inline", "/Gd", "/TP", "/wd4477", "/errorReport:prompt"} },
{ BuildConfiguration.release, new string[] {"/Zi", "/nologo", "/W3", "/WX-", "/sdl", "/O2", "/Oi", "/GL", "/D", "CPPCODEGEN", "/D", "WIN32", "/D", "NDEBUG", "/D", "_CONSOLE", "/D", "_LIB", "/D", "_UNICODE", "/D", "UNICODE", "/Gm-", "/EHsc", "/MD", "/GS", "/Gy", "/fp:precise", "/Zc:wchar_t", "/Zc:forScope", "/Zc:inline", "/Gd", "/TP", "/wd4477", "/errorReport:prompt"} }
};
private string CompilerArgStr { get; set; }
private IEnumerable<string> CompilerArgs { get; set; }
private NativeCompileSettings config;
@ -70,10 +70,10 @@ namespace Microsoft.DotNet.Tools.Compiler.Native
// Add Includes
var ilcSdkIncPath = Path.Combine(config.IlcSdkPath, "inc");
argsList.Add("/I");
argsList.Add($"\"{ilcSdkIncPath}\"");
argsList.Add($"{ilcSdkIncPath}");
// Configuration Based Compiler Options
argsList.Add(ConfigurationCompilerOptionsMap[config.BuildType]);
argsList.AddRange(ConfigurationCompilerOptionsMap[config.BuildType]);
// Pass the optional native compiler flags if specified
if (!string.IsNullOrWhiteSpace(config.CppCompilerFlags))
@ -83,13 +83,14 @@ namespace Microsoft.DotNet.Tools.Compiler.Native
// Output
var objOut = DetermineOutputFile(config);
argsList.Add($"/Fo\"{objOut}\"");
argsList.Add($"/Fo");
argsList.Add($"{objOut}");
// Input File
var inCppFile = DetermineInFile(config);
argsList.Add($"\"{inCppFile}\"");
this.CompilerArgStr = string.Join(" ", argsList);
argsList.Add($"{inCppFile}");
this.CompilerArgs = argsList;
}
private int InvokeCompiler()
@ -97,7 +98,7 @@ namespace Microsoft.DotNet.Tools.Compiler.Native
var vcInstallDir = Environment.GetEnvironmentVariable("VS140COMNTOOLS");
var compilerPath = Path.Combine(vcInstallDir, VSBin, CompilerName);
var result = Command.Create(compilerPath, CompilerArgStr)
var result = Command.Create(compilerPath, CompilerArgs.ToArray())
.ForwardStdErr()
.ForwardStdOut()
.Execute();

View file

@ -54,7 +54,7 @@ namespace Microsoft.DotNet.Tools.Compiler.Native
{ BuildConfiguration.release , new string[] { "msvcrt.lib" } }
};
private string ArgStr { get; set; }
private IEnumerable<string> Args { get; set; }
private NativeCompileSettings config;
public WindowsLinkStep(NativeCompileSettings config)
@ -95,10 +95,14 @@ namespace Microsoft.DotNet.Tools.Compiler.Native
//Output
var outFile = DetermineOutputFile(config);
argsList.Add($"/out:\"{outFile}\"");
argsList.Add($"/out");
argsList.Add($"{outFile}");
// Constant Libs
argsList.Add(string.Join(" ", ConstantLinkLibs));
foreach (var lib in ConstantLinkLibs)
{
argsList.Add(lib);
}
// ILC SDK Libs
var SDKLibs = IlcSdkLibMap[config.NativeMode];
@ -106,19 +110,19 @@ namespace Microsoft.DotNet.Tools.Compiler.Native
foreach (var lib in SDKLibs)
{
var sdkLibPath = Path.Combine(IlcSdkLibPath, lib);
argsList.Add($"\"{sdkLibPath}\"");
argsList.Add($"{sdkLibPath}");
}
// Configuration Based Libs
var configLibs = ConfigurationLinkLibMap[config.BuildType];
foreach (var lib in configLibs)
{
argsList.Add($"\"{lib}\"");
argsList.Add($"{lib}");
}
// Link Libs
foreach(var path in config.LinkLibPaths){
argsList.Add($"\"{path}\"");
argsList.Add($"{path}");
}
//arch
@ -126,9 +130,9 @@ namespace Microsoft.DotNet.Tools.Compiler.Native
//Input Obj file
var inputFile = DetermineInputFile(config);
argsList.Add($"\"{inputFile}\"");
this.ArgStr = string.Join(" ", argsList);
argsList.Add($"{inputFile}");
this.Args = argsList;
}
private int InvokeLinker()
@ -136,7 +140,7 @@ namespace Microsoft.DotNet.Tools.Compiler.Native
var vcInstallDir = Environment.GetEnvironmentVariable("VS140COMNTOOLS");
var linkerPath = Path.Combine(vcInstallDir, VSBin, LinkerName);
var result = Command.Create(linkerPath, ArgStr)
var result = Command.Create(linkerPath, Args.ToArray())
.ForwardStdErr()
.ForwardStdOut()
.Execute();

View file

@ -150,7 +150,7 @@ namespace Microsoft.DotNet.Tools.Compiler
// Need CoreRT Framework published to nuget
// Do Native Compilation
var result = Command.Create("dotnet-compile-native", $"--rsp \"{rsp}\"")
var result = Command.Create("dotnet-compile-native", new string[] { "--rsp", $"{rsp}" })
.ForwardStdErr()
.ForwardStdOut()
.Execute();
@ -238,10 +238,10 @@ namespace Microsoft.DotNet.Tools.Compiler
references.AddRange(dependency.CompilationAssemblies.Select(r => r.ResolvedPath));
}
compilerArgs.AddRange(dependency.SourceReferences);
compilerArgs.AddRange(dependency.SourceReferences.Select(s => $"\"{s}\""));
}
compilerArgs.AddRange(references.Select(r => $"--reference:{r}"));
compilerArgs.AddRange(references.Select(r => $"--reference:\"{r}\""));
if (compilationOptions.PreserveCompilationContext == true)
{
@ -298,7 +298,7 @@ namespace Microsoft.DotNet.Tools.Compiler
};
RunScripts(context, ScriptNames.PreCompile, contextVariables);
var result = Command.Create($"dotnet-compile-{compilerName}", $"@\"{rsp}\"")
var result = Command.Create($"dotnet-compile-{compilerName}", new string[] {"@" + $"{rsp}" })
.OnErrorLine(line =>
{
var diagnostic = ParseDiagnostic(context.ProjectDirectory, line);
@ -423,7 +423,14 @@ namespace Microsoft.DotNet.Tools.Compiler
{
var result =
Command.Create("dotnet-resgen",
$"\"{resgenFile.InputFile}\" -o \"{resgenFile.OutputFile}\" -v \"{project.Version.Version}\"")
new string[]
{
$"{resgenFile.InputFile}",
"-o",
$"{resgenFile.OutputFile}",
"-v",
$"{project.Version.Version}"
})
.ForwardStdErr()
.ForwardStdOut()
.Execute();

View file

@ -5,6 +5,7 @@ using System.Linq;
using System.Text;
using Microsoft.DotNet.Cli.Utils;
using Microsoft.DotNet.ProjectModel;
using System.Collections.Generic;
namespace Microsoft.DotNet.Tools.Pack
{
@ -39,22 +40,25 @@ namespace Microsoft.DotNet.Tools.Pack
if (_project.Files.SourceFiles.Any())
{
var argsBuilder = new StringBuilder();
argsBuilder.Append($"--configuration {_configuration}");
var argsBuilder = new List<string>();
argsBuilder.Add("--configuration");
argsBuilder.Add($"{_configuration}");
if (_artifactPathsCalculator.PackageOutputPathSet)
{
argsBuilder.Append($" --output \"{_artifactPathsCalculator.PackageOutputPathParameter}\"");
argsBuilder.Add("--output");
argsBuilder.Add($"{_artifactPathsCalculator.PackageOutputPathParameter}");
}
if (!string.IsNullOrEmpty(_intermediateOutputPath))
{
argsBuilder.Append($" --temp-output \"{_intermediateOutputPath}\"");
argsBuilder.Add("--temp-output");
argsBuilder.Add($"{_intermediateOutputPath}");
}
argsBuilder.Append($" \"{_project.ProjectFilePath}\"");
argsBuilder.Add($"{_project.ProjectFilePath}");
var result = Command.Create("dotnet-build", argsBuilder.ToString())
var result = Command.Create("dotnet-build", argsBuilder)
.ForwardStdOut()
.ForwardStdErr()
.Execute();

View file

@ -102,12 +102,17 @@ namespace Microsoft.DotNet.Tools.Publish
}
// Compile the project (and transitively, all it's dependencies)
var result = Command.Create("dotnet-build",
$"--framework \"{context.TargetFramework.DotNetFrameworkName}\" " +
$"--output \"{outputPathCalculator.BaseCompilationOutputPath}\" " +
$"--configuration \"{configuration}\" " +
"--no-host " +
$"\"{context.ProjectFile.ProjectDirectory}\"")
var result = Command.Create("dotnet-build",
new string[] {
"--framework",
$"{context.TargetFramework.DotNetFrameworkName}",
"--output",
$"{outputPathCalculator.BaseCompilationOutputPath}",
"--configuration",
$"{configuration}",
"--no-host",
$"{context.ProjectFile.ProjectDirectory}"
})
.ForwardStdErr()
.ForwardStdOut()
.Execute();

View file

@ -5,7 +5,6 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using Microsoft.Dnx.Runtime.Common.CommandLine;
using Microsoft.DotNet.Cli.Utils;
using Microsoft.DotNet.ProjectModel;
@ -60,10 +59,21 @@ namespace Microsoft.DotNet.Tools.Repl.Csi
Reporter.Output.WriteLine($"Compiling {projectContext.RootProject.Identity.Name.Yellow()} for {projectContext.TargetFramework.DotNetFrameworkName.Yellow()} to use with the {"C# REPL".Yellow()} environment.");
// --temp-output is actually the intermediate output folder and can be the same as --output for our temporary compilation (`dotnet run` can be seen doing the same)
return Command.Create($"dotnet-build", $"--output \"{tempOutputDir}\" --temp-output \"{tempOutputDir}\" --framework \"{projectContext.TargetFramework}\" --configuration \"{configuration}\" \"{projectContext.ProjectDirectory}\"")
.ForwardStdOut(onlyIfVerbose: true)
.ForwardStdErr()
.Execute();
return Command.Create($"dotnet-build", new []
{
$"--output",
$"{tempOutputDir}",
$"--temp-output",
$"{tempOutputDir}",
$"--framework",
$"{projectContext.TargetFramework}",
$"--configuration",
$"{configuration}",
$"{projectContext.ProjectDirectory}"
})
.ForwardStdOut(onlyIfVerbose: true)
.ForwardStdErr()
.Execute();
}
private static IEnumerable<string> GetRuntimeDependencies(ProjectContext projectContext, string buildConfiguration)
@ -148,7 +158,7 @@ namespace Microsoft.DotNet.Tools.Repl.Csi
}
string responseFile = CreateResponseFile(projectContext, buildConfiguration, tempOutputDir);
csiArgs.Add($"@\"{responseFile}\"");
csiArgs.Add($"@{responseFile}");
}
if (string.IsNullOrEmpty(script) && !remainingArguments.Any())

View file

@ -90,7 +90,18 @@ namespace Microsoft.DotNet.Tools.Run
var tempDir = Path.Combine(_context.ProjectDirectory, "bin", ".dotnetrun", Guid.NewGuid().ToString("N"));
// Compile to that directory
var result = Command.Create($"dotnet-build", $"--output \"{tempDir}\" --temp-output \"{tempDir}\" --framework \"{_context.TargetFramework}\" --configuration \"{Configuration}\" {_context.ProjectFile.ProjectDirectory}")
var result = Command.Create($"dotnet-build", new []
{
$"--output",
$"{tempDir}",
$"--temp-output",
$"{tempDir}",
$"--framework",
$"{_context.TargetFramework}",
$"--configuration",
$"{Configuration}",
$"{_context.ProjectFile.ProjectDirectory}"
})
.ForwardStdOut(onlyIfVerbose: true)
.ForwardStdErr()
.Execute();
@ -134,7 +145,7 @@ namespace Microsoft.DotNet.Tools.Run
}
}
result = Command.Create(outputName, string.Join(" ", _args))
result = Command.Create(outputName, _args)
.ForwardStdOut()
.ForwardStdErr()
.EnvironmentVariable("DOTNET_HOME", runtime)
@ -151,7 +162,7 @@ namespace Microsoft.DotNet.Tools.Run
private static int RunInteractive(string scriptName)
{
var command = Command.Create($"dotnet-repl-csi", scriptName)
var command = Command.Create($"dotnet-repl-csi", new [] {scriptName})
.ForwardStdOut()
.ForwardStdErr();
var result = command.Execute();

View file

@ -185,7 +185,7 @@ namespace Microsoft.DotNet.Tools.Restore
Console.WriteLine($"Restoring Tool '{tooldep.Name}' for '{projectPath}' in '{tempPath}'");
File.WriteAllText(projectPath, GenerateProjectJsonContents(new[] {"dnxcore50"}, tooldep));
NuGet3.Restore(new [] { $"\"{projectPath}\"", "--runtime", $"{DefaultRid}"}.Concat(args), quiet);
NuGet3.Restore(new [] { $"{projectPath}", "--runtime", $"{DefaultRid}"}.Concat(args), quiet);
}
private static string GenerateProjectJsonContents(IEnumerable<string> frameworks, LibraryRange tooldep)

View file

@ -16,8 +16,8 @@
"Microsoft.NETCore.TestHost": "1.0.0-rc2-23704",
"NETStandard.Library": "1.0.0-rc2-23704",
"System.Linq.Expressions": "4.0.11-rc2-23704",
"Microsoft.DotNet.Cli.Utils": "1.0.0-*",
"Microsoft.DotNet.Compiler.Common": "1.0.0-*",
"Microsoft.DotNet.Cli.Utils": {"target":"project"},
"Microsoft.DotNet.Compiler.Common": {"target":"project"},
"Microsoft.Dnx.Runtime.CommandParsing.Sources": {
"version": "1.0.0-*",
"type": "build"