public void buildProject() { if (String.IsNullOrWhiteSpace(CompilorPath) == false) { m_commands = GetGnuCommands(); m_externalProcessHandler.evProcessComplete -= (ProcessHandler_evProcessComplete); m_externalProcessHandler.evProgress -= (ProcessHandler_evProgress); m_externalProcessHandler.evProcessComplete += (ProcessHandler_evProcessComplete); m_externalProcessHandler.evProgress+=(ProcessHandler_evProgress); BuildJobs(); } else { m_ui.setStatus("No compilor settings Found"); } }
private ListofStrings GetGnuCommands() { ListofStrings buildCommands = new ListofStrings(); try { ListofStrings LinkCommands = new ListofStrings(); ListofStrings buildOptionCommandLine = new ListofStrings(); ListofStrings LinkerOptionCommandLine = new ListofStrings(); List<ObjectList> ObjectList = new List<ObjectList>(); string buildDir = BuildDirectory; string objDir = BuildDirectory + "\\obj"; if (Directory.Exists(buildDir) == false) { Directory.CreateDirectory(buildDir); } if (Directory.Exists(objDir) == false) { Directory.CreateDirectory(objDir); } switch (WarningLevel) { case WarningLevel.AbortCompilationOnFirstError: buildOptionCommandLine += "-Wfatal-errors"; break; case WarningLevel.EnableAllWarning: buildOptionCommandLine += "-Wall"; break; case WarningLevel.SyntaxCheckOnly: buildOptionCommandLine += "-fsyntax-only"; break; case WarningLevel.TreatAllWarningAsError: buildOptionCommandLine += "-Werror"; break; } buildOptionCommandLine += "-MMD"; buildOptionCommandLine += "-MP"; buildOptionCommandLine += "-ffast-math"; buildOptionCommandLine += "-g"; buildOptionCommandLine += "-O0"; buildOptionCommandLine += "-fpermissive"; if (IsCodeInstrumented == true) { buildOptionCommandLine += "-fprofile-arcs"; buildOptionCommandLine += "-ftest-coverage"; } //buildOptionCommandLine += "-x c++"; foreach (string str in Owner.ProjectData.IncludePaths) { buildOptionCommandLine += "-I"; buildOptionCommandLine += str; } foreach (string str in Owner.ProjectData.PreIncludes) { buildOptionCommandLine += "-include"; buildOptionCommandLine += (str); } foreach (string str in Owner.ProjectData.Defines) { buildOptionCommandLine += "-D"; buildOptionCommandLine += str; } buildOptionCommandLine += "-D"; buildOptionCommandLine += "GTEST_HAS_TR1_TUPLE=1"; //buildOptionCommandLine += "-x c++"; if (IsCodeInstrumented == true) { LinkerOptionCommandLine += "-fprofile-arcs "; } foreach (string str in Owner.ProjectData.LibPaths) { LinkerOptionCommandLine += "-L"; LinkerOptionCommandLine += str; } foreach (string lib in Owner.ProjectData.LibNames) { LinkerOptionCommandLine += "-l"; LinkerOptionCommandLine += lib; } ObjectList.Clear(); foreach (string str in Owner.ProjectData.SourceFiles) { string fileName = Path.GetFileName(str); ObjectList obj = new ObjectList(); obj.sourceFile = str; try { if (fileName.Contains('.')) { fileName = fileName.Split('.')[0]; } } catch { } fileName = objDir + "\\" + fileName + ".o"; obj.objectPath = fileName; ObjectList.Add(obj); } buildCommands.Clear(); LinkCommands.Clear(); switch (OutputType) { case OutputTypes.ConsoleApplication: LinkCommands += "-o " + buildDir + "\\" + Owner.ProjectData.ProjectName + ".exe"; Owner.ProjectData.Output = buildDir + "\\" + Owner.ProjectData.ProjectName + ".exe"; break; case OutputTypes.SharedLibrary: LinkCommands += "-shared -o " + buildDir + "\\" + Owner.ProjectData.ProjectName + ".dll"; Owner.ProjectData.Output = buildDir + "\\" + Owner.ProjectData.ProjectName + ".dll"; break; default: LinkCommands += "-o " + buildDir + "\\" + Owner.ProjectData.ProjectName + ".exe"; Owner.ProjectData.Output = buildDir + "\\" + Owner.ProjectData.ProjectName + ".exe"; break; } foreach (ObjectList obj in ObjectList) { string command = " " + String.Join(" ", buildOptionCommandLine.ToArray()) + " -o " + obj.objectPath + " -c " + obj.sourceFile; buildCommands += command; LinkCommands += obj.objectPath; } //adding google library files //if (Directory.Exists(Path.GetFullPath("./GoogleLib"))) //{ // if (Directory.Exists(Path.GetFullPath("./GoogleLib/gmock")) && Directory.Exists(Path.GetFullPath("./GoogleLib/gtest"))) // { // string includeOption = " -DGTEST_HAS_TR1_TUPLE=1 -I" + Path.GetFullPath("./GoogleLib"); // if (File.Exists(Path.GetFullPath("./GoogleLib/gmock-gtest-all.cc"))) // { // buildCommands += " " + String.Join(" ", includeOption + " -o " + objDir + "\\gmock-gtest-all.o" + " -c " + Path.GetFullPath("./GoogleLib/gmock-gtest-all.cc")); // LinkCommands += objDir + "\\gmock-gtest-all.o"; // } // if (File.Exists(Path.GetFullPath("./GoogleLib/gtest_main.cc"))) // { // buildCommands += " " + String.Join(" ", includeOption + " -o " + objDir + "\\gtest_main.o" + " -c " + Path.GetFullPath("./GoogleLib/gtest_main.cc")); // LinkCommands += objDir + "\\gtest_main.o"; // } // } //} //end adding google library files LinkCommands.AddRange(LinkerOptionCommandLine); string projectLink = String.Join(" ", LinkCommands); buildCommands += projectLink; } catch { } return buildCommands; }