This is the mail archive of the ecos-patches@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Configtool to look for user and build tools relative to its own location


Index: ChangeLog
===================================================================
RCS file: /cvs/ecos/ecos/host/tools/configtool/ChangeLog,v
retrieving revision 1.32.2.13
diff -u -5 -r1.32.2.13 ChangeLog
--- ChangeLog	6 Apr 2003 20:52:02 -0000	1.32.2.13
+++ ChangeLog	7 Apr 2003 15:58:06 -0000
@@ -1,5 +1,11 @@
+2003-04-07  John Dallaway  <jld at ecoscentric dot 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 at ecoscentric dot com>

 	* standalone/wxwin/makefile.gnu: Build Cygwin hosted configtool with
 	"--subsystem windows" to eliminate the console window.
 
Index: standalone/wxwin/appsettings.cpp
===================================================================
RCS file: /cvs/ecos/ecos/host/tools/configtool/standalone/wxwin/appsettings.cpp,v
retrieving revision 1.7.2.3
diff -u -5 -r1.7.2.3 appsettings.cpp
--- standalone/wxwin/appsettings.cpp	20 Mar 2003 09:44:44 -0000	1.7.2.3
+++ standalone/wxwin/appsettings.cpp	7 Apr 2003 15:58:24 -0000
@@ -312,11 +312,40 @@
     }
 
     // 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__
         SYSTEM_INFO SystemInfo;
         GetSystemInfo(&SystemInfo);
@@ -576,17 +605,51 @@

             m_strRepository = envVarValue;
         }
     }

-#ifdef __WXGTK__
+#ifdef __WXMSW__
+    if (m_userToolsDir.IsEmpty())
+        m_userToolsDir =  GetCygwinInstallPath() + wxT("\\bin");
+#else
     if (m_userToolsDir.IsEmpty())
         m_userToolsDir = wxT("/bin");
 #endif

     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()
 {
     wxConfig config(wxGetApp().GetSettings().GetConfigAppName());
Index: standalone/wxwin/appsettings.h
===================================================================
RCS file: /cvs/ecos/ecos/host/tools/configtool/standalone/wxwin/appsettings.h,v
retrieving revision 1.4
diff -u -5 -r1.4 appsettings.h
--- standalone/wxwin/appsettings.h	15 Dec 2001 13:42:19 -0000	1.4
+++ standalone/wxwin/appsettings.h	7 Apr 2003 15:58:24 -0000
@@ -1,9 +1,10 @@
 //####COPYRIGHTBEGIN####
 //
 // ----------------------------------------------------------------------------
 // Copyright (C) 1998, 1999, 2000 Red Hat, Inc.
+// Copyright (C) 2003 John Dallaway
 //
 // This program is part of the eCos host tools.
 //
 // This program is free software; you can redistribute it and/or modify it
 // under the terms of the GNU General Public License as published by the Free
@@ -25,11 +26,11 @@
 // appsettings.h :
 //
 //===========================================================================
 //#####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 $
 // Purpose:
 // Description: Header file for the ConfigTool application settings
@@ -151,10 +152,15 @@
     // Finds the path of the latest installed eCos (Unix only)
     wxString FindLatestVersion();

     // 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

     wxString GetAppName() const { return m_appName; }



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]