RemoveSomeLines() public static method

public static RemoveSomeLines ( string input, List dropLines ) : string
input string
dropLines List
return string
Beispiel #1
0
        public CompilerData Compile(InputData idata, CompilerData cdata)
        {
            Directory.SetCurrentDirectory(idata.BaseDir);
            List <string> dropLines = new List <string>();

            dropLines.Add("F# Compiler for F# 4.1");
            dropLines.Add("Freely distributed under the Apache 2.0 Open Source License");
            dropLines.Add("F# Compiler for F# 4.0");


            string compiler = "fsharpc";
            string args     = "-o " + idata.BaseDir + "a.exe " + idata.PathToSource;
            long   compileTime;

            var res = Engine.CallCompiler(compiler, args, out compileTime);

            cdata.CompileTimeMs = compileTime;
            if (!File.Exists(idata.BaseDir + "a.exe"))
            {
                if (res.Count > 1)
                {
                    cdata.Error = Utils.RemoveSomeLines(Utils.ConcatenateString(res[0], res[1]), dropLines);
                }
                cdata.Success = false;
                return(cdata);
            }
            if (res.Count > 1 && (!string.IsNullOrEmpty(res[0]) || !string.IsNullOrEmpty(res[1])))
            {
                cdata.Warning = Utils.RemoveSomeLines(Utils.ConcatenateString(res[0], res[1]), dropLines);
            }
            cdata.ExecuteThis = idata.BaseDir + "a.exe";
            cdata.Executor    = "mono";
            cdata.Success     = true;
            return(cdata);
        }
Beispiel #2
0
        public CompilerData Compile(InputData idata, CompilerData cdata)
        {
            Directory.SetCurrentDirectory(idata.BaseDir);
            List <string> dropLines = new List <string>();

            dropLines.Add("Compiling");
            dropLines.Add("Linking");

            string compiler = "ghc";

            if (string.IsNullOrEmpty(idata.Compiler_args) || !idata.Compiler_args.Contains("-o a.out"))
            {
                cdata.Error   = "Compiler args must contain '-o a.out'";
                cdata.Success = false;
                return(cdata);
            }
            if (string.IsNullOrEmpty(idata.Compiler_args) || !idata.Compiler_args.Contains("source_file.hs"))
            {
                cdata.Error   = "Compiler args must contain 'source_file.hs'";
                cdata.Success = false;
                return(cdata);
            }

            idata.Compiler_args = idata.Compiler_args.Replace("source_file.hs", idata.PathToSource);
            idata.Compiler_args = idata.Compiler_args.Replace("-o a.out", "-o " + idata.BaseDir + "a.out ");

            string args = idata.Compiler_args;
            //string args = /*"-Wall*/" -o " + idata.BaseDir + "a.out " + idata.PathToSource;

            long compileTime;
            var  res = Engine.CallCompiler(compiler, args, out compileTime);

            cdata.CompileTimeMs = compileTime;
            if (!File.Exists(idata.BaseDir + "a.out"))
            {
                if (res.Count > 1)
                {
                    cdata.Error = Utils.RemoveSomeLines(Utils.ConcatenateString(res[0], res[1]), dropLines);
                }
                cdata.Success = false;
                return(cdata);
            }
            if (res.Count > 1 && (!string.IsNullOrEmpty(res[0]) || !string.IsNullOrEmpty(res[1])))
            {
                cdata.Warning = Utils.RemoveSomeLines(Utils.ConcatenateString(res[0], res[1]), dropLines);
            }
            cdata.ExecuteThis = idata.BaseDir + "a.out";
            cdata.Executor    = "";
            cdata.Success     = true;
            return(cdata);
        }
        public CompilerData Compile(InputData idata, CompilerData cdata)
        {
            List <string> dropLines = new List <string>();

            dropLines.Add("Free Pascal Compiler version");
            dropLines.Add("Copyright (c)");
            dropLines.Add("Target OS:");
            dropLines.Add("Compiling ");
            dropLines.Add("Linking ");
            dropLines.Add("lines compiled");
            dropLines.Add("contains output sections; did you forget -T?");
            dropLines.Add("Fatal: Compilation aborted");
            dropLines.Add("returned an error exitcode (normal if you did not specify a source file to be compiled)");


            string compiler = "fpc";
            string args     = "-o" + idata.BaseDir + "a.out " + " -Fi" + idata.BaseDir + " " + idata.PathToSource;
            long   compileTime;
            var    res = Engine.CallCompiler(compiler, args, out compileTime);

            cdata.CompileTimeMs = compileTime;
            if (!File.Exists(idata.BaseDir + "a.out"))
            {
                if (res.Count > 1)
                {
                    cdata.Error = Utils.RemoveSomeLines(Utils.ConcatenateString(res[0], res[1]), dropLines);
                }
                cdata.Success = false;
                return(cdata);
            }
            if (res.Count > 1 && (!string.IsNullOrEmpty(res[0]) || !string.IsNullOrEmpty(res[1])))
            {
                cdata.Warning = Utils.RemoveSomeLines(Utils.ConcatenateString(res[0], res[1]), dropLines);
            }
            cdata.ExecuteThis = idata.BaseDir + "a.out";
            cdata.Executor    = "";
            cdata.Success     = true;
            return(cdata);
        }
        public CompilerData Compile(InputData idata, CompilerData cdata)
        {
            List <string> dropLines = new List <string>();

            dropLines.Add("gcc-4.9 -c -I");
            dropLines.Add("file name does not match unit name, should be");


            Directory.SetCurrentDirectory(idata.BaseDir);
            string compiler = "gnat compile";
            string args     = idata.PathToSource;
            long   compileTime;
            var    res = Engine.CallCompiler(compiler, args, out compileTime);

            cdata.CompileTimeMs = compileTime;
            if (!File.Exists(idata.BaseDir + "source.o"))
            {
                if (res.Count > 1)
                {
                    cdata.Error = Utils.RemoveSomeLines(Utils.ConcatenateString(res[0], res[1]), dropLines);
                }
                cdata.Success = false;
                return(cdata);
            }
            if (res.Count > 1 && (!string.IsNullOrEmpty(res[0]) || !string.IsNullOrEmpty(res[1])))
            {
                cdata.Warning = Utils.RemoveSomeLines(Utils.ConcatenateString(res[0], res[1]), dropLines);
            }

            //now binder
            compiler             = "gnatbind";
            args                 = idata.BaseDir + "source";
            res                  = Engine.CallCompiler(compiler, args, out compileTime);
            cdata.CompileTimeMs += compileTime;
            if (!File.Exists(idata.BaseDir + "b~source.adb"))
            {
                if (res.Count > 1)
                {
                    cdata.Error = "Binder:\n" + Utils.RemoveSomeLines(Utils.ConcatenateString(res[0], res[1]), dropLines);
                }
                cdata.Success = false;
                return(cdata);
            }
            if (res.Count > 1 && (!string.IsNullOrEmpty(res[0]) || !string.IsNullOrEmpty(res[1])))
            {
                if (!string.IsNullOrEmpty(cdata.Warning))
                {
                    cdata.Warning += "\n";
                }
                else
                {
                    cdata.Warning = "";
                }
                cdata.Warning += "Binder:\n";
                cdata.Warning  = Utils.RemoveSomeLines(Utils.ConcatenateString(res[0], res[1]), dropLines);
            }

            //now linker
            compiler             = "gnatlink";
            args                 = idata.BaseDir + "source";
            res                  = Engine.CallCompiler(compiler, args, out compileTime);
            cdata.CompileTimeMs += compileTime;
            if (!File.Exists(idata.BaseDir + "source"))
            {
                if (res.Count > 1)
                {
                    cdata.Error = "Linker:\n" + Utils.RemoveSomeLines(Utils.ConcatenateString(res[0], res[1]), dropLines);
                }
                cdata.Success = false;
                return(cdata);
            }
            if (res.Count > 1 && (!string.IsNullOrEmpty(res[0]) || !string.IsNullOrEmpty(res[1])))
            {
                if (!string.IsNullOrEmpty(cdata.Warning))
                {
                    cdata.Warning += "\n";
                }
                else
                {
                    cdata.Warning = "";
                }
                cdata.Warning += "Linker:\n";
                cdata.Warning  = Utils.RemoveSomeLines(Utils.ConcatenateString(res[0], res[1]), dropLines);
            }

            cdata.ExecuteThis = idata.BaseDir + "source";
            cdata.Executor    = "";
            cdata.Success     = true;
            return(cdata);
        }