Code Review Feedback. Refactor Config Class Name
This commit is contained in:
parent
22b3b497e0
commit
17232e836d
12 changed files with 47 additions and 111 deletions
|
@ -1,64 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Microsoft.DotNet.Tools.Compiler.Native
|
||||
{
|
||||
public class Config
|
||||
{
|
||||
public string LogPath { get; set; }
|
||||
public string InputManagedAssemblyPath { get; set; }
|
||||
|
||||
public string OutputDirectory { get; set; }
|
||||
public string IntermediateDirectory { get; set; }
|
||||
|
||||
public BuildConfiguration BuildType { get; set; }
|
||||
public ArchitectureMode Architecture { get; set; }
|
||||
public NativeIntermediateMode NativeMode { get; set; }
|
||||
public OSMode OS { get; set; }
|
||||
|
||||
public List<string> ReferencePaths { get; set; }
|
||||
|
||||
// Optional Customization Points (Can be null)
|
||||
public string IlcArgs { get; set; }
|
||||
public List<string> LinkLibPaths { get; set; }
|
||||
|
||||
// Required Customization Points (Must have default)
|
||||
public string AppDepSDKPath { get; set; }
|
||||
public string ILToNativePath { get; set; }
|
||||
public string RuntimeLibPath { get; set; }
|
||||
|
||||
public Config()
|
||||
{
|
||||
LinkLibPaths = new List<string>();
|
||||
ReferencePaths = new List<string>();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public enum NativeIntermediateMode
|
||||
{
|
||||
cpp,
|
||||
ryujit,
|
||||
custom
|
||||
}
|
||||
|
||||
public enum ArchitectureMode
|
||||
{
|
||||
x86,
|
||||
x64
|
||||
}
|
||||
|
||||
public enum OSMode
|
||||
{
|
||||
Linux,
|
||||
Windows,
|
||||
Mac
|
||||
}
|
||||
|
||||
public enum BuildConfiguration
|
||||
{
|
||||
debug,
|
||||
release
|
||||
}
|
||||
|
||||
}
|
|
@ -32,12 +32,12 @@ namespace Microsoft.DotNet.Tools.Compiler.Native
|
|||
|
||||
private string ArgStr { get; set; }
|
||||
|
||||
public ILCompilerInvoker(Config config)
|
||||
public ILCompilerInvoker(NativeCompileSettings config)
|
||||
{
|
||||
InitializeArgs(config);
|
||||
}
|
||||
|
||||
private void InitializeArgs(Config config)
|
||||
private void InitializeArgs(NativeCompileSettings config)
|
||||
{
|
||||
var argsList = new List<string>();
|
||||
|
||||
|
@ -77,7 +77,7 @@ namespace Microsoft.DotNet.Tools.Compiler.Native
|
|||
this.ArgStr = string.Join(" ", argsList);
|
||||
}
|
||||
|
||||
public int Invoke(Config config)
|
||||
public int Invoke(NativeCompileSettings config)
|
||||
{
|
||||
var executablePath = Path.Combine(config.ILToNativePath, ExecutableName);
|
||||
|
||||
|
@ -89,7 +89,7 @@ namespace Microsoft.DotNet.Tools.Compiler.Native
|
|||
return result.ExitCode;
|
||||
}
|
||||
|
||||
public string DetermineOutputFile(Config config)
|
||||
public string DetermineOutputFile(NativeCompileSettings config)
|
||||
{
|
||||
var intermediateDirectory = config.IntermediateDirectory;
|
||||
|
||||
|
|
|
@ -12,8 +12,8 @@ namespace Microsoft.DotNet.Tools.Compiler.Native
|
|||
{
|
||||
public interface IPlatformNativeStep
|
||||
{
|
||||
int Invoke(Config config);
|
||||
string DetermineOutputFile(Config config);
|
||||
int Invoke(NativeCompileSettings config);
|
||||
string DetermineOutputFile(NativeCompileSettings config);
|
||||
bool CheckPreReqs();
|
||||
}
|
||||
}
|
|
@ -12,14 +12,14 @@ namespace Microsoft.DotNet.Tools.Compiler.Native
|
|||
{
|
||||
public class IntermediateCompiler
|
||||
{
|
||||
public static IntermediateCompiler Create(Config config)
|
||||
public static IntermediateCompiler Create(NativeCompileSettings config)
|
||||
{
|
||||
var platformStepList = CreatePlatformNativeSteps(config);
|
||||
|
||||
return new IntermediateCompiler(platformStepList);
|
||||
}
|
||||
|
||||
private static List<IPlatformNativeStep> CreatePlatformNativeSteps(Config config)
|
||||
private static List<IPlatformNativeStep> CreatePlatformNativeSteps(NativeCompileSettings config)
|
||||
{
|
||||
if (config.NativeMode == NativeIntermediateMode.cpp)
|
||||
{
|
||||
|
@ -35,7 +35,7 @@ namespace Microsoft.DotNet.Tools.Compiler.Native
|
|||
}
|
||||
}
|
||||
|
||||
private static List<IPlatformNativeStep> CreateCppSteps(Config config)
|
||||
private static List<IPlatformNativeStep> CreateCppSteps(NativeCompileSettings config)
|
||||
{
|
||||
var stepList = new List<IPlatformNativeStep>();
|
||||
|
||||
|
@ -60,7 +60,7 @@ namespace Microsoft.DotNet.Tools.Compiler.Native
|
|||
return stepList;
|
||||
}
|
||||
|
||||
private static List<IPlatformNativeStep> CreateJitSteps(Config config)
|
||||
private static List<IPlatformNativeStep> CreateJitSteps(NativeCompileSettings config)
|
||||
{
|
||||
var stepList = new List<IPlatformNativeStep>();
|
||||
|
||||
|
@ -96,7 +96,7 @@ namespace Microsoft.DotNet.Tools.Compiler.Native
|
|||
this.StepList = stepList;
|
||||
}
|
||||
|
||||
public int Invoke(Config config)
|
||||
public int Invoke(NativeCompileSettings config)
|
||||
{
|
||||
foreach(var step in StepList)
|
||||
{
|
||||
|
@ -111,7 +111,7 @@ namespace Microsoft.DotNet.Tools.Compiler.Native
|
|||
return 0;
|
||||
}
|
||||
|
||||
public string DetermineOutputFile(Config config)
|
||||
public string DetermineOutputFile(NativeCompileSettings config)
|
||||
{
|
||||
return StepList.Last().DetermineOutputFile(config);
|
||||
}
|
||||
|
|
|
@ -32,12 +32,12 @@ namespace Microsoft.DotNet.Tools.Compiler.Native
|
|||
|
||||
private string CompilerArgStr { get; set; }
|
||||
|
||||
public LinuxCppCompiler(Config config)
|
||||
public LinuxCppCompiler(NativeCompileSettings config)
|
||||
{
|
||||
InitializeArgs(config);
|
||||
}
|
||||
|
||||
public int Invoke(Config config)
|
||||
public int Invoke(NativeCompileSettings config)
|
||||
{
|
||||
var result = InvokeCompiler(config);
|
||||
if (result != 0)
|
||||
|
@ -54,7 +54,7 @@ namespace Microsoft.DotNet.Tools.Compiler.Native
|
|||
return true;
|
||||
}
|
||||
|
||||
private void InitializeArgs(Config config)
|
||||
private void InitializeArgs(NativeCompileSettings config)
|
||||
{
|
||||
var argsList = new List<string>();
|
||||
|
||||
|
@ -92,7 +92,7 @@ namespace Microsoft.DotNet.Tools.Compiler.Native
|
|||
this.CompilerArgStr = string.Join(" ", argsList);
|
||||
}
|
||||
|
||||
private int InvokeCompiler(Config config)
|
||||
private int InvokeCompiler(NativeCompileSettings config)
|
||||
{
|
||||
var result = Command.Create(CompilerName, CompilerArgStr)
|
||||
.ForwardStdErr()
|
||||
|
@ -102,7 +102,7 @@ namespace Microsoft.DotNet.Tools.Compiler.Native
|
|||
return result.ExitCode;
|
||||
}
|
||||
|
||||
private string DetermineInFile(Config config)
|
||||
private string DetermineInFile(NativeCompileSettings config)
|
||||
{
|
||||
var intermediateDirectory = config.IntermediateDirectory;
|
||||
|
||||
|
@ -113,7 +113,7 @@ namespace Microsoft.DotNet.Tools.Compiler.Native
|
|||
return infile;
|
||||
}
|
||||
|
||||
public string DetermineOutputFile(Config config)
|
||||
public string DetermineOutputFile(NativeCompileSettings config)
|
||||
{
|
||||
var inputFile = DetermineInFile(config);
|
||||
|
||||
|
|
|
@ -32,12 +32,12 @@ namespace Microsoft.DotNet.Tools.Compiler.Native
|
|||
|
||||
private string CompilerArgStr { get; set; }
|
||||
|
||||
public LinuxRyuJitCompileStep(Config config)
|
||||
public LinuxRyuJitCompileStep(NativeCompileSettings config)
|
||||
{
|
||||
InitializeArgs(config);
|
||||
}
|
||||
|
||||
public int Invoke(Config config)
|
||||
public int Invoke(NativeCompileSettings config)
|
||||
{
|
||||
var result = InvokeCompiler(config);
|
||||
if (result != 0)
|
||||
|
@ -54,7 +54,7 @@ namespace Microsoft.DotNet.Tools.Compiler.Native
|
|||
return true;
|
||||
}
|
||||
|
||||
private void InitializeArgs(Config config)
|
||||
private void InitializeArgs(NativeCompileSettings config)
|
||||
{
|
||||
var argsList = new List<string>();
|
||||
|
||||
|
@ -82,7 +82,7 @@ namespace Microsoft.DotNet.Tools.Compiler.Native
|
|||
this.CompilerArgStr = string.Join(" ", argsList);
|
||||
}
|
||||
|
||||
private int InvokeCompiler(Config config)
|
||||
private int InvokeCompiler(NativeCompileSettings config)
|
||||
{
|
||||
var result = Command.Create(CompilerName, CompilerArgStr)
|
||||
.ForwardStdErr()
|
||||
|
@ -104,7 +104,7 @@ namespace Microsoft.DotNet.Tools.Compiler.Native
|
|||
return result.ExitCode;
|
||||
}
|
||||
|
||||
private string DetermineInFile(Config config)
|
||||
private string DetermineInFile(NativeCompileSettings config)
|
||||
{
|
||||
var intermediateDirectory = config.IntermediateDirectory;
|
||||
|
||||
|
@ -115,7 +115,7 @@ namespace Microsoft.DotNet.Tools.Compiler.Native
|
|||
return infile;
|
||||
}
|
||||
|
||||
public string DetermineOutputFile(Config config)
|
||||
public string DetermineOutputFile(NativeCompileSettings config)
|
||||
{
|
||||
var intermediateDirectory = config.OutputDirectory;
|
||||
|
||||
|
|
|
@ -12,12 +12,12 @@ namespace Microsoft.DotNet.Tools.Compiler.Native
|
|||
{
|
||||
public class MacCppCompileStep : IPlatformNativeStep
|
||||
{
|
||||
public MacCppCompileStep(Config config)
|
||||
public MacCppCompileStep(NativeCompileSettings config)
|
||||
{
|
||||
throw new NotImplementedException("Mac Cpp Not Supported Yet");
|
||||
}
|
||||
|
||||
public int Invoke(Config config)
|
||||
public int Invoke(NativeCompileSettings config)
|
||||
{
|
||||
throw new NotImplementedException("mac cpp Not supported yet.");
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ namespace Microsoft.DotNet.Tools.Compiler.Native
|
|||
throw new NotImplementedException("mac cpp Not supported yet.");
|
||||
}
|
||||
|
||||
public string DetermineOutputFile(Config config)
|
||||
public string DetermineOutputFile(NativeCompileSettings config)
|
||||
{
|
||||
throw new NotImplementedException("Mac cpp Not supported yet.");
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ namespace Microsoft.DotNet.Tools.Compiler.Native
|
|||
{
|
||||
public class MacLinkStep : IPlatformNativeStep
|
||||
{
|
||||
public int Invoke(Config config)
|
||||
public int Invoke(NativeCompileSettings config)
|
||||
{
|
||||
throw new NotImplementedException("Mac linker Not supported yet.");
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ namespace Microsoft.DotNet.Tools.Compiler.Native
|
|||
throw new NotImplementedException("Mac linker Not supported yet.");
|
||||
}
|
||||
|
||||
public string DetermineOutputFile(Config config)
|
||||
public string DetermineOutputFile(NativeCompileSettings config)
|
||||
{
|
||||
throw new NotImplementedException("Mac linker Not supported yet.");
|
||||
}
|
||||
|
|
|
@ -28,12 +28,12 @@ namespace Microsoft.DotNet.Tools.Compiler.Native
|
|||
|
||||
private string CompilerArgStr { get; set; }
|
||||
|
||||
public WindowsCppCompileStep(Config config)
|
||||
public WindowsCppCompileStep(NativeCompileSettings config)
|
||||
{
|
||||
InitializeArgs(config);
|
||||
}
|
||||
|
||||
public int Invoke(Config config)
|
||||
public int Invoke(NativeCompileSettings config)
|
||||
{
|
||||
var result = WindowsCommon.SetVCVars();
|
||||
if (result != 0)
|
||||
|
@ -57,7 +57,7 @@ namespace Microsoft.DotNet.Tools.Compiler.Native
|
|||
return !string.IsNullOrEmpty(vcInstallDir);
|
||||
}
|
||||
|
||||
private void InitializeArgs(Config config)
|
||||
private void InitializeArgs(NativeCompileSettings config)
|
||||
{
|
||||
var argsList = new List<string>();
|
||||
|
||||
|
@ -85,7 +85,7 @@ namespace Microsoft.DotNet.Tools.Compiler.Native
|
|||
this.CompilerArgStr = string.Join(" ", argsList);
|
||||
}
|
||||
|
||||
private int InvokeCompiler(Config config)
|
||||
private int InvokeCompiler(NativeCompileSettings config)
|
||||
{
|
||||
var vcInstallDir = Environment.GetEnvironmentVariable("VS140COMNTOOLS");
|
||||
var compilerPath = Path.Combine(vcInstallDir, VSBin, CompilerName);
|
||||
|
@ -98,7 +98,7 @@ namespace Microsoft.DotNet.Tools.Compiler.Native
|
|||
return result.ExitCode;
|
||||
}
|
||||
|
||||
private string DetermineInFile(Config config)
|
||||
private string DetermineInFile(NativeCompileSettings config)
|
||||
{
|
||||
var intermediateDirectory = config.IntermediateDirectory;
|
||||
|
||||
|
@ -109,7 +109,7 @@ namespace Microsoft.DotNet.Tools.Compiler.Native
|
|||
return infile;
|
||||
}
|
||||
|
||||
public string DetermineOutputFile(Config config)
|
||||
public string DetermineOutputFile(NativeCompileSettings config)
|
||||
{
|
||||
var intermediateDirectory = config.IntermediateDirectory;
|
||||
|
||||
|
|
|
@ -48,12 +48,12 @@ namespace Microsoft.DotNet.Tools.Compiler.Native
|
|||
|
||||
private string ArgStr { get; set; }
|
||||
|
||||
public WindowsLinkStep(Config config)
|
||||
public WindowsLinkStep(NativeCompileSettings config)
|
||||
{
|
||||
InitializeArgs(config);
|
||||
}
|
||||
|
||||
public int Invoke(Config config)
|
||||
public int Invoke(NativeCompileSettings config)
|
||||
{
|
||||
var result = WindowsCommon.SetVCVars();
|
||||
if (result != 0)
|
||||
|
@ -76,7 +76,7 @@ namespace Microsoft.DotNet.Tools.Compiler.Native
|
|||
return !string.IsNullOrEmpty(vcInstallDir);
|
||||
}
|
||||
|
||||
private void InitializeArgs(Config config)
|
||||
private void InitializeArgs(NativeCompileSettings config)
|
||||
{
|
||||
var argsList = new List<string>();
|
||||
|
||||
|
@ -107,7 +107,7 @@ namespace Microsoft.DotNet.Tools.Compiler.Native
|
|||
this.ArgStr = string.Join(" ", argsList);
|
||||
}
|
||||
|
||||
private int InvokeLinker(Config config)
|
||||
private int InvokeLinker(NativeCompileSettings config)
|
||||
{
|
||||
var vcInstallDir = Environment.GetEnvironmentVariable("VS140COMNTOOLS");
|
||||
var linkerPath = Path.Combine(vcInstallDir, VSBin, LinkerName);
|
||||
|
@ -120,7 +120,7 @@ namespace Microsoft.DotNet.Tools.Compiler.Native
|
|||
return result.ExitCode;
|
||||
}
|
||||
|
||||
public string DetermineOutputFile(Config config)
|
||||
public string DetermineOutputFile(NativeCompileSettings config)
|
||||
{
|
||||
var outputDirectory = config.OutputDirectory;
|
||||
|
||||
|
@ -131,7 +131,7 @@ namespace Microsoft.DotNet.Tools.Compiler.Native
|
|||
return outFile;
|
||||
}
|
||||
|
||||
private string DetermineInputFile(Config config)
|
||||
private string DetermineInputFile(NativeCompileSettings config)
|
||||
{
|
||||
var intermediateDirectory = config.IntermediateDirectory;
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ namespace Microsoft.DotNet.Tools.Compiler.Native
|
|||
{
|
||||
public class NativeCompiler
|
||||
{
|
||||
public static NativeCompiler Create(Config config)
|
||||
public static NativeCompiler Create(NativeCompileSettings config)
|
||||
{
|
||||
var invoker = new ILCompilerInvoker(config);
|
||||
var intCompiler = IntermediateCompiler.Create(config);
|
||||
|
@ -21,7 +21,7 @@ namespace Microsoft.DotNet.Tools.Compiler.Native
|
|||
private ILCompilerInvoker invoker;
|
||||
private IntermediateCompiler intermediateCompiler;
|
||||
|
||||
public bool CompileToNative(Config config)
|
||||
public bool CompileToNative(NativeCompileSettings config)
|
||||
{
|
||||
int result = invoker.Invoke(config);
|
||||
if(result != 0)
|
||||
|
|
|
@ -142,9 +142,9 @@ namespace Microsoft.DotNet.Tools.Compiler.Native
|
|||
return app;
|
||||
}
|
||||
|
||||
private static Config ParseAndValidateArgs(ArgValues args)
|
||||
private static NativeCompileSettings ParseAndValidateArgs(ArgValues args)
|
||||
{
|
||||
var config = new Config();
|
||||
var config = new NativeCompileSettings();
|
||||
|
||||
// Managed Input
|
||||
if (string.IsNullOrEmpty(args.InputManagedAssemblyPath) || !File.Exists(args.InputManagedAssemblyPath))
|
||||
|
@ -307,14 +307,14 @@ namespace Microsoft.DotNet.Tools.Compiler.Native
|
|||
return config;
|
||||
}
|
||||
|
||||
private static string GetDefaultOutputDir(Config config)
|
||||
private static string GetDefaultOutputDir(NativeCompileSettings config)
|
||||
{
|
||||
var dir = Path.Combine(Constants.BinDirectoryName, config.Architecture.ToString(), config.BuildType.ToString(), "native");
|
||||
|
||||
return Path.GetFullPath(dir);
|
||||
}
|
||||
|
||||
private static string GetDefaultIntermediateDir(Config config)
|
||||
private static string GetDefaultIntermediateDir(NativeCompileSettings config)
|
||||
{
|
||||
var dir = Path.Combine(Constants.ObjDirectoryName, config.Architecture.ToString(), config.BuildType.ToString(), "native");
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue