mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-29 15:52:07 +00:00
Bug 927388 - Produce and upload GeckoView AAR during packaging. r=nalexander
This commit is contained in:
parent
f804ea1fe4
commit
4d1013a6c2
@ -0,0 +1,9 @@
|
|||||||
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
package="org.mozilla.gecko">
|
||||||
|
|
||||||
|
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
|
||||||
|
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
|
||||||
|
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
|
||||||
|
<uses-permission android:name="android.permission.INTERNET"/>
|
||||||
|
|
||||||
|
</manifest>
|
@ -13,14 +13,18 @@ from __future__ import print_function
|
|||||||
import argparse
|
import argparse
|
||||||
import hashlib
|
import hashlib
|
||||||
import os
|
import os
|
||||||
|
import shutil
|
||||||
import sys
|
import sys
|
||||||
|
import zipfile
|
||||||
|
|
||||||
from mozbuild import util
|
from mozbuild import util
|
||||||
from mozpack.copier import Jarrer
|
from mozpack.copier import Jarrer
|
||||||
from mozpack.files import (
|
from mozpack.files import (
|
||||||
File,
|
File,
|
||||||
FileFinder,
|
FileFinder,
|
||||||
|
JarFinder,
|
||||||
)
|
)
|
||||||
|
from mozpack.mozjar import JarReader
|
||||||
|
|
||||||
MAVEN_POM_TEMPLATE = r'''
|
MAVEN_POM_TEMPLATE = r'''
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
@ -31,9 +35,21 @@ MAVEN_POM_TEMPLATE = r'''
|
|||||||
<artifactId>{artifactId}</artifactId>
|
<artifactId>{artifactId}</artifactId>
|
||||||
<version>{version}</version>
|
<version>{version}</version>
|
||||||
<packaging>{packaging}</packaging>
|
<packaging>{packaging}</packaging>
|
||||||
|
<dependencies>
|
||||||
|
{dependencies}
|
||||||
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
'''.lstrip()
|
'''.lstrip()
|
||||||
|
|
||||||
|
MAVEN_POM_DEPENDENCY_TEMPLATE = r'''
|
||||||
|
<dependency>
|
||||||
|
<groupId>{groupId}</groupId>
|
||||||
|
<artifactId>{artifactId}</artifactId>
|
||||||
|
<version>{version}</version>
|
||||||
|
<type>{packaging}</type>
|
||||||
|
</dependency>
|
||||||
|
'''.lstrip()
|
||||||
|
|
||||||
IVY_XML_TEMPLATE = r'''
|
IVY_XML_TEMPLATE = r'''
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<ivy-module version="2.0">
|
<ivy-module version="2.0">
|
||||||
@ -42,10 +58,40 @@ IVY_XML_TEMPLATE = r'''
|
|||||||
<publications>
|
<publications>
|
||||||
<artifact name="{name}" type="{type}" ext="{ext}"/>
|
<artifact name="{name}" type="{type}" ext="{ext}"/>
|
||||||
</publications>
|
</publications>
|
||||||
<dependencies/>
|
<dependencies>
|
||||||
|
{dependencies}
|
||||||
|
</dependencies>
|
||||||
</ivy-module>
|
</ivy-module>
|
||||||
'''.lstrip()
|
'''.lstrip()
|
||||||
|
|
||||||
|
IVY_XML_DEPENDENCY_TEMPLATE = r'''
|
||||||
|
<dependency org="{organisation}" name="{name}" rev="{revision}" />
|
||||||
|
'''.lstrip()
|
||||||
|
|
||||||
|
def _zipdir(path, output_file):
|
||||||
|
zip = zipfile.ZipFile(output_file, "w")
|
||||||
|
for root, dirs, files in os.walk(path, topdown=True):
|
||||||
|
archive_root = root.replace(path, '')
|
||||||
|
for file in files:
|
||||||
|
zip.write(os.path.join(root, file), os.path.join(archive_root, file))
|
||||||
|
|
||||||
|
def _generate_geckoview_classes_jar(distdir, base_path):
|
||||||
|
base_folder = FileFinder(base_path, ignore=['gecko-R.jar'])
|
||||||
|
|
||||||
|
# Unzip all jar files into $(DISTDIR)/geckoview_aar_classes.
|
||||||
|
geckoview_aar_classes_path = os.path.join(distdir, 'geckoview_aar_classes')
|
||||||
|
shutil.rmtree(geckoview_aar_classes_path, ignore_errors=True)
|
||||||
|
util.ensureParentDir(geckoview_aar_classes_path)
|
||||||
|
|
||||||
|
for p, f in base_folder.find('*.jar'):
|
||||||
|
with zipfile.ZipFile(f.path) as zf:
|
||||||
|
zf.extractall(geckoview_aar_classes_path)
|
||||||
|
|
||||||
|
# Rezip them into a single classes.jar file.
|
||||||
|
classes_jar_path = os.path.join(distdir, 'classes.jar')
|
||||||
|
_zipdir(geckoview_aar_classes_path, classes_jar_path)
|
||||||
|
return File(classes_jar_path)
|
||||||
|
|
||||||
def package_geckolibs_aar(topsrcdir, distdir, output_file):
|
def package_geckolibs_aar(topsrcdir, distdir, output_file):
|
||||||
jarrer = Jarrer(optimize=False)
|
jarrer = Jarrer(optimize=False)
|
||||||
|
|
||||||
@ -71,12 +117,40 @@ def package_geckolibs_aar(topsrcdir, distdir, output_file):
|
|||||||
jarrer.copy(output_file)
|
jarrer.copy(output_file)
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
def package_geckoview_aar(topsrcdir, distdir, output_file):
|
||||||
|
jarrer = Jarrer(optimize=False)
|
||||||
|
fennec_path = os.path.join(distdir, 'fennec')
|
||||||
|
assets = FileFinder(os.path.join(fennec_path, 'assets'), ignore=['*.so'])
|
||||||
|
for p, f in assets.find('omni.ja'):
|
||||||
|
jarrer.add(os.path.join('assets', p), f)
|
||||||
|
|
||||||
|
# The folder that contains Fennec's JAR files and resources.
|
||||||
|
base_path = os.path.join(distdir, '..', 'mobile', 'android', 'base')
|
||||||
|
|
||||||
|
# The resource set is packaged during Fennec's build.
|
||||||
|
resjar = JarReader(os.path.join(base_path, 'geckoview_resources.zip'))
|
||||||
|
for p, f in JarFinder(p, resjar).find('*'):
|
||||||
|
jarrer.add(os.path.join('res', p), f)
|
||||||
|
|
||||||
|
# Package the contents of all Fennec JAR files into classes.jar.
|
||||||
|
classes_jar_file = _generate_geckoview_classes_jar(distdir, base_path)
|
||||||
|
jarrer.add('classes.jar', classes_jar_file)
|
||||||
|
|
||||||
|
# Add R.txt.
|
||||||
|
jarrer.add('R.txt', File(os.path.join(base_path, 'R.txt')))
|
||||||
|
|
||||||
|
# Finally add AndroidManifest.xml.
|
||||||
|
srcdir = os.path.join(topsrcdir, 'mobile', 'android', 'geckoview_library', 'geckoview')
|
||||||
|
jarrer.add('AndroidManifest.xml', File(os.path.join(srcdir, 'AndroidManifest.xml')))
|
||||||
|
|
||||||
|
jarrer.copy(output_file)
|
||||||
|
return 0
|
||||||
|
|
||||||
def main(args):
|
def main(args):
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
parser.add_argument(dest='dir',
|
parser.add_argument(dest='dir',
|
||||||
metavar='DIR',
|
metavar='DIR',
|
||||||
help='Path to write geckolibs Android ARchive and metadata to.')
|
help='Path to write Android ARchives and metadata to.')
|
||||||
parser.add_argument('--verbose', '-v', default=False, action='store_true',
|
parser.add_argument('--verbose', '-v', default=False, action='store_true',
|
||||||
help='be verbose')
|
help='be verbose')
|
||||||
parser.add_argument('--revision',
|
parser.add_argument('--revision',
|
||||||
@ -87,33 +161,82 @@ def main(args):
|
|||||||
help='Distribution directory (usually $OBJDIR/dist).')
|
help='Distribution directory (usually $OBJDIR/dist).')
|
||||||
args = parser.parse_args(args)
|
args = parser.parse_args(args)
|
||||||
|
|
||||||
|
# An Ivy 'publication' date must be given in the form yyyyMMddHHmmss, and Mozilla buildids are in this format.
|
||||||
|
if len(args.revision) != 14:
|
||||||
|
raise ValueError('Revision must be in yyyyMMddHHmmss format: %s' % args.revision)
|
||||||
|
|
||||||
paths_to_hash = []
|
paths_to_hash = []
|
||||||
|
|
||||||
aar = os.path.join(args.dir, 'geckolibs-{revision}.aar').format(revision=args.revision)
|
groupId='org.mozilla'
|
||||||
paths_to_hash.append(aar)
|
packaging_type='aar'
|
||||||
package_geckolibs_aar(args.topsrcdir, args.distdir, aar)
|
gecklibs_aar = os.path.join(args.dir, 'geckolibs-{revision}.aar').format(revision=args.revision)
|
||||||
|
paths_to_hash.append(gecklibs_aar)
|
||||||
|
geckoview_aar = os.path.join(args.dir, 'geckoview-{revision}.aar').format(revision=args.revision)
|
||||||
|
paths_to_hash.append(geckoview_aar)
|
||||||
|
|
||||||
pom = os.path.join(args.dir, 'geckolibs-{revision}.pom').format(revision=args.revision)
|
package_geckolibs_aar(args.topsrcdir, args.distdir, gecklibs_aar)
|
||||||
paths_to_hash.append(pom)
|
package_geckoview_aar(args.topsrcdir, args.distdir, geckoview_aar)
|
||||||
with open(pom, 'wt') as f:
|
|
||||||
f.write(MAVEN_POM_TEMPLATE.format(
|
geckolibs_pom_path = os.path.join(args.dir, 'geckolibs-{revision}.pom').format(revision=args.revision)
|
||||||
groupId='org.mozilla',
|
paths_to_hash.append(geckolibs_pom_path)
|
||||||
|
geckolibs_pom = MAVEN_POM_TEMPLATE.format(
|
||||||
|
groupId=groupId,
|
||||||
artifactId='geckolibs',
|
artifactId='geckolibs',
|
||||||
version=args.revision,
|
version=args.revision,
|
||||||
packaging='aar',
|
packaging=packaging_type,
|
||||||
))
|
dependencies=''
|
||||||
|
)
|
||||||
|
|
||||||
ivy = os.path.join(args.dir, 'ivy-geckolibs-{revision}.xml').format(revision=args.revision)
|
with open(geckolibs_pom_path, 'wt') as f:
|
||||||
paths_to_hash.append(ivy)
|
f.write(geckolibs_pom)
|
||||||
with open(ivy, 'wt') as f:
|
|
||||||
|
geckoview_pom_path = os.path.join(args.dir, 'geckoview-{revision}.pom').format(revision=args.revision)
|
||||||
|
paths_to_hash.append(geckoview_pom_path)
|
||||||
|
geckoview_pom = MAVEN_POM_TEMPLATE.format(
|
||||||
|
groupId=groupId,
|
||||||
|
artifactId='geckoview',
|
||||||
|
version=args.revision,
|
||||||
|
packaging=packaging_type,
|
||||||
|
dependencies=MAVEN_POM_DEPENDENCY_TEMPLATE.format(
|
||||||
|
groupId=groupId,
|
||||||
|
artifactId='geckolibs',
|
||||||
|
version=args.revision,
|
||||||
|
packaging=packaging_type
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
with open(geckoview_pom_path, 'wt') as f:
|
||||||
|
f.write(geckoview_pom)
|
||||||
|
|
||||||
|
geckolibs_ivy_path = os.path.join(args.dir, 'ivy-geckolibs-{revision}.xml').format(revision=args.revision)
|
||||||
|
paths_to_hash.append(geckolibs_ivy_path)
|
||||||
|
with open(geckolibs_ivy_path, 'wt') as f:
|
||||||
f.write(IVY_XML_TEMPLATE.format(
|
f.write(IVY_XML_TEMPLATE.format(
|
||||||
organisation='org.mozilla',
|
organisation=groupId,
|
||||||
module='geckolibs',
|
module='geckolibs',
|
||||||
revision=args.revision,
|
revision=args.revision,
|
||||||
publication=args.revision, # A white lie.
|
publication=args.revision, # A white lie.
|
||||||
name='geckolibs',
|
name='geckolibs',
|
||||||
type='aar',
|
type=packaging_type,
|
||||||
ext='aar',
|
ext=packaging_type,
|
||||||
|
dependencies=''
|
||||||
|
))
|
||||||
|
|
||||||
|
geckoview_ivy_path = os.path.join(args.dir, 'ivy-geckoview-{revision}.xml').format(revision=args.revision)
|
||||||
|
paths_to_hash.append(geckoview_ivy_path)
|
||||||
|
with open(geckoview_ivy_path, 'wt') as f:
|
||||||
|
f.write(IVY_XML_TEMPLATE.format(
|
||||||
|
organisation=groupId,
|
||||||
|
module='geckoview',
|
||||||
|
revision=args.revision,
|
||||||
|
publication=args.revision, # A white lie.
|
||||||
|
name='geckoview',
|
||||||
|
type=packaging_type,
|
||||||
|
ext=packaging_type,
|
||||||
|
dependencies=IVY_XML_DEPENDENCY_TEMPLATE.format(
|
||||||
|
organisation=groupId,
|
||||||
|
name='geckolibs',
|
||||||
|
revision=args.revision)
|
||||||
))
|
))
|
||||||
|
|
||||||
for p in paths_to_hash:
|
for p in paths_to_hash:
|
||||||
|
@ -363,18 +363,24 @@ 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'
|
INNER_MAKE_GECKOVIEW_EXAMPLE=echo 'GeckoView example packaging is only enabled on Nightly'
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# Create geckolibs Android ARchive and metadata for download by local
|
# Create Android ARchives and metadata for download by local
|
||||||
# developers using Gradle.
|
# developers using Gradle.
|
||||||
ifdef MOZ_ANDROID_GECKOLIBS_AAR
|
ifdef MOZ_ANDROID_GECKOLIBS_AAR
|
||||||
geckolibs-revision := $(BUILDID)
|
geckoaar-revision := $(BUILDID)
|
||||||
|
|
||||||
UPLOAD_EXTRA_FILES += \
|
UPLOAD_EXTRA_FILES += \
|
||||||
geckolibs-$(geckolibs-revision).aar \
|
geckolibs-$(geckoaar-revision).aar \
|
||||||
geckolibs-$(geckolibs-revision).aar.sha1 \
|
geckolibs-$(geckoaar-revision).aar.sha1 \
|
||||||
geckolibs-$(geckolibs-revision).pom \
|
geckolibs-$(geckoaar-revision).pom \
|
||||||
geckolibs-$(geckolibs-revision).pom.sha1 \
|
geckolibs-$(geckoaar-revision).pom.sha1 \
|
||||||
ivy-geckolibs-$(geckolibs-revision).xml \
|
ivy-geckolibs-$(geckoaar-revision).xml \
|
||||||
ivy-geckolibs-$(geckolibs-revision).xml.sha1 \
|
ivy-geckolibs-$(geckoaar-revision).xml.sha1 \
|
||||||
|
geckoview-$(geckoaar-revision).aar \
|
||||||
|
geckoview-$(geckoaar-revision).aar.sha1 \
|
||||||
|
geckoview-$(geckoaar-revision).pom \
|
||||||
|
geckoview-$(geckoaar-revision).pom.sha1 \
|
||||||
|
ivy-geckoview-$(geckoaar-revision).xml \
|
||||||
|
ivy-geckoview-$(geckoaar-revision).xml.sha1 \
|
||||||
$(NULL)
|
$(NULL)
|
||||||
|
|
||||||
INNER_MAKE_GECKOLIBS_AAR= \
|
INNER_MAKE_GECKOLIBS_AAR= \
|
||||||
|
Loading…
Reference in New Issue
Block a user