Merge pull request #622 from gkhanna79/SDKPath

Add  --ilcsdkpath
This commit is contained in:
Gaurav Khanna 2015-12-19 22:36:35 -08:00
commit 2faa8a1270
10 changed files with 67 additions and 27 deletions

View file

@ -16,6 +16,7 @@ namespace Microsoft.DotNet.Tools.Compiler.Native
public IEnumerable<string> LinkLibPaths { get; set; }
public string AppDepSDKPath { get; set; }
public string IlcPath { get; set; }
public string IlcSdkPath { get; set; }
public bool IsHelp { get; set; }
public int ReturnCode { get; set; }
@ -57,6 +58,11 @@ namespace Microsoft.DotNet.Tools.Compiler.Native
config.IlcPath = IlcPath;
}
if (!string.IsNullOrEmpty(IlcSdkPath))
{
config.IlcSdkPath = IlcSdkPath;
}
if (!string.IsNullOrEmpty(LogPath))
{
config.LogPath = LogPath;

View file

@ -17,6 +17,7 @@ namespace Microsoft.DotNet.Tools.Compiler.Native
NativeIntermediateMode? nativeMode = null;
string ilcArgs = null;
string ilcPath = null;
string ilcSdkPath = null;
string appDepSdk = null;
string logPath = null;
var help = false;
@ -45,7 +46,9 @@ namespace Microsoft.DotNet.Tools.Compiler.Native
// Custom Extensibility Points to support CoreRT workflow TODO better descriptions
syntax.DefineOption("ilcargs", ref ilcArgs, "Use to specify custom arguments for the IL Compiler.");
syntax.DefineOption("ilcpath", ref ilcPath, "Use to plug in a custom built ilc.exe");
syntax.DefineOption("ilcpath", ref ilcPath, "Use to specify a custom build of IL Compiler.");
syntax.DefineOption("ilcsdkpath", ref ilcSdkPath, "Use to specify a custom build of IL Compiler SDK");
syntax.DefineOptionList("linklib", ref linklib, "Use to link in additional static libs");
// TEMPORARY Hack until CoreRT compatible Framework Libs are available
@ -125,6 +128,7 @@ namespace Microsoft.DotNet.Tools.Compiler.Native
ReferencePaths = references,
IlcArgs = ilcArgs,
IlcPath = ilcPath,
IlcSdkPath = ilcSdkPath,
LinkLibPaths = linklib,
AppDepSDKPath = appDepSdk,
LogPath = logPath

View file

@ -46,11 +46,10 @@ namespace Microsoft.DotNet.Tools.Compiler.Native
argsList.Add($"\"{inputFilePath}\"");
// System.Private.CoreLib Reference
String[] coreLibs = new String[] { "System.Private.CoreLib.dll", "System.Private.Corelib.dll" };
var coreLibPath = Path.Combine(config.IlcPath, Array.Find(coreLibs, lib => File.Exists(Path.Combine(config.IlcPath, lib))));
var coreLibPath = Path.Combine(config.IlcSdkPath, "System.Private.CoreLib.dll");
argsList.Add($"-r \"{coreLibPath}\"");
// Dependency References
// AppDep References
foreach (var reference in config.ReferencePaths)
{
argsList.Add($"-r \"{reference}\"");

View file

@ -19,7 +19,7 @@ namespace Microsoft.DotNet.Tools.Compiler.Native
private readonly string cLibsFlags = "-lm -ldl";
private readonly string cflags = "-g -lstdc++ -lrt -Wno-invalid-offsetof -pthread";
private readonly string[] libs = new string[]
private readonly string[] IlcSdkLibs = new string[]
{
"libbootstrappercpp.a",
"libPortableRuntime.a",
@ -79,10 +79,10 @@ namespace Microsoft.DotNet.Tools.Compiler.Native
// Add Stubs
argsList.Add(Path.Combine(config.AppDepSDKPath, "CPPSdk/ubuntu.14.04/lxstubs.cpp"));
// Libs
foreach (var lib in libs)
// ILC SDK Libs
foreach (var lib in IlcSdkLibs)
{
var libPath = Path.Combine(config.IlcPath, lib);
var libPath = Path.Combine(config.IlcSdkPath, lib);
argsList.Add(libPath);
}

View file

@ -20,7 +20,7 @@ namespace Microsoft.DotNet.Tools.Compiler.Native
// TODO: debug/release support
private readonly string cflags = "-lstdc++ -lpthread -ldl -lm -lrt";
private readonly string[] libs = new string[]
private readonly string[] IlcSdkLibs = new string[]
{
"libbootstrapper.a",
"libRuntime.a",
@ -70,10 +70,10 @@ namespace Microsoft.DotNet.Tools.Compiler.Native
var inLibFile = DetermineInFile(config);
argsList.Add(inLibFile);
// Libs
foreach (var lib in libs)
// ILC SDK Libs
foreach (var lib in IlcSdkLibs)
{
var libPath = Path.Combine(config.IlcPath, lib);
var libPath = Path.Combine(config.IlcSdkPath, lib);
argsList.Add(libPath);
}

View file

@ -21,7 +21,7 @@ namespace Microsoft.DotNet.Tools.Compiler.Native
// Link to iconv APIs
private readonly string libFlags = "-liconv";
private readonly string[] libs = new string[]
private readonly string[] IlcSdkLibs = new string[]
{
"libbootstrappercpp.a",
"libPortableRuntime.a",
@ -84,10 +84,10 @@ namespace Microsoft.DotNet.Tools.Compiler.Native
// Lib flags
argsList.Add(libFlags);
// Libs
foreach (var lib in libs)
// ILC SDK Libs
foreach (var lib in IlcSdkLibs)
{
var libPath = Path.Combine(config.IlcPath, lib);
var libPath = Path.Combine(config.IlcSdkPath, lib);
// Forward the library to linked to the linker
argsList.Add("-Xlinker");

View file

@ -20,7 +20,7 @@ namespace Microsoft.DotNet.Tools.Compiler.Native
// TODO: debug/release support
private readonly string cflags = "-g -lstdc++ -Wno-invalid-offsetof -pthread -ldl -lm -liconv";
private readonly string[] libs = new string[]
private readonly string[] IlcSdkLibs = new string[]
{
"libbootstrapper.a",
"libRuntime.a",
@ -75,10 +75,10 @@ namespace Microsoft.DotNet.Tools.Compiler.Native
var inLibFile = DetermineInFile(config);
argsList.Add("-Xlinker "+inLibFile);
// Libs
foreach (var lib in libs)
// ILC SDK Libs
foreach (var lib in IlcSdkLibs)
{
var libPath = Path.Combine(config.IlcPath, lib);
var libPath = Path.Combine(config.IlcSdkPath, lib);
argsList.Add("-Xlinker "+libPath);
}

View file

@ -24,7 +24,7 @@ namespace Microsoft.DotNet.Tools.Compiler.Native
{ 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[]> IlcSdkLibMap = new Dictionary<NativeIntermediateMode, string[]>
{
{ NativeIntermediateMode.cpp, new string[] { "PortableRuntime.lib", "bootstrappercpp.lib" } },
{ NativeIntermediateMode.ryujit, new string[] { "Runtime.lib", "bootstrapper.lib" } }
@ -98,11 +98,11 @@ namespace Microsoft.DotNet.Tools.Compiler.Native
// Constant Libs
argsList.Add(string.Join(" ", ConstantLinkLibs));
// SDK Libs
var SDKLibs = ModeLibMap[config.NativeMode];
// ILC SDK Libs
var SDKLibs = IlcSdkLibMap[config.NativeMode];
foreach (var lib in SDKLibs)
{
var sdkLibPath = Path.Combine(config.IlcPath, lib);
var sdkLibPath = Path.Combine(config.IlcSdkPath, lib);
argsList.Add($"\"{sdkLibPath}\"");
}

View file

@ -14,6 +14,7 @@ namespace Microsoft.DotNet.Tools.Compiler.Native
private string _inputManagedAssemblyPath;
private string _appDepSdkPath;
private string _ilcPath;
private string _ilcSdkPath;
private string _outputDirectory;
private string _intermediateDirectory;
private string _logPath;
@ -129,12 +130,32 @@ namespace Microsoft.DotNet.Tools.Compiler.Native
}
}
public string IlcSdkPath
{
get
{
return _ilcSdkPath;
}
set
{
if (!Directory.Exists(value))
{
throw new Exception($"ILC SDK Directory does not exist: {value}.");
}
_ilcSdkPath = value;
}
}
private NativeCompileSettings()
{
_linkLibPaths = new List<string>();
_referencePaths = new List<string>();
IlcPath = AppContext.BaseDirectory;
// By default, ILC SDK Path is assumed to be the same folder as ILC path
IlcSdkPath = IlcPath;
Architecture = DefaultArchitectureMode;
BuildType = DefaultBuiltType;
NativeMode = DefaultNativeModel;

View file

@ -45,7 +45,8 @@ namespace Microsoft.DotNet.Tools.Compiler
var arch = app.Option("-a|--arch <ARCH>", "The architecture for which to compile. x64 only currently supported.", CommandOptionType.SingleValue);
var ilcArgs = app.Option("--ilcargs <ARGS>", "Command line arguments to be passed directly to ILCompiler.", CommandOptionType.SingleValue);
var ilcPath = app.Option("--ilcpath <PATH>", "Path to the folder containing custom built ILCompiler.", CommandOptionType.SingleValue);
var ilcSdkPath = app.Option("--ilcsdkpath <PATH>", "Path to the folder containing ILCompiler application dependencies.", CommandOptionType.SingleValue);
var ilcSdkPath = app.Option("--ilcsdkpath <PATH>", "Path to the folder containing custom built ILCompiler SDK.", CommandOptionType.SingleValue);
var appDepSdkPath = app.Option("--appdepsdkpath <PATH>", "Path to the folder containing ILCompiler application dependencies.", CommandOptionType.SingleValue);
var cppMode = app.Option("--cpp", "Flag to do native compilation with C++ code generator.", CommandOptionType.NoValue);
app.OnExecute(() =>
@ -64,6 +65,7 @@ namespace Microsoft.DotNet.Tools.Compiler
var ilcArgsValue = ilcArgs.Value();
var ilcPathValue = ilcPath.Value();
var ilcSdkPathValue = ilcSdkPath.Value();
var appDepSdkPathValue = appDepSdkPath.Value();
var configValue = configuration.Value() ?? Constants.DefaultConfiguration;
var outputValue = output.Value();
var intermediateValue = intermediateOutput.Value();
@ -78,7 +80,7 @@ namespace Microsoft.DotNet.Tools.Compiler
success &= Compile(context, configValue, outputValue, intermediateValue, buildProjectReferences, noHost.HasValue());
if (isNative && success)
{
success &= CompileNative(context, configValue, outputValue, buildProjectReferences, intermediateValue, archValue, ilcArgsValue, ilcPathValue, ilcSdkPathValue, isCppMode);
success &= CompileNative(context, configValue, outputValue, buildProjectReferences, intermediateValue, archValue, ilcArgsValue, ilcPathValue, ilcSdkPathValue, appDepSdkPathValue, isCppMode);
}
}
@ -110,6 +112,7 @@ namespace Microsoft.DotNet.Tools.Compiler
string ilcArgsValue,
string ilcPathValue,
string ilcSdkPathValue,
string appDepSdkPathValue,
bool isCppMode)
{
var outputPath = GetOutputPath(context, configuration, outputOptionValue);
@ -146,10 +149,17 @@ namespace Microsoft.DotNet.Tools.Compiler
// ILC SDK Path
if (!string.IsNullOrWhiteSpace(ilcSdkPathValue))
{
nativeArgs.Add("--appdepsdk");
nativeArgs.Add("--ilcsdkpath");
nativeArgs.Add(ilcSdkPathValue);
}
// AppDep SDK Path
if (!string.IsNullOrWhiteSpace(appDepSdkPathValue))
{
nativeArgs.Add("--appdepsdk");
nativeArgs.Add(appDepSdkPathValue);
}
// CodeGen Mode
if(isCppMode)
{