private void CompileProject(PProjectInfo project) { var compileArgs = new CommandLineOptions { inputFileNames = new List <string>(project.psources.Select(Path.GetFullPath).ToList()) }; //populate all dependencies var depFiles = (from depFile in project.depends let outDir = Path.GetFullPath(CurrentSolution.projects.First(x => x.Name == depFile).outputDir) select Path.Combine(outDir, depFile + ".4ml")).ToList(); compileArgs.dependencies = new List <string>(depFiles); compileArgs.shortFileNames = true; compileArgs.outputDir = project.outputDir; compileArgs.unitName = project.Name + ".4ml"; compileArgs.liveness = LivenessOption.None; compileArgs.compilerOutput = Options.Output; compileArgs.profile = true; var compileResult = false; var svc = new CompilerServiceClient(); if (Options.Relink && !Options.Rebuild) { compileResult = true; } else { // use separate process that contains pre-compiled P compiler. Console.WriteLine("=============================================================="); Console.WriteLine("=== Compiling project {0} ===", project.Name); compileResult = svc.Compile(new StandardOutput(), compileArgs); } if (!compileResult) { Environment.Exit(-1); } if (project.testscripts.Count > 0) { Console.WriteLine("=== Linking project {0} ===", project.Name); //start linking the project compileArgs.inputFileNames = new List <string>(project.testscripts.Select(Path.GetFullPath).ToList()); //populate all summary files compileArgs.dependencies.Add(Path.Combine(project.outputDir, project.Name + ".4ml")); svc.Link(new StandardOutput(), compileArgs); } Console.WriteLine("=============================================================="); }
public override bool Execute() { UseBuildService = DetectBuildService(); var outputAssembly = OutputAssembly.ItemSpec; OutputGeneratedDir = Path.GetDirectoryName(outputAssembly); AssemblyFilenameWithoutExtension = Path.GetFileNameWithoutExtension(outputAssembly); OutputAssembly.ItemSpec = Path.Combine(OutputGeneratedDir, Path.GetFileName(outputAssembly)); if (UseBuildService) { var ext = new CommandLineBuilderExtension(); //var args = new CompilerToolArgs(); AddResponseFileCommands(ext); var res = new CompilerServiceClient().Compile(new CompileRequest { CommandLineArgs = ext.ToString() }); foreach (var s in res.Output) { LogEventsFromTextOutput(s, MessageImportance.High); } return res.ExitCode == 0; } else { var success = base.Execute(); return success; } }
bool DetectBuildService() { try { var x = new CompilerServiceClient(); x.Test(); return true; } catch// (Exception e) { return false; } //var sc = new ServiceController("SharpKit"); //if (sc.Status == ServiceControllerStatus.Running) // return true; //return false; //var service = Process.GetProcessesByName("skc5").Where(t => t.Id != Process.GetCurrentProcess().Id).FirstOrDefault(); //return service != null; }