Small tweaks to fix mono bootstrapping

This commit is contained in:
David Fowler 2015-10-18 07:32:42 -07:00
parent c45ff35aed
commit ba743b1ae6
3 changed files with 24 additions and 10 deletions

View file

@ -14,4 +14,7 @@ DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
# Makes development easier # Makes development easier
export PATH=$PATH:$DIR export PATH=$PATH:$DIR
# Assume bootstrapping with mono if this script still exists
export BOOTSTRAPPING_WITH_MONO=true
exec "dnx" -p "$DIR/../../src/Microsoft.DotNet.Tools.Compiler" run "$@" exec "dnx" -p "$DIR/../../src/Microsoft.DotNet.Tools.Compiler" run "$@"

View file

@ -121,7 +121,7 @@ namespace Microsoft.DotNet.Tools.Compiler
if (compileResult.ExitCode != 0) if (compileResult.ExitCode != 0)
{ {
Console.Error.WriteLine($"Failed to compile dependency: {projectDependency.Identity.Name}"); Console.Error.WriteLine($"Failed to compile dependency: {projectDependency.Identity.Name.Red().Bold()}");
return false; return false;
} }
} }
@ -151,19 +151,26 @@ namespace Microsoft.DotNet.Tools.Compiler
var compilationOptions = context.ProjectFile.GetCompilerOptions(context.TargetFramework, configuration); var compilationOptions = context.ProjectFile.GetCompilerOptions(context.TargetFramework, configuration);
var outputName = Path.Combine(outputPath, context.ProjectFile.Name + ".dll"); var outputName = Path.Combine(outputPath, context.ProjectFile.Name + ".dll");
var bootstrappingWithMono = !string.IsNullOrEmpty(Environment.GetEnvironmentVariable("BOOTSTRAPPING_WITH_MONO"));
// Assemble args // Assemble args
var compilerArgs = new List<string>() var compilerArgs = new List<string>()
{ {
// Default suppressions
"-nowarn:CS1701",
"-nowarn:CS1702",
"-nostdlib", "-nostdlib",
"-nologo", "-nologo",
$"-out:\"{outputName}\"" $"-out:\"{outputName}\""
}; };
if (!bootstrappingWithMono)
{
// Default suppressions, some versions of mono don't support these
compilerArgs.Add("-nowarn:CS1701");
compilerArgs.Add("-nowarn:CS1702");
compilerArgs.Add("-nowarn:CS1705");
}
// Add compilation options to the args // Add compilation options to the args
ApplyCompilationOptions(compilationOptions, compilerArgs); ApplyCompilationOptions(compilationOptions, compilerArgs, bootstrappingWithMono);
foreach (var dependency in dependencies) foreach (var dependency in dependencies)
{ {
@ -181,14 +188,19 @@ namespace Microsoft.DotNet.Tools.Compiler
var rsp = Path.Combine(outputPath, $"dotnet-compile.{compiler}.rsp"); var rsp = Path.Combine(outputPath, $"dotnet-compile.{compiler}.rsp");
File.WriteAllLines(rsp, compilerArgs); File.WriteAllLines(rsp, compilerArgs);
var result = Command.Create("dotnet-compile-csc", $"\"{rsp}\"") var result = Command.Create($"dotnet-compile-{compiler}", $"\"{rsp}\"")
.ForwardStdErr() .ForwardStdErr()
.ForwardStdOut() .ForwardStdOut()
.RunAsync() .RunAsync()
.GetAwaiter() .GetAwaiter()
.GetResult(); .GetResult();
return result.ExitCode == 0; if (result.ExitCode == 0)
{
Reporter.Output.WriteLine($"Compiled to {outputPath} successfully!".Green().Bold());
}
return false;
} }
private static ISet<ProjectDescription> Sort(Dictionary<string, ProjectDescription> projects) private static ISet<ProjectDescription> Sort(Dictionary<string, ProjectDescription> projects)
@ -218,7 +230,7 @@ namespace Microsoft.DotNet.Tools.Compiler
outputs.Add(project); outputs.Add(project);
} }
private static void ApplyCompilationOptions(CompilerOptions compilationOptions, List<string> cscArgs) private static void ApplyCompilationOptions(CompilerOptions compilationOptions, List<string> cscArgs, bool bootstrappingWithMono)
{ {
// TODO: Move compilation arguments into the compiler itself // TODO: Move compilation arguments into the compiler itself
var targetType = compilationOptions.EmitEntryPoint.GetValueOrDefault() ? "exe" : "library"; var targetType = compilationOptions.EmitEntryPoint.GetValueOrDefault() ? "exe" : "library";
@ -257,7 +269,7 @@ namespace Microsoft.DotNet.Tools.Compiler
cscArgs.Add($"-keyFile:\"{compilationOptions.KeyFile}\""); cscArgs.Add($"-keyFile:\"{compilationOptions.KeyFile}\"");
} }
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) if (bootstrappingWithMono || RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{ {
cscArgs.Add("-debug:full"); cscArgs.Add("-debug:full");
} }

View file

@ -218,7 +218,6 @@ exec ""$DIR/corerun"" ""$DIR/{context.ProjectFile.Name}.exe"" $*";
// Use the 'command' field to generate the name // Use the 'command' field to generate the name
var outputExe = Path.Combine(outputPath, context.ProjectFile.Name + Constants.ExeSuffix); var outputExe = Path.Combine(outputPath, context.ProjectFile.Name + Constants.ExeSuffix);
var outputDll = Path.Combine(outputPath, context.ProjectFile.Name + ".dll");
File.Copy(coreConsole, outputExe, overwrite: true); File.Copy(coreConsole, outputExe, overwrite: true);
return 0; return 0;