Compiler::Compiler(wxXmlNode* node, Compiler::eRegexType regexType) : m_objectNameIdenticalToFileName(false) , m_isDefault(false) { // ensure all relevant entries exist in switches map (makes sure they show up in build settings dlg) SetSwitch("Include", ""); SetSwitch("Debug", ""); SetSwitch("Preprocessor", ""); SetSwitch("Library", ""); SetSwitch("LibraryPath", ""); SetSwitch("Source", ""); SetSwitch("Output", ""); SetSwitch("Object", ""); SetSwitch("ArchiveOutput", ""); SetSwitch("PreprocessOnly", ""); // ensure all relevant entries exist in tools map (makes sure they show up in build settings dlg) SetTool("LinkerName", ""); SetTool("SharedObjectLinkerName", ""); SetTool("CXX", ""); SetTool("CC", ""); SetTool("AR", ""); SetTool("ResourceCompiler", ""); SetTool("MAKE", ""); SetTool("AS", "as"); // Assembler, default to as m_fileTypes.clear(); if(node) { m_name = XmlUtils::ReadString(node, wxT("Name")); m_compilerFamily = XmlUtils::ReadString(node, "CompilerFamily"); if(m_compilerFamily == "GNU GCC") { // fix wrong name m_compilerFamily = COMPILER_FAMILY_GCC; } m_isDefault = XmlUtils::ReadBool(node, "IsDefault"); if(!node->HasProp(wxT("GenerateDependenciesFiles"))) { if(m_name == wxT("gnu g++") || m_name == wxT("gnu gcc")) { m_generateDependeciesFile = true; } else m_generateDependeciesFile = false; } else { m_generateDependeciesFile = XmlUtils::ReadBool(node, wxT("GenerateDependenciesFiles")); } if(!node->HasProp(wxT("ReadObjectsListFromFile"))) { m_readObjectFilesFromList = true; } else { m_readObjectFilesFromList = XmlUtils::ReadBool(node, wxT("ReadObjectsListFromFile")); } m_objectNameIdenticalToFileName = XmlUtils::ReadBool(node, wxT("ObjectNameIdenticalToFileName")); wxXmlNode* child = node->GetChildren(); while(child) { if(child->GetName() == wxT("Switch")) { m_switches[XmlUtils::ReadString(child, wxT("Name"))] = XmlUtils::ReadString(child, wxT("Value")); } else if(child->GetName() == wxT("Tool")) { m_tools[XmlUtils::ReadString(child, wxT("Name"))] = XmlUtils::ReadString(child, wxT("Value")); } else if(child->GetName() == wxT("Option")) { wxString name = XmlUtils::ReadString(child, wxT("Name")); if(name == wxT("ObjectSuffix")) { m_objectSuffix = XmlUtils::ReadString(child, wxT("Value")); } else if(name == wxT("DependSuffix")) { m_dependSuffix = XmlUtils::ReadString(child, wxT("Value")); } else if(name == wxT("PreprocessSuffix")) { m_preprocessSuffix = XmlUtils::ReadString(child, wxT("Value")); } } else if(child->GetName() == wxT("File")) { Compiler::CmpFileTypeInfo ft; ft.compilation_line = XmlUtils::ReadString(child, wxT("CompilationLine")); ft.extension = XmlUtils::ReadString(child, wxT("Extension")).Lower(); long kind = (long)CmpFileKindSource; if(XmlUtils::ReadLong(child, wxT("Kind"), kind) == CmpFileKindSource) { ft.kind = CmpFileKindSource; } else { ft.kind = CmpFileKindResource; } m_fileTypes[ft.extension] = ft; } else if(child->GetName() == wxT("Pattern")) { if(XmlUtils::ReadString(child, wxT("Name")) == wxT("Error")) { // found an error description CmpInfoPattern errPattern; errPattern.fileNameIndex = XmlUtils::ReadString(child, wxT("FileNameIndex")); errPattern.lineNumberIndex = XmlUtils::ReadString(child, wxT("LineNumberIndex")); errPattern.columnIndex = XmlUtils::ReadString(child, "ColumnIndex", "-1"); errPattern.pattern = child->GetNodeContent(); m_errorPatterns.push_back(errPattern); } else if(XmlUtils::ReadString(child, wxT("Name")) == wxT("Warning")) { // found a warning description CmpInfoPattern warnPattern; warnPattern.fileNameIndex = XmlUtils::ReadString(child, wxT("FileNameIndex")); warnPattern.lineNumberIndex = XmlUtils::ReadString(child, wxT("LineNumberIndex")); warnPattern.columnIndex = XmlUtils::ReadString(child, "ColumnIndex", "-1"); warnPattern.pattern = child->GetNodeContent(); m_warningPatterns.push_back(warnPattern); } } else if(child->GetName() == wxT("GlobalIncludePath")) { m_globalIncludePath = child->GetNodeContent(); } else if(child->GetName() == wxT("GlobalLibPath")) { m_globalLibPath = child->GetNodeContent(); } else if(child->GetName() == wxT("PathVariable")) { m_pathVariable = child->GetNodeContent(); } else if(child->GetName() == wxT("CompilerOption")) { CmpCmdLineOption cmpOption; cmpOption.name = XmlUtils::ReadString(child, wxT("Name")); cmpOption.help = child->GetNodeContent(); m_compilerOptions[cmpOption.name] = cmpOption; } else if(child->GetName() == wxT("LinkerOption")) { CmpCmdLineOption cmpOption; cmpOption.name = XmlUtils::ReadString(child, wxT("Name")); cmpOption.help = child->GetNodeContent(); m_linkerOptions[cmpOption.name] = cmpOption; } else if(child->GetName() == wxT("InstallationPath")) { m_installationPath = child->GetNodeContent(); } child = child->GetNext(); } if(GetTool("MAKE").IsEmpty()) { BuilderConfigPtr bldr = BuildSettingsConfigST::Get()->GetBuilderConfig(""); if(bldr) { SetTool("MAKE", wxString() << bldr->GetToolPath() << " -j " << bldr->GetToolJobs()); } } // Default values for the assembler if(GetTool("AS").IsEmpty() && GetName().CmpNoCase("vc++") == 0) { SetTool("AS", "nasm"); } else if(GetTool("AS").IsEmpty()) { SetTool("AS", "as"); } // For backward compatibility, if the compiler / linker options are empty - add them if(IsGnuCompatibleCompiler() && m_compilerOptions.empty()) { AddDefaultGnuComplierOptions(); } if(IsGnuCompatibleCompiler() && m_linkerOptions.empty()) { AddDefaultGnuLinkerOptions(); } } else { // Create a default compiler: g++ m_name = ""; m_compilerFamily = COMPILER_FAMILY_GCC; m_isDefault = false; SetSwitch("Include", "-I"); SetSwitch("Debug", "-g "); SetSwitch("Preprocessor", "-D"); SetSwitch("Library", "-l"); SetSwitch("LibraryPath", "-L"); SetSwitch("Source", "-c "); SetSwitch("Output", "-o "); SetSwitch("Object", "-o "); SetSwitch("ArchiveOutput", " "); SetSwitch("PreprocessOnly", "-E"); m_objectSuffix = ".o"; m_preprocessSuffix = ".i"; if(regexType == kRegexGNU) { AddPattern(eErrorPattern, "^([^ ][a-zA-Z:]{0,2}[ a-zA-Z\\.0-9_/\\+\\-]+ *)(:)([0-9]*)([:0-9]*)(: )((fatal " "error)|(error)|(undefined reference))", 1, 3, 4); AddPattern(eErrorPattern, "^([^ ][a-zA-Z:]{0,2}[ a-zA-Z\\.0-9_/\\+\\-]+ *)(:)([^ ][a-zA-Z:]{0,2}[ a-zA-Z\\.0-9_/\\+\\-]+ " "*)(:)(\\(\\.text\\+[0-9a-fx]*\\))", 3, 1, -1); AddPattern(eErrorPattern, "^([^ ][a-zA-Z:]{0,2}[ a-zA-Z\\.0-9_/\\+\\-]+ *)(:)([^ ][a-zA-Z:]{0,2}[ a-zA-Z\\.0-9_/\\+\\-]+ " "*)(:)([0-9]+)(:)", 3, 1, -1); AddPattern(eErrorPattern, "undefined reference to", -1, -1, -1); AddPattern(eErrorPattern, "\\*\\*\\* \\[[a-zA-Z\\-_0-9 ]+\\] (Error)", -1, -1, -1); AddPattern(eWarningPattern, "([a-zA-Z:]{0,2}[ a-zA-Z\\.0-9_/\\+\\-]+ *)(:)([0-9]+ *)(:)([0-9:]*)?( warning)", 1, 3, 4); AddPattern(eWarningPattern, "([a-zA-Z:]{0,2}[ a-zA-Z\\.0-9_/\\+\\-]+ *)(:)([0-9]+ *)(:)([0-9:]*)?( note)", 1, 3, -1); AddPattern(eWarningPattern, "([a-zA-Z:]{0,2}[ a-zA-Z\\.0-9_/\\+\\-]+ *)(:)([0-9]+ *)(:)([0-9:]*)?([ ]+instantiated)", 1, 3, -1); AddPattern(eWarningPattern, "(In file included from *)([a-zA-Z:]{0,2}[ a-zA-Z\\.0-9_/\\+\\-]+ *)(:)([0-9]+ *)(:)([0-9:]*)?", 2, 4, -1); AddDefaultGnuComplierOptions(); AddDefaultGnuLinkerOptions(); } else { AddPattern( eErrorPattern, "^windres: ([a-zA-Z:]{0,2}[ a-zA-Z\\\\.0-9_/\\+\\-]+) *:([0-9]+): syntax error", 1, 2); AddPattern(eErrorPattern, "(^[a-zA-Z\\\\.0-9 _/\\:\\+\\-]+ *)(\\()([0-9]+)(\\))( \\: )(error)", 1, 3); AddPattern(eErrorPattern, "(LINK : fatal error)", 1, 1); AddPattern(eErrorPattern, "(NMAKE : fatal error)", 1, 1); AddPattern(eWarningPattern, "(^[a-zA-Z\\\\.0-9 _/\\:\\+\\-]+ *)(\\()([0-9]+)(\\))( \\: )(warning)", 1, 3); AddPattern(eWarningPattern, "([a-z_A-Z]*\\.obj)( : warning)", 1, 1); AddPattern(eWarningPattern, "(cl : Command line warning)", 1, 1); } SetTool("LinkerName", "g++"); #ifdef __WXMAC__ SetTool("SharedObjectLinkerName", "g++ -dynamiclib -fPIC"); #else SetTool("SharedObjectLinkerName", "g++ -shared -fPIC"); #endif SetTool("CXX", "g++"); SetTool("CC", "gcc"); SetTool("AR", "ar rcu"); SetTool("ResourceCompiler", "windres"); SetTool("AS", "as"); #ifdef __WXMSW__ SetTool("MAKE", "mingw32-make"); #else SetTool("MAKE", "make"); #endif m_globalIncludePath = wxEmptyString; m_globalLibPath = wxEmptyString; m_pathVariable = wxEmptyString; m_generateDependeciesFile = false; m_readObjectFilesFromList = true; m_objectNameIdenticalToFileName = false; } if(m_generateDependeciesFile && m_dependSuffix.IsEmpty()) { m_dependSuffix = m_objectSuffix + wxT(".d"); } if(!m_switches[wxT("PreprocessOnly")].IsEmpty() && m_preprocessSuffix.IsEmpty()) { m_preprocessSuffix = m_objectSuffix + wxT(".i"); } if(m_fileTypes.empty()) { AddCmpFileType("cpp", CmpFileKindSource, "$(CXX) $(SourceSwitch) \"$(FileFullPath)\" $(CXXFLAGS) " "$(ObjectSwitch)$(IntermediateDirectory)/$(ObjectName)$(ObjectSuffix) " "$(IncludePath)"); AddCmpFileType("cxx", CmpFileKindSource, "$(CXX) $(SourceSwitch) \"$(FileFullPath)\" $(CXXFLAGS) " "$(ObjectSwitch)$(IntermediateDirectory)/$(ObjectName)$(ObjectSuffix) " "$(IncludePath)"); AddCmpFileType("c++", CmpFileKindSource, "$(CXX) $(SourceSwitch) \"$(FileFullPath)\" $(CXXFLAGS) " "$(ObjectSwitch)$(IntermediateDirectory)/$(ObjectName)$(ObjectSuffix) " "$(IncludePath)"); AddCmpFileType("c", CmpFileKindSource, "$(CC) $(SourceSwitch) \"$(FileFullPath)\" $(CFLAGS) " "$(ObjectSwitch)$(IntermediateDirectory)/$(ObjectName)$(ObjectSuffix) " "$(IncludePath)"); AddCmpFileType("cc", CmpFileKindSource, "$(CXX) $(SourceSwitch) \"$(FileFullPath)\" $(CXXFLAGS) " "$(ObjectSwitch)$(IntermediateDirectory)/$(ObjectName)$(ObjectSuffix) " "$(IncludePath)"); AddCmpFileType("m", CmpFileKindSource, "$(CXX) -x objective-c $(SourceSwitch) \"$(FileFullPath)\" $(CXXFLAGS) " "$(ObjectSwitch)$(IntermediateDirectory)/$(ObjectName)$(ObjectSuffix) " "$(IncludePath)"); AddCmpFileType("mm", CmpFileKindSource, "$(CXX) -x objective-c++ $(SourceSwitch) \"$(FileFullPath)\" " "$(CXXFLAGS) " "$(ObjectSwitch)$(IntermediateDirectory)/$(ObjectName)$(ObjectSuffix) " "$(IncludePath)"); AddCmpFileType("s", CmpFileKindSource, "$(AS) \"$(FileFullPath)\" $(ASFLAGS) " "$(ObjectSwitch)$(IntermediateDirectory)/$(ObjectName)$(ObjectSuffix) " "-I$(IncludePath)"); AddCmpFileType("rc", CmpFileKindResource, "$(RcCompilerName) -i \"$(FileFullPath)\" $(RcCmpOptions) " "$(ObjectSwitch)$(IntermediateDirectory)/" "$(ObjectName)$(ObjectSuffix) $(RcIncludePath)"); } // Add support for assembler file if(m_fileTypes.count("s") == 0) { AddCmpFileType("s", CmpFileKindSource, "$(AS) \"$(FileFullPath)\" $(ASFLAGS) " "$(ObjectSwitch)$(IntermediateDirectory)/$(ObjectName)$(ObjectSuffix) " "-I$(IncludePath)"); } }
Compiler::Compiler(wxXmlNode *node) { // ensure all relevant entries exist in switches map (makes sure they show up in build settings dlg) m_switches[wxT("Include")] = wxEmptyString; m_switches[wxT("Debug")] = wxEmptyString; m_switches[wxT("Preprocessor")] = wxEmptyString; m_switches[wxT("Library")] = wxEmptyString; m_switches[wxT("LibraryPath")] = wxEmptyString; m_switches[wxT("Source")] = wxEmptyString; m_switches[wxT("Output")] = wxEmptyString; m_switches[wxT("Object")] = wxEmptyString; m_switches[wxT("ArchiveOutput")] = wxEmptyString; m_switches[wxT("PreprocessOnly")] = wxEmptyString; // ensure all relevant entries exist in tools map (makes sure they show up in build settings dlg) m_tools[wxT("LinkerName")] = wxEmptyString; m_tools[wxT("SharedObjectLinkerName")] = wxEmptyString; m_tools[wxT("CompilerName")] = wxEmptyString; m_tools[wxT("C_CompilerName")] = wxEmptyString; m_tools[wxT("ArchiveTool")] = wxEmptyString; m_tools[wxT("ResourceCompiler")] = wxEmptyString; m_fileTypes.clear(); if (node) { m_name = XmlUtils::ReadString(node, wxT("Name")); if (!node->HasProp(wxT("GenerateDependenciesFiles"))) { if (m_name == wxT("gnu g++") || m_name == wxT("gnu gcc")) { m_generateDependeciesFile = true; } else m_generateDependeciesFile = false; } else { m_generateDependeciesFile = XmlUtils::ReadBool(node, wxT("GenerateDependenciesFiles")); } SetBuildToolsBaseDir(XmlUtils::ReadString(node, wxT("BuildToolsBaseDir"))); wxXmlNode *child = node->GetChildren(); while (child) { if (child->GetName() == wxT("Switch")) { m_switches[XmlUtils::ReadString(child, wxT("Name"))] = XmlUtils::ReadString(child, wxT("Value")); } else if (child->GetName() == wxT("Tool")) { m_tools[XmlUtils::ReadString(child, wxT("Name"))] = XmlUtils::ReadString(child, wxT("Value")); } else if (child->GetName() == wxT("Option")) { wxString name = XmlUtils::ReadString(child, wxT("Name")); if (name == wxT("ObjectSuffix")) { m_objectSuffix = XmlUtils::ReadString(child, wxT("Value")); } else if (name == wxT("DependSuffix")) { m_dependSuffix = XmlUtils::ReadString(child, wxT("Value")); } else if (name == wxT("PreprocessSuffix")) { m_preprocessSuffix = XmlUtils::ReadString(child, wxT("Value")); } } else if (child->GetName() == wxT("File")) { Compiler::CmpFileTypeInfo ft; ft.compilation_line = XmlUtils::ReadString(child, wxT("CompilationLine")); ft.extension = XmlUtils::ReadString(child, wxT("Extension")).Lower(); long kind = (long)CmpFileKindSource; if (XmlUtils::ReadLong(child, wxT("Kind"), kind) == CmpFileKindSource) { ft.kind = CmpFileKindSource; } else { ft.kind = CmpFileKindResource; } m_fileTypes[ft.extension] = ft; } else if (child->GetName() == wxT("Pattern")) { if (XmlUtils::ReadString(child, wxT("Name")) == wxT("Error")) { //found an error description CmpInfoPattern errPattern; errPattern.fileNameIndex = XmlUtils::ReadString(child, wxT("FileNameIndex")); errPattern.lineNumberIndex = XmlUtils::ReadString(child, wxT("LineNumberIndex")); errPattern.pattern = child->GetNodeContent(); m_errorPatterns.push_back(errPattern); } else if (XmlUtils::ReadString(child, wxT("Name")) == wxT("Warning")) { //found a warning description CmpInfoPattern warnPattern; warnPattern.fileNameIndex = XmlUtils::ReadString(child, wxT("FileNameIndex")); warnPattern.lineNumberIndex = XmlUtils::ReadString(child, wxT("LineNumberIndex")); warnPattern.pattern = child->GetNodeContent(); m_warningPatterns.push_back(warnPattern); } } else if (child->GetName() == wxT("GlobalIncludePath")) { m_globalIncludePath = child->GetNodeContent(); } else if (child->GetName() == wxT("GlobalLibPath")) { m_globalLibPath = child->GetNodeContent(); } else if (child->GetName() == wxT("PathVariable")) { m_pathVariable = child->GetNodeContent(); } else if (child->GetName() == wxT("CompilerOption")) { CmpCmdLineOption cmpOption; cmpOption.name = XmlUtils::ReadString(child, wxT("Name")); cmpOption.help = child->GetNodeContent(); m_compilerOptions[cmpOption.name] = cmpOption; } else if (child->GetName() == wxT("AssemblerOption")) { CmpCmdLineOption asmOption; asmOption.name = XmlUtils::ReadString(child, wxT("Name")); asmOption.help = child->GetNodeContent(); m_assemblerOptions[asmOption.name] = asmOption; } else if (child->GetName() == wxT("LinkerOption")) { CmpCmdLineOption cmpOption; cmpOption.name = XmlUtils::ReadString(child, wxT("Name")); cmpOption.help = child->GetNodeContent(); m_linkerOptions[cmpOption.name] = cmpOption; } child = child->GetNext(); } } else { //create a default compiler: g++ m_name = wxT("gnu g++"); m_switches[wxT("Include")] = wxT("-I"); m_switches[wxT("Debug")] = wxT("-g "); m_switches[wxT("Preprocessor")] = wxT("-D"); m_switches[wxT("Library")] = wxT("-l"); m_switches[wxT("LibraryPath")] = wxT("-L"); m_switches[wxT("Source")] = wxT("-c "); m_switches[wxT("Output")] = wxT("-o "); m_switches[wxT("Object")] = wxT("-o "); m_switches[wxT("ArchiveOutput")] = wxT(" "); m_switches[wxT("PreprocessOnly")] = wxT("-E"); m_objectSuffix = wxT(".o"); m_preprocessSuffix = wxT(".i"); CmpInfoPattern pattern; pattern.pattern = wxT("^([^ ][a-zA-Z:]{0,2}[ a-zA-Z\\.0-9_/\\+\\-]+ *)(:)([0-9]+ *)(:)( error)"); pattern.fileNameIndex = wxT("1"); pattern.lineNumberIndex = wxT("3"); m_errorPatterns.push_back(pattern); pattern.pattern = wxT("^([^ ][a-zA-Z:]{0,2}[ a-zA-Z\\.0-9_/\\+\\-]+ *)(:)([0-9]+ *)(:)([0-9:]*)?( warning:)"); pattern.fileNameIndex = wxT("1"); pattern.lineNumberIndex = wxT("3"); m_warningPatterns.push_back(pattern); m_tools[wxT("LinkerName")] = wxT("g++"); m_tools[wxT("SharedObjectLinkerName")] = wxT("g++ -shared -fPIC"); m_tools[wxT("CompilerName")] = wxT("g++"); m_tools[wxT("C_CompilerName")] = wxT("gcc"); m_tools[wxT("ArchiveTool")] = wxT("ar rcu"); m_tools[wxT("ResourceCompiler")] = wxT("windres"); m_globalIncludePath = wxEmptyString; m_globalLibPath = wxEmptyString; m_pathVariable = wxEmptyString; m_generateDependeciesFile = false; } if (m_generateDependeciesFile && m_dependSuffix.IsEmpty()) { m_dependSuffix = m_objectSuffix + wxT(".d"); } if (!m_switches[wxT("PreprocessOnly")].IsEmpty() && m_preprocessSuffix.IsEmpty()) { m_preprocessSuffix = m_objectSuffix + wxT(".i"); } if (m_fileTypes.empty()) { AddCmpFileType(wxT("cpp"), CmpFileKindSource, wxT("$(CompilerName) $(SourceSwitch) \"$(FileFullPath)\" $(CmpOptions) $(ObjectSwitch)$(FilePath)$(IntermediateDirectory)/$(FileName)$(ObjectSuffix) $(IncludePath)")); AddCmpFileType(wxT("cxx"), CmpFileKindSource, wxT("$(CompilerName) $(SourceSwitch) \"$(FileFullPath)\" $(CmpOptions) $(ObjectSwitch)$(FilePath)$(IntermediateDirectory)/$(FileName)$(ObjectSuffix) $(IncludePath)")); AddCmpFileType(wxT("c++"), CmpFileKindSource, wxT("$(CompilerName) $(SourceSwitch) \"$(FileFullPath)\" $(CmpOptions) $(ObjectSwitch)$(FilePath)$(IntermediateDirectory)/$(FileName)$(ObjectSuffix) $(IncludePath)")); AddCmpFileType(wxT("c"), CmpFileKindSource, wxT("$(C_CompilerName) $(SourceSwitch) \"$(FileFullPath)\" $(CmpOptions) $(ObjectSwitch)$(FilePath)$(IntermediateDirectory)/$(FileName)$(ObjectSuffix) $(IncludePath)")); AddCmpFileType(wxT("cc"), CmpFileKindSource, wxT("$(CompilerName) $(SourceSwitch) \"$(FileFullPath)\" $(CmpOptions) $(ObjectSwitch)$(FilePath)$(IntermediateDirectory)/$(FileName)$(ObjectSuffix) $(IncludePath)")); AddCmpFileType(wxT("m"), CmpFileKindSource, wxT("$(CompilerName) -x objective-c $(SourceSwitch) \"$(FileFullPath)\" $(CmpOptions) $(ObjectSwitch)$(FilePath)$(IntermediateDirectory)/$(FileName)$(ObjectSuffix) $(IncludePath)")); AddCmpFileType(wxT("mm"), CmpFileKindSource, wxT("$(CompilerName) -x objective-c++ $(SourceSwitch) \"$(FileFullPath)\" $(CmpOptions) $(ObjectSwitch)$(FilePath)$(IntermediateDirectory)/$(FileName)$(ObjectSuffix) $(IncludePath)")); AddCmpFileType(wxT("rc"), CmpFileKindResource, wxT("$(RcCompilerName) -i \"$(FileFullPath)\" $(RcCmpOptions) $(ObjectSwitch)$(FilePath)$(IntermediateDirectory)/$(FileFullName)$(ObjectSuffix) $(RcIncludePath)")); } }