Mercurial > ecos-v2_0-branch
changeset 786:3c2a619e9d36
* standalone/wxwin/appsettings.cpp, standalone/wxwin/appsettings.h: Look
for user tools and build tools relative to the configtool executable file.
| author | jld |
|---|---|
| date | Mon, 07 Apr 2003 16:09:48 +0000 |
| parents | a4d9abbbefff |
| children | 549cd176c0b5 |
| files | host/tools/configtool/ChangeLog host/tools/configtool/standalone/wxwin/appsettings.cpp host/tools/configtool/standalone/wxwin/appsettings.h |
| diffstat | 3 files changed, 78 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/host/tools/configtool/ChangeLog +++ b/host/tools/configtool/ChangeLog @@ -1,3 +1,9 @@ +2003-04-07 John Dallaway <jld@ecoscentric.com> + + * standalone/wxwin/appsettings.cpp, + standalone/wxwin/appsettings.h: Look for user tools and build + tools relative to the configtool executable file. + 2003-04-05 John Dallaway <jld@ecoscentric.com> * standalone/wxwin/makefile.gnu: Build Cygwin hosted configtool with
--- a/host/tools/configtool/standalone/wxwin/appsettings.cpp +++ b/host/tools/configtool/standalone/wxwin/appsettings.cpp @@ -314,7 +314,36 @@ bool ecSettings::LoadConfig() // 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 bin/*-objcopy under the build tools directory + 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]); + m_arstrBinDirs.Set(file.GetFullName().Left (file.GetFullName().Find(objcopyFileSpec)), file.GetPath(wxPATH_GET_VOLUME)); + } + if (!config.Read(_("/Build/Make Options"), & m_strMakeOptions)) { #ifdef __WXMSW__ @@ -578,7 +607,10 @@ bool ecSettings::LoadConfig() } } -#ifdef __WXGTK__ +#ifdef __WXMSW__ + if (m_userToolsDir.IsEmpty()) + m_userToolsDir = GetCygwinInstallPath() + wxT("\\bin"); +#else if (m_userToolsDir.IsEmpty()) m_userToolsDir = wxT("/bin"); #endif @@ -586,6 +618,37 @@ bool ecSettings::LoadConfig() return TRUE; } +#ifdef __WXMSW__ +wxString ecSettings::GetCygwinInstallPath() +{ + HKEY hKey = 0; + DWORD type; + BYTE value[256]; + DWORD sz = sizeof(value); + wxString strCygwinInstallPath; + + // look for the "/" mount point in the system registry settings + if (ERROR_SUCCESS == RegOpenKeyEx(HKEY_LOCAL_MACHINE, "Software\\Cygnus Solutions\\Cygwin\\mounts v2\\/", 0, KEY_READ, &hKey)) { + if (ERROR_SUCCESS == RegQueryValueEx(hKey, "native", NULL, & type, value, & sz)) { + strCygwinInstallPath = (const char*) value; + } + RegCloseKey(hKey); + } + + // if not yet found, look for the "/" mount point in the user's registry settings + hKey = 0; + sz = sizeof(value); + if (strCygwinInstallPath.IsEmpty() && (ERROR_SUCCESS == RegOpenKeyEx(HKEY_CURRENT_USER, "Software\\Cygnus Solutions\\Cygwin\\mounts v2\\/", 0, KEY_READ, &hKey))) { + if (ERROR_SUCCESS == RegQueryValueEx(hKey, "native", NULL, & type, value, & sz)) { + strCygwinInstallPath = (const char*) value; + } + RegCloseKey(hKey); + } + + return strCygwinInstallPath; +} +#endif + // Save config info bool ecSettings::SaveConfig() {
--- a/host/tools/configtool/standalone/wxwin/appsettings.h +++ b/host/tools/configtool/standalone/wxwin/appsettings.h @@ -2,6 +2,7 @@ // // ---------------------------------------------------------------------------- // Copyright (C) 1998, 1999, 2000 Red Hat, Inc. +// Copyright (C) 2003 John Dallaway // // This program is part of the eCos host tools. // @@ -27,7 +28,7 @@ //=========================================================================== //#####DESCRIPTIONBEGIN#### // -// Author(s): julians +// Author(s): julians, jld // Contact(s): julians // Date: 2000/08/29 // Version: $Id: appsettings.h,v 1.12 2001/12/14 17:34:03 julians Exp $ @@ -153,6 +154,11 @@ public: // Find the subkey of the latest installed eCos, e.g. "1.4.9" wxString GetInstallVersionKey (); + +#ifdef __WXMSW__ + // Find the location of the Cygwin installation + wxString GetCygwinInstallPath (); +#endif //// Accessors
