build.gradle
author Lars T Hansen <lhansen@mozilla.com>
Fri, 15 Dec 2017 13:10:23 -0600
changeset 455775 045ded11d3f810ea430b0eed3026534f2508d955
parent 453994 ef04f3ad847540c876c130b7d140a960d922a024
child 456956 bc47964180063422d7c81e1d71aeac9946fa25b3
permissions -rw-r--r--
Bug 1430161 - Factor ARM disassembler, implement for ARM64. r=nbp We extract the ARM disassembler bits and place them in jit/shared/Disassembler-shared.{cpp,h}, and then clean them up and generalize them. The ARM assembler is slightly modified to deal with this but the changes are local. We then add code to the ARM64 assembler to drive the disassembler. The structure is as for the ARM disassembler.

def tryInt = { string ->
    if (string == null) {
        return string
    }
    if (string.isInteger()) {
        return string as Integer
    }
    return string
}

allprojects {
    // Expose the per-object-directory configuration to all projects.
    ext {
        mozconfig = gradle.mozconfig
        topsrcdir = gradle.mozconfig.topsrcdir
        topobjdir = gradle.mozconfig.topobjdir

        compileSdkVersion = tryInt(mozconfig.substs.ANDROID_COMPILE_SDK_VERSION)
        buildToolsVersion = tryInt(mozconfig.substs.ANDROID_BUILD_TOOLS_VERSION)
        targetSdkVersion = tryInt(mozconfig.substs.ANDROID_TARGET_SDK)
        minSdkVersion = tryInt(mozconfig.substs.MOZ_ANDROID_MIN_SDK_VERSION)
        manifestPlaceholders = [
            ANDROID_PACKAGE_NAME: mozconfig.substs.ANDROID_PACKAGE_NAME,
            ANDROID_TARGET_SDK: mozconfig.substs.ANDROID_TARGET_SDK,
            MOZ_ANDROID_MIN_SDK_VERSION: mozconfig.substs.MOZ_ANDROID_MIN_SDK_VERSION,
            MOZ_ANDROID_SHARED_ID: "${mozconfig.substs.ANDROID_PACKAGE_NAME}.sharedID",
        ]
    }

    repositories {
        gradle.mozconfig.substs.GRADLE_MAVEN_REPOSITORIES.each { repository ->
            maven {
                url repository
            }
        }
    }
}

buildDir "${topobjdir}/gradle/build"

buildscript {
    repositories {
        gradle.mozconfig.substs.GRADLE_MAVEN_REPOSITORIES.each { repository ->
            maven {
                url repository
            }
        }
        // For in tree plugins.
        maven {
            url "file://${gradle.mozconfig.topsrcdir}/mobile/android/gradle/m2repo"
        }
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:2.3.3'
        // Provided in tree.
        classpath 'com.getkeepsafe.dexcount:dexcount-gradle-plugin:0.7.3'
    }
}

if ('multi' == System.env.AB_CD) {
    // Multi-l10n builds set `AB_CD=multi`, which isn't a valid locale.  This
    // causes the
    //
    // |mach build| > |mach gradle| > |make gradle-targets| > AndroidManifest.xml > strings.xml > multi/brand.dtd
    //
    // dependency chain to fail, since multi isn't a real locale.  To avoid
    // this, if Gradle is invoked with AB_CD=multi, we don't invoke Make at all.
    task generateCodeAndResources()
} else if (System.env.IS_LANGUAGE_REPACK == '1') {
    // Single-locale l10n repacks set `IS_LANGUAGE_REPACK=1` and handle resource
    // and code generation themselves.
    task generateCodeAndResources()
} else {
    task generateCodeAndResources(type:Exec) {
        workingDir "${topobjdir}"

        commandLine mozconfig.substs.GMAKE
        args '-C'
        args "${topobjdir}/mobile/android/base"
        args 'gradle-targets'

        // Only show the output if something went wrong.
        ignoreExitValue = true
        standardOutput = new ByteArrayOutputStream()
        errorOutput = standardOutput
        doLast {
            if (execResult.exitValue != 0) {
                throw new GradleException("Process '${commandLine}' finished with non-zero exit value ${execResult.exitValue}:\n\n${standardOutput.toString()}")
            }
        }
    }
}

afterEvaluate {
    subprojects {
        if (!hasProperty('android')) {
            return
        }
        android.applicationVariants.all {
            preBuild.dependsOn rootProject.generateCodeAndResources
        }
        android.libraryVariants.all {
            preBuild.dependsOn rootProject.generateCodeAndResources
        }
    }
}

apply plugin: 'idea'

idea {
    project {
        languageLevel = '1.7'
    }

    module {
        // Object directories take a huge amount of time for IntelliJ to index.
        // Exclude them.  Convention is that object directories start with obj.
        // IntelliJ is clever and will not exclude the parts of the object
        // directory that are referenced, if there are any.  In practice,
        // indexing the entirety of the tree is taking too long, so exclude all
        // but mobile/.
        def topsrcdirURI = file(topsrcdir).toURI()
        excludeDirs += files(file(topsrcdir)
            .listFiles({it.isDirectory()} as FileFilter)
            .collect({topsrcdirURI.relativize(it.toURI()).toString()}) // Relative paths.
            .findAll({!it.equals('mobile/')}))

        // If topobjdir is below topsrcdir, hide only some portions of that tree.
        def topobjdirURI = file(topobjdir).toURI()
        if (!topsrcdirURI.relativize(topobjdirURI).isAbsolute()) {
            excludeDirs -= file(topobjdir)
            excludeDirs += files(file(topobjdir).listFiles())
            excludeDirs -= file("${topobjdir}/gradle")
        }

        if (!mozconfig.substs.MOZ_INSTALL_TRACKING) {
            excludeDirs += file("${topsrcdir}/mobile/android/thirdparty/com/adjust")
        }
    }
}

task wrapper(type: Wrapper) {
}