Bug 1352602 - Part 1: Don't AC_DEFINE ANDROID_TARGET_SDK, MOZ_ANDROID_{MIN,MAX}_SDK_VERSION. r=chmanchester draft
authorNick Alexander <nalexander@mozilla.com>
Wed, 21 Jun 2017 11:16:08 -0700
changeset 608534 0e55c0967cbb7f0df0d297eb330fc615e5759346
parent 608448 5c3e7cb5a35e1e56c7eb24ca392d22309f7af9f5
child 608535 07afb00de0e4a72af4026eb19ff4f2530c119336
push id68311
push usernalexander@mozilla.com
push dateThu, 13 Jul 2017 20:08:47 +0000
reviewerschmanchester
bugs1352602
milestone56.0a1
Bug 1352602 - Part 1: Don't AC_DEFINE ANDROID_TARGET_SDK, MOZ_ANDROID_{MIN,MAX}_SDK_VERSION. r=chmanchester This is just a small piece in the larger project of minimizing the set of global AC_DEFINEs. None of these are relevant to C/C++ code; they're mobile/android specific, so we should get them out of mozilla-config.h. In addition, this replaces hard-coded values with values from the build system throughout mobile/android. MozReview-Commit-ID: 9IJlsm38LFK
build/autoconf/android.m4
mobile/android/base/AndroidManifest.xml.in
mobile/android/base/generate_build_config.py
mobile/android/bouncer/AndroidManifest.xml.in
mobile/android/bouncer/moz.build
mobile/android/tests/background/junit3/AndroidManifest.xml.in
mobile/android/tests/background/junit3/moz.build
mobile/android/tests/browser/junit3/AndroidManifest.xml.in
mobile/android/tests/browser/junit3/moz.build
mobile/android/tests/browser/robocop/AndroidManifest.xml.in
mobile/android/tests/browser/robocop/moz.build
--- a/build/autoconf/android.m4
+++ b/build/autoconf/android.m4
@@ -324,17 +324,16 @@ case "$target" in
       AC_MSG_ERROR([The program emulator was not found.  Try |mach bootstrap|.])
     fi
 
     ANDROID_TARGET_SDK="${android_target_sdk}"
     ANDROID_SDK="${android_sdk}"
     ANDROID_SDK_ROOT="${android_sdk_root}"
     ANDROID_TOOLS="${android_tools}"
     ANDROID_BUILD_TOOLS_VERSION="$android_build_tools_version"
-    AC_DEFINE_UNQUOTED(ANDROID_TARGET_SDK,$ANDROID_TARGET_SDK)
     AC_SUBST(ANDROID_TARGET_SDK)
     AC_SUBST(ANDROID_SDK_ROOT)
     AC_SUBST(ANDROID_SDK)
     AC_SUBST(ANDROID_TOOLS)
     AC_SUBST(ANDROID_BUILD_TOOLS_VERSION)
 
     MOZ_ANDROID_AAR(customtabs, $ANDROID_SUPPORT_LIBRARY_VERSION, android, com/android/support)
     MOZ_ANDROID_AAR(appcompat-v7, $ANDROID_SUPPORT_LIBRARY_VERSION, android, com/android/support)
@@ -392,18 +391,14 @@ if test -n "$MOZ_ANDROID_MIN_SDK_VERSION
             AC_MSG_ERROR([--with-android-max-sdk must be at least the value of --with-android-min-sdk.])
         fi
     fi
 
     if test $MOZ_ANDROID_MIN_SDK_VERSION -gt $ANDROID_TARGET_SDK ; then
         AC_MSG_ERROR([--with-android-min-sdk is expected to be less than $ANDROID_TARGET_SDK])
     fi
 
-    AC_DEFINE_UNQUOTED(MOZ_ANDROID_MIN_SDK_VERSION, $MOZ_ANDROID_MIN_SDK_VERSION)
     AC_SUBST(MOZ_ANDROID_MIN_SDK_VERSION)
 fi
 
-if test -n "$MOZ_ANDROID_MAX_SDK_VERSION"; then
-    AC_DEFINE_UNQUOTED(MOZ_ANDROID_MAX_SDK_VERSION, $MOZ_ANDROID_MAX_SDK_VERSION)
-    AC_SUBST(MOZ_ANDROID_MAX_SDK_VERSION)
-fi
+AC_SUBST(MOZ_ANDROID_MAX_SDK_VERSION)
 
 ])
--- a/mobile/android/base/AndroidManifest.xml.in
+++ b/mobile/android/base/AndroidManifest.xml.in
@@ -8,17 +8,17 @@
 #ifdef MOZ_ANDROID_SHARED_ID
       android:sharedUserId="@MOZ_ANDROID_SHARED_ID@"
 #endif
       >
     <uses-sdk android:minSdkVersion="@MOZ_ANDROID_MIN_SDK_VERSION@"
 #ifdef MOZ_ANDROID_MAX_SDK_VERSION
               android:maxSdkVersion="@MOZ_ANDROID_MAX_SDK_VERSION@"
 #endif
-              android:targetSdkVersion="23"/>
+              android:targetSdkVersion="@ANDROID_TARGET_SDK@"/>
 
 <!-- The bouncer APK and the main APK should define the same set of
      <permission>, <uses-permission>, and <uses-feature> elements.  This reduces
      the likelihood of permission-related surprises when installing the main APK
      on top of a pre-installed bouncer APK.  Add such shared elements in the
      fileincluded here, so that they can be referenced by both APKs. -->
 #include FennecManifest_permissions.xml.in
 
--- a/mobile/android/base/generate_build_config.py
+++ b/mobile/android/base/generate_build_config.py
@@ -55,23 +55,26 @@ def _defines():
                 'MOZ_DEBUG',
                 'MOZ_INSTALL_TRACKING',
                 'MOZ_NATIVE_DEVICES',
                 'MOZ_SWITCHBOARD'):
         if CONFIG[var]:
             DEFINES[var] = 1
 
     for var in ('MOZ_ANDROID_GCM_SENDERID',
+                'MOZ_ANDROID_MAX_SDK_VERSION',
+                'MOZ_ANDROID_MIN_SDK_VERSION',
                 'MOZ_PKG_SPECIAL',
                 'MOZ_UPDATER'):
         if CONFIG[var]:
             DEFINES[var] = CONFIG[var]
 
     for var in ('ANDROID_CPU_ARCH',
                 'ANDROID_PACKAGE_NAME',
+                'ANDROID_TARGET_SDK',
                 'GRE_MILESTONE',
                 'MOZ_ANDROID_SHARED_ID',
                 'MOZ_ANDROID_APPLICATION_CLASS',
                 'MOZ_ANDROID_BROWSER_INTENT_CLASS',
                 'MOZ_ANDROID_SEARCH_INTENT_CLASS',
                 'MOZ_APP_BASENAME',
                 'MOZ_APP_DISPLAYNAME',
                 'MOZ_APP_ID',
--- a/mobile/android/bouncer/AndroidManifest.xml.in
+++ b/mobile/android/bouncer/AndroidManifest.xml.in
@@ -8,17 +8,17 @@
 #ifdef MOZ_ANDROID_SHARED_ID
       android:sharedUserId="@MOZ_ANDROID_SHARED_ID@"
 #endif
       >
     <uses-sdk android:minSdkVersion="@MOZ_ANDROID_MIN_SDK_VERSION@"
 #ifdef MOZ_ANDROID_MAX_SDK_VERSION
               android:maxSdkVersion="@MOZ_ANDROID_MAX_SDK_VERSION@"
 #endif
-              android:targetSdkVersion="23"/>
+              android:targetSdkVersion="@ANDROID_TARGET_SDK@"/>
 
 <!-- The bouncer APK and the main APK should define the same set of
      <permission>, <uses-permission>, and <uses-feature> elements.  This reduces
      the likelihood of permission-related surprises when installing the main APK
      on top of a pre-installed bouncer APK.  Add such shared elements in the
      fileincluded here, so that they can be referenced by both APKs. -->
 #include ../base/FennecManifest_permissions.xml.in
 
--- a/mobile/android/bouncer/moz.build
+++ b/mobile/android/bouncer/moz.build
@@ -2,22 +2,25 @@
 # vim: set filetype=python:
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 DEFINES['ANDROID_VERSION_CODE'] = '1'
 
 for var in ('ANDROID_PACKAGE_NAME',
+            'ANDROID_TARGET_SDK',
             'MOZ_ANDROID_BROWSER_INTENT_CLASS',
             'MOZ_APP_DISPLAYNAME',
             'MOZ_APP_VERSION'):
     DEFINES[var] = CONFIG[var]
 
 for var in ('MOZ_ANDROID_GCM',
+            'MOZ_ANDROID_MIN_SDK_VERSION',
+            'MOZ_ANDROID_MAX_SDK_VERSION',
             'MOZ_ANDROID_DOWNLOADS_INTEGRATION',
             'MOZ_ANDROID_BEAM',
             'MOZ_ANDROID_SEARCH_ACTIVITY',
             'MOZ_ANDROID_MLS_STUMBLER'):
     if CONFIG[var]:
         DEFINES[var] = CONFIG[var]
 
 ANDROID_APK_NAME = 'bouncer'
--- a/mobile/android/tests/background/junit3/AndroidManifest.xml.in
+++ b/mobile/android/tests/background/junit3/AndroidManifest.xml.in
@@ -1,17 +1,17 @@
 #filter substitution
 <?xml version="1.0" encoding="utf-8"?>
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
     package="org.mozilla.gecko.background.tests"
     sharedUserId="@MOZ_ANDROID_SHARED_ID@"
     android:versionCode="1"
     android:versionName="1.0" >
 
-    <uses-sdk android:minSdkVersion="8"
+    <uses-sdk android:minSdkVersion="@MOZ_ANDROID_MIN_SDK_VERSION@"
               android:targetSdkVersion="@ANDROID_TARGET_SDK@" />
 
     <application
         android:debuggable="true"
         android:icon="@drawable/icon"
         android:label="@ANDROID_BACKGROUND_APP_DISPLAYNAME@">
         <uses-library android:name="android.test.runner" />
     </application>
--- a/mobile/android/tests/background/junit3/moz.build
+++ b/mobile/android/tests/background/junit3/moz.build
@@ -1,15 +1,22 @@
 # -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=python:
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-DEFINES['ANDROID_PACKAGE_NAME'] = CONFIG['ANDROID_PACKAGE_NAME']
+for var in ('ANDROID_PACKAGE_NAME',
+            'ANDROID_TARGET_SDK'):
+    DEFINES[var] = CONFIG[var]
+
+for var in ('MOZ_ANDROID_MIN_SDK_VERSION',
+            'MOZ_ANDROID_MAX_SDK_VERSION'):
+    if CONFIG[var]:
+        DEFINES[var] = CONFIG[var]
 
 ANDROID_APK_NAME = 'background-junit3-debug'
 ANDROID_APK_PACKAGE = 'org.mozilla.gecko.background.tests'
 
 include('background_junit3_sources.mozbuild')
 
 jar = add_java_jar('background-junit3')
 jar.sources += background_junit3_sources
--- a/mobile/android/tests/browser/junit3/AndroidManifest.xml.in
+++ b/mobile/android/tests/browser/junit3/AndroidManifest.xml.in
@@ -1,17 +1,17 @@
 #filter substitution
 <?xml version="1.0" encoding="utf-8"?>
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
     package="org.mozilla.gecko.browser.tests"
     sharedUserId="@MOZ_ANDROID_SHARED_ID@"
     android:versionCode="1"
     android:versionName="1.0" >
 
-    <uses-sdk android:minSdkVersion="8"
+    <uses-sdk android:minSdkVersion="@MOZ_ANDROID_MIN_SDK_VERSION@"
               android:targetSdkVersion="@ANDROID_TARGET_SDK@" />
 
     <application
         android:debuggable="true"
         android:icon="@drawable/icon"
         android:label="@ANDROID_BROWSER_APP_DISPLAYNAME@">
         <uses-library android:name="android.test.runner" />
     </application>
--- a/mobile/android/tests/browser/junit3/moz.build
+++ b/mobile/android/tests/browser/junit3/moz.build
@@ -1,15 +1,22 @@
 # -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=python:
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-DEFINES['ANDROID_PACKAGE_NAME'] = CONFIG['ANDROID_PACKAGE_NAME']
+for var in ('ANDROID_PACKAGE_NAME',
+            'ANDROID_TARGET_SDK'):
+    DEFINES[var] = CONFIG[var]
+
+for var in ('MOZ_ANDROID_MIN_SDK_VERSION',
+            'MOZ_ANDROID_MAX_SDK_VERSION'):
+    if CONFIG[var]:
+        DEFINES[var] = CONFIG[var]
 
 ANDROID_APK_NAME = 'browser-junit3-debug'
 ANDROID_APK_PACKAGE = 'org.mozilla.gecko.browser.tests'
 
 jar = add_java_jar('browser-junit3')
 jar.sources += [
     'src/org/mozilla/tests/browser/junit3/harness/BrowserInstrumentationTestRunner.java',
     'src/org/mozilla/tests/browser/junit3/harness/BrowserTestListener.java',
--- a/mobile/android/tests/browser/robocop/AndroidManifest.xml.in
+++ b/mobile/android/tests/browser/robocop/AndroidManifest.xml.in
@@ -7,17 +7,17 @@
 #endif
     android:versionCode="1"
     android:versionName="1.0" >
 
     <uses-sdk android:minSdkVersion="@MOZ_ANDROID_MIN_SDK_VERSION@"
 #ifdef MOZ_ANDROID_MAX_SDK_VERSION
               android:maxSdkVersion="@MOZ_ANDROID_MAX_SDK_VERSION@"
 #endif
-              android:targetSdkVersion="23"/>
+              android:targetSdkVersion="@ANDROID_TARGET_SDK@"/>
 
     <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
 
     <uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
     <uses-permission android:name="android.permission.WAKE_LOCK" />
 
     <instrumentation
         android:name="org.mozilla.gecko.FennecInstrumentationTestRunner"
--- a/mobile/android/tests/browser/robocop/moz.build
+++ b/mobile/android/tests/browser/robocop/moz.build
@@ -1,15 +1,22 @@
 # -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=python:
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-DEFINES['ANDROID_PACKAGE_NAME'] = CONFIG['ANDROID_PACKAGE_NAME']
+for var in ('ANDROID_PACKAGE_NAME',
+            'ANDROID_TARGET_SDK'):
+    DEFINES[var] = CONFIG[var]
+
+for var in ('MOZ_ANDROID_MIN_SDK_VERSION',
+            'MOZ_ANDROID_MAX_SDK_VERSION'):
+    if CONFIG[var]:
+        DEFINES[var] = CONFIG[var]
 
 ANDROID_APK_NAME = 'robocop-debug'
 ANDROID_APK_PACKAGE = 'org.mozilla.roboexample.test'
 ANDROID_ASSETS_DIRS += ['assets']
 
 TEST_HARNESS_FILES.testing.mochitest += [
     'robocop.ini',
     'robocop_autophone.ini',