changeset 951:3021b4922c80

* standalone/wxwin/appsettings.cpp, standalone/wxwin/mainwin.cpp: Rationalise the treatment of the build tools directory during startup and when using the build tools dialog. * standalone/wxwin/configtool.cpp: Wait for the installation of platform definitions to complete on Linux.
author jld
date Thu, 17 Apr 2003 14:18:40 +0000
parents 98c42a7977c8
children ff91ad81d086
files host/tools/configtool/ChangeLog host/tools/configtool/standalone/wxwin/appsettings.cpp host/tools/configtool/standalone/wxwin/configtool.cpp host/tools/configtool/standalone/wxwin/mainwin.cpp
diffstat 4 files changed, 63 insertions(+), 46 deletions(-) [+]
line wrap: on
line diff
--- a/host/tools/configtool/ChangeLog
+++ b/host/tools/configtool/ChangeLog
@@ -1,3 +1,12 @@
+2003-04-17  John Dallaway  <jld@ecoscentric.com>
+
+	* standalone/wxwin/appsettings.cpp, standalone/wxwin/mainwin.cpp:
+	Rationalise the treatment of the build tools directory during startup
+	and when using the build tools dialog.
+
+	* standalone/wxwin/configtool.cpp: Wait for the installation of platform
+	definitions to complete on Linux.
+
 2003-04-16  John Dallaway  <jld@ecoscentric.com>
 
 	* standalone/wxwin/configtool.cpp: Install default platform definitions
--- a/host/tools/configtool/standalone/wxwin/appsettings.cpp
+++ b/host/tools/configtool/standalone/wxwin/appsettings.cpp
@@ -331,17 +331,23 @@ bool ecSettings::LoadConfig()
         }
     }
 
-    // look for bin/*-objcopy under the build tools directory
-    wxArrayString objcopyFiles;
-    wxString objcopyFileSpec(wxT("-objcopy"));
+    // 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");
+        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));
+        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))
--- a/host/tools/configtool/standalone/wxwin/configtool.cpp
+++ b/host/tools/configtool/standalone/wxwin/configtool.cpp
@@ -209,7 +209,7 @@ bool ecApp::OnInit()
         wxFileName platforms (m_appDir, wxT("platforms.tar"));
         platforms.Normalize();
         if (platforms.FileExists())
-            wxExecute (wxT("tar -C ") + wxFileName::GetHomeDir() + wxT(" -xf ") + platforms.GetFullPath());
+            wxExecute (wxT("tar -C ") + wxFileName::GetHomeDir() + wxT(" -xf ") + platforms.GetFullPath(), wxEXEC_SYNC);
     }
 #endif
 
--- a/host/tools/configtool/standalone/wxwin/mainwin.cpp
+++ b/host/tools/configtool/standalone/wxwin/mainwin.cpp
@@ -1220,62 +1220,64 @@ void ecMainFrame::OnBuildToolsPath(wxCom
     if (!doc)
         return;
 
-    // Add all the paths from the bin dirs to the path array,
-    // making the default path the appropriate target prefix
-    wxString defaultPath;
-    const wxString strPrefix(doc->GetCurrentTargetPrefix());
+    // add the current build tools dir to the drop-down list box
     wxArrayString arstrPaths;
+    if (!wxGetApp().GetSettings().m_buildToolsDir.IsEmpty())
+        arstrPaths.Add(wxGetApp().GetSettings().m_buildToolsDir);
 
+    // also add the sub-directory containing tools for the current command prefix
+    wxString value;
     wxStringToStringMap& map = wxGetApp().GetSettings().GetBinDirs();
-    map.BeginFind();
-    wxString key, value;
-    bool hasDefaultDir = FALSE;
-    while (map.Next(key, value))
-    {
+    const wxString strPrefix(doc->GetCurrentTargetPrefix());
+    if (map.Find(strPrefix, value) && (wxNOT_FOUND == arstrPaths.Index(value)))
         arstrPaths.Add(value);
-        if (key == strPrefix)
-            defaultPath = value;
-        if (value == wxGetApp().GetSettings().m_buildToolsDir)
-            hasDefaultDir = TRUE;
-    }
-    if (!wxGetApp().GetSettings().m_buildToolsDir.IsEmpty() && !hasDefaultDir)
-    {
-        arstrPaths.Add(wxGetApp().GetSettings().m_buildToolsDir);
-    }
-    
+
     wxString msg;
     msg.Printf(_("Enter the location of the %s build tools\n"
-          "folder, which should contain %sgcc. You can\n"
+          "folder. You can\n"
           "type in a path or use the Browse button to\n"
           "navigate to a folder."),
-          (const wxChar*) (strPrefix.IsEmpty() ? wxString(wxT("native")) : strPrefix),
-          (const wxChar*) (strPrefix.IsEmpty() ? wxString(wxT("")) : strPrefix + wxT("-"))
-          );
+          (const wxChar*) (strPrefix.IsEmpty() ? wxString(wxT("native")) : strPrefix));
     wxString caption(_("Build Tools Path"));
 
-    ecFolderDialog dialog(defaultPath, arstrPaths, msg, this, ecID_BUILD_TOOLS_DIALOG, caption);
+    ecFolderDialog dialog(wxGetApp().GetSettings().m_buildToolsDir, arstrPaths, msg, this, ecID_BUILD_TOOLS_DIALOG, caption);
     if (dialog.ShowModal() == wxID_OK)
     {
-        ecFileName strExe;
+        wxString path (dialog.GetPath());
 
+        // look for *objcopy under the user-specified build tools directory
+        wxArrayString objcopyFiles;
+        wxString objcopyFileSpec(wxT("objcopy"));
 #ifdef __WXMSW__
-        wxString exeSuffix(wxT(".exe"));
-#else
-        wxString exeSuffix(wxEmptyString);
+        objcopyFileSpec += wxT(".exe");
 #endif
-        wxString path(dialog.GetPath());
-        strExe.Printf(wxT("%s%c%s%sgcc%s"), (const wxChar*) path, wxFILE_SEP_PATH, (const wxChar*) strPrefix,
-            (const wxChar*) strPrefix.IsEmpty() ? wxT("") : wxT("-"), (const wxChar*) exeSuffix);
+        size_t objcopyCount = wxDir::GetAllFiles(path, &objcopyFiles, wxT("*") + objcopyFileSpec, wxDIR_FILES | wxDIR_DIRS);
+        bool bPrefixFound = false;
+        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 
+            if (new_prefix == strPrefix)
+                bPrefixFound = true;
+        }
 
         wxString msg;
         msg.Printf(wxT("%s does not appear to contain the build tools - use this folder anyway?"), (const wxChar*) path);
 
-        if(strExe.Exists() ||
-            (wxID_YES == wxMessageBox(msg, wxGetApp().GetSettings().GetAppName(), wxICON_QUESTION|wxYES_NO)))
+        if(bPrefixFound ||
+            (wxYES == wxMessageBox(msg, wxGetApp().GetSettings().GetAppName(), wxICON_QUESTION|wxYES_NO)))
         {
-            map.Set(strPrefix, path);
-            if (!hasDefaultDir)
-                wxGetApp().GetSettings().m_buildToolsDir = path;
+            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
+                map.Set(new_prefix, file.GetPath(wxPATH_GET_VOLUME));
+            }
+            wxGetApp().GetSettings().m_buildToolsDir = path;
         }
     }
 }