2016-07-14 19:16:42 +03:00
|
|
|
# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
|
2016-03-17 21:04:08 +03:00
|
|
|
# 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/.
|
|
|
|
|
|
|
|
# If --with-gradle is specified, build mobile/android with Gradle. If no
|
2018-02-22 22:38:27 +03:00
|
|
|
# Gradle binary is specified use the in tree Gradle wrapper. The wrapper
|
|
|
|
# downloads and installs Gradle, which is good for local developers but not
|
|
|
|
# good in automation.
|
2018-10-16 14:28:12 +03:00
|
|
|
option('--without-gradle', nargs='?',
|
|
|
|
help='Disable building mobile/android with Gradle '
|
2016-03-17 21:04:08 +03:00
|
|
|
'(argument: location of binary or wrapper (gradle/gradlew))')
|
|
|
|
|
2016-03-22 08:21:32 +03:00
|
|
|
@depends('--with-gradle')
|
|
|
|
def with_gradle(value):
|
2018-02-22 22:38:27 +03:00
|
|
|
if not value:
|
|
|
|
die('Building --without-gradle is no longer supported: '
|
|
|
|
'see https://bugzilla.mozilla.org/show_bug.cgi?id=1414415.')
|
|
|
|
|
2016-03-17 21:04:08 +03:00
|
|
|
if value:
|
2016-03-22 08:21:32 +03:00
|
|
|
return True
|
|
|
|
|
|
|
|
|
2019-02-26 05:06:12 +03:00
|
|
|
@depends(host, '--with-gradle', check_build_environment)
|
2016-11-04 00:50:43 +03:00
|
|
|
@imports(_from='os.path', _import='isfile')
|
2019-02-26 05:06:12 +03:00
|
|
|
def gradle(host, value, build_env):
|
|
|
|
if len(value):
|
|
|
|
gradle = value[0]
|
|
|
|
else:
|
|
|
|
gradle = os.path.join(build_env.topsrcdir, 'gradlew')
|
|
|
|
if host.os == 'WINNT':
|
|
|
|
gradle = gradle + '.bat'
|
2016-03-17 21:04:08 +03:00
|
|
|
|
|
|
|
# TODO: verify that $GRADLE is executable.
|
2016-11-04 00:50:43 +03:00
|
|
|
if not isfile(gradle):
|
2016-03-25 09:48:21 +03:00
|
|
|
die('GRADLE must be executable: %s', gradle)
|
2016-03-17 21:04:08 +03:00
|
|
|
|
|
|
|
return gradle
|
|
|
|
|
2016-03-22 08:21:32 +03:00
|
|
|
set_config('GRADLE', gradle)
|
|
|
|
|
2016-03-17 21:04:08 +03:00
|
|
|
|
2017-11-09 02:27:36 +03:00
|
|
|
@dependable
|
|
|
|
@imports(_from='itertools', _import='chain')
|
|
|
|
def gradle_android_build_config():
|
|
|
|
def capitalize(s):
|
|
|
|
# str.capitalize lower cases trailing letters.
|
|
|
|
if s:
|
|
|
|
return s[0].upper() + s[1:]
|
|
|
|
else:
|
|
|
|
return s
|
|
|
|
|
|
|
|
def variant(productFlavors, buildType):
|
|
|
|
return namespace(
|
|
|
|
productFlavors=productFlavors,
|
|
|
|
buildType=buildType,
|
2018-11-07 02:21:30 +03:00
|
|
|
# Like 'WithoutGeckoBinariesDebug'
|
2017-11-09 02:27:36 +03:00
|
|
|
name = ''.join(capitalize(t) for t in chain(productFlavors, (buildType, )))
|
|
|
|
)
|
|
|
|
|
|
|
|
return namespace(
|
2017-11-10 03:47:05 +03:00
|
|
|
geckoview=namespace(
|
2018-11-07 02:21:30 +03:00
|
|
|
variant=variant(('withGeckoBinaries',), 'debug'),
|
2017-11-10 03:47:05 +03:00
|
|
|
),
|
|
|
|
geckoview_example=namespace(
|
2018-11-07 02:21:30 +03:00
|
|
|
variant=variant(('withGeckoBinaries',), 'debug'),
|
2017-11-09 02:27:36 +03:00
|
|
|
),
|
|
|
|
)
|
|
|
|
|
|
|
|
|
2018-11-19 19:03:55 +03:00
|
|
|
@depends(gradle_android_build_config)
|
|
|
|
def gradle_android_intermediates_folder(build_config):
|
|
|
|
'''Path to intermediates classes folder.'''
|
|
|
|
def uncapitalize(s):
|
|
|
|
if s:
|
|
|
|
return s[0].lower() + s[1:]
|
|
|
|
else:
|
|
|
|
return s
|
|
|
|
|
|
|
|
def capitalize(s):
|
|
|
|
# str.capitalize lower cases trailing letters.
|
|
|
|
if s:
|
|
|
|
return s[0].upper() + s[1:]
|
|
|
|
else:
|
|
|
|
return s
|
|
|
|
|
2020-04-05 11:51:20 +03:00
|
|
|
productFlavor = uncapitalize(''.join(capitalize(f) for f in build_config.geckoview.variant.productFlavors))
|
2018-11-19 19:03:55 +03:00
|
|
|
buildType = uncapitalize(build_config.geckoview.variant.buildType)
|
|
|
|
|
2019-07-20 20:27:53 +03:00
|
|
|
return "gradle/build/mobile/android/geckoview/intermediates/javac/{}{}/compile{}{}JavaWithJavac/classes".format(
|
2018-11-19 19:03:55 +03:00
|
|
|
productFlavor,
|
2019-07-20 20:27:53 +03:00
|
|
|
capitalize(buildType),
|
|
|
|
capitalize(productFlavor),
|
|
|
|
capitalize(buildType))
|
2018-11-19 19:03:55 +03:00
|
|
|
|
|
|
|
set_config('GRADLE_ANDROID_GECKOVIEW_APILINT_FOLDER', gradle_android_intermediates_folder)
|
|
|
|
|
2017-11-09 02:27:36 +03:00
|
|
|
@depends(gradle_android_build_config)
|
2018-02-08 21:36:22 +03:00
|
|
|
def gradle_android_variant_name(build_config):
|
2018-11-07 02:21:30 +03:00
|
|
|
'''Like "withoutGeckoBinariesDebug".'''
|
2017-11-09 02:27:36 +03:00
|
|
|
def uncapitalize(s):
|
|
|
|
if s:
|
|
|
|
return s[0].lower() + s[1:]
|
|
|
|
else:
|
|
|
|
return s
|
|
|
|
|
2018-02-08 21:36:22 +03:00
|
|
|
return namespace(
|
|
|
|
geckoview=uncapitalize(build_config.geckoview.variant.name),
|
|
|
|
)
|
|
|
|
|
|
|
|
set_config('GRADLE_ANDROID_GECKOVIEW_VARIANT_NAME', gradle_android_variant_name.geckoview)
|
2017-11-09 02:27:36 +03:00
|
|
|
|
|
|
|
|
|
|
|
@depends(gradle_android_build_config)
|
|
|
|
def gradle_android_app_tasks(build_config):
|
|
|
|
'''Gradle tasks run by |mach android assemble-app|.'''
|
|
|
|
return [
|
2017-11-10 03:47:05 +03:00
|
|
|
'geckoview:generateJNIWrappersForGenerated{geckoview.variant.name}'.format(geckoview=build_config.geckoview),
|
2019-10-04 23:55:11 +03:00
|
|
|
]
|
2017-11-09 02:27:36 +03:00
|
|
|
|
|
|
|
set_config('GRADLE_ANDROID_APP_TASKS', gradle_android_app_tasks)
|
|
|
|
|
|
|
|
|
2018-03-07 06:19:48 +03:00
|
|
|
@dependable
|
|
|
|
def gradle_android_generate_sdk_bindings_tasks():
|
|
|
|
'''Gradle tasks run by |mach android generate-sdk-bindings|.'''
|
|
|
|
return [
|
|
|
|
'geckoview:generateSDKBindings',
|
|
|
|
]
|
|
|
|
|
|
|
|
set_config('GRADLE_ANDROID_GENERATE_SDK_BINDINGS_TASKS', gradle_android_generate_sdk_bindings_tasks)
|
|
|
|
|
|
|
|
|
2018-03-07 07:09:37 +03:00
|
|
|
@depends(gradle_android_build_config)
|
|
|
|
def gradle_android_generate_generated_jni_wrappers_tasks(build_config):
|
|
|
|
'''Gradle tasks run by |mach android generate-generated-jni-wrappers|.'''
|
|
|
|
return [
|
|
|
|
'geckoview:generateJNIWrappersForGenerated{geckoview.variant.name}'.format(geckoview=build_config.geckoview),
|
|
|
|
]
|
|
|
|
|
|
|
|
set_config('GRADLE_ANDROID_GENERATE_GENERATED_JNI_WRAPPERS_TASKS', gradle_android_generate_generated_jni_wrappers_tasks)
|
|
|
|
|
|
|
|
|
2017-11-11 02:39:09 +03:00
|
|
|
@depends(gradle_android_build_config)
|
|
|
|
def gradle_android_test_tasks(build_config):
|
|
|
|
'''Gradle tasks run by |mach android test|.'''
|
|
|
|
return [
|
2018-02-08 21:36:22 +03:00
|
|
|
'geckoview:test{geckoview.variant.name}UnitTest'.format(
|
|
|
|
geckoview=build_config.geckoview),
|
2017-11-11 02:39:09 +03:00
|
|
|
]
|
|
|
|
|
2018-07-02 13:32:35 +03:00
|
|
|
|
2017-11-11 02:39:09 +03:00
|
|
|
set_config('GRADLE_ANDROID_TEST_TASKS', gradle_android_test_tasks)
|
|
|
|
|
|
|
|
|
|
|
|
@depends(gradle_android_build_config)
|
|
|
|
def gradle_android_lint_tasks(build_config):
|
|
|
|
'''Gradle tasks run by |mach android lint|.'''
|
|
|
|
return [
|
2019-10-04 23:55:11 +03:00
|
|
|
'geckoview:lint{geckoview.variant.name}'.format(geckoview=build_config.geckoview),
|
2017-11-11 02:39:09 +03:00
|
|
|
]
|
|
|
|
|
|
|
|
set_config('GRADLE_ANDROID_LINT_TASKS', gradle_android_lint_tasks)
|
|
|
|
|
2018-11-19 19:03:55 +03:00
|
|
|
@depends(gradle_android_build_config)
|
|
|
|
def gradle_android_api_lint_tasks(build_config):
|
|
|
|
'''Gradle tasks run by |mach android api-lint|.'''
|
|
|
|
return [
|
|
|
|
'geckoview:apiLint{geckoview.variant.name}'.format(geckoview=build_config.geckoview),
|
|
|
|
]
|
|
|
|
|
|
|
|
set_config('GRADLE_ANDROID_API_LINT_TASKS', gradle_android_api_lint_tasks)
|
|
|
|
|
2017-11-11 02:39:09 +03:00
|
|
|
|
2019-03-16 00:21:57 +03:00
|
|
|
@depends(gradle_android_build_config)
|
|
|
|
def gradle_android_checkstyle_tasks(build_config):
|
2017-11-11 02:39:09 +03:00
|
|
|
'''Gradle tasks run by |mach android checkstyle|.'''
|
|
|
|
return [
|
2019-03-16 00:21:57 +03:00
|
|
|
'geckoview:checkstyle{geckoview.variant.name}'.format(geckoview=build_config.geckoview),
|
2017-11-11 02:39:09 +03:00
|
|
|
]
|
2019-10-04 23:55:11 +03:00
|
|
|
|
2017-11-11 02:39:09 +03:00
|
|
|
|
|
|
|
set_config('GRADLE_ANDROID_CHECKSTYLE_TASKS', gradle_android_checkstyle_tasks)
|
|
|
|
|
|
|
|
|
2019-04-01 19:20:28 +03:00
|
|
|
@depends(gradle_android_build_config)
|
|
|
|
def gradle_android_checkstyle_output_files(build_config):
|
|
|
|
def uncapitalize(s):
|
|
|
|
if s:
|
|
|
|
return s[0].lower() + s[1:]
|
|
|
|
else:
|
|
|
|
return s
|
|
|
|
|
|
|
|
variant = uncapitalize(build_config.geckoview.variant.name)
|
|
|
|
|
|
|
|
'''Output folder for checkstyle'''
|
|
|
|
return [
|
|
|
|
'gradle/build/mobile/android/geckoview/reports/checkstyle/{}.xml'.format(variant),
|
|
|
|
]
|
|
|
|
|
|
|
|
|
2019-10-04 23:55:11 +03:00
|
|
|
set_config('GRADLE_ANDROID_CHECKSTYLE_OUTPUT_FILES', gradle_android_checkstyle_output_files)
|
2017-11-11 02:39:09 +03:00
|
|
|
|
|
|
|
|
2017-10-26 21:00:36 +03:00
|
|
|
@depends(gradle_android_build_config)
|
|
|
|
def gradle_android_archive_geckoview_tasks(build_config):
|
2017-11-11 02:39:09 +03:00
|
|
|
'''Gradle tasks run by |mach android archive-geckoview|.'''
|
|
|
|
return [
|
2017-11-10 03:47:05 +03:00
|
|
|
'geckoview:assemble{geckoview.variant.name}'.format(geckoview=build_config.geckoview),
|
2018-04-04 20:50:34 +03:00
|
|
|
'geckoview:assemble{geckoview.variant.name}AndroidTest'.format(geckoview=build_config.geckoview),
|
2017-11-10 03:47:05 +03:00
|
|
|
'geckoview_example:assemble{geckoview_example.variant.name}'.format(geckoview_example=build_config.geckoview_example),
|
|
|
|
'geckoview_example:assemble{geckoview_example.variant.name}AndroidTest'.format(geckoview_example=build_config.geckoview_example),
|
2020-03-13 21:11:45 +03:00
|
|
|
'messaging_example:assemble{geckoview_example.variant.name}AndroidTest'.format(geckoview_example=build_config.geckoview_example),
|
|
|
|
'port_messaging_example:assemble{geckoview_example.variant.name}AndroidTest'.format(geckoview_example=build_config.geckoview_example),
|
2018-11-29 22:39:11 +03:00
|
|
|
'geckoview:publish{geckoview.variant.name}PublicationToMavenRepository'.format(geckoview=build_config.geckoview),
|
2017-11-11 02:39:09 +03:00
|
|
|
]
|
|
|
|
|
|
|
|
set_config('GRADLE_ANDROID_ARCHIVE_GECKOVIEW_TASKS', gradle_android_archive_geckoview_tasks)
|
|
|
|
|
|
|
|
|
2018-12-20 23:05:39 +03:00
|
|
|
@depends(gradle_android_build_config)
|
|
|
|
def gradle_android_geckoview_docs_tasks(build_config):
|
|
|
|
'''Gradle tasks run by |mach android geckoview-docs|.'''
|
|
|
|
return [
|
|
|
|
'geckoview:javadoc{geckoview.variant.name}'.format(geckoview=build_config.geckoview),
|
|
|
|
]
|
|
|
|
|
|
|
|
set_config('GRADLE_ANDROID_GECKOVIEW_DOCS_TASKS', gradle_android_geckoview_docs_tasks)
|
|
|
|
|
|
|
|
|
|
|
|
@depends(gradle_android_build_config)
|
|
|
|
def gradle_android_geckoview_docs_archive_tasks(build_config):
|
|
|
|
'''Gradle tasks run by |mach android geckoview-docs --archive| or |... --upload.'''
|
|
|
|
return [
|
2018-12-20 22:37:42 +03:00
|
|
|
'geckoview:javadocCopyJar{geckoview.variant.name}'.format(geckoview=build_config.geckoview),
|
2018-12-20 23:05:39 +03:00
|
|
|
]
|
|
|
|
|
|
|
|
set_config('GRADLE_ANDROID_GECKOVIEW_DOCS_ARCHIVE_TASKS', gradle_android_geckoview_docs_archive_tasks)
|
|
|
|
|
|
|
|
|
2019-08-13 04:45:03 +03:00
|
|
|
@depends(gradle_android_build_config)
|
|
|
|
def gradle_android_geckoview_docs_output_files(build_config):
|
|
|
|
'''Output files for GeckoView javadoc.'''
|
|
|
|
|
|
|
|
def uncapitalize(s):
|
|
|
|
if s:
|
|
|
|
return s[0].lower() + s[1:]
|
|
|
|
else:
|
|
|
|
return s
|
|
|
|
|
|
|
|
variant = uncapitalize(build_config.geckoview.variant.name)
|
|
|
|
|
|
|
|
return [
|
|
|
|
'gradle/build/mobile/android/geckoview/reports/javadoc-results-{}.json'.format(variant),
|
|
|
|
]
|
|
|
|
|
|
|
|
set_config('GRADLE_ANDROID_GECKOVIEW_DOCS_OUTPUT_FILES', gradle_android_geckoview_docs_output_files)
|
|
|
|
|
|
|
|
|
2018-07-24 13:44:24 +03:00
|
|
|
@depends(gradle_android_build_config)
|
2018-09-06 20:00:17 +03:00
|
|
|
def gradle_android_archive_coverage_artifacts_tasks(build_config):
|
|
|
|
'''Gradle tasks run by |mach android archive-coverage-artifacts|.'''
|
2018-07-24 13:44:24 +03:00
|
|
|
return [
|
|
|
|
'geckoview:archiveClassfiles{geckoview.variant.name}'.format(geckoview=build_config.geckoview),
|
|
|
|
'geckoview:copyCoverageDependencies',
|
|
|
|
]
|
|
|
|
|
2018-09-06 20:00:17 +03:00
|
|
|
set_config('GRADLE_ANDROID_ARCHIVE_COVERAGE_ARTIFACTS_TASKS',
|
|
|
|
gradle_android_archive_coverage_artifacts_tasks)
|
2018-07-24 13:44:24 +03:00
|
|
|
|
|
|
|
|
2018-10-31 06:18:54 +03:00
|
|
|
@depends(gradle_android_build_config)
|
|
|
|
def gradle_android_build_geckoview_example_tasks(build_config):
|
|
|
|
'''Gradle tasks run by |mach android build-geckoview_example|.'''
|
|
|
|
return [
|
|
|
|
'geckoview_example:assemble{geckoview_example.variant.name}'.format(geckoview_example=build_config.geckoview_example),
|
|
|
|
'geckoview_example:assemble{geckoview_example.variant.name}AndroidTest'.format(geckoview_example=build_config.geckoview_example),
|
|
|
|
]
|
|
|
|
|
|
|
|
set_config('GRADLE_ANDROID_BUILD_GECKOVIEW_EXAMPLE_TASKS', gradle_android_build_geckoview_example_tasks)
|
|
|
|
|
|
|
|
|
|
|
|
@depends(gradle_android_build_config)
|
|
|
|
def gradle_android_install_geckoview_example_tasks(build_config):
|
|
|
|
'''Gradle tasks run by |mach android install-geckoview_example|.'''
|
|
|
|
return [
|
|
|
|
'geckoview_example:install{geckoview_example.variant.name}'.format(geckoview_example=build_config.geckoview_example),
|
|
|
|
'geckoview_example:install{geckoview_example.variant.name}AndroidTest'.format(geckoview_example=build_config.geckoview_example),
|
|
|
|
]
|
|
|
|
|
|
|
|
set_config('GRADLE_ANDROID_INSTALL_GECKOVIEW_EXAMPLE_TASKS', gradle_android_install_geckoview_example_tasks)
|
|
|
|
|
|
|
|
|
2018-12-15 00:37:37 +03:00
|
|
|
@dependable
|
|
|
|
def gradle_android_dependencies():
|
|
|
|
'''Gradle tasks that download all dependencies.'''
|
|
|
|
# These tasks download most dependencies from each configuration, the
|
|
|
|
# notable exception is dependencies added at runtime by gradle plugins
|
|
|
|
return [
|
|
|
|
'downloadDependencies',
|
|
|
|
]
|
|
|
|
|
2017-11-11 02:39:09 +03:00
|
|
|
@depends(
|
2018-11-19 19:03:55 +03:00
|
|
|
gradle_android_api_lint_tasks,
|
2017-11-11 02:39:09 +03:00
|
|
|
gradle_android_checkstyle_tasks,
|
2018-12-15 00:37:37 +03:00
|
|
|
gradle_android_dependencies,
|
2017-11-11 02:39:09 +03:00
|
|
|
)
|
|
|
|
@imports(_from='itertools', _import='chain')
|
|
|
|
def gradle_android_dependencies_tasks(*tasks):
|
|
|
|
'''Gradle tasks run by |mach android dependencies|.'''
|
|
|
|
# The union, plus a bit more, of all of the Gradle tasks
|
|
|
|
# invoked by the android-* automation jobs.
|
|
|
|
def withoutGeckoBinaries(task):
|
|
|
|
return task.replace('withGeckoBinaries', 'withoutGeckoBinaries')
|
|
|
|
|
2020-04-05 11:51:20 +03:00
|
|
|
return list(withoutGeckoBinaries(t) for t in chain(*tasks))
|
2017-11-11 02:39:09 +03:00
|
|
|
|
|
|
|
set_config('GRADLE_ANDROID_DEPENDENCIES_TASKS', gradle_android_dependencies_tasks)
|
|
|
|
|
|
|
|
|
2016-03-17 21:04:08 +03:00
|
|
|
# Automation uses this to change log levels, not use the daemon, and use
|
|
|
|
# offline mode.
|
|
|
|
option(env='GRADLE_FLAGS', default='', help='Flags to pass to Gradle.')
|
|
|
|
|
|
|
|
@depends('GRADLE_FLAGS')
|
|
|
|
def gradle_flags(value):
|
2016-03-22 08:21:32 +03:00
|
|
|
return value[0] if value else ''
|
|
|
|
|
|
|
|
set_config('GRADLE_FLAGS', gradle_flags)
|
2016-03-17 21:04:08 +03:00
|
|
|
|
2017-07-26 21:28:07 +03:00
|
|
|
# Automation will set this to (file:///path/to/local, ...) via the mozconfig.
|
|
|
|
# Local developer default is (jcenter, maven.google.com).
|
|
|
|
option(env='GRADLE_MAVEN_REPOSITORIES',
|
|
|
|
nargs='+',
|
2018-10-23 20:27:54 +03:00
|
|
|
default=('https://maven.google.com/',
|
|
|
|
'https://jcenter.bintray.com/',
|
2018-11-19 19:03:33 +03:00
|
|
|
'https://plugins.gradle.org/m2/',
|
2017-07-26 21:28:07 +03:00
|
|
|
),
|
|
|
|
help='Comma-separated URLs of Maven repositories containing Gradle dependencies.')
|
|
|
|
|
|
|
|
@depends('GRADLE_MAVEN_REPOSITORIES')
|
|
|
|
@imports(_from='os.path', _import='isdir')
|
|
|
|
def gradle_maven_repositories(values):
|
|
|
|
if not values:
|
|
|
|
die('GRADLE_MAVEN_REPOSITORIES must not be empty')
|
|
|
|
if not all(values):
|
|
|
|
die('GRADLE_MAVEN_REPOSITORIES entries must not be empty')
|
|
|
|
return values
|
|
|
|
|
|
|
|
set_config('GRADLE_MAVEN_REPOSITORIES', gradle_maven_repositories)
|