示例#1
0
 private Program(CommandLineOptions commandLineOptions)
 {
     _commandLineOptions = commandLineOptions;
 }
示例#2
0
        private void ProcessCommandLine(string[] args)
        {
            PerfEventSource.StartStopEvents.CommandLineProcessingStart();
            _commandLineOptions = new CommandLineOptions(args);
            PerfEventSource.StartStopEvents.CommandLineProcessingStop();

            if (_commandLineOptions.Help)
            {
                return;
            }

            if (_commandLineOptions.WaitForDebugger)
            {
                Console.WriteLine(SR.WaitingForDebuggerAttach);
                Console.ReadLine();
            }

            if (_commandLineOptions.CompileBubbleGenerics)
            {
                if (!_commandLineOptions.CompositeOrInputBubble)
                {
                    Console.WriteLine(SR.WarningIgnoringBubbleGenerics);
                    _commandLineOptions.CompileBubbleGenerics = false;
                }
            }

            _optimizationMode = OptimizationMode.None;
            if (_commandLineOptions.OptimizeSpace)
            {
                if (_commandLineOptions.OptimizeTime)
                {
                    Console.WriteLine(SR.WarningOverridingOptimizeSpace);
                }
                _optimizationMode = OptimizationMode.PreferSize;
            }
            else if (_commandLineOptions.OptimizeTime)
            {
                _optimizationMode = OptimizationMode.PreferSpeed;
            }
            else if (_commandLineOptions.Optimize)
            {
                _optimizationMode = OptimizationMode.Blended;
            }

            foreach (var input in _commandLineOptions.InputFilePaths)
            {
                Helpers.AppendExpandedPaths(_inputFilePaths, input, true);
            }

            foreach (var input in _commandLineOptions.UnrootedInputFilePaths)
            {
                Helpers.AppendExpandedPaths(_unrootedInputFilePaths, input, true);
            }

            foreach (var reference in _commandLineOptions.ReferenceFilePaths)
            {
                Helpers.AppendExpandedPaths(_referenceFilePaths, reference, false);
            }


            int alignment = _commandLineOptions.CustomPESectionAlignment;

            if (alignment != 0)
            {
                // Must be a power of two and >= 4096
                if (alignment < 4096 || (alignment & (alignment - 1)) != 0)
                {
                    throw new CommandLineException(SR.InvalidCustomPESectionAlignment);
                }
            }

            if (_commandLineOptions.MethodLayout != null)
            {
                _methodLayout = _commandLineOptions.MethodLayout.ToLowerInvariant() switch
                {
                    "defaultsort" => ReadyToRunMethodLayoutAlgorithm.DefaultSort,
                    "exclusiveweight" => ReadyToRunMethodLayoutAlgorithm.ExclusiveWeight,
                    "hotcold" => ReadyToRunMethodLayoutAlgorithm.HotCold,
                    "hotwarmcold" => ReadyToRunMethodLayoutAlgorithm.HotWarmCold,
                    _ => throw new CommandLineException(SR.InvalidMethodLayout)
                };
            }

            if (_commandLineOptions.FileLayout != null)
            {
                _fileLayout = _commandLineOptions.FileLayout.ToLowerInvariant() switch
                {
                    "defaultsort" => ReadyToRunFileLayoutAlgorithm.DefaultSort,
                    "methodorder" => ReadyToRunFileLayoutAlgorithm.MethodOrder,
                    _ => throw new CommandLineException(SR.InvalidFileLayout)
                };
            }
        }