diff options
author | Michal Strehovský <MichalStrehovsky@users.noreply.github.com> | 2018-05-11 03:55:02 +0300 |
---|---|---|
committer | Jan Kotas <jkotas@microsoft.com> | 2018-05-11 03:55:02 +0300 |
commit | a704dda8675a8c7924f37b6b7a5995e0b2356cf0 (patch) | |
tree | 0542b42f79ba68449c35263ac64a3c83c7250f6f /src/ILCompiler | |
parent | 832b86f06850fa1faa349dc3302efc3151499046 (diff) |
Extract class library composition into `.targets` (#5793)
Contributes to #5662. Still not putting that library under a `Condition = Exe` because I'm not quite sure how many concepts `System.Private.DeveloperExperience.Console` is conflating (it doesn't seem like it's doing only what the name implies).
I'm doing this mostly so that the compiler is more hack-friendly for an after work project of mine.
Diffstat (limited to 'src/ILCompiler')
-rw-r--r-- | src/ILCompiler/src/Program.cs | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/src/ILCompiler/src/Program.cs b/src/ILCompiler/src/Program.cs index 03ae9284d..ca927797c 100644 --- a/src/ILCompiler/src/Program.cs +++ b/src/ILCompiler/src/Program.cs @@ -58,6 +58,8 @@ namespace ILCompiler private IReadOnlyList<string> _rdXmlFilePaths = Array.Empty<string>(); + private IReadOnlyList<string> _initAssemblies = Array.Empty<string>(); + private bool _help; private Program() @@ -155,6 +157,7 @@ namespace ILCompiler syntax.DefineOption("noscan", ref _noScanner, "Do not use IL scanner to generate optimized code"); syntax.DefineOption("ildump", ref _ilDump, "Dump IL assembly listing for compiler-generated IL"); syntax.DefineOption("stacktracedata", ref _emitStackTraceData, "Emit data to support generating stack trace strings at runtime"); + syntax.DefineOptionList("initassembly", ref _initAssemblies, "Assembly(ies) with a library initializer"); syntax.DefineOption("targetarch", ref _targetArchitectureStr, "Target architecture for cross compilation"); syntax.DefineOption("targetos", ref _targetOSStr, "Target OS for cross compilation"); @@ -182,6 +185,21 @@ namespace ILCompiler return argSyntax; } + private IReadOnlyCollection<MethodDesc> CreateInitializerList(TypeSystemContext context) + { + List<ModuleDesc> assembliesWithInitalizers = new List<ModuleDesc>(); + + foreach (string initAssemblyName in _initAssemblies) + { + ModuleDesc assembly = context.ResolveAssembly(new AssemblyName(initAssemblyName)); + assembliesWithInitalizers.Add(assembly); + } + + var initializers = new LibraryInitializers(context, assembliesWithInitalizers); + + return initializers.LibraryInitializerMethods; + } + private int Run(string[] args) { InitializeDefaultOptions(); @@ -314,9 +332,7 @@ namespace ILCompiler if (entrypointModule != null) { - LibraryInitializers libraryInitializers = - new LibraryInitializers(typeSystemContext, _isCppCodegen); - compilationRoots.Add(new MainMethodRootProvider(entrypointModule, libraryInitializers.LibraryInitializerMethods)); + compilationRoots.Add(new MainMethodRootProvider(entrypointModule, CreateInitializerList(typeSystemContext))); } if (_multiFile) @@ -350,8 +366,7 @@ namespace ILCompiler { // Set owning module of generated native library startup method to compiler generated module, // to ensure the startup method is included in the object file during multimodule mode build - LibraryInitializers libraryInitializers = new LibraryInitializers(typeSystemContext, _isCppCodegen); - compilationRoots.Add(new NativeLibraryInitializerRootProvider(typeSystemContext.GeneratedAssembly, libraryInitializers.LibraryInitializerMethods)); + compilationRoots.Add(new NativeLibraryInitializerRootProvider(typeSystemContext.GeneratedAssembly, CreateInitializerList(typeSystemContext))); } if (_rdXmlFilePaths.Count > 0) |