/* 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/. */ // The JNI wrapper generation tasks depend on the JAR creation task of the :annotations project. evaluationDependsOn(':annotations') // Whether to include compiled artifacts: `lib/**/*.so` and `assets/omni.ja`. // Multi-locale packaging wants to include compiled artifacts but *not* rebuild // them: see also the `rootProject.machStagePackage` task and `MachExec.geckoBinariesOnlyIf`. def hasCompileArtifacts() { return project.mozconfig.substs.COMPILE_ENVIRONMENT // Full builds. || project.mozconfig.substs.MOZ_ARTIFACT_BUILDS // Artifact builds. || System.getenv("MOZ_CHROME_MULTILOCALE") // Multi-locale packaging. } ext.configureVariantWithGeckoBinaries = { variantName -> // Local (read, not 'official') builds want to reflect developer changes to // the omnijar sources, and (when compiling) to reflect developer changes to // the native binaries. To do this, the Gradle build calls out to the // moz.build system, which can be re-entrant. Official builds are driven by // the moz.build system and should never be re-entrant in this way. if (hasCompileArtifacts() && !mozconfig.substs.MOZILLA_OFFICIAL && !mozconfig.substs.ENABLE_MOZSEARCH_PLUGIN) { // `onVariants` runs before AGP creates these tasks, so defer the wiring with `configureEach`. ["generate${variantName.capitalize()}Assets", "merge${variantName.capitalize()}JniLibFolders"].each { taskName -> tasks.matching { it.name == taskName }.configureEach { dependsOn rootProject.machStagePackage } } } } ext.configureLibraryVariantWithJNIWrappers = { variantName, javacClasspath, module -> // BundleLibRuntime prepares the library for further processing to be // incorporated in an app. We use this version to create the JNI wrappers. def jarTask = tasks.named("bundleLibRuntimeToJar${variantName.capitalize()}") def bundleJar = jarTask.map { it.outputs.files.find({ f -> f.name == 'classes.jar' }) } def annotationProcessorsJarTask = project(':annotations').jar def wrapperTask if (System.env.IS_LANGUAGE_REPACK == '1') { // Single-locale l10n repacks set `IS_LANGUAGE_REPACK=1` and don't // really have a build environment. wrapperTask = tasks.register("generateJNIWrappersFor${module}${variantName.capitalize()}") } else { wrapperTask = tasks.register("generateJNIWrappersFor${module}${variantName.capitalize()}", JavaExec) { classpath annotationProcessorsJarTask.archiveFile // Configure the classpath at evaluation-time, not at // configuration-time: see above comment. doFirst { classpath javacClasspath } mainClass = 'org.mozilla.gecko.annotationProcessors.AnnotationProcessor' args module args bundleJar.get() workingDir "${topobjdir}/widget/android" inputs.file(bundleJar) inputs.file(annotationProcessorsJarTask.archiveFile) inputs.property("module", module) outputs.dir("${topobjdir}/widget/android/GeneratedJNI") dependsOn jarTask dependsOn annotationProcessorsJarTask dependsOn rootProject.verifyGleanVersion } } }