Load() public method

public Load ( List inputFiles ) : void
inputFiles List
return void
Exemplo n.º 1
0
        public void Compile()
        {
            HasCompileError = true;
            Log.Clear();
            Counters.Clear();

            var compiler = new MosaCompiler();

            try
            {
                CompileStartTime = DateTime.Now;

                CompiledFile = Path.Combine(Options.DestinationDirectory, Path.GetFileNameWithoutExtension(Options.SourceFile) + ".bin");

                compiler.CompilerFactory = delegate { return new AotCompiler(); };

                compiler.CompilerOptions.EnableSSA = Options.EnableSSA;
                compiler.CompilerOptions.EnableOptimizations = Options.EnableIROptimizations;
                compiler.CompilerOptions.EnableSparseConditionalConstantPropagation = Options.EnableSparseConditionalConstantPropagation;
                compiler.CompilerOptions.EnableInlinedMethods = Options.EnableInlinedMethods;
                compiler.CompilerOptions.InlinedIRMaximum = Options.InlinedIRMaximum;
                compiler.CompilerOptions.EnableVariablePromotion = Options.EnableVariablePromotion;
                compiler.CompilerOptions.OutputFile = CompiledFile;

                compiler.CompilerOptions.Architecture = SelectArchitecture(Options.PlatformType);
                compiler.CompilerOptions.LinkerFormatType = Options.LinkerFormatType;
                compiler.CompilerOptions.BootStageFactory = GetBootStageFactory(Options.BootFormat);

                compiler.CompilerOptions.SetCustomOption("multiboot.video", Options.VBEVideo ? "true" : "false");
                compiler.CompilerOptions.SetCustomOption("multiboot.width", Options.Width.ToString());
                compiler.CompilerOptions.SetCustomOption("multiboot.height", Options.Height.ToString());
                compiler.CompilerOptions.SetCustomOption("multiboot.depth", Options.Depth.ToString());

                compiler.CompilerOptions.BaseAddress = Options.BaseAddress;
                compiler.CompilerOptions.EmitSymbols = Options.EmitSymbols;
                compiler.CompilerOptions.EmitRelocations = Options.EmitRelocations;

                compiler.CompilerOptions.SetCustomOption("x86.irq-methods", Options.Emitx86IRQMethods ? "true" : "false");

                if (Options.GenerateMapFile)
                {
                    compiler.CompilerOptions.MapFile = Path.Combine(Options.DestinationDirectory, Path.GetFileNameWithoutExtension(Options.SourceFile) + ".map");
                }

                if (!Directory.Exists(Options.DestinationDirectory))
                {
                    Directory.CreateDirectory(Options.DestinationDirectory);
                }

                compiler.CompilerTrace.TraceListener = traceListener;

                if (string.IsNullOrEmpty(Options.SourceFile))
                {
                    AddOutput("Please select a source file");
                    return;
                }
                else if (!File.Exists(Options.SourceFile))
                {
                    AddOutput(string.Format("File {0} does not exists", Options.SourceFile));
                    return;
                }

                var inputFiles = new List<FileInfo>();
                inputFiles.Add(new FileInfo(Options.SourceFile));

                compiler.Load(inputFiles);

                var threads = Options.UseMultipleThreadCompiler ? Environment.ProcessorCount : 1;
                compiler.Execute(threads);

                Linker = compiler.Linker;
                TypeSystem = compiler.TypeSystem;

                if (Options.ImageFormat == ImageFormat.ISO)
                {
                    if (Options.BootLoader == BootLoader.Grub_0_97 || Options.BootLoader == BootLoader.Grub_2_00)
                    {
                        CreateISOImageWithGrub(CompiledFile);
                    }
                    else // assuming syslinux
                    {
                        CreateISOImageWithSyslinux(CompiledFile);
                    }
                }
                else
                {
                    CreateDiskImage(CompiledFile);

                    if (Options.ImageFormat == ImageFormat.VMDK)
                    {
                        CreateVMDK(ImageFile);
                    }
                }

                HasCompileError = false;

                if (Options.GenerateASMFile)
                {
                    LaunchNDISASM();
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
            }
            finally
            {
                compiler.Dispose();
                compiler = null;
            }
        }
Exemplo n.º 2
0
        public void Compile()
        {
            HasCompileError = false;
            try
            {
                Compiler = new MosaCompiler();
                CompileStartTime = DateTime.Now;

                compiledFile = Path.Combine(Options.DestinationDirectory, Path.GetFileNameWithoutExtension(Options.SourceFile) + ".bin");

                Compiler.CompilerFactory = delegate { return new AotCompiler(); };

                Compiler.CompilerOptions.EnableSSA = Options.EnableSSA;
                Compiler.CompilerOptions.EnableOptimizations = Options.EnableIROptimizations;
                Compiler.CompilerOptions.EnableSparseConditionalConstantPropagation = Options.EnableSparseConditionalConstantPropagation;
                Compiler.CompilerOptions.EnableInlinedMethods = Options.EnableInlinedMethods;
                Compiler.CompilerOptions.OutputFile = compiledFile;

                Compiler.CompilerOptions.Architecture = SelectArchitecture(Options.PlatformType);
                Compiler.CompilerOptions.LinkerFactory = GetLinkerFactory(Options.LinkerFormat);
                Compiler.CompilerOptions.BootStageFactory = GetBootStageFactory(Options.BootFormat);

                if (Options.GenerateMapFile)
                {
                    Compiler.CompilerOptions.MapFile = Path.Combine(Options.DestinationDirectory, Path.GetFileNameWithoutExtension(Options.SourceFile) + ".map");
                }

                if (!Directory.Exists(Options.DestinationDirectory))
                {
                    Directory.CreateDirectory(Options.DestinationDirectory);
                }

                Compiler.CompilerTrace.TraceListener = traceListener;

                if (string.IsNullOrEmpty(Options.SourceFile))
                {
                    AddOutput("Please select a source file");
                    HasCompileError = true;
                    return;
                }
                else if (!File.Exists(Options.SourceFile))
                {
                    AddOutput(string.Format("File {0} does not exists", Options.SourceFile));
                    HasCompileError = true;
                    return;
                }

                var inputFiles = new List<FileInfo>();
                inputFiles.Add(new FileInfo(Options.SourceFile));

                Compiler.Load(inputFiles);

                var threads = Options.CompilerUsesMultipleThreads ? Environment.ProcessorCount : 1;
                Compiler.Execute(threads);

                if (Options.ImageFormat == ImageFormat.ISO)
                {
                    CreateISOImage(compiledFile);
                }
                else
                {
                    CreateDiskImage(compiledFile);

                    if (Options.ImageFormat == ImageFormat.VMDK)
                    {
                        CreateVMDK(imageFile);
                    }
                }

                if (Options.GenerateASMFile)
                {
                    LaunchNDISASM();
                }
            }
            finally
            {
                Compiler.Dispose();
                Compiler = null;
            }
        }