AutoDetectResult CompilerICC::AutoDetectInstallationDir() { wxString sep = wxFileName::GetPathSeparator(); if (platform::windows) { if ( wxDirExists(_T("C:\\Program Files\\Intel\\Compiler")) ) { wxDir icc_dir(_T("C:\\Program Files\\Intel\\Compiler\\C++")); if (icc_dir.IsOpened()) { wxArrayString dirs; wxIccDirTraverser IccDirTraverser(dirs); icc_dir.Traverse(IccDirTraverser); if (!dirs.IsEmpty()) { // Now sort the array in reverse order to get the latest version's path dirs.Sort(true); m_MasterPath = dirs[0]; m_MasterPath.Append(_T("\\IA32")); } } } int version = 0; while ( m_MasterPath.IsEmpty() || !wxDirExists(m_MasterPath) ) { wxString iccEnvVar; if (version==0) { // Try default w/o version number iccEnvVar = _T("ICPP_COMPILER"); version = 8; } else if (version>15) break; // exit while-loop else { // Try ICPP_COMPILER80 ... ICPP_COMPILER12 iccEnvVar.Printf(wxT("ICPP_COMPILER%d0"), version); version++; } // Read the ICPP_COMPILER[XX] environment variable if ( !wxGetEnv(iccEnvVar, &m_MasterPath) ) m_MasterPath.Clear(); } // Now check for the installation of MSVC const wxString msvcIds[4] = { _T("msvc6"), _T("msvctk"), _T("msvc8"), _T("msvc10") }; bool msvcFound = false; for (unsigned int which_msvc = 0; which_msvc < array_size(msvcIds); ++which_msvc) { Compiler* vcComp = CompilerFactory::GetCompiler(msvcIds[which_msvc]); if (!vcComp) continue; // compiler not registered? try next one wxString vcMasterNoMacros = vcComp->GetMasterPath(); Manager::Get()->GetMacrosManager()->ReplaceMacros(vcMasterNoMacros); if ( !wxFileExists(vcMasterNoMacros + sep + wxT("bin") + sep + vcComp->GetPrograms().C) && !wxFileExists(vcMasterNoMacros + sep + vcComp->GetPrograms().C) ) continue; // this MSVC is not installed; try next one const wxString& vcMasterPath = vcComp->GetMasterPath(); if (m_ExtraPaths.Index(vcMasterPath) == wxNOT_FOUND) m_ExtraPaths.Add(vcMasterPath); if ( !vcMasterPath.EndsWith(wxT("bin")) && m_ExtraPaths.Index(vcMasterPath + sep + wxT("bin")) == wxNOT_FOUND ) { m_ExtraPaths.Add(vcMasterPath + sep + wxT("bin")); } AddIncludeDir(vcMasterPath + _T("\\Include")); AddLibDir(vcMasterPath + _T("\\Lib")); AddResourceIncludeDir(vcMasterPath + _T("\\Include")); const wxArrayString& vcExtraPaths = vcComp->GetExtraPaths(); for (size_t i = 0; i < vcExtraPaths.GetCount(); ++i) { if ( m_ExtraPaths.Index(vcExtraPaths[i]) == wxNOT_FOUND && wxDirExists(vcExtraPaths[i]) ) { m_ExtraPaths.Add(vcExtraPaths[i]); } } const wxArrayString& vcIncludeDirs = vcComp->GetIncludeDirs(); for (size_t i = 0; i < vcIncludeDirs.GetCount(); ++i) { if (wxDirExists(vcIncludeDirs[i])) { if (m_IncludeDirs.Index(vcIncludeDirs[i]) == wxNOT_FOUND) AddIncludeDir(vcIncludeDirs[i]); if (m_ResIncludeDirs.Index(vcIncludeDirs[i]) == wxNOT_FOUND) AddResourceIncludeDir(vcIncludeDirs[i]); } } const wxArrayString& vcLibDirs = vcComp->GetLibDirs(); for (size_t i = 0; i < vcLibDirs.GetCount(); ++i) { if ( m_LibDirs.Index(vcLibDirs[i]) == wxNOT_FOUND && wxDirExists(vcLibDirs[i]) ) { AddLibDir(vcLibDirs[i]); } } msvcFound = true; break; } if ( m_MasterPath.IsEmpty() || !wxDirExists(m_MasterPath) ) { // Just a final guess for the default installation dir wxString Programs = _T("C:\\Program Files"); // what's the "Program Files" location // TO DO : support 64 bit -> 32 bit apps are in "ProgramFiles(x86)" // 64 bit apps are in "ProgramFiles" wxGetEnv(_T("ProgramFiles"), &Programs); m_MasterPath = Programs + _T("\\Intel\\Compiler\\C++\\9.0"); } else if (!msvcFound) { cbMessageBox(_T("It seems your computer doesn't have a MSVC compiler installed.\n\n" "The ICC compiler requires MSVC for proper functioning and\n" "it may not work without it."), _T("Error"), wxOK | wxICON_ERROR); } } else { m_MasterPath = _T("/opt/intel/cc/9.0"); if (wxDirExists(_T("/opt/intel"))) { wxDir icc_dir(_T("/opt/intel/cc")); if (icc_dir.IsOpened()) { wxArrayString dirs; wxIccDirTraverser IccDirTraverser(dirs); icc_dir.Traverse(IccDirTraverser); if (!dirs.IsEmpty()) { // Now sort the array in reverse order to get the latest version's path dirs.Sort(true); m_MasterPath = dirs[0]; } } } } AutoDetectResult ret = wxFileExists(m_MasterPath + sep + _T("bin") + sep + m_Programs.C) ? adrDetected : adrGuessed; if (ret == adrGuessed) ret = wxFileExists(m_MasterPath + sep + _T("bin") + sep + _T("ia32") + sep + m_Programs.C) ? adrDetected : adrGuessed; if (ret == adrGuessed) ret = wxFileExists(m_MasterPath + sep + _T("bin") + sep + _T("intel64") + sep + m_Programs.C) ? adrDetected : adrGuessed; if (ret == adrDetected) { if ( wxFileExists(m_MasterPath + sep + _T("bin") + sep + _T("ia32") + sep + m_Programs.C) ) m_ExtraPaths.Add(m_MasterPath + sep + _T("bin") + sep + _T("ia32")); if ( wxFileExists(m_MasterPath + sep + _T("bin") + sep + _T("intel64") + sep + m_Programs.C) ) m_ExtraPaths.Add(m_MasterPath + sep + _T("bin") + sep + _T("intel64")); if ( wxDirExists(m_MasterPath + sep + _T("include")) ) { m_IncludeDirs.Insert(m_MasterPath + sep + _T("include"), 0); m_ResIncludeDirs.Insert(m_MasterPath + sep + _T("include"), 0); } if ( wxDirExists(m_MasterPath + sep + _T("compiler") + sep + _T("include")) ) { m_IncludeDirs.Insert(m_MasterPath + sep + _T("compiler") + sep + _T("include"), 0); m_ResIncludeDirs.Insert(m_MasterPath + sep + _T("compiler") + sep + _T("include"), 0); } if ( wxDirExists(m_MasterPath + sep + _T("lib")) ) { m_IncludeDirs.Insert(m_MasterPath + sep + _T("lib"), 0); m_ResIncludeDirs.Insert(m_MasterPath + sep + _T("lib"), 0); } if ( wxDirExists(m_MasterPath + sep + _T("compiler") + sep + _T("lib")) ) m_LibDirs.Insert(m_MasterPath + sep + _T("compiler") + sep + _T("lib"), 0); if ( wxDirExists(m_MasterPath + sep + _T("compiler") + sep + _T("lib") + sep + _T("ia32")) ) m_LibDirs.Insert(m_MasterPath + sep + _T("compiler") + sep + _T("lib") + sep + _T("ia32"), 0); if ( wxDirExists(m_MasterPath + sep + _T("compiler") + sep + _T("lib") + sep + _T("intel64")) ) m_LibDirs.Insert(m_MasterPath + sep + _T("compiler") + sep + _T("lib") + sep + _T("intel64"), 0); } // Try to detect the debugger. If not detected successfully the debugger plugin will // complain, so only the autodetection of compiler is considered in return value wxString path; wxString dbg; if (platform::windows) { dbg = _T("idb.exe"); wxGetEnv(_T("IDB_PATH"), &path); if ( !path.IsEmpty() && wxDirExists(path) ) { int version = 9; while ( true ) { wxString idbPath = path + sep + _T("IDB") + sep + wxString::Format(_T("%d.0"), version) + sep + _T("IA32"); if ( wxDirExists(idbPath) ) { path = idbPath; // found break; // exit while-loop } else if (version>15) break; // exit while-loop else version++; } } } else { dbg = _T("idb"); path = _T("/opt/intel/idb/9.0"); if ( wxDirExists(_T("/opt/intel")) ) { wxDir icc_debug_dir(_T("/opt/intel/idb")); if (icc_debug_dir.IsOpened()) { wxArrayString debug_dirs; wxIccDirTraverser IccDebugDirTraverser(debug_dirs); icc_debug_dir.Traverse(IccDebugDirTraverser); if (!debug_dirs.IsEmpty()) { // Now sort the array in reverse order to get the latest version's path debug_dirs.Sort(true); path = debug_dirs[0]; } } } } if ( wxFileExists(path + sep + _T("bin") + sep + dbg) ) m_ExtraPaths.Add(path); return ret; }
AutoDetectResult CompilerICC::AutoDetectInstallationDir() { wxString sep = wxFileName::GetPathSeparator(); wxString extraDir = _T(""); if (platform::windows) { if (wxDirExists(_T("C:\\Program Files\\Intel\\Compiler"))) { wxDir icc_dir(_T("C:\\Program Files\\Intel\\Compiler\\C++")); if (icc_dir.IsOpened()) { wxArrayString dirs; wxIccDirTraverser IccDirTraverser(dirs); icc_dir.Traverse(IccDirTraverser); if (!dirs.IsEmpty()) { // Now sort the array in reverse order to get the latest version's path dirs.Sort(true); m_MasterPath = dirs[0]; m_MasterPath.Append(_T("\\IA32")); // Now check for the installation of MSVC const wxString msvcIds[4] = { _T("msvc6"), _T("msvctk"), _T("msvc8"), _T("msvc10") }; bool msvcFound = false; for (unsigned int which_msvc = 0; which_msvc < array_size(msvcIds); ++which_msvc) { Compiler* vcComp = CompilerFactory::GetCompiler(msvcIds[which_msvc]); if (vcComp) { if (vcComp->AutoDetectInstallationDir() == adrDetected) { const wxString& vcMasterPath = vcComp->GetMasterPath(); if (m_ExtraPaths.Index(vcMasterPath) == wxNOT_FOUND && wxDirExists(vcMasterPath)) { m_ExtraPaths.Add(vcMasterPath); } AddIncludeDir(vcMasterPath + _T("\\Include")); AddLibDir(vcMasterPath + _T("\\Lib")); AddResourceIncludeDir(vcMasterPath + _T("\\Include")); const wxArrayString& vcExtraPaths = vcComp->GetExtraPaths(); for (size_t i = 0; i < vcExtraPaths.GetCount(); ++i) { if (m_ExtraPaths.Index(vcExtraPaths[i]) == wxNOT_FOUND && wxDirExists(vcExtraPaths[i])) { m_ExtraPaths.Add(vcExtraPaths[i]); } } const wxArrayString& vcIncludeDirs = vcComp->GetIncludeDirs(); for (size_t i = 0; i < vcIncludeDirs.GetCount(); ++i) { if (wxDirExists(vcIncludeDirs[i])) { if (m_IncludeDirs.Index(vcIncludeDirs[i]) == wxNOT_FOUND) { AddIncludeDir(vcIncludeDirs[i]); } if (m_ResIncludeDirs.Index(vcIncludeDirs[i]) == wxNOT_FOUND) { AddResourceIncludeDir(vcIncludeDirs[i]); } } } const wxArrayString& vcLibDirs = vcComp->GetLibDirs(); for (size_t i = 0; i < vcLibDirs.GetCount(); ++i) { if (m_LibDirs.Index(vcLibDirs[i]) == wxNOT_FOUND && wxDirExists(vcLibDirs[i])) { AddLibDir(vcLibDirs[i]); } } msvcFound = true; break; } } } if (!msvcFound) { cbMessageBox(_T("It seems your computer doesn't have a working MSVC compiler.\n\n" "This compiler requires MS compiler for proper functioning and\n" "it may not work without it."), _T("Error"), wxOK | wxICON_ERROR); } } } } // Read the ICPP_COMPILER90 environment variable wxGetEnv(_T("ICPP_COMPILER90"), &m_MasterPath); extraDir = sep + _T("IA32");// Intel also provides compiler for Itanium processors if (m_MasterPath.IsEmpty()) { // just a guess the default installation dir wxString Programs = _T("C:\\Program Files"); // what's the "Program Files" location // TO DO : support 64 bit -> 32 bit apps are in "ProgramFiles(x86)" // 64 bit apps are in "ProgramFiles" wxGetEnv(_T("ProgramFiles"), &Programs); m_MasterPath = Programs + _T("\\Intel\\Compiler\\C++\\9.0"); } } else { m_MasterPath = _T("/opt/intel/cc/9.0"); if (wxDirExists(_T("/opt/intel"))) { wxDir icc_dir(_T("/opt/intel/cc")); if (icc_dir.IsOpened()) { wxArrayString dirs; wxIccDirTraverser IccDirTraverser(dirs); icc_dir.Traverse(IccDirTraverser); if (!dirs.IsEmpty()) { // Now sort the array in reverse order to get the latest version's path dirs.Sort(true); m_MasterPath = dirs[0]; } } } } AutoDetectResult ret = wxFileExists(m_MasterPath + sep + _T("bin") + sep + m_Programs.C) ? adrDetected : adrGuessed; if (ret == adrDetected) { m_IncludeDirs.Insert(m_MasterPath + sep + _T("Include"), 0); m_LibDirs.Insert(m_MasterPath + sep + _T("Lib"), 0); m_ResIncludeDirs.Insert(m_MasterPath + sep + _T("Include"), 0); } // Try to detect the debugger. If not detected successfully the debugger plugin will // complain, so only the autodetection of compiler is considered in return value wxString path; wxString dbg; if (platform::windows) { dbg = _T("idb.exe"); wxGetEnv(_T("IDB_PATH"), &path); path += _T("IDB\\9.0\\IA32"); } else { dbg = _T("idb"); path= _T("/opt/intel/idb/9.0"); if (wxDirExists(_T("/opt/intel"))) { wxDir icc_debug_dir(_T("/opt/intel/idb")); if (icc_debug_dir.IsOpened()) { wxArrayString debug_dirs; wxIccDirTraverser IccDebugDirTraverser(debug_dirs); icc_debug_dir.Traverse(IccDebugDirTraverser); if (!debug_dirs.IsEmpty()) { // Now sort the array in reverse order to get the latest version's path debug_dirs.Sort(true); path = debug_dirs[0]; } } } } if (wxFileExists(path + sep + _T("bin") + sep + dbg)) m_ExtraPaths.Add(path); return ret; }
/** external deps are manually set by the user * e.g. a static library linked to the project is an external dep (if set as such by the user) * so that a re-linking is forced if the static lib is updated */ bool DirectCommands::AreExternalDepsOutdated(ProjectBuildTarget* target, const wxString& buildOutput, wxArrayString* filesMissing) const { Compiler* compiler = CompilerFactory::GetCompiler(target->GetCompilerID()); // if no output, probably a commands-only target; nothing to relink // but we have to check other dependencies time_t timeOutput = 0; if (!buildOutput.IsEmpty()) { wxString output = buildOutput; Manager::Get()->GetMacrosManager()->ReplaceMacros(output); depsTimeStamp(output.mb_str(), &timeOutput); // if build output exists, check for updated static libraries if (timeOutput) { // look for static libraries in target/project library dirs wxArrayString libs = target->GetLinkLibs(); const wxArrayString& prjLibs = target->GetParentProject()->GetLinkLibs(); const wxArrayString& cmpLibs = compiler->GetLinkLibs(); AppendArray(prjLibs, libs); AppendArray(cmpLibs, libs); const wxArrayString& prjLibDirs = target->GetParentProject()->GetLibDirs(); const wxArrayString& cmpLibDirs = compiler->GetLibDirs(); wxArrayString libDirs = target->GetLibDirs(); AppendArray(prjLibDirs, libDirs); AppendArray(cmpLibDirs, libDirs); for (size_t i = 0; i < libs.GetCount(); ++i) { wxString lib = libs[i]; // if user manually pointed to a library, without using the lib dirs, // then just check the file directly w/out involving the search dirs... if (lib.Contains(_T("/")) || lib.Contains(_T("\\"))) { Manager::Get()->GetMacrosManager()->ReplaceMacros(lib, target); lib = UnixFilename(lib); time_t timeExtDep; depsTimeStamp(lib.mb_str(), &timeExtDep); if (timeExtDep > timeOutput) { // force re-link Manager::Get()->GetLogManager()->DebugLog(F(_T("Forcing re-link of '%s/%s' because '%s' is newer"), target->GetParentProject()->GetTitle().wx_str(), target->GetTitle().wx_str(), lib.wx_str())); return true; } continue; } if (!lib.StartsWith(compiler->GetSwitches().libPrefix)) lib = compiler->GetSwitches().libPrefix + lib; if (!lib.EndsWith(_T(".") + compiler->GetSwitches().libExtension)) lib += _T(".") + compiler->GetSwitches().libExtension; for (size_t l = 0; l < libDirs.GetCount(); ++l) { wxString dir = libDirs[l] + wxFILE_SEP_PATH + lib; Manager::Get()->GetMacrosManager()->ReplaceMacros(dir, target); dir = UnixFilename(dir); time_t timeExtDep; depsTimeStamp(dir.mb_str(), &timeExtDep); if (timeExtDep > timeOutput) { // force re-link Manager::Get()->GetLogManager()->DebugLog(F(_T("Forcing re-link of '%s/%s' because '%s' is newer"), target->GetParentProject()->GetTitle().wx_str(), target->GetTitle().wx_str(), dir.wx_str())); return true; } } } } } // array is separated by ; wxArrayString extDeps = GetArrayFromString(target->GetExternalDeps(), _T(";")); wxArrayString addFiles = GetArrayFromString(target->GetAdditionalOutputFiles(), _T(";")); for (size_t i = 0; i < extDeps.GetCount(); ++i) { if (extDeps[i].IsEmpty()) continue; Manager::Get()->GetMacrosManager()->ReplaceMacros(extDeps[i]); time_t timeExtDep; depsTimeStamp(extDeps[i].mb_str(), &timeExtDep); // if external dep doesn't exist, no need to relink // but we have to check other dependencies if (!timeExtDep) { if (filesMissing) filesMissing->Add(extDeps[i]); continue; } // let's check the additional output files for (size_t j = 0; j < addFiles.GetCount(); ++j) { if (addFiles[j].IsEmpty()) continue; Manager::Get()->GetMacrosManager()->ReplaceMacros(addFiles[j]); time_t timeAddFile; depsTimeStamp(addFiles[j].mb_str(), &timeAddFile); // if additional file doesn't exist, we can skip it if (!timeAddFile) { if (filesMissing) filesMissing->Add(addFiles[j]); continue; } // if external dep is newer than additional file, relink if (timeExtDep > timeAddFile) return true; } // if no output, probably a commands-only target; nothing to relink // but we have to check other dependencies if (buildOutput.IsEmpty()) continue; // now check the target's output // this is moved last because, for "commands only" targets, // it would return before we had a chance to check the // additional output files (above) // if build output doesn't exist, relink if (!timeOutput) return true; // if external dep is newer than build output, relink if (timeExtDep > timeOutput) return true; } return false; // no force relink }