void MSVC10Loader::HandleFilesAndExcludes(const TiXmlElement* e, ProjectFile* pf) { if (!e || !pf) return; // add it to all configurations, not just the first for (size_t i=0; i<m_pcNames.Count(); ++i) pf->AddBuildTarget(m_pcNames.Item(i)); // handle explicit exclusions like: // <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild> // <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild> const TiXmlElement* excl = e->FirstChildElement("ExcludedFromBuild"); // Operate existing excludes while (excl) { const TiXmlText* do_excl = excl->ToText(); if (do_excl) { const char* value = do_excl->Value(); wxString s_value = cbC2U(value); if (s_value.MakeUpper().IsSameAs(_T("TRUE"))) { const char* cond = excl->Attribute("Condition"); if (cond) { wxString sName = cbC2U(cond); sName = SubstituteConfigMacros(sName); pf->RemoveBuildTarget(sName); } } } excl = excl->NextSiblingElement(); } }
void MSVC10Loader::HandleFilesAndExcludes(const TiXmlElement* e, ProjectFile* pf) { if (!e || !pf) return; // add it to all configurations, not just the first for (HashProjectsConfs::iterator it=m_pc.begin(); it!=m_pc.end(); ++it) pf->AddBuildTarget(it->second.sName); // handle explicit exclusions like: // <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild> // <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild> const TiXmlElement* excl = e->FirstChildElement("ExcludedFromBuild"); for (; excl; excl=excl->NextSiblingElement("ExcludedFromBuild")) { const TiXmlText* do_excl = excl->ToText(); if (do_excl) { const char* value = do_excl->Value(); wxString s_value = cbC2U(value); if (s_value.IsSameAs(_T("true"), false)) { const char* cond = excl->Attribute("Condition"); if (cond) { wxString sName = cbC2U(cond); sName = SubstituteConfigMacros(sName); pf->RemoveBuildTarget(sName); } } } } }
/** get project includes * \param root : the root node of the XML project file (<Project > **/ bool MSVC10Loader::GetProjectIncludes(const TiXmlElement* root) { if (!root) return false; LogManager* pMsg = Manager::Get()->GetLogManager(); if (!pMsg) return false; bool bResult = false; // parse all global parameters const TiXmlElement* prop = root->FirstChildElement("PropertyGroup"); while (prop) { const char* attr = prop->Attribute("Condition"); if (!attr) { prop = prop->NextSiblingElement(); continue; } wxString conf = cbC2U(attr); for (size_t i=0; i<m_pcNames.Count(); ++i) { wxString sName = m_pcNames.Item(i); wxString sConf = SubstituteConfigMacros(conf); if (sConf.IsSameAs(sName)) { const TiXmlElement* cinc = prop->FirstChildElement("IncludePath"); wxArrayString cdirs = GetDirectories(cinc); for (size_t j=0; j<cdirs.Count(); ++j) { ProjectBuildTarget* bt = m_pc[sName].bt; if (bt) bt->AddIncludeDir(cdirs.Item(j)); } const TiXmlElement* linc = prop->FirstChildElement("LibraryPath"); wxArrayString ldirs = GetDirectories(linc); for (size_t j=0; j<ldirs.Count(); ++j) { ProjectBuildTarget* bt = m_pc[sName].bt; if (bt) bt->AddLibDir(ldirs.Item(j)); } bResult = true; // got something } } prop = prop->NextSiblingElement(); } if (!bResult) pMsg->DebugLog(_("Failed to find any includes in the project...?!")); return bResult; }
bool MSVC10Loader::GetProjectIncludes(const TiXmlElement* root) { if (!root) return false; LogManager* pMsg = Manager::Get()->GetLogManager(); if (!pMsg) return false; bool bResult = false; // parse all global parameters const TiXmlElement* prop = root->FirstChildElement("PropertyGroup"); for (; prop; prop=prop->NextSiblingElement("PropertyGroup")) { const char* attr = prop->Attribute("Condition"); if (!attr) continue; wxString conf = cbC2U(attr); for (HashProjectsConfs::iterator it=m_pc.begin(); it!=m_pc.end(); ++it) { wxString sName = it->second.sName; wxString sConf = SubstituteConfigMacros(conf); if (sConf.IsSameAs(sName)) { // $(VCInstallDir)include , $(VCInstallDir)atlmfc\include , $(WindowsSdkDir)include , $(FrameworkSDKDir)\include const TiXmlElement* cinc = prop->FirstChildElement("IncludePath"); wxArrayString cdirs = GetArrayPaths(cinc, m_pc[sName]); for (size_t j=0; j<cdirs.Count(); ++j) { ProjectBuildTarget* bt = m_pc[sName].bt; if (bt) bt->AddIncludeDir(cdirs.Item(j)); } // $(VCInstallDir)lib , $(VCInstallDir)atlmfc\lib , $(WindowsSdkDir)lib , $(FrameworkSDKDir)\lib const TiXmlElement* linc = prop->FirstChildElement("LibraryPath"); wxArrayString ldirs = GetArrayPaths(linc, m_pc[sName]); for (size_t j=0; j<ldirs.Count(); ++j) { ProjectBuildTarget* bt = m_pc[sName].bt; if (bt) bt->AddLibDir(ldirs.Item(j)); } bResult = true; // got something } } } if (!bResult) pMsg->DebugLog(_("Failed to find any includes in the project...?!")); return bResult; }
bool MSVC10Loader::GetConfigurationName(const TiXmlElement* e, wxString& config, const wxString& defconfig) { if (!defconfig.IsEmpty()) config = defconfig; else { const char* name = e->Attribute("Condition"); if (name) { config = SubstituteConfigMacros(cbC2U(name)); if (!m_pc.count(config)) return false; } } return true; }
/** get target specific stuff * \param root : the root node of the XML project file (<Project > **/ bool MSVC10Loader::GetTargetSpecific(const TiXmlElement* root) { if (!root) return false; LogManager* pMsg = Manager::Get()->GetLogManager(); if (!pMsg) return false; bool bResult = false; // parse all global parameters const TiXmlElement* idef = root->FirstChildElement("ItemDefinitionGroup"); while (idef) { const char* attr = idef->Attribute("Condition"); if (!attr) { idef = idef->NextSiblingElement(); continue; } wxString conf = cbC2U(attr); for (size_t i=0; i<m_pcNames.Count(); ++i) { wxString sName = m_pcNames.Item(i); wxString sConf = SubstituteConfigMacros(conf); if (sConf.IsSameAs(sName)) { const TiXmlElement* comp = idef->FirstChildElement("ClCompile"); if (comp) { const TiXmlElement* pp = comp->FirstChildElement("PreprocessorDefinitions"); wxArrayString pps = GetPreprocessors(pp); for (size_t j=0; j<pps.Count(); ++j) { ProjectBuildTarget* bt = m_pc[sName].bt; if (bt) bt->AddCompilerOption((m_ConvertSwitches ? _T("-D") : _T("/D")) + pps.Item(j)); } const TiXmlElement* cinc = comp->FirstChildElement("AdditionalIncludeDirectories"); wxArrayString cdirs = GetDirectories(cinc); for (size_t j=0; j<cdirs.Count(); ++j) { ProjectBuildTarget* bt = m_pc[sName].bt; if (bt) bt->AddIncludeDir(cdirs.Item(j)); } const TiXmlElement* copt = comp->FirstChildElement("AdditionalOptions"); wxArrayString copts = GetOptions(copt); for (size_t j=0; j<copts.Count(); ++j) { ProjectBuildTarget* bt = m_pc[sName].bt; if (bt && !m_ConvertSwitches) bt->AddCompilerOption(copts.Item(j)); } } const TiXmlElement* link = idef->FirstChildElement("Link"); if (link) { const TiXmlElement* llib = link->FirstChildElement("AdditionalDependencies"); wxArrayString libs = GetLibs(llib); for (size_t j=0; j<libs.Count(); ++j) { ProjectBuildTarget* bt = m_pc[sName].bt; if (bt) bt->AddLinkLib(libs.Item(j)); } const TiXmlElement* linc = link->FirstChildElement("AdditionalLibraryDirectories"); wxArrayString ldirs = GetDirectories(linc); for (size_t j=0; j<ldirs.Count(); ++j) { ProjectBuildTarget* bt = m_pc[sName].bt; if (bt) bt->AddLibDir(ldirs.Item(j)); } const TiXmlElement* lopt = comp->FirstChildElement("AdditionalOptions"); wxArrayString lopts = GetOptions(lopt); for (size_t j=0; j<lopts.Count(); ++j) { ProjectBuildTarget* bt = m_pc[sName].bt; if (bt && !m_ConvertSwitches) bt->AddLinkerOption(lopts.Item(j)); } const TiXmlElement* debug = link->FirstChildElement("GenerateDebugInformation"); wxString sDebug = GetText(debug); if (sDebug.MakeUpper().IsSameAs(_T("TRUE"))) { ProjectBuildTarget* bt = m_pc[sName].bt; if (bt && !m_ConvertSwitches) bt->AddLinkerOption(_T("/debug")); } } const TiXmlElement* res = idef->FirstChildElement("ResourceCompile"); if (res) { const TiXmlElement* pp = res->FirstChildElement("PreprocessorDefinitions"); wxArrayString pps = GetPreprocessors(pp); for (size_t j=0; j<pps.Count(); ++j) { ProjectBuildTarget* bt = m_pc[sName].bt; if (bt) bt->AddCompilerOption((m_ConvertSwitches ? _T("-D") : _T("/D")) + pps.Item(j)); } } bResult = true; // got something } } idef = idef->NextSiblingElement(); } if (!bResult) pMsg->DebugLog(_("Failed to find any includes in the project...?!")); return bResult; }
/** get the configuration in the project * \param root : the root node of the XML project file (<Project > **/ bool MSVC10Loader::GetConfiguration(const TiXmlElement* root) { if (!root) return false; LogManager* pMsg = Manager::Get()->GetLogManager(); if (!pMsg) return false; bool bResult = false; // now that we have (in theory) the list of configurations, we will parse each configuration const TiXmlElement* prop = root->FirstChildElement("PropertyGroup"); while (prop) { const char* attr = prop->Attribute("Label"); if (!attr) { prop = prop->NextSiblingElement(); continue; } wxString label = cbC2U(attr); if (label.MakeUpper().IsSameAs(_T("CONFIGURATION"))) { const char* name = prop->Attribute("Condition"); const TiXmlElement* type = prop->FirstChildElement("ConfigurationType"); const TiXmlElement* dbg = prop->FirstChildElement("UseDebugLibraries"); const TiXmlElement* cset = prop->FirstChildElement("CharacterSet"); if (name && type && dbg && cset) { wxString sName = cbC2U(name); sName = SubstituteConfigMacros(sName); if (m_pcNames.Index(sName)==wxNOT_FOUND) m_pcNames.Add(sName); m_pc[sName].sName = sName; // OK, probably not so useful, just for completeness sake m_pc[sName].TargetType = GetText(type); m_pc[sName].UseDebugLibs = GetText(dbg); m_pc[sName].Charset = GetText(cset); const TiXmlElement* e = NULL; // By default, OutDir is $(SolutionDir)$(Configuration) e = prop->FirstChildElement("OutDir"); if (e) m_pc[sName].sOutDir = GetText(e); // By default, IntDir is $(Configuration) e = prop->FirstChildElement("IntDir"); if (e) m_pc[sName].sIntDir = GetText(e); // By default, TargetName is $(ProjectName) e = prop->FirstChildElement("TargetName"); if (e) m_pc[sName].sTargetName = GetText(e); // By default, TargetExt is .exe e = prop->FirstChildElement("TargetExt"); if (e) m_pc[sName].sTargetExt = GetText(e); // $(VCInstallDir)include , $(VCInstallDir)atlmfc\include , $(WindowsSdkDir)include , $(FrameworkSDKDir)\include e = prop->FirstChildElement("IncludePath"); if (e) m_pc[sName].sIncludePath = GetText(e); // $(VCInstallDir)lib , $(VCInstallDir)atlmfc\lib , $(WindowsSdkDir)lib , $(FrameworkSDKDir)\lib e = prop->FirstChildElement("LibraryPath"); if (e) m_pc[sName].sLibPath = GetText(e); // $(VCInstallDir)bin , $(WindowsSdkDir)bin\NETFX 4.0 Tools , $(WindowsSdkDir)bin , $(VSInstallDir)Common7\Tools\bin , // $(VSInstallDir)Common7\tools , $(VSInstallDir)Common7\ide , $(ProgramFiles)\HTML Help Workshop , $(FrameworkSDKDir)\bin , // $(MSBuildToolsPath32) , $(VSInstallDir) , $(SystemRoot)\SysWow64 , $(FxCopDir) , $(PATH) e = prop->FirstChildElement("ExecutablePath"); if (e) m_pc[sName].sExePath = GetText(e); // $(VCInstallDir)atlmfc\src\mfc , $(VCInstallDir)atlmfc\src\mfcm , $(VCInstallDir)atlmfc\src\atl , $(VCInstallDir)crt\src e = prop->FirstChildElement("SourcePath"); if (e) m_pc[sName].sSourcePath = GetText(e); bResult = true; } } prop = prop->NextSiblingElement(); } if (!bResult) pMsg->DebugLog(_("Failed to find configuration, using default one.")); return bResult; }
bool MSVC10Loader::GetTargetSpecific(const TiXmlElement* root) { if (!root) return false; LogManager* pMsg = Manager::Get()->GetLogManager(); if (!pMsg) return false; bool bResult = false; // parse all global parameters const TiXmlElement* idef = root->FirstChildElement("ItemDefinitionGroup"); for (; idef; idef=idef->NextSiblingElement("ItemDefinitionGroup")) { const char* attr = idef->Attribute("Condition"); if (!attr) continue; wxString conf = cbC2U(attr); for (HashProjectsConfs::iterator it=m_pc.begin(); it!=m_pc.end(); ++it) { wxString sName = it->second.sName; wxString sConf = SubstituteConfigMacros(conf); if (sConf.IsSameAs(sName)) { assert(m_pc[sName].bt); if (!m_pc[sName].bt) continue; ProjectBuildTarget* bt = m_pc[sName].bt; if (!m_ConvertSwitches && !m_pc[sName].Charset.IsEmpty()) { if (m_pc[sName].Charset.IsSameAs(_T("NotSet"),false)) ; // nop else if (m_pc[sName].Charset.IsSameAs(_T("Unicode"),false)) bt->AddCompilerOption(_T("/D_UNICODE /DUNICODE")); else if (m_pc[sName].Charset.IsSameAs(_T("MultiByte"),false)) bt->AddCompilerOption(_T("/D_MBCS")); else pMsg->DebugLog(_("Import; Unsupported CharacterSet: ") + m_pc[sName].Charset); } if (!m_pc[sName].sIntDir.IsEmpty()) bt->SetObjectOutput(m_pc[sName].sIntDir); if (!m_pc[sName].sOutDir.IsEmpty()) { bt->SetOutputFilename(m_pc[sName].sOutDir+m_pc[sName].sTargetName+m_pc[sName].sTargetExt); bt->SetDepsOutput(m_pc[sName].sOutDir); } if (!m_pc[sName].sConf.IsEmpty()) { if (m_pc[sName].sConf.IsSameAs(_T("Release"), false)) { // nop } else if (m_pc[sName].sConf.IsSameAs(_T("Debug"),false)) bt->AddCompilerOption(!m_ConvertSwitches ? _T("/Zi") : _T("-g")); else pMsg->DebugLog(_("Import; Unsupported Configuration: ") + m_pc[sName].sConf); } if (m_pc[sName].bNoImportLib) { bt->SetCreateDefFile(false); bt->SetCreateStaticLib(false); } const TiXmlElement* comp = idef->FirstChildElement("ClCompile"); if (comp) { const TiXmlElement* pp = comp->FirstChildElement("PreprocessorDefinitions"); wxArrayString pps = GetArray(pp); for (size_t j=0; j<pps.Count(); ++j) bt->AddCompilerOption((m_ConvertSwitches ? _T("-D") : _T("/D")) + pps.Item(j)); const TiXmlElement* cinc = comp->FirstChildElement("AdditionalIncludeDirectories"); wxArrayString cdirs = GetArrayPaths(cinc, m_pc[sName]); for (size_t j=0; j<cdirs.Count(); ++j) bt->AddIncludeDir(cdirs.Item(j)); const TiXmlElement* copt = comp->FirstChildElement("AdditionalOptions"); wxArrayString copts = GetArray(copt,_T(" ")); if (!m_ConvertSwitches) { for (size_t j=0; j<copts.Count(); ++j) bt->AddCompilerOption(copts.Item(j)); } if ((copt=comp->FirstChildElement("Optimization"))) { wxString val = GetText(copt); if (val.IsSameAs(_T("Disabled"),false)) bt->AddCompilerOption(!m_ConvertSwitches ? _T("/Od") : _T("-O0")); else if (val.IsSameAs(_T("MinSpace"), false)) { if (!m_ConvertSwitches) bt->AddCompilerOption(_T("/O1")); else { bt->AddLinkerOption(_T("-s")); bt->AddCompilerOption(_T("-Os")); } } else if (val.IsSameAs(_T("MaxSpeed"),false)) { if (!m_ConvertSwitches) bt->AddCompilerOption(_T("/O2")); else { bt->AddLinkerOption(_T("-s")); bt->AddCompilerOption(_T("-O1")); } } else if (val.IsSameAs(_T("Full"),false)) { if (!m_ConvertSwitches) bt->AddCompilerOption(_T("/Ox")); else { bt->AddLinkerOption(_T("-s")); bt->AddCompilerOption(_T("-O2")); } } else pMsg->DebugLog(_("Import; Unsupported Optimization: ") + val+_T("\n")); } if (!m_ConvertSwitches && (copt=comp->FirstChildElement("RuntimeLibrary"))) { wxString val = GetText(copt); if (val.IsSameAs(_T("MultiThreaded"),false)) bt->AddCompilerOption(_T("/MT")); else if (val.IsSameAs(_T("MultiThreadedDebug"),false)) bt->AddCompilerOption(_T("/MTd")); else if (val.IsSameAs(_T("MultiThreadedDll"),false)) bt->AddCompilerOption(_T("/MD")); else if(val.IsSameAs(_T("MultiThreadedDebugDll"),false)) bt->AddCompilerOption(_T("/MDd")); else pMsg->DebugLog(_("Import; Unsupported RuntimeLibrary: ")+val); } if ((copt=comp->FirstChildElement("WarningLevel"))) { wxString val = GetText(copt); if (val.IsSameAs(_T("Level1"),false)) { if (!m_ConvertSwitches) bt->AddCompilerOption(_T("/W1")); } else if (val.IsSameAs(_T("Level2"),false)) bt->AddCompilerOption(!m_ConvertSwitches ? _T("/W2") : _T("-Wall")); else if (val.IsSameAs(_T("Level3"),false)) bt->AddCompilerOption(!m_ConvertSwitches ? _T("/W3") : _T("-Wall")); else if (val.IsSameAs(_T("Level4"),false)) { if (!m_ConvertSwitches) bt->AddCompilerOption(_T("/W4")); else { bt->AddCompilerOption(_T("-Wall")); bt->AddCompilerOption(_T("-Wextra")); } } else pMsg->DebugLog(_("Import; Unsupported WarningLevel: ") + val); } if (!m_ConvertSwitches && (copt=comp->FirstChildElement("DisableSpecificWarnings"))) { wxArrayString warns = GetArray(copt); for (size_t j=0; j<warns.Count(); ++j) bt->AddCompilerOption(_T("/wd") + warns.Item(j)); } } const TiXmlElement* res = idef->FirstChildElement("ResourceCompile"); if (res) { const TiXmlElement* pp = res->FirstChildElement("PreprocessorDefinitions"); wxArrayString pps = GetArray(pp); for (size_t j=0; j<pps.Count(); ++j) bt->AddCompilerOption((m_ConvertSwitches ? _T("-D") : _T("/D")) + pps.Item(j)); const TiXmlElement* cinc = res->FirstChildElement("AdditionalIncludeDirectories"); wxArrayString cdirs = GetArrayPaths(cinc,m_pc[sName]); for (size_t j=0; j<cdirs.Count(); ++j) bt->AddResourceIncludeDir(cdirs.Item(j)); const TiXmlElement* copt = res->FirstChildElement("AdditionalOptions"); wxArrayString copts = GetArray(copt,_T(" ")); if (!m_ConvertSwitches) { for (size_t j=0; j<copts.Count(); ++j) bt->AddCompilerOption(copts.Item(j)); } } const TiXmlElement* link = idef->FirstChildElement("Link"); if (link) { const TiXmlElement* copt; if ((copt=link->FirstChildElement("OutputFile"))) { wxString val = GetText(copt); ReplaceConfigMacros(m_pc[sName],val); if (!val.IsEmpty()) bt->SetOutputFilename(val); } if ((copt=link->FirstChildElement("ModuleDefinitionFile"))) { wxString val = GetText(copt); ReplaceConfigMacros(m_pc[sName],val); if (!val.IsEmpty()) bt->SetDefinitionFileFilename(val); } if ((copt=link->FirstChildElement("ImportLibrary"))) { wxString val=GetText(copt); ReplaceConfigMacros(m_pc[sName],val); if (!val.IsEmpty()) bt->SetImportLibraryFilename(val); } copt = link->FirstChildElement("AdditionalDependencies"); wxArrayString libs = GetLibs(copt); for (size_t j=0; j<libs.Count(); ++j) bt->AddLinkLib(libs.Item(j)); copt = link->FirstChildElement("AdditionalLibraryDirectories"); /// @note : maybe use loops on all elements for (; copt; copt=copt->NextSiblingElement("AdditionalLibraryDirectories")) { wxArrayString ldirs = GetArrayPaths(copt,m_pc[sName]); for (size_t j=0; j<ldirs.Count(); ++j) bt->AddLibDir(ldirs.Item(j)); } if (!m_ConvertSwitches) { copt = link->FirstChildElement("AdditionalOptions"); wxArrayString lopts = GetArray(copt,_T(" ")); for (size_t j=0; j<lopts.Count(); ++j) bt->AddLinkerOption(lopts.Item(j)); copt = link->FirstChildElement("GenerateDebugInformation"); wxString sDebug = GetText(copt); if (sDebug.IsSameAs(_T("true"),false)) bt->AddLinkerOption(_T("/debug")); } } const TiXmlElement* event; if ((event=idef->FirstChildElement("PreBuildEvent"))) { const TiXmlElement* copt=event->FirstChildElement("Command"); for (; copt; copt=copt->NextSiblingElement("Command")) { wxString cmd = UnixFilename(GetText(copt)); ReplaceConfigMacros(m_pc[sName],cmd); if (!cmd.IsEmpty()) bt->AddCommandsBeforeBuild(cmd); } } if ((event=idef->FirstChildElement("PostBuildEvent"))) { const TiXmlElement* copt = event->FirstChildElement("Command"); for (; copt; copt=copt->NextSiblingElement("Command")) { wxString cmd=UnixFilename(GetText(copt)); ReplaceConfigMacros(m_pc[sName],cmd); if (!cmd.IsEmpty()) bt->AddCommandsAfterBuild(cmd); } } bResult = true; // got something } } } if (!bResult) pMsg->DebugLog(_("Failed to find any includes in the project...?!")); return bResult; }