Bug 1365419 - Allow to apply manifest entries for all non-(Darwin,Windows,Android) OSes. r?bsmedberg draft
authorMike Hommey <mh+mozilla@glandium.org>
Fri, 26 May 2017 08:56:18 +0900
changeset 588014 b4669d944e2bd12804e75d35c7bbf539261e8b48
parent 587906 b138d2f271fdb598bf8a66c2dcb7fe391ca2a96f
child 588015 3a7f1b7d021fabf21521956b3f557b9a47b3ebbf
push id61882
push userbmo:mh+mozilla@glandium.org
push dateFri, 02 Jun 2017 01:53:45 +0000
reviewersbsmedberg
bugs1365419
milestone55.0a1
Bug 1365419 - Allow to apply manifest entries for all non-(Darwin,Windows,Android) OSes. r?bsmedberg Manifest entries can contain flags, one of which allows to match on the os running Gecko. The match is performed against the value returned by nsIXULRuntime.getOS, which itself comes from the build-system's OS_TARGET. In practice, this means that things like os=WINNT, os=Darwin, os=Android, os=Linux are valid filters, but the latter is too specific, and most of the time, one would want something that is "any OS but WINNT, Darwin, Android", which can't be expressed with manifest entry flags (there is no "and" for them, only "or"). For convenience, we add the keyword "LikeUnix", which has that meaning.
xpcom/components/ManifestParser.cpp
--- a/xpcom/components/ManifestParser.cpp
+++ b/xpcom/components/ManifestParser.cpp
@@ -314,16 +314,29 @@ CheckStringFlag(const nsSubstring& aFlag
     } else {
       aResult = comparison ? eBad : eOK;
     }
   }
 
   return true;
 }
 
+static bool
+CheckOsFlag(const nsSubstring& aFlag, const nsSubstring& aData,
+            const nsSubstring& aValue, TriState& aResult)
+{
+  bool result = CheckStringFlag(aFlag, aData, aValue, aResult);
+#if defined(XP_UNIX) && !defined(XP_DARWIN) && !defined(ANDROID)
+  if (result && aResult == eBad) {
+    result = CheckStringFlag(aFlag, aData, NS_LITERAL_STRING("likeunix"), aResult);
+  }
+#endif
+  return result;
+}
+
 /**
  * Check for a modifier flag of the following form:
  *   "flag=version"
  *   "flag<=version"
  *   "flag<version"
  *   "flag>=version"
  *   "flag>version"
  * @param aFlag The flag to compare.
@@ -660,17 +673,17 @@ ParseManifest(NSLocationType aType, File
     int flags = 0;
 
     while ((token = nsCRT::strtok(whitespace, kWhitespace, &whitespace)) &&
            ok) {
       ToLowerCase(token);
       NS_ConvertASCIItoUTF16 wtoken(token);
 
       if (CheckStringFlag(kApplication, wtoken, appID, stApp) ||
-          CheckStringFlag(kOs, wtoken, osTarget, stOs) ||
+          CheckOsFlag(kOs, wtoken, osTarget, stOs) ||
           CheckStringFlag(kABI, wtoken, abi, stABI) ||
           CheckStringFlag(kProcess, wtoken, process, stProcess) ||
           CheckVersionFlag(kOsVersion, wtoken, osVersion, stOsVersion) ||
           CheckVersionFlag(kAppVersion, wtoken, appVersion, stAppVersion) ||
           CheckVersionFlag(kGeckoVersion, wtoken, geckoVersion, stGeckoVersion)) {
         continue;
       }