Bug 1093242 - Produce and upload geckolibs artifacts for Android API v11+ opt builds. r=gps

The Android ARchive contains the compiled Gecko libraries that Firefox
for Android interfaces to.  It does not contain the Gecko resources
(the omnijar, omni.ja) nor the compiled Java code (classes.dex).

This also uploads metadata and sha1 hashes for future consumption by
Maven and/or Ivy dependency managers.  In some brave future world,
we'll work out exactly what that looks like; for now, this solves a
storage problem (each .aar file is ~20MB) and it's possible to point
Gradle directly at the uploaded Ivy metadata and artifacts.
This commit is contained in:
Nick Alexander 2015-02-17 17:23:23 -08:00
parent 9b1126b8fa
commit 7f50a87bf6
7 changed files with 159 additions and 4 deletions

View File

@ -8535,6 +8535,7 @@ AC_SUBST(MOZ_WEBSMS_BACKEND)
AC_SUBST(MOZ_ANDROID_BEAM)
AC_SUBST(MOZ_LOCALE_SWITCHER)
AC_SUBST(MOZ_DISABLE_GECKOVIEW)
AC_SUBST(MOZ_ANDROID_GECKOLIBS_AAR)
AC_SUBST(MOZ_ANDROID_READING_LIST_SERVICE)
AC_SUBST(MOZ_ANDROID_SEARCH_ACTIVITY)
AC_SUBST(MOZ_ANDROID_SHARE_OVERLAY)

View File

@ -15,4 +15,6 @@ STRIP_FLAGS="--strip-debug"
export MOZILLA_OFFICIAL=1
export MOZ_TELEMETRY_REPORTING=1
MOZ_ANDROID_GECKOLIBS_AAR=1
. "$topsrcdir/mobile/android/config/mozconfigs/common.override"

View File

@ -0,0 +1,4 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.mozilla.gecko.libs">
</manifest>

Binary file not shown.

View File

@ -0,0 +1,125 @@
# 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/.
'''
Script to produce an Android ARchive (.aar) containing the compiled
Gecko library binaries. The AAR file is intended for use by local
developers using Gradle.
'''
from __future__ import print_function
import argparse
import hashlib
import os
import sys
from mozbuild import util
from mozpack.copier import Jarrer
from mozpack.files import (
File,
FileFinder,
)
MAVEN_POM_TEMPLATE = r'''
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>{groupId}</groupId>
<artifactId>{artifactId}</artifactId>
<version>{version}</version>
<packaging>{packaging}</packaging>
</project>
'''.lstrip()
IVY_XML_TEMPLATE = r'''
<?xml version="1.0" encoding="UTF-8"?>
<ivy-module version="2.0">
<info organisation="{organisation}" module="{module}" revision="{revision}" status="integration" publication="{publication}"/>
<configurations/>
<publications>
<artifact name="{name}" type="{type}" ext="{ext}"/>
</publications>
<dependencies/>
</ivy-module>
'''.lstrip()
def package_geckolibs_aar(topsrcdir, distdir, output_file):
jarrer = Jarrer(optimize=False)
srcdir = os.path.join(topsrcdir, 'mobile', 'android', 'geckoview_library', 'geckolibs')
jarrer.add('AndroidManifest.xml', File(os.path.join(srcdir, 'AndroidManifest.xml')))
jarrer.add('classes.jar', File(os.path.join(srcdir, 'classes.jar')))
jni = FileFinder(os.path.join(distdir, 'fennec', 'lib'))
for p, f in jni.find('**/*.so'):
jarrer.add(os.path.join('jni', p), f)
# Include the buildinfo JSON as an asset, to give future consumers at least
# a hope of determining where this AAR came from.
json = FileFinder(distdir, ignore=['*.mozinfo.json'])
for p, f in json.find('*.json'):
jarrer.add(os.path.join('assets', p), f)
# This neatly ignores omni.ja.
assets = FileFinder(os.path.join(distdir, 'fennec', 'assets'))
for p, f in assets.find('**/*.so'):
jarrer.add(os.path.join('assets', p), f)
jarrer.copy(output_file)
return 0
def main(args):
parser = argparse.ArgumentParser()
parser.add_argument(dest='dir',
metavar='DIR',
help='Path to write geckolibs Android ARchive and metadata to.')
parser.add_argument('--revision',
help='Revision identifier to write.')
parser.add_argument('--topsrcdir',
help='Top source directory.')
parser.add_argument('--distdir',
help='Distribution directory (usually $OBJDIR/dist).')
args = parser.parse_args(args)
paths_to_hash = []
aar = os.path.join(args.dir, 'geckolibs-{revision}.aar').format(revision=args.revision)
paths_to_hash.append(aar)
package_geckolibs_aar(args.topsrcdir, args.distdir, aar)
pom = os.path.join(args.dir, 'geckolibs-{revision}.pom').format(revision=args.revision)
paths_to_hash.append(pom)
with open(pom, 'wt') as f:
f.write(MAVEN_POM_TEMPLATE.format(
groupId='org.mozilla',
artifactId='geckolibs',
version=args.revision,
packaging='aar',
))
ivy = os.path.join(args.dir, 'ivy-geckolibs-{revision}.xml').format(revision=args.revision)
paths_to_hash.append(ivy)
with open(ivy, 'wt') as f:
f.write(IVY_XML_TEMPLATE.format(
organisation='org.mozilla',
module='geckolibs',
revision=args.revision,
publication=args.revision, # A white lie.
name='geckolibs',
type='aar',
ext='aar',
))
for p in paths_to_hash:
with open("%s.sha1" % p, 'wt') as f:
f.write(util.hash_file(p, hasher=hashlib.sha1()))
return 0
if __name__ == '__main__':
sys.exit(main(sys.argv[1:]))

View File

@ -31,12 +31,12 @@ if sys.version_info[0] == 3:
else:
str_type = basestring
def hash_file(path):
def hash_file(path, hasher=None):
"""Hashes a file specified by the path given and returns the hex digest."""
# If the hashing function changes, this may invalidate lots of cached data.
# Don't change it lightly.
h = hashlib.sha1()
# If the default hashing function changes, this may invalidate
# lots of cached data. Don't change it lightly.
h = hasher or hashlib.sha1()
with open(path, 'rb') as fh:
while True:

View File

@ -362,6 +362,28 @@ INNER_MAKE_GECKOVIEW_LIBRARY=echo 'GeckoView library packaging is only enabled o
INNER_MAKE_GECKOVIEW_EXAMPLE=echo 'GeckoView example packaging is only enabled on Nightly'
endif
# Create geckolibs Android ARchive and metadata for download by local
# developers using Gradle.
ifdef MOZ_ANDROID_GECKOLIBS_AAR
UPLOAD_EXTRA_FILES += \
geckolibs-$(geckolibs-revision).aar \
geckolibs-$(geckolibs-revision).aar.sha1 \
geckolibs-$(geckolibs-revision).pom \
geckolibs-$(geckolibs-revision).pom.sha1 \
ivy-geckolibs-$(geckolibs-revision).xml \
ivy-geckolibs-$(geckolibs-revision).xml.sha1 \
$(NULL)
INNER_MAKE_GECKOLIBS_AAR= \
$(PYTHON) -m mozbuild.action.package_geckolibs_aar \
--revision '$(BUILDID)' \
--topsrcdir '$(topsrcdir)' \
--distdir '$(_ABS_DIST)' \
'$(_ABS_DIST)'
else
INNER_MAKE_GECKOLIBS_AAR=echo 'Android geckolibs.aar packaging is disabled'
endif
ifdef MOZ_OMX_PLUGIN
DIST_FILES += libomxplugin.so libomxplugingb.so libomxplugingb235.so \
libomxpluginhc.so libomxpluginkk.so
@ -438,6 +460,7 @@ INNER_MAKE_PACKAGE = \
$(RELEASE_JARSIGNER) $(_ABS_DIST)/gecko.apk && \
$(ZIPALIGN) -f -v 4 $(_ABS_DIST)/gecko.apk $(PACKAGE) && \
$(INNER_ROBOCOP_PACKAGE) && \
$(INNER_MAKE_GECKOLIBS_AAR) && \
$(INNER_MAKE_GECKOVIEW_LIBRARY) && \
$(INNER_MAKE_GECKOVIEW_EXAMPLE)