/// <summary> /// Initializes a new instance of the Compiler class. /// </summary> public Compiler() { usageString = "Usage: mosacl -o outputfile --Architecture=[x86] --format=[ELF32|ELF64|PE] {--boot=[mb0.7]} {additional options} inputfiles"; optionSet = new OptionSet(); inputFiles = new List <FileInfo>(); this.linkerStage = new LinkerFormatSelector(); this.bootFormatStage = new BootFormatSelector(); this.architectureSelector = new ArchitectureSelector(); this.mapFileWrapper = new MapFileGeneratorWrapper(); #region Setup general options optionSet.Add( "v|version", "Display version information.", delegate(string v) { if (v != null) { // only show _header and exit Environment.Exit(0); } }); optionSet.Add( "h|?|help", "Display the full set of available options.", delegate(string v) { if (v != null) { this.ShowHelp(); Environment.Exit(0); } }); // default option handler for input files optionSet.Add( "<>", "Input files.", delegate(string v) { if (!File.Exists(v)) { throw new OptionException(String.Format("Input file or option '{0}' doesn't exist.", v), String.Empty); } FileInfo file = new FileInfo(v); if (file.Extension.ToLower() == ".exe") { if (isExecutable) { // there are more than one exe files in the list throw new OptionException("Multiple executables aren't allowed.", String.Empty); } isExecutable = true; } inputFiles.Add(file); }); #endregion this.linkerStage.AddOptions(optionSet); this.bootFormatStage.AddOptions(optionSet); this.architectureSelector.AddOptions(optionSet); this.mapFileWrapper.AddOptions(optionSet); }
/// <summary> /// Initializes a new instance of the Compiler class. /// </summary> public Compiler() { usageString = "Usage: mosacl -o outputfile --Architecture=[x86] --format=[ELF32|ELF64|PE] {--boot=[mb0.7]} {additional options} inputfiles"; optionSet = new OptionSet(); inputFiles = new List<FileInfo>(); this.linkerStage = new LinkerFormatSelector(); this.bootFormatStage = new BootFormatSelector(); this.architectureSelector = new ArchitectureSelector(); this.mapFileWrapper = new MapFileGeneratorWrapper(); #region Setup general options optionSet.Add( "v|version", "Display version information.", delegate(string v) { if (v != null) { // only show _header and exit Environment.Exit(0); } }); optionSet.Add( "h|?|help", "Display the full set of available options.", delegate(string v) { if (v != null) { this.ShowHelp(); Environment.Exit(0); } }); // default option handler for input files optionSet.Add( "<>", "Input files.", delegate(string v) { if (!File.Exists(v)) { throw new OptionException(String.Format("Input file or option '{0}' doesn't exist.", v), String.Empty); } FileInfo file = new FileInfo(v); if (file.Extension.ToLower() == ".exe") { if (isExecutable) { // there are more than one exe files in the list throw new OptionException("Multiple executables aren't allowed.", String.Empty); } isExecutable = true; } inputFiles.Add(file); }); #endregion this.linkerStage.AddOptions(optionSet); this.bootFormatStage.AddOptions(optionSet); this.architectureSelector.AddOptions(optionSet); this.mapFileWrapper.AddOptions(optionSet); StaticAllocationResolutionStageWrapper.Instance.AddOptions(optionSet); }