예제 #1
0
        public String compile(Boolean explorerBit = false)
        {
            if (!(File.Exists(this.instructionsFile)))
            {
                Byte[] defaultInst = Encoding.UTF8.GetBytes("3,-fobj,bin" + Environment.NewLine);
                using (FileStream fs = File.Create(this.instructionsFile))
                    fs.Write(defaultInst, 0, defaultInst.Length);
            }

            OptData data = OptData.getOptData(File.ReadAllLines(this.instructionsFile));
            String  compiledFn = "\"" + compileDir + @"\" + header.pName + "." + data.fileExt + "\"", compileBatchFile = this.compileDir + @"\compile.bat", retVal = compiledFn.Substring(1).Remove(compiledFn.Length - 2);
            String  append = (explorerBit)?"\nexplorer \"" + this.compileDir + '"':"";

            append += (data.bonusInstructions.Count() > 0)?'\n' + data.bonusInstructions.Where(x => (!(String.IsNullOrEmpty(x)))).Select(x => x.Replace("%EXEPATH%", '"' + Application.ExecutablePath + '"').Replace("%BINDIR%", this.compileDir).Replace("%CMPFILE%", compiledFn)).merge("\n"):"";

            this.compileType = data.compileType;

            switch (this.compileType)
            {
            case CompileType.FASM:
                File.WriteAllText(compileBatchFile, "(\ncd \"" + Compiler.exeDir + "\\include\"\n" + "fasm " + '"' + this.entryFile + "\" " + compiledFn + append + "\n)1> \"" + this.compileDir + "\\output.txt\" 2>&1");
                this.compilerProcess = Process.Start(new ProcessStartInfo()
                {
                    FileName = compileBatchFile, CreateNoWindow = true, UseShellExecute = false, WindowStyle = ProcessWindowStyle.Hidden
                });
                return(retVal);

            case CompileType.NASM:
                //TODO:: Load in NASM includes @ compile time, this is probably easy, test if setting WorkingDirectory in the ProcessStartInfo to src folder will work.
                File.WriteAllText(compileBatchFile, "(\ncd \"" + Compiler.exeDir + "\\include\"\n" + "nasm " + data.nasmArgs + " \"" + this.entryFile + "\" -o " + compiledFn + append + "\n)1> \"" + this.compileDir + "\\output.txt\" 2>&1");
                this.compilerProcess = Process.Start(new ProcessStartInfo()
                {
                    FileName = compileBatchFile, CreateNoWindow = true, UseShellExecute = false, WindowStyle = ProcessWindowStyle.Hidden
                });
                return(retVal);

            case CompileType.MASM:
                MessageBox.Show("Sorry!! MASM Is not yet supported!");                         //TODO:: Support compiling with MASM
                return(retVal);

            default:
                this.compilerProcess = Process.Start(new ProcessStartInfo()
                {
                    FileName = @"C:\Windows\Cmd.exe", Arguments = " /c echo whatever"
                });
                return(Compiler.exeDir + @"\invalidCompileType.vbs");
            }
        }
예제 #2
0
        private void CompilerOptionsLoad(Object sender, EventArgs e)
        {
            this.ShowIcon        = false;
            this.FormBorderStyle = FormBorderStyle.FixedToolWindow;
            this.MinimizeBox     = true;

            if (!(this.nasmRadioBtn.Checked))
            {
                this.nasmCompileInstruction.Hide();
            }


            if (!(File.Exists(this.fn)))
            {
                Byte[] defaultInst = Encoding.UTF8.GetBytes("3,-fobj,bin" + Environment.NewLine);
                using (FileStream fs = File.Create(this.fn))
                    fs.Write(defaultInst, 0, defaultInst.Length);
            }

            OptData data = OptData.getOptData(File.ReadAllLines(this.fn));

            switch (data.compileType)
            {
            case CompileType.NASM:
                this.selRbtnTR            = "1";
                this.nasmRadioBtn.Checked = true;
                break;

            case CompileType.MASM:
                this.selRbtnTR            = "2";
                this.masmRadioBtn.Checked = true;
                break;

            default:
                this.selRbtnTR            = "3";
                this.fasmRadioBtn.Checked = true;
                break;
            }

            this.nasmCompileInstruction.Text = data.nasmArgs;
            this.compileAsTextBox.Text       = data.fileExt;
        }