Replacing TABs with SPACEs in WindowsLinkStep
This commit is contained in:
parent
fe110f4497
commit
cd97e2d8c6
1 changed files with 99 additions and 99 deletions
|
@ -10,19 +10,19 @@ using Microsoft.DotNet.Tools.Common;
|
||||||
|
|
||||||
namespace Microsoft.DotNet.Tools.Compiler.Native
|
namespace Microsoft.DotNet.Tools.Compiler.Native
|
||||||
{
|
{
|
||||||
public class WindowsLinkStep : IPlatformNativeStep
|
public class WindowsLinkStep : IPlatformNativeStep
|
||||||
{
|
{
|
||||||
private readonly string LinkerName = "link.exe";
|
private readonly string LinkerName = "link.exe";
|
||||||
private readonly string LinkerOutputExtension = ".exe";
|
private readonly string LinkerOutputExtension = ".exe";
|
||||||
private readonly string VSBin = "..\\..\\VC\\bin\\amd64";
|
private readonly string VSBin = "..\\..\\VC\\bin\\amd64";
|
||||||
|
|
||||||
private readonly string InputExtension = ".obj";
|
private readonly string InputExtension = ".obj";
|
||||||
|
|
||||||
private static readonly Dictionary<BuildConfiguration, string> ConfigurationLinkerOptionsMap = new Dictionary<BuildConfiguration, string>
|
private static readonly Dictionary<BuildConfiguration, string> ConfigurationLinkerOptionsMap = new Dictionary<BuildConfiguration, string>
|
||||||
{
|
{
|
||||||
{ BuildConfiguration.debug, "/NOLOGO /ERRORREPORT:PROMPT /MANIFEST /MANIFESTUAC:\"level='asInvoker' uiAccess='false'\" /manifest:embed /Debug /SUBSYSTEM:CONSOLE /TLBID:1 /DYNAMICBASE /NXCOMPAT" },
|
{ BuildConfiguration.debug, "/NOLOGO /ERRORREPORT:PROMPT /MANIFEST /MANIFESTUAC:\"level='asInvoker' uiAccess='false'\" /manifest:embed /Debug /SUBSYSTEM:CONSOLE /TLBID:1 /DYNAMICBASE /NXCOMPAT" },
|
||||||
{ BuildConfiguration.release, "/NOLOGO /ERRORREPORT:PROMPT /INCREMENTAL:NO /OPT:REF /OPT:ICF /LTCG:incremental /MANIFEST /MANIFESTUAC:\"level='asInvoker' uiAccess='false'\" /manifest:embed /Debug /SUBSYSTEM:CONSOLE /TLBID:1 /DYNAMICBASE /NXCOMPAT" }
|
{ BuildConfiguration.release, "/NOLOGO /ERRORREPORT:PROMPT /INCREMENTAL:NO /OPT:REF /OPT:ICF /LTCG:incremental /MANIFEST /MANIFESTUAC:\"level='asInvoker' uiAccess='false'\" /manifest:embed /Debug /SUBSYSTEM:CONSOLE /TLBID:1 /DYNAMICBASE /NXCOMPAT" }
|
||||||
};
|
};
|
||||||
|
|
||||||
private static readonly Dictionary<NativeIntermediateMode, string[]> ModeLibMap = new Dictionary<NativeIntermediateMode, string[]>
|
private static readonly Dictionary<NativeIntermediateMode, string[]> ModeLibMap = new Dictionary<NativeIntermediateMode, string[]>
|
||||||
{
|
{
|
||||||
|
@ -48,108 +48,108 @@ namespace Microsoft.DotNet.Tools.Compiler.Native
|
||||||
|
|
||||||
private static readonly Dictionary<BuildConfiguration, string[]> ConfigurationLinkLibMap = new Dictionary<BuildConfiguration, string[]>()
|
private static readonly Dictionary<BuildConfiguration, string[]> ConfigurationLinkLibMap = new Dictionary<BuildConfiguration, string[]>()
|
||||||
{
|
{
|
||||||
{ BuildConfiguration.debug , new string[] { "msvcrtd.lib" } },
|
{ BuildConfiguration.debug , new string[] { "msvcrtd.lib" } },
|
||||||
{ BuildConfiguration.release , new string[] { "msvcrt.lib" } }
|
{ BuildConfiguration.release , new string[] { "msvcrt.lib" } }
|
||||||
};
|
};
|
||||||
|
|
||||||
private string ArgStr { get; set; }
|
private string ArgStr { get; set; }
|
||||||
private NativeCompileSettings config;
|
private NativeCompileSettings config;
|
||||||
|
|
||||||
public WindowsLinkStep(NativeCompileSettings config)
|
public WindowsLinkStep(NativeCompileSettings config)
|
||||||
{
|
{
|
||||||
this.config = config;
|
this.config = config;
|
||||||
InitializeArgs(config);
|
InitializeArgs(config);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int Invoke()
|
public int Invoke()
|
||||||
{
|
{
|
||||||
var result = WindowsCommon.SetVCVars();
|
var result = WindowsCommon.SetVCVars();
|
||||||
if (result != 0)
|
if (result != 0)
|
||||||
{
|
{
|
||||||
Reporter.Error.WriteLine("vcvarsall.bat invocation failed.");
|
Reporter.Error.WriteLine("vcvarsall.bat invocation failed.");
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
result = InvokeLinker();
|
result = InvokeLinker();
|
||||||
if (result != 0)
|
if (result != 0)
|
||||||
{
|
{
|
||||||
Reporter.Error.WriteLine("Linking of intermediate files failed.");
|
Reporter.Error.WriteLine("Linking of intermediate files failed.");
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool CheckPreReqs()
|
public bool CheckPreReqs()
|
||||||
{
|
{
|
||||||
var vcInstallDir = Environment.GetEnvironmentVariable("VS140COMNTOOLS");
|
var vcInstallDir = Environment.GetEnvironmentVariable("VS140COMNTOOLS");
|
||||||
return !string.IsNullOrEmpty(vcInstallDir);
|
return !string.IsNullOrEmpty(vcInstallDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void InitializeArgs(NativeCompileSettings config)
|
private void InitializeArgs(NativeCompileSettings config)
|
||||||
{
|
{
|
||||||
var argsList = new List<string>();
|
var argsList = new List<string>();
|
||||||
|
|
||||||
// Configuration Based Linker Options
|
// Configuration Based Linker Options
|
||||||
argsList.Add(ConfigurationLinkerOptionsMap[config.BuildType]);
|
argsList.Add(ConfigurationLinkerOptionsMap[config.BuildType]);
|
||||||
|
|
||||||
//Output
|
//Output
|
||||||
var outFile = DetermineOutputFile(config);
|
var outFile = DetermineOutputFile(config);
|
||||||
argsList.Add($"/out:\"{outFile}\"");
|
argsList.Add($"/out:\"{outFile}\"");
|
||||||
|
|
||||||
// Constant Libs
|
// Constant Libs
|
||||||
argsList.Add(string.Join(" ", ConstantLinkLibs));
|
argsList.Add(string.Join(" ", ConstantLinkLibs));
|
||||||
|
|
||||||
// SDK Libs
|
// SDK Libs
|
||||||
var SDKLibs = ModeLibMap[config.NativeMode];
|
var SDKLibs = ModeLibMap[config.NativeMode];
|
||||||
foreach (var lib in SDKLibs)
|
foreach (var lib in SDKLibs)
|
||||||
{
|
{
|
||||||
argsList.Add(Path.Combine(config.IlcPath, lib));
|
argsList.Add(Path.Combine(config.IlcPath, lib));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Configuration Based Libs
|
// Configuration Based Libs
|
||||||
var configLibs = ConfigurationLinkLibMap[config.BuildType];
|
var configLibs = ConfigurationLinkLibMap[config.BuildType];
|
||||||
foreach (var lib in configLibs)
|
foreach (var lib in configLibs)
|
||||||
{
|
{
|
||||||
argsList.Add(lib);
|
argsList.Add(lib);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Link Libs
|
// Link Libs
|
||||||
foreach(var path in config.LinkLibPaths){
|
foreach(var path in config.LinkLibPaths){
|
||||||
argsList.Add($"\"{path}\"");
|
argsList.Add($"\"{path}\"");
|
||||||
}
|
}
|
||||||
|
|
||||||
//arch
|
//arch
|
||||||
argsList.Add($"/MACHINE:{config.Architecture}");
|
argsList.Add($"/MACHINE:{config.Architecture}");
|
||||||
|
|
||||||
//Input Obj file
|
//Input Obj file
|
||||||
var inputFile = DetermineInputFile(config);
|
var inputFile = DetermineInputFile(config);
|
||||||
argsList.Add($"\"{inputFile}\"");
|
argsList.Add($"\"{inputFile}\"");
|
||||||
|
|
||||||
this.ArgStr = string.Join(" ", argsList);
|
this.ArgStr = string.Join(" ", argsList);
|
||||||
}
|
}
|
||||||
|
|
||||||
private int InvokeLinker()
|
private int InvokeLinker()
|
||||||
{
|
{
|
||||||
var vcInstallDir = Environment.GetEnvironmentVariable("VS140COMNTOOLS");
|
var vcInstallDir = Environment.GetEnvironmentVariable("VS140COMNTOOLS");
|
||||||
var linkerPath = Path.Combine(vcInstallDir, VSBin, LinkerName);
|
var linkerPath = Path.Combine(vcInstallDir, VSBin, LinkerName);
|
||||||
|
|
||||||
var result = Command.Create(linkerPath, ArgStr)
|
var result = Command.Create(linkerPath, ArgStr)
|
||||||
.ForwardStdErr()
|
.ForwardStdErr()
|
||||||
.ForwardStdOut()
|
.ForwardStdOut()
|
||||||
.Execute();
|
.Execute();
|
||||||
|
|
||||||
return result.ExitCode;
|
return result.ExitCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
public string DetermineOutputFile(NativeCompileSettings config)
|
public string DetermineOutputFile(NativeCompileSettings config)
|
||||||
{
|
{
|
||||||
var outputDirectory = config.OutputDirectory;
|
var outputDirectory = config.OutputDirectory;
|
||||||
|
|
||||||
var filename = Path.GetFileNameWithoutExtension(config.InputManagedAssemblyPath);
|
var filename = Path.GetFileNameWithoutExtension(config.InputManagedAssemblyPath);
|
||||||
|
|
||||||
var outFile = Path.Combine(outputDirectory, filename + LinkerOutputExtension);
|
var outFile = Path.Combine(outputDirectory, filename + LinkerOutputExtension);
|
||||||
|
|
||||||
return outFile;
|
return outFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
private string DetermineInputFile(NativeCompileSettings config)
|
private string DetermineInputFile(NativeCompileSettings config)
|
||||||
{
|
{
|
||||||
|
@ -161,6 +161,6 @@ namespace Microsoft.DotNet.Tools.Compiler.Native
|
||||||
|
|
||||||
return infile;
|
return infile;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Add table
Add a link
Reference in a new issue