// Load config info bool ecSettings::LoadConfig() { wxConfig config(wxGetApp().GetSettings().GetConfigAppName()); config.Read(_("/Window Status/FrameStatus"), & m_frameStatus); config.Read(_("/Window Status/ShowToolBar"), (bool*) & m_showToolBar); config.Read(_("/Window Status/ShowSplashScreen"), (bool*) & m_showSplashScreen); config.Read(_("/Window Status/ShowConflictsWindow"), (bool*) & m_showConflictsWindow); config.Read(_("/Window Status/ShowPropertiesWindow"), (bool*) & m_showPropertiesWindow); config.Read(_("/Window Status/ShowShortDescrWindow"), (bool*) & m_showShortDescrWindow); config.Read(_("/Window Status/ShowMemoryWindow"), (bool*) & m_showMemoryWindow); config.Read(_("/Window Status/ShowOutputWindow"), (bool*) & m_showOutputWindow); config.Read(_("/Files/LastFile"), & m_lastFilename); config.Read(_("/Window Size/WindowX"), & m_frameSize.x); config.Read(_("/Window Size/WindowY"), & m_frameSize.y); config.Read(_("/Window Size/WindowWidth"), & m_frameSize.width); config.Read(_("/Window Size/WindowHeight"), & m_frameSize.height); config.Read(_("/Window Size/TreeSashWidth"), & m_treeSashSize.x); config.Read(_("/Window Size/TreeSashHeight"), & m_treeSashSize.y); config.Read(_("/Window Size/ConfigPaneWidth"), & m_configPaneWidth); config.Read(_("/Window Size/ConflictsWidth"), & m_conflictsSashSize.x); config.Read(_("/Window Size/ConflictsHeight"), & m_conflictsSashSize.y); config.Read(_("/Window Size/PropertiesWidth"), & m_propertiesSashSize.x); config.Read(_("/Window Size/PropertiesHeight"), & m_propertiesSashSize.y); config.Read(_("/Window Size/ShortDescrWidth"), & m_shortDescrSashSize.x); config.Read(_("/Window Size/ShortDescrHeight"), & m_shortDescrSashSize.y); config.Read(_("/Window Size/OutputWidth"), & m_outputSashSize.x); config.Read(_("/Window Size/OutputHeight"), & m_outputSashSize.y); config.Read(_("/Window Size/MemoryWidth"), & m_memorySashSize.x); config.Read(_("/Window Size/MemoryHeight"), & m_memorySashSize.y); config.Read(_("/Options/ShowMacroNames"), (bool*) & m_showMacroNames); config.Read(_("/Options/UseCustomViewer"), (bool*) & m_bUseCustomViewer); config.Read(_("/Options/UseExternalBrowser"), (bool*) & m_bUseExternalBrowser); int tmp = (int) m_eUseCustomBrowser; config.Read(_("/Options/UseCustomBrowser"), & tmp); m_eUseCustomBrowser = (ecBrowserType) tmp; config.Read(_("/Options/Browser"), & m_strBrowser); config.Read(_("/Options/Viewer"), & m_strViewer); config.Read(_("/Options/HexDisplay"), (bool*) & m_bHex); config.Read(_("/Options/UseDefaultFonts"), (bool*) & m_windowSettings.m_useDefaults); config.Read(_("/Rule/Checking"), & m_nRuleChecking); // Find dialog settings config.Read(_("/Find/Text"), & m_findText); config.Read(_("/Find/MatchWholeWord"), (bool*) & m_findMatchWholeWord); config.Read(_("/Find/MatchCase"), & m_findMatchCase); config.Read(_("/Find/Direction"), (bool*) & m_findDirection); config.Read(_("/Find/SearchWhat"), & m_findSearchWhat); config.Read(_("/Find/DialogX"), & m_findDialogPos.x); config.Read(_("/Find/DialogY"), & m_findDialogPos.y); // Package dialog settings config.Read(_("/Packages/OmitHardwarePackages"), & m_omitHardwarePackages); config.Read(_("/Packages/MatchPackageNamesExactly"), & m_matchPackageNamesExactly); // Run tests settings m_runTestsSettings.LoadConfig(config); // Fonts m_windowSettings.LoadConfig(config); if (!config.Read(_("/Paths/UserToolsDir"), & m_userToolsDir)) { // Use the default provided by the installer config.Read(_("Default User Tools Path"), & m_userToolsDir); } // Only to be used if we fail to find the information installed // with the Configuration Tool. config.Read(_("/Paths/BuildToolsDir"), & m_buildToolsDir); if (m_buildToolsDir.IsEmpty()) // first invocation by this user { // we have no clues as to the location of the build tools so // test for ../../../gnutools relative to the configtool location wxFileName gnutools = wxFileName (wxGetApp().GetAppDir(), wxEmptyString); gnutools.Normalize(); // remove trailing "./" if present if (2 < gnutools.GetDirCount()) { gnutools.RemoveDir (gnutools.GetDirCount()-1); gnutools.RemoveDir (gnutools.GetDirCount()-1); gnutools.RemoveDir (gnutools.GetDirCount()-1); gnutools.AppendDir (wxT("gnutools")); if (gnutools.DirExists()) // we've found the gnutools m_buildToolsDir = gnutools.GetFullPath(); } } // look for *objcopy in and under the build tools directory if (! m_buildToolsDir.IsEmpty()) { wxArrayString objcopyFiles; wxString objcopyFileSpec(wxT("objcopy")); #ifdef __WXMSW__ objcopyFileSpec += wxT(".exe"); #endif size_t objcopyCount = wxDir::GetAllFiles(m_buildToolsDir, &objcopyFiles, wxT("*") + objcopyFileSpec, wxDIR_FILES | wxDIR_DIRS); for (int count=0; count < objcopyCount; count++) { wxFileName file (objcopyFiles [count]); wxString new_prefix (file.GetFullName().Left (file.GetFullName().Find(objcopyFileSpec))); if ((! new_prefix.IsEmpty()) && ('-' == new_prefix.Last())) new_prefix = new_prefix.Left (new_prefix.Len() - 1); // strip off trailing hyphen m_arstrBinDirs.Set(new_prefix, file.GetPath(wxPATH_GET_VOLUME)); } } if (!config.Read(_("/Build/Make Options"), & m_strMakeOptions)) { #ifdef __WXMSW__ SYSTEM_INFO SystemInfo; GetSystemInfo(&SystemInfo); // disable -j option for now due to problem with Cygwin 1.3.18 // m_strMakeOptions.Printf(_T("-j%d"),SystemInfo.dwNumberOfProcessors); #endif } // Set default build tools binary directories as specified by the installer ecFileName strDefaultBuildToolsPath; #ifdef __WXMSW__ { // This should look in HKEY_LOCAL_MACHINE wxConfig config2(wxT("eCos"), wxEmptyString, wxEmptyString, wxEmptyString, wxCONFIG_USE_GLOBAL_FILE|wxCONFIG_USE_LOCAL_FILE); wxString versionKey = GetInstallVersionKey(); wxConfigPathChanger path(& config2, wxString(wxT("/")) + versionKey + wxT("/")); if (!versionKey.IsEmpty() && config2.Read(wxT("Default Build Tools Path"), & strDefaultBuildToolsPath)) { #ifdef __WXMSW__ wxString gccExe(wxT("*-gcc.exe")); #else wxString gccExe(wxT("*-gcc")); #endif // Note that this is not a recursive search. Compilers for // different targets may be in the same directory. This finds all targets. // look for *-gcc[.exe] in the default build tools directory wxLogNull log; wxDir finder(strDefaultBuildToolsPath); wxString filename; if (finder.IsOpened()) { bool bMore = finder.GetFirst(& filename, gccExe); while (bMore) { wxString targetName = filename.Left(filename.Find(wxT("-gcc"))); m_arstrBinDirs.Set(targetName, strDefaultBuildToolsPath); bMore = finder.GetNext(& filename); } } } } #endif #ifndef __WXMSW__ // Look in the PATH for build tools, under Unix { wxString strPath; if (wxGetEnv(wxT("PATH"), & strPath)) { wxString gccExe(wxT("*-gcc")); wxArrayString arstrPath; ecUtils::Chop(strPath, arstrPath, wxT(':')); for (int i = arstrPath.GetCount()-1;i >= 0; --i) { // Reverse order is important to treat path correctly if (wxT(".") != arstrPath[i] && !arstrPath[i].IsEmpty()) { wxLogNull log; wxDir finder(arstrPath[i]); wxString filename; if (finder.IsOpened()) { bool bMore = finder.GetFirst(& filename, gccExe); while (bMore) { wxString targetName = filename.Left(filename.Find(wxT("-gcc"))); m_arstrBinDirs.Set(targetName, arstrPath[i]); bMore = finder.GetNext(& filename); } } } } } } #endif // Read build tools directories (current user) { wxConfigPathChanger path(& config, wxT("/Build Tools/")); //config.SetPath(wxT("/Build Tools")); wxString key(wxT("")); long index; bool bMore = config.GetFirstEntry(key, index); while (bMore) { wxString value; if (config.Read(key, & value)) { m_arstrBinDirs.Set(key, value); } bMore = config.GetNextEntry(key, index); } } // Read toolchain paths (local machine again) #ifdef __WXMSW__ wxArrayString arstrToolChainPaths; // Use eCos just as a test. //GetRepositoryRegistryClues(arstrToolChainPaths,_T("eCos")); GetRepositoryRegistryClues(arstrToolChainPaths,_T("GNUPro eCos")); size_t i; for (i = (size_t) 0; i < arstrToolChainPaths.GetCount(); i++) { ecFileName strDir(arstrToolChainPaths[i]); strDir += wxT("H-i686-cygwin32\\bin"); if (strDir.IsDir()) { // This is a potential toolchain location. Look for *-gcc.exe wxLogNull log; wxDir finder(strDefaultBuildToolsPath); wxString filename; if (finder.IsOpened()) { bool bMore = finder.GetFirst(& filename, wxT("*-gcc.exe")); while (bMore) { // TODO: if there is more than one path, we will have to // check the existance of this target name in m_arstrBinDirs and // append to the end, or something. wxString targetName = filename.Left(filename.Find(wxT("-gcc"))); m_arstrBinDirs.Set(targetName, strDefaultBuildToolsPath); bMore = finder.GetNext(& filename); } } } } // The official user tools are now Cygwin 00r1. If you can't find these, // try GNUPro unsupported. GetRepositoryRegistryClues(m_userToolPaths, wxT("GNUPro 00r1")); if (m_userToolPaths.GetCount() == 0) { GetRepositoryRegistryClues(m_userToolPaths, wxT("Cygwin 00r1")); } if (m_userToolPaths.GetCount() > 0) { for ( i = (size_t) 0 ; i < m_userToolPaths.GetCount(); i++) { ecFileName str(m_userToolPaths[i]); str += "H-i686-cygwin32\\bin"; if(str.IsDir()) { m_userToolPaths[i] = str; } else { m_userToolPaths.Remove(i); i--; } } } else { GetRepositoryRegistryClues(m_userToolPaths, wxT("GNUPro unsupported")); for ( i = (size_t) 0 ; i < m_userToolPaths.GetCount(); i++) { ecFileName str(m_userToolPaths[i]); str += "H-i686-cygwin32\\bin"; if(str.IsDir()) { m_userToolPaths[i] = str; } else { m_userToolPaths.Remove(i); i--; } } } #endif // Include the path in the set of potential user paths { wxString strPath; if (wxGetEnv(wxT("PATH"), & strPath)) { wxArrayString arstrPath; ecUtils::Chop(strPath, arstrPath, wxT(';')); for (int i = arstrPath.GetCount()-1;i >= 0; --i) { // Reverse order is important to treat path correctly const ecFileName &strFolder = arstrPath[i]; if (wxT(".") != strFolder && !strFolder.IsEmpty()) { ecFileName strFile(strFolder); strFile += wxT("ls.exe"); if ( strFile.Exists() ) { if (!wxArrayStringIsMember(m_userToolPaths, strFolder)) { m_userToolPaths.Add(strFolder); } if ( m_userToolsDir.IsEmpty() ) { m_userToolsDir = strFolder; } } } } } } // Load current repository from eCos Configuration Tool/Paths/RepositoryDir { wxConfig eCosConfig(wxGetApp().GetSettings().GetConfigAppName(), wxEmptyString, wxEmptyString, wxEmptyString, wxCONFIG_USE_GLOBAL_FILE|wxCONFIG_USE_LOCAL_FILE); wxConfigPathChanger path(& config, wxT("/Repository/")); //if (!eCosConfig.Read(wxT("Folder"), & m_strRepository)) if (!eCosConfig.Read(wxT("/Paths/RepositoryDir"), & m_strRepository)) { #ifdef __WXMSW__ // If we can't find the current folder, look for clues in the registry. wxArrayString arstr; switch (GetRepositoryRegistryClues(arstr, wxT("eCos"))) { case 0: break; case 1: default: m_strRepository = arstr[0]; break; } #elif defined(__WXGTK__) // If we can't find the current folder, look for the latest version // in /opt/ecos m_strRepository = FindLatestVersion(); #else // Unsupported platform m_strRepositor = wxEmptyString; #endif } // If we have set ECOS_REPOSITORY, this overrides whatever we have // read or found. wxString envVarValue = wxGetenv(wxT("ECOS_REPOSITORY")); if (!envVarValue.IsEmpty()) { // Note that ECOS_REPOSITORY has the packages (or ecc) folder in the name. // In order to be in the form that is compatible with configtool operation, // it needs to have that stripped off. envVarValue = ecUtils::PosixToNativePath(envVarValue); // accommodate posix-style ECOS_REPOSITORY value under Cygwin wxString packagesName = wxFileNameFromPath(envVarValue); if (packagesName == wxT("ecc") || packagesName == wxT("packages")) envVarValue = wxPathOnly(envVarValue); m_strRepository = envVarValue; } } #ifdef __WXMSW__ if (m_userToolsDir.IsEmpty()) m_userToolsDir = GetCygwinInstallPath() + wxT("\\bin"); #else if (m_userToolsDir.IsEmpty()) m_userToolsDir = wxT("/bin"); #endif return TRUE; }
bool CompilerLocatorMinGW::Locate() { m_compilers.clear(); m_locatedFolders.clear(); // for wxRegKey #ifdef __WXMSW__ { // HKEY_LOCAL_MACHINE\SOFTWARE\codelite\settings wxRegKey regClMinGW(wxRegKey::HKLM, "SOFTWARE\\codelite\\settings"); wxString clInstallFolder; if ( regClMinGW.QueryValue("MinGW", clInstallFolder) && wxDirExists(clInstallFolder)) { wxFileName gccExe(clInstallFolder, "gcc.exe"); wxString ver; regClMinGW.QueryValue("MinGW_Version", ver); gccExe.AppendDir("bin"); if ( gccExe.FileExists() ) { AddTools(gccExe.GetPath(), "CodeLite-" + ver); } } } { // HKEY_LOCAL_MACHINE\SOFTWARE\codelite\settings wxRegKey regClMinGW(wxRegKey::HKLM, "SOFTWARE\\Wow6432Node\\codelite\\settings"); wxString clInstallFolder; if ( regClMinGW.QueryValue("MinGW", clInstallFolder) && wxDirExists(clInstallFolder)) { wxFileName gccExe(clInstallFolder, "gcc.exe"); wxString ver; regClMinGW.QueryValue("MinGW_Version", ver); gccExe.AppendDir("bin"); if ( gccExe.FileExists() ) { AddTools(gccExe.GetPath(), "CodeLite-" + ver); } } } // Check registry for TDM-GCC-64 wxRegKey regTDM(wxRegKey::HKCU, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\TDM-GCC"); wxString tdmInstallFolder; tdmInstallFolder.Clear(); if ( regTDM.QueryValue("InstallLocation", tdmInstallFolder) && wxFileName::DirExists(tdmInstallFolder)) { wxFileName fnTDMBinFolder( tdmInstallFolder, "" ); fnTDMBinFolder.AppendDir("bin"); AddTools(fnTDMBinFolder.GetPath(), "TDM-GCC-64"); } // Check for 32 bit wxRegKey regTDM_32(wxRegKey::HKLM, "SOFTWARE\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\TDM-GCC"); tdmInstallFolder.Clear(); if ( regTDM_32.QueryValue("InstallLocation", tdmInstallFolder) && wxFileName::DirExists(tdmInstallFolder)) { wxFileName fnTDMBinFolder( tdmInstallFolder, "" ); fnTDMBinFolder.AppendDir("bin"); AddTools(fnTDMBinFolder.GetPath(), "TDM-GCC-32"); } // locate codeblock's MinGW wxRegKey regCB(wxRegKey::HKCU, "SOFTWARE\\CodeBlocks"); wxString cbInstallPath; if ( regCB.QueryValue("Path", cbInstallPath) ) { wxFileName mingwBinFolder( cbInstallPath, "" ); mingwBinFolder.AppendDir("MinGW"); mingwBinFolder.AppendDir("bin"); if ( mingwBinFolder.DirExists() && wxFileName(mingwBinFolder.GetFullPath(), "gcc.exe").FileExists() ) { AddTools(mingwBinFolder.GetPath(), "Code::Blocks"); } } // Last: many people install MinGW by simply extracting it into the // root folder: // C:\MinGW-X.Y.Z wxArrayString volumes = wxFSVolume::GetVolumes(); wxArrayString mingwFolderArr; // Get list of folders for the volume only for(size_t i=0; i<volumes.GetCount(); ++i) { wxDir dir( volumes.Item(i) ); if ( dir.IsOpened() ) { wxString path; bool cont = dir.GetFirst(&path, "*mingw*", wxDIR_DIRS); while (cont ) { wxString fullpath; fullpath << volumes.Item(i) << path; CL_DEBUG("Found folder containing MinGW: %s", fullpath); mingwFolderArr.Add( fullpath ); cont = dir.GetNext( &path ); } } } for(size_t i=0; i<mingwFolderArr.GetCount(); ++i) { wxString binFolder = FindBinFolder( mingwFolderArr.Item(i) ); if ( binFolder.IsEmpty() ) continue; wxFileName gcc(binFolder, "gcc.exe"); if( gcc.FileExists() ) { AddTools(gcc.GetPath()); } } #endif // try to find MinGW in environment variable PATH (last) wxString pathValues; wxGetEnv("PATH", &pathValues); if ( !pathValues.IsEmpty() ) { wxArrayString pathArray = ::wxStringTokenize(pathValues, wxPATH_SEP, wxTOKEN_STRTOK); for (size_t i = 0; i < pathArray.GetCount(); ++i) { wxFileName gccComp( pathArray.Item(i), "gcc.exe" ); if ( gccComp.GetDirs().Last() == "bin" && gccComp.Exists() ) { // We found gcc.exe wxString pathToGcc = gccComp.GetPath(); pathToGcc.MakeLower(); // Don't mix cygwin and mingw if ( !pathToGcc.Contains("cygwin") ) { AddTools( gccComp.GetPath() ); } } } } return !m_compilers.empty(); }