Bug 420373 - "need a way to distinguish GREs based on architecture in nsGREGlue" [p=mozilla@rosenauer.org (Wolfgang Rosenauer) r=bsmedberg a1.9b5=schrep]
authorreed@reedloden.com
Fri, 21 Mar 2008 21:25:34 -0700
changeset 13460 db081fb58e333960068c85df8ebc54dcb2969be2
parent 13459 07d36f2e9f45c90fec734c4983eee9b6c5cd1043
child 13461 8fe950195468431972f7d373841df3f78c87c994
push id2
push userjorendorff@mozilla.com
push dateWed, 26 Mar 2008 17:39:06 +0000
treeherdermozilla-central@1d969540aa4e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbsmedberg
bugs420373
milestone1.9b5pre
Bug 420373 - "need a way to distinguish GREs based on architecture in nsGREGlue" [p=mozilla@rosenauer.org (Wolfgang Rosenauer) r=bsmedberg a1.9b5=schrep]
xpcom/build/Makefile.in
xpcom/glue/Makefile.in
xpcom/glue/nsGREGlue.cpp
xpcom/glue/standalone/Makefile.in
xulrunner/app/Makefile.in
xulrunner/app/nsXULRunnerApp.cpp
xulrunner/installer/Makefile.in
--- a/xpcom/build/Makefile.in
+++ b/xpcom/build/Makefile.in
@@ -169,16 +169,20 @@ DEFINES		+= \
 		-DEXPORT_XPTC_API
 
 EXTRA_DSO_LDOPTS += $(NSPR_LIBS)
 
 ifdef GC_LEAK_DETECTOR
 DEFINES += -DGC_LEAK_DETECTOR
 endif
 
+ifdef TARGET_XPCOM_ABI
+DEFINES += -DTARGET_XPCOM_ABI=\"$(TARGET_XPCOM_ABI)\"
+endif
+
 ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT)))
 CXXFLAGS	+= $(TK_CFLAGS)
 EXTRA_DSO_LDOPTS += \
   ../MoreFiles/$(LIB_PREFIX)macmorefiles_s.$(LIB_SUFFIX) \
   $(TK_LIBS) \
   $(NULL)
 endif
 
--- a/xpcom/glue/Makefile.in
+++ b/xpcom/glue/Makefile.in
@@ -140,8 +140,12 @@ USE_STATIC_LIBS = 1
 include $(topsrcdir)/config/rules.mk
 
 ifdef _MSC_VER
 # Don't include directives about which CRT to use
 OS_COMPILE_CXXFLAGS += -Zl
 OS_COMPILE_CFLAGS += -Zl
 DEFINES += -D_USE_ANSI_CPP
 endif
+
+ifdef TARGET_XPCOM_ABI
+DEFINES += -DTARGET_XPCOM_ABI=\"$(TARGET_XPCOM_ABI)\"
+endif
--- a/xpcom/glue/nsGREGlue.cpp
+++ b/xpcom/glue/nsGREGlue.cpp
@@ -148,16 +148,38 @@ GRE_GetPathFromRegKey(HKEY aRegKey,
 
 nsresult
 GRE_GetGREPathWithProperties(const GREVersionRange *versions,
                              PRUint32 versionsLength,
                              const GREProperty *properties,
                              PRUint32 propertiesLength,
                              char *aBuffer, PRUint32 aBufLen)
 {
+#ifdef TARGET_XPCOM_ABI
+  // append the ABI to the properties to match only binary 
+  // compatible GREs
+  static const GREProperty kExtraProperty =
+    { "abi", TARGET_XPCOM_ABI };
+
+  GREProperty *allProperties = new GREProperty[propertiesLength + 1];
+  if (!allProperties)
+    return NS_ERROR_OUT_OF_MEMORY;
+
+  for (PRUint32 i=0; i<propertiesLength; i++) {
+    allProperties[i].property = properties[i].property;
+    allProperties[i].value    = properties[i].value;
+  }
+  allProperties[propertiesLength].property = kExtraProperty.property;
+  allProperties[propertiesLength].value    = kExtraProperty.value;
+  PRUint32 allPropertiesLength = propertiesLength + 1;
+#else
+  GREProperty *allProperties = properties;
+  PRUint32 allPropertiesLength = propertiesLength;
+#endif
+
   // if GRE_HOME is in the environment, use that GRE
   const char* env = getenv("GRE_HOME");
   if (env && *env) {
     char p[MAXPATHLEN];
     snprintf(p, sizeof(p), "%s" XPCOM_FILE_PATH_SEPARATOR XPCOM_DLL, env);
     p[sizeof(p) - 1] = '\0';
 
 #if XP_UNIX
@@ -251,140 +273,140 @@ GRE_GetGREPathWithProperties(const GREVe
 
   if (aBuffer[0])
     return NS_OK;
 
   // Check ~/Library/Frameworks/XUL.framework/Versions/<version>/libxpcom.dylib
   const char *home = getenv("HOME");
   if (home && *home && GRE_FindGREFramework(home,
                                             versions, versionsLength,
-                                            properties, propertiesLength,
+                                            allProperties, allPropertiesLength,
                                             aBuffer, aBufLen)) {
     return NS_OK;
   }
 
   // Check /Library/Frameworks/XUL.framework/Versions/<version>/libxpcom.dylib
   if (GRE_FindGREFramework("",
                            versions, versionsLength,
-                           properties, propertiesLength,
+                           allProperties, allPropertiesLength,
                            aBuffer, aBufLen)) {
     return NS_OK;
   }
 
 #elif defined(XP_UNIX) 
   env = getenv("MOZ_GRE_CONF");
   if (env && GRE_GetPathFromConfigFile(env,
                                        versions, versionsLength,
-                                       properties, propertiesLength,
+                                       allProperties, allPropertiesLength,
                                        aBuffer, aBufLen)) {
     return NS_OK;
   }
 
   env = getenv("HOME");
   if (env && *env) {
     char buffer[MAXPATHLEN];
 
     // Look in ~/.gre.config
 
     snprintf(buffer, sizeof(buffer),
              "%s" XPCOM_FILE_PATH_SEPARATOR GRE_CONF_NAME, env);
     
     if (GRE_GetPathFromConfigFile(buffer,
                                   versions, versionsLength,
-                                  properties, propertiesLength,
+                                  allProperties, allPropertiesLength,
                                   aBuffer, aBufLen)) {
       return NS_OK;
     }
 
     // Look in ~/.gre.d/*.conf
 
     snprintf(buffer, sizeof(buffer),
              "%s" XPCOM_FILE_PATH_SEPARATOR GRE_USER_CONF_DIR, env);
 
     if (GRE_GetPathFromConfigDir(buffer,
                                  versions, versionsLength,
-                                 properties, propertiesLength,
+                                 allProperties, allPropertiesLength,
                                  aBuffer, aBufLen)) {
       return NS_OK;
     }
   }
 
   // Look for a global /etc/gre.conf file
   if (GRE_GetPathFromConfigFile(GRE_CONF_PATH,
                                 versions, versionsLength,
-                                properties, propertiesLength,
+                                allProperties, allPropertiesLength,
                                 aBuffer, aBufLen)) {
     return NS_OK;
   }
 
   // Look for a group of config files in /etc/gre.d/
   if (GRE_GetPathFromConfigDir(GRE_CONF_DIR,
                                versions, versionsLength,
-                               properties, propertiesLength,
+                               allProperties, allPropertiesLength,
                                aBuffer, aBufLen)) {
     return NS_OK;
   }
 
 #elif defined(XP_BEOS)
   env = getenv("MOZ_GRE_CONF");
   if (env && GRE_GetPathFromConfigFile(env,
                                        versions, versionsLength,
-                                       properties, propertiesLength,
+                                       allProperties, allPropertiesLength,
                                        aBuffer, aBufLen)) {
     return NS_OK;
   }
 
   char p[MAXPATHLEN]; 
   if (find_directory(B_USER_SETTINGS_DIRECTORY, 0, 0, p, MAXPATHLEN)) {
     char buffer[MAXPATHLEN];
 
     // Look in B_USER_SETTINGS_DIRECTORY/gre.config
     snprintf(buffer, sizeof(buffer),
              "%s" XPCOM_FILE_PATH_SEPARATOR GRE_CONF_NAME, p);
     
     if (GRE_GetPathFromConfigFile(buffer,
                                   versions, versionsLength,
-                                  properties, propertiesLength,
+                                  allProperties, allPropertiesLength,
                                   aBuffer, aBufLen)) {
       return NS_OK;
     }
 
     // Look in B_USER_SETTINGS_DIRECTORY/gre.d/*.conf
     snprintf(buffer, sizeof(buffer),
              "%s" XPCOM_FILE_PATH_SEPARATOR GRE_CONF_DIR, p);
 
     if (GRE_GetPathFromConfigDir(buffer,
                                  versions, versionsLength,
-                                 properties, propertiesLength,
+                                 allProperties, allPropertiesLength,
                                  aBuffer, aBufLen)) {
       return NS_OK;
     }
   }
   
   // Hope Zeta OS and Haiku OS multiuser versions will respect BeBook,
   // for BeOS R5 COMMON and USER are equal
   if (find_directory(B_COMMON_SETTINGS_DIRECTORY, 0, 0, p, MAXPATHLEN)) {
     char buffer[MAXPATHLEN];
     
     // Look for a B_COMMON_SETTINGS_DIRECTORY/gre.conf file
     snprintf(buffer, sizeof(buffer),
              "%s" XPCOM_FILE_PATH_SEPARATOR GRE_CONF_PATH, p);
     if (GRE_GetPathFromConfigFile(buffer,
                                   versions, versionsLength,
-                                  properties, propertiesLength,
+                                  allProperties, allPropertiesLength,
                                   aBuffer, aBufLen)) {
       return NS_OK;
     }
 
     // Look for a group of config files in B_COMMON_SETTINGS_DIRECTORY/gre.d/
     snprintf(buffer, sizeof(buffer),
              "%s" XPCOM_FILE_PATH_SEPARATOR GRE_CONF_DIR, p);
     if (GRE_GetPathFromConfigDir(buffer,
                                  versions, versionsLength,
-                                 properties, propertiesLength,
+                                 allProperties, allPropertiesLength,
                                  aBuffer, aBufLen)) {
       return NS_OK;
     }
   }
 
 #elif defined(XP_WIN)
   HKEY hRegKey = NULL;
     
@@ -398,29 +420,29 @@ GRE_GetGREPathWithProperties(const GREVe
   //
   // Please see http://www.mozilla.org/projects/embedding/GRE.html for
   // more info.
   //
   if (::RegOpenKeyEx(HKEY_CURRENT_USER, GRE_WIN_REG_LOC, 0,
                      KEY_READ, &hRegKey) == ERROR_SUCCESS) {
     PRBool ok = GRE_GetPathFromRegKey(hRegKey,
                                       versions, versionsLength,
-                                      properties, propertiesLength,
+                                      allProperties, allPropertiesLength,
                                       aBuffer, aBufLen);
     ::RegCloseKey(hRegKey);
 
     if (ok)
       return NS_OK;
   }
 
   if (::RegOpenKeyEx(HKEY_LOCAL_MACHINE, GRE_WIN_REG_LOC, 0,
                      KEY_ENUMERATE_SUB_KEYS, &hRegKey) == ERROR_SUCCESS) {
     PRBool ok = GRE_GetPathFromRegKey(hRegKey,
                                       versions, versionsLength,
-                                      properties, propertiesLength,
+                                      allProperties, allPropertiesLength,
                                       aBuffer, aBufLen);
     ::RegCloseKey(hRegKey);
 
     if (ok)
       return NS_OK;
   }
 #endif
 
@@ -654,17 +676,17 @@ GRE_GetPathFromRegKey(HKEY aRegKey,
   // HKLM/Software/mozilla.org/GRE/<version> valuepair GreHome=Path.
   // Nowadays, they are registered in any subkey of
   // Software/mozilla.org/GRE, with the following valuepairs:
   //   Version=<version> (REG_SZ)
   //   GreHome=<path>    (REG_SZ or REG_EXPAND_SZ)
   //   <Property>=<value> (REG_SZ)
   //
   // Additional meta-info may be available in the future, including
-  // localization info, ABI, and other information which might be pertinent
+  // localization info and other information which might be pertinent
   // to selecting one GRE over another.
   //
   // When a GRE is being registered, it should try to register itself at
   // HKLM/Software/mozilla.org/GRE/<Version> first, to preserve compatibility
   // with older glue. If this key is already taken (i.e. there is more than
   // one GRE of that version installed), it should append a unique number to
   // the version, for example:
   //   1.1 (already in use), 1.1_1, 1.1_2, etc...
--- a/xpcom/glue/standalone/Makefile.in
+++ b/xpcom/glue/standalone/Makefile.in
@@ -121,8 +121,13 @@ DEFINES += -D_USE_ANSI_CPP
 endif
 
 export:: $(XPCOM_GLUE_SRC_CSRCS) $(XPCOM_GLUE_SRC_CPPSRCS) $(topsrcdir)/xpcom/glue/nsStringAPI.cpp
 	$(INSTALL) $^ .
 
 GARBAGE += nsStringAPI.cpp
 
 DEFINES		+= -DXPCOM_GLUE
+
+ifdef TARGET_XPCOM_ABI
+DEFINES += -DTARGET_XPCOM_ABI=\"$(TARGET_XPCOM_ABI)\"
+endif
+
--- a/xulrunner/app/Makefile.in
+++ b/xulrunner/app/Makefile.in
@@ -60,16 +60,20 @@ else
 PROGRAM = xulrunner-bin$(BIN_SUFFIX)
 endif
 DEFINES += -DXULRUNNER_PROGNAME=\"xulrunner\"
 
 ifdef MOZ_JAVAXPCOM
 DEFINES += -DMOZ_JAVAXPCOM
 endif
 
+ifdef TARGET_XPCOM_ABI
+DEFINES += -DTARGET_XPCOM_ABI=\"$(TARGET_XPCOM_ABI)\"
+endif
+
 REQUIRES = \
         xpcom \
         string \
         appshell \
         xulapp \
         xulrunner \
 	$(NULL)
 
--- a/xulrunner/app/nsXULRunnerApp.cpp
+++ b/xulrunner/app/nsXULRunnerApp.cpp
@@ -248,16 +248,19 @@ InstallXULApp(nsIFile* aXULRunnerDir,
   if (NS_FAILED(rv))
     return 3;
 
   return 0;
 }
 
 static const GREProperty kGREProperties[] = {
   { "xulrunner", "true" }
+#ifdef TARGET_XPCOM_ABI
+  , { "abi", TARGET_XPCOM_ABI }
+#endif
 #ifdef MOZ_JAVAXPCOM
   , { "javaxpcom", "1" }
 #endif
 };
 
 class AutoAppData
 {
 public:
--- a/xulrunner/installer/Makefile.in
+++ b/xulrunner/installer/Makefile.in
@@ -63,17 +63,18 @@ endif
 
 include $(topsrcdir)/config/rules.mk
 
 INSTALL_SDK = 1
 
 include $(topsrcdir)/toolkit/mozapps/installer/packager.mk
 
 $(MOZILLA_VERSION).system.conf: $(topsrcdir)/config/milestone.txt Makefile
-	printf "[%s]\nGRE_PATH=%s\nxulrunner=true" $(MOZILLA_VERSION) $(installdir)> $@
+	printf "[%s]\nGRE_PATH=%s\nxulrunner=true\nabi=%s" \
+	  $(MOZILLA_VERSION) $(installdir) $(TARGET_XPCOM_ABI)> $@
 
 ifndef SKIP_GRE_REGISTRATION
 # to register xulrunner per-user, override this with $HOME/.gre.d
 regdir = /etc/gre.d
 
 install:: $(MOZILLA_VERSION).system.conf
 	$(NSINSTALL) -D $(DESTDIR)$(regdir)
 	$(SYSINSTALL) $^ $(DESTDIR)$(regdir)