private int Run(string[] args) { InitializeDefaultOptions(); ArgumentSyntax syntax = ParseCommandLine(args); if (_help) { Help(syntax.GetHelpText()); return 1; } if (_inputFilePaths.Count == 0) throw new CommandLineException("No input files specified"); if (_options.OutputFilePath == null) throw new CommandLineException("Output filename must be specified (/out <file>)"); // // Initialize type system context // SharedGenericsMode genericsMode = _useSharedGenerics ? SharedGenericsMode.CanonicalReferenceTypes : SharedGenericsMode.Disabled; var typeSystemContext = new CompilerTypeSystemContext(new TargetDetails(_targetArchitecture, _targetOS), genericsMode); typeSystemContext.InputFilePaths = _inputFilePaths; typeSystemContext.ReferenceFilePaths = _referenceFilePaths; typeSystemContext.SetSystemModule(typeSystemContext.GetModuleForSimpleName(_systemModuleName)); // // Initialize compilation group // // Single method mode? MethodDesc singleMethod = CheckAndParseSingleMethodModeArguments(typeSystemContext); CompilationModuleGroup compilationGroup; if (singleMethod != null) { compilationGroup = new SingleMethodCompilationModuleGroup(typeSystemContext, singleMethod); } else if (_multiFile) { compilationGroup = new MultiFileCompilationModuleGroup(typeSystemContext); } else { compilationGroup = new SingleFileCompilationModuleGroup(typeSystemContext); } // // Compile // Compilation compilation = new Compilation(_options, typeSystemContext, compilationGroup); compilation.Log = _options.Verbose ? Console.Out : TextWriter.Null; compilation.Compile(); return 0; }
private int Run(string[] args) { InitializeDefaultOptions(); ArgumentSyntax syntax = ParseCommandLine(args); if (_help) { Help(syntax.GetHelpText()); return(1); } if (_inputFilePaths.Count == 0) { throw new CommandLineException("No input files specified"); } if (_outputFilePath == null) { throw new CommandLineException("Output filename must be specified (/out <file>)"); } // // Initialize type system context // SharedGenericsMode genericsMode = _useSharedGenerics ? SharedGenericsMode.CanonicalReferenceTypes : SharedGenericsMode.Disabled; var typeSystemContext = new CompilerTypeSystemContext(new TargetDetails(_targetArchitecture, _targetOS), genericsMode); typeSystemContext.InputFilePaths = _inputFilePaths; typeSystemContext.ReferenceFilePaths = _referenceFilePaths; typeSystemContext.SetSystemModule(typeSystemContext.GetModuleForSimpleName(_systemModuleName)); // // Initialize compilation group and compilation roots // // Single method mode? MethodDesc singleMethod = CheckAndParseSingleMethodModeArguments(typeSystemContext); CompilationModuleGroup compilationGroup; List <ICompilationRootProvider> compilationRoots = new List <ICompilationRootProvider>(); if (singleMethod != null) { // Compiling just a single method compilationGroup = new SingleMethodCompilationModuleGroup(singleMethod); compilationRoots.Add(new SingleMethodRootProvider(singleMethod)); } else { // Either single file, or multifile library, or multifile consumption. EcmaModule entrypointModule = null; foreach (var inputFile in typeSystemContext.InputFilePaths) { EcmaModule module = typeSystemContext.GetModuleFromPath(inputFile.Value); if (module.PEReader.PEHeaders.IsExe) { if (entrypointModule != null) { throw new Exception("Multiple EXE modules"); } entrypointModule = module; } compilationRoots.Add(new ExportedMethodsRootProvider(module)); } if (entrypointModule != null) { compilationRoots.Add(new MainMethodRootProvider(entrypointModule)); } if (_multiFile) { List <EcmaModule> inputModules = new List <EcmaModule>(); foreach (var inputFile in typeSystemContext.InputFilePaths) { EcmaModule module = typeSystemContext.GetModuleFromPath(inputFile.Value); if (entrypointModule == null) { // This is a multifile production build - we need to root all methods compilationRoots.Add(new LibraryRootProvider(module)); } inputModules.Add(module); } compilationGroup = new MultiFileCompilationModuleGroup(inputModules); } else { if (entrypointModule == null) { throw new Exception("No entrypoint module"); } compilationRoots.Add(new ExportedMethodsRootProvider((EcmaModule)typeSystemContext.SystemModule)); // System.Private.Reflection.Execution needs to establish a communication channel with System.Private.CoreLib // at process startup. This is done through an eager constructor that calls into CoreLib and passes it // a callback object. // // Since CoreLib cannot reference anything, the type and it's eager constructor won't be added to the compilation // unless we explictly add it. var refExec = typeSystemContext.GetModuleForSimpleName("System.Private.Reflection.Execution", false); if (refExec != null) { var exec = refExec.GetType("Internal.Reflection.Execution", "ReflectionExecution"); compilationRoots.Add(new SingleMethodRootProvider(exec.GetStaticConstructor())); } compilationGroup = new SingleFileCompilationModuleGroup(); } foreach (var rdXmlFilePath in _rdXmlFilePaths) { compilationRoots.Add(new RdXmlRootProvider(typeSystemContext, rdXmlFilePath)); } } // // Compile // CompilationBuilder builder; if (_isCppCodegen) { builder = new CppCodegenCompilationBuilder(typeSystemContext, compilationGroup); } else { builder = new RyuJitCompilationBuilder(typeSystemContext, compilationGroup); } var logger = _isVerbose ? new Logger(Console.Out, true) : Logger.Null; DependencyTrackingLevel trackingLevel = _dgmlLogFileName == null ? DependencyTrackingLevel.None : (_generateFullDgmlLog ? DependencyTrackingLevel.All : DependencyTrackingLevel.First); ICompilation compilation = builder .UseBackendOptions(_codegenOptions) .UseLogger(logger) .UseDependencyTracking(trackingLevel) .UseCompilationRoots(compilationRoots) .ToCompilation(); compilation.Compile(_outputFilePath); if (_dgmlLogFileName != null) { compilation.WriteDependencyLog(_dgmlLogFileName); } return(0); }
private int Run(string[] args) { InitializeDefaultOptions(); ArgumentSyntax syntax = ParseCommandLine(args); if (_help) { Help(syntax.GetHelpText()); return(1); } if (_inputFilePaths.Count == 0) { throw new CommandLineException("No input files specified"); } if (_options.OutputFilePath == null) { throw new CommandLineException("Output filename must be specified (/out <file>)"); } // // Initialize type system context // SharedGenericsMode genericsMode = _useSharedGenerics ? SharedGenericsMode.CanonicalReferenceTypes : SharedGenericsMode.Disabled; var typeSystemContext = new CompilerTypeSystemContext(new TargetDetails(_targetArchitecture, _targetOS), genericsMode); typeSystemContext.InputFilePaths = _inputFilePaths; typeSystemContext.ReferenceFilePaths = _referenceFilePaths; typeSystemContext.SetSystemModule(typeSystemContext.GetModuleForSimpleName(_systemModuleName)); // // Initialize compilation group // // Single method mode? MethodDesc singleMethod = CheckAndParseSingleMethodModeArguments(typeSystemContext); CompilationModuleGroup compilationGroup; if (singleMethod != null) { compilationGroup = new SingleMethodCompilationModuleGroup(typeSystemContext, singleMethod); } else if (_multiFile) { compilationGroup = new MultiFileCompilationModuleGroup(typeSystemContext); } else { compilationGroup = new SingleFileCompilationModuleGroup(typeSystemContext); } // // Compile // Compilation compilation = new Compilation(_options, typeSystemContext, compilationGroup); compilation.Log = _options.Verbose ? Console.Out : TextWriter.Null; compilation.Compile(); return(0); }
private int Run(string[] args) { InitializeDefaultOptions(); ArgumentSyntax syntax = ParseCommandLine(args); if (_help) { Help(syntax.GetHelpText()); return 1; } if (_inputFilePaths.Count == 0) throw new CommandLineException("No input files specified"); if (_outputFilePath == null) throw new CommandLineException("Output filename must be specified (/out <file>)"); // // Initialize type system context // SharedGenericsMode genericsMode = _useSharedGenerics ? SharedGenericsMode.CanonicalReferenceTypes : SharedGenericsMode.Disabled; var typeSystemContext = new CompilerTypeSystemContext(new TargetDetails(_targetArchitecture, _targetOS), genericsMode); typeSystemContext.InputFilePaths = _inputFilePaths; typeSystemContext.ReferenceFilePaths = _referenceFilePaths; typeSystemContext.SetSystemModule(typeSystemContext.GetModuleForSimpleName(_systemModuleName)); // // Initialize compilation group and compilation roots // // Single method mode? MethodDesc singleMethod = CheckAndParseSingleMethodModeArguments(typeSystemContext); CompilationModuleGroup compilationGroup; List<ICompilationRootProvider> compilationRoots = new List<ICompilationRootProvider>(); if (singleMethod != null) { // Compiling just a single method compilationGroup = new SingleMethodCompilationModuleGroup(singleMethod); compilationRoots.Add(new SingleMethodRootProvider(singleMethod)); } else { // Either single file, or multifile library, or multifile consumption. EcmaModule entrypointModule = null; foreach (var inputFile in typeSystemContext.InputFilePaths) { EcmaModule module = typeSystemContext.GetModuleFromPath(inputFile.Value); if (module.PEReader.PEHeaders.IsExe) { if (entrypointModule != null) throw new Exception("Multiple EXE modules"); entrypointModule = module; } compilationRoots.Add(new ExportedMethodsRootProvider(module)); } if (entrypointModule != null) { compilationRoots.Add(new MainMethodRootProvider(entrypointModule)); } if (_multiFile) { List<EcmaModule> inputModules = new List<EcmaModule>(); foreach (var inputFile in typeSystemContext.InputFilePaths) { EcmaModule module = typeSystemContext.GetModuleFromPath(inputFile.Value); if (entrypointModule == null) { // This is a multifile production build - we need to root all methods compilationRoots.Add(new LibraryRootProvider(module)); } inputModules.Add(module); } compilationGroup = new MultiFileCompilationModuleGroup(inputModules); } else { if (entrypointModule == null) throw new Exception("No entrypoint module"); compilationRoots.Add(new ExportedMethodsRootProvider((EcmaModule)typeSystemContext.SystemModule)); // System.Private.Reflection.Execution needs to establish a communication channel with System.Private.CoreLib // at process startup. This is done through an eager constructor that calls into CoreLib and passes it // a callback object. // // Since CoreLib cannot reference anything, the type and it's eager constructor won't be added to the compilation // unless we explictly add it. var refExec = typeSystemContext.GetModuleForSimpleName("System.Private.Reflection.Execution", false); if (refExec != null) { var exec = refExec.GetType("Internal.Reflection.Execution", "ReflectionExecution"); compilationRoots.Add(new SingleMethodRootProvider(exec.GetStaticConstructor())); } compilationGroup = new SingleFileCompilationModuleGroup(); } foreach (var rdXmlFilePath in _rdXmlFilePaths) { compilationRoots.Add(new RdXmlRootProvider(typeSystemContext, rdXmlFilePath)); } } // // Compile // CompilationBuilder builder; if (_isCppCodegen) builder = new CppCodegenCompilationBuilder(typeSystemContext, compilationGroup); else builder = new RyuJitCompilationBuilder(typeSystemContext, compilationGroup); var logger = _isVerbose ? new Logger(Console.Out, true) : Logger.Null; DependencyTrackingLevel trackingLevel = _dgmlLogFileName == null ? DependencyTrackingLevel.None : (_generateFullDgmlLog ? DependencyTrackingLevel.All : DependencyTrackingLevel.First); ICompilation compilation = builder .UseBackendOptions(_codegenOptions) .UseLogger(logger) .UseDependencyTracking(trackingLevel) .UseCompilationRoots(compilationRoots) .ToCompilation(); compilation.Compile(_outputFilePath); if (_dgmlLogFileName != null) compilation.WriteDependencyLog(_dgmlLogFileName); return 0; }
private int Run(string[] args) { InitializeDefaultOptions(); ArgumentSyntax syntax = ParseCommandLine(args); if (_help) { Help(syntax.GetHelpText()); return(1); } if (_inputFilePaths.Count == 0) { throw new CommandLineException("No input files specified"); } if (_outputFilePath == null) { throw new CommandLineException("Output filename must be specified (/out <file>)"); } // // Initialize type system context // SharedGenericsMode genericsMode = _useSharedGenerics ? SharedGenericsMode.CanonicalReferenceTypes : SharedGenericsMode.Disabled; var typeSystemContext = new CompilerTypeSystemContext(new TargetDetails(_targetArchitecture, _targetOS), genericsMode); typeSystemContext.InputFilePaths = _inputFilePaths; typeSystemContext.ReferenceFilePaths = _referenceFilePaths; typeSystemContext.SetSystemModule(typeSystemContext.GetModuleForSimpleName(_systemModuleName)); // // Initialize compilation group // // Single method mode? MethodDesc singleMethod = CheckAndParseSingleMethodModeArguments(typeSystemContext); CompilationModuleGroup compilationGroup; if (singleMethod != null) { compilationGroup = new SingleMethodCompilationModuleGroup(typeSystemContext, singleMethod); } else if (_multiFile) { compilationGroup = new MultiFileCompilationModuleGroup(typeSystemContext); } else { compilationGroup = new SingleFileCompilationModuleGroup(typeSystemContext); } // // Compile // CompilationBuilder builder; if (_isCppCodegen) { builder = new CppCodegenCompilationBuilder(typeSystemContext, compilationGroup); } else { builder = new RyuJitCompilationBuilder(typeSystemContext, compilationGroup); } var logger = _isVerbose ? new Logger(Console.Out, true) : Logger.Null; DependencyTrackingLevel trackingLevel = _dgmlLogFileName == null ? DependencyTrackingLevel.None : (_generateFullDgmlLog ? DependencyTrackingLevel.All : DependencyTrackingLevel.First); ICompilation compilation = builder .UseBackendOptions(_codegenOptions) .UseLogger(logger) .UseDependencyTracking(trackingLevel) .ToCompilation(); compilation.Compile(_outputFilePath); if (_dgmlLogFileName != null) { compilation.WriteDependencyLog(_dgmlLogFileName); } return(0); }