ProcessArguments() public method

public ProcessArguments ( string args ) : bool
args string
return bool
Beispiel #1
0
        public void ParseSupportedArgs(params string[] argv)
        {
            var c = new Compiler();
            c.SetWorkingDirectory(InitialDir);
            c.SetEnvironment(Compiler.GetEnvironmentDictionary());
            var sbo = new StringBuilder();
            var sbe = new StringBuilder();
            Assert.IsTrue(c.ProcessArguments(argv));
            Assert.IsFalse(c.Linking);
            Assert.IsTrue(c.SingleSource);
            Assert.IsNotNullOrEmpty(c.ObjectTarget);
            Assert.IsFalse(c.PrecompiledHeaders);
            Assert.AreNotEqual(c.SingleSourceFile, c.ObjectTarget);

            EnsureDeleted(c.ObjectTarget);
            EnsureDeleted(c.PdbFile);
            
            c.CompilerExe = CompilerPath;
            c.SetWorkingDirectory(InitialDir);
            c.SetEnvironment(Compiler.GetEnvironmentDictionary());
            var ec = c.InvokeCompiler(
                c.CommandLine,
                Console.Error.WriteLine, Console.Error.WriteLine, false, null);

            Assert.AreEqual(0, ec);

            Assert.IsTrue(File.Exists(c.ObjectTarget));
        }
Beispiel #2
0
 public virtual bool IsSupported(IEnumerable <string> args)
 {
     OperationStart = DateTime.Now;
     if (FileUtils.Exists(Compiler.CompilerExe))
     {
         var rv = Compiler.ProcessArguments(args.ToArray());
         if (!rv)
         {
             Logging.Emit("args not supported {0}", Cache.GetType().Name);
         }
         return(rv);
     }
     throw new FileNotFoundException(Compiler.CompilerExe);
 }
Beispiel #3
0
 public void DetectNotSupported(params string[] argv)
 {
     var c = new Compiler() { 
         CompilerExe = CompilerPath };
     c.SetWorkingDirectory(InitialDir);
     c.SetEnvironment(Compiler.GetEnvironmentDictionary());
     Assert.IsFalse(c.ProcessArguments(argv));
 }
Beispiel #4
0
        public void CompileObjectTest(params string[] argv)
        {
            var c = new Compiler() { CompilerExe = CompilerPath };
            c.SetWorkingDirectory(InitialDir);
            c.SetEnvironment(Compiler.GetEnvironmentDictionary());
            
            Assert.IsTrue(c.ProcessArguments(argv));
            Assert.AreEqual(1, c.CliIncludePaths.Count);
            Assert.AreEqual( Path.Combine(InitialDir, "test-sources\\inc with spaces"), c.CliIncludePaths[0]);
            Assert.AreEqual( Path.Combine(InitialDir, "test-sources\\hello.c"), c.SingleSourceFile);
            var stderr = new StringBuilder();
            var stdout = new StringBuilder();
            var rv = c.InvokeCompiler(c.CommandLine, x => stderr.Append(x), x => stdout.Append(x), false, null);

            Assert.AreEqual(0, rv);
        }
Beispiel #5
0
        public void PreprocessorTest(params string[] argv)
        {
            var c = new Compiler() { CompilerExe = CompilerPath };
            c.SetWorkingDirectory(InitialDir);
            c.SetEnvironment(Compiler.GetEnvironmentDictionary());

            var supported = c.ProcessArguments(argv);
            
            Assert.IsTrue(supported);
            Assert.AreEqual(1, c.CliIncludePaths.Count);
            Assert.AreEqual( Path.Combine(InitialDir, "test-sources\\inc with spaces"), c.CliIncludePaths[0]);
            Assert.AreEqual( Path.Combine(InitialDir, "test-sources\\hello.c"), c.SingleSourceFile);
            using (var sw = new StreamWriter(new MemoryStream()))
            {
                var rv = c.InvokePreprocessor(sw);
                Assert.AreEqual(0, rv);
            }
        }
Beispiel #6
0
 public void IncludeFileTest(params string[] argv)
 {
     var c = new Compiler() { CompilerExe = CompilerPath };
     var hv = new List<string>();
     c.SetWorkingDirectory(InitialDir);
     c.SetEnvironment(Compiler.GetEnvironmentDictionary());
     Assert.IsTrue(c.ProcessArguments(argv));
     hv.Add(Path.GetFullPath(c.SingleSourceFile));
     List<string> incfiles = new List<string>();
     var rv = c.InvokeCompiler(argv, Console.Error.Write, Console.Out.Write, true, incfiles);
     hv.AddRange(incfiles);
     Assert.AreEqual(0, rv);
     Assert.IsTrue(hv.Count > 0);
 }
Beispiel #7
0
 public void ParseUnSupportedArgs(params string[] argv)
 {
     var c = new Compiler();
     c.SetWorkingDirectory(InitialDir);
     Assert.IsFalse(c.ProcessArguments(argv));
 }
Beispiel #8
0
 public void ParseSupportedDebugArgs(params string[] argv) {
     var c = new Compiler();
     c.SetWorkingDirectory(InitialDir);
     c.CompilerExe = CompilerPath;
     Assert.IsTrue(c.ProcessArguments(argv));
     Assert.IsFalse(c.GeneratePdb);
 }
Beispiel #9
0
 public void ParseSupportedPdbArgs(params string[] argv)
 {
     Assert.IsFalse(Settings.AttemptPDBCaching);
     var c = new Compiler();
     c.SetWorkingDirectory(InitialDir);
     c.CompilerExe = CompilerPath;
     Assert.IsFalse(c.ProcessArguments(argv));
 }