tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

with_gecko_binaries.gradle (3712B)


      1 /* -*- Mode: Groovy; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*-
      2 * This Source Code Form is subject to the terms of the Mozilla Public
      3 * License, v. 2.0. If a copy of the MPL was not distributed with this
      4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      5 
      6 // The JNI wrapper generation tasks depend on the JAR creation task of the :annotations project.
      7 evaluationDependsOn(':annotations')
      8 
      9 // Whether to include compiled artifacts: `lib/**/*.so` and `assets/omni.ja`.
     10 // Multi-locale packaging wants to include compiled artifacts but *not* rebuild
     11 // them: see also `rootProject.{machStagePackage,geckoBinariesOnlyIf}`.
     12 def hasCompileArtifacts() {
     13    return project.mozconfig.substs.COMPILE_ENVIRONMENT // Full builds.
     14        || project.mozconfig.substs.MOZ_ARTIFACT_BUILDS // Artifact builds.
     15        || System.getenv("MOZ_CHROME_MULTILOCALE") // Multi-locale packaging.
     16 }
     17 
     18 ext.configureVariantWithGeckoBinaries = { variant ->
     19    if (hasCompileArtifacts() || true) {
     20        // Local (read, not 'official') builds want to reflect developer changes to
     21        // the omnijar sources, and (when compiling) to reflect developer changes to
     22        // the native binaries.  To do this, the Gradle build calls out to the
     23        // moz.build system, which can be re-entrant.  Official builds are driven by
     24        // the moz.build system and should never be re-entrant in this way.
     25        def assetGenTask = tasks.findByName("generate${variant.name.capitalize()}Assets")
     26        def jniLibFoldersTask = tasks.findByName("merge${variant.name.capitalize()}JniLibFolders")
     27        if (!mozconfig.substs.MOZILLA_OFFICIAL && !mozconfig.substs.ENABLE_MOZSEARCH_PLUGIN) {
     28            assetGenTask.dependsOn rootProject.machStagePackage
     29            jniLibFoldersTask.dependsOn rootProject.machStagePackage
     30        }
     31    }
     32 }
     33 
     34 ext.configureLibraryVariantWithJNIWrappers = { variant, module ->
     35    // BundleLibRuntime prepares the library for further processing to be
     36    // incorporated in an app. We use this version to create the JNI wrappers.
     37    def jarTask = tasks["bundleLibRuntimeToJar${variant.name.capitalize()}"]
     38    def bundleJar = jarTask.outputs.files.find({ it.name == 'classes.jar' })
     39 
     40    def annotationProcessorsJarTask = project(':annotations').jar
     41 
     42    def classpathFilesProvider = variant.javaCompileProvider.flatMap { javaCompileTask ->
     43        project.provider { javaCompileTask.classpath.files }
     44    }
     45 
     46    def wrapperTask
     47    if (System.env.IS_LANGUAGE_REPACK == '1') {
     48        // Single-locale l10n repacks set `IS_LANGUAGE_REPACK=1` and don't
     49        // really have a build environment.
     50        wrapperTask = tasks.register("generateJNIWrappersFor${module}${variant.name.capitalize()}")
     51    } else {
     52        wrapperTask = tasks.register("generateJNIWrappersFor${module}${variant.name.capitalize()}", JavaExec) {
     53            classpath annotationProcessorsJarTask.archiveFile
     54        
     55            // Configure the classpath at evaluation-time, not at
     56            // configuration-time: see above comment.
     57            doFirst {
     58                classpath classpathFilesProvider.get()
     59            }
     60 
     61            mainClass = 'org.mozilla.gecko.annotationProcessors.AnnotationProcessor'
     62            args module
     63            args bundleJar
     64            
     65            workingDir "${topobjdir}/widget/android"
     66 
     67            inputs.file(bundleJar)
     68            inputs.file(annotationProcessorsJarTask.archiveFile)
     69            inputs.property("module", module)
     70 
     71            outputs.dir("${topobjdir}/widget/android/GeneratedJNI")
     72 
     73            dependsOn jarTask
     74            dependsOn annotationProcessorsJarTask
     75            dependsOn rootProject.verifyGleanVersion
     76        }
     77    }
     78 }