# 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/.
---
loader: taskgraph.loader.transform:loader

kind-dependencies:
    - build
    - toolchain

transforms:
    - gecko_taskgraph.transforms.build:transforms
    - gecko_taskgraph.transforms.build_attrs:transforms
    - gecko_taskgraph.transforms.build_schedules:transforms
    - gecko_taskgraph.transforms.build_lints:transforms
    - gecko_taskgraph.transforms.build_fat_aar:transforms
    - gecko_taskgraph.transforms.job:transforms
    - gecko_taskgraph.transforms.artifact:transforms
    - gecko_taskgraph.transforms.task:transforms

task-defaults:
    attributes:
        artifact_map: taskcluster/gecko_taskgraph/manifests/fennec_geckoview.yml
    index:
        product: mobile
    worker-type: b-linux-gcp
    use-python: default
    worker:
        docker-image: {in-tree: android-build}
        max-run-time: 7200
        env:
            # Online in order to download the per-architecture AARs.
            GRADLE_USER_HOME: "/builds/worker/checkouts/build/gecko/mobile/android/gradle/dotgradle-online"
            TOOLTOOL_MANIFEST: "mobile/android/config/tooltool-manifests/android/releng.manifest"
            MOZ_ANDROID_FAT_AAR_ARCHITECTURES: "armeabi-v7a,arm64-v8a,x86,x86_64"
            MACH_BUILD_PYTHON_NATIVE_PACKAGE_SOURCE: system
        artifacts:
            - name: public/build/maven
              path: /builds/worker/workspace/obj-build/gradle/maven/
              type: directory
            - name: public/build/target.maven.tar.xz
              path: /builds/worker/workspace/obj-build/gradle/target.maven.tar.xz
              type: file
            - name: public/build
              path: /builds/worker/artifacts/
              type: directory
            - name: public/build/geckoview-androidTest.apk
              path: /builds/worker/workspace/obj-build/gradle/build/mobile/android/geckoview/outputs/apk/androidTest/debug/geckoview-debug-androidTest.apk
              type: file
            - name: public/build/geckoview-test_runner.apk
              path: /builds/worker/workspace/obj-build/gradle/build/mobile/android/test_runner/outputs/apk/debug/test_runner-debug.apk
              type: file
            - name: public/build/geckoview-test_runner.aab
              path: /builds/worker/workspace/obj-build/gradle/build/mobile/android/test_runner/outputs/bundle/debug/test_runner-debug.aab
              type: file
            - name: public/build/geckoview_example.apk
              path: /builds/worker/workspace/obj-build/gradle/build/mobile/android/geckoview_example/outputs/apk/debug/geckoview_example-debug.apk
              type: file
            - name: public/build/geckoview_example.aab
              path: /builds/worker/workspace/obj-build/gradle/build/mobile/android/geckoview_example/outputs/bundle/debug/geckoview_example-debug.aab
              type: file
            - name: public/build/mozconfig
              path: /builds/worker/workspace/obj-build/.mozconfig
              type: file
            - name: public/reports
              path: /builds/worker/workspace/obj-build/gradle/build/reports
              type: directory
    run:
        using: mozharness
        script: "mozharness/scripts/fx_desktop_build.py"
        secrets: true
        mozconfig-variant:
            by-release-type:
                beta: beta
                release.*: release
                esr.*: release
                default: nightly
        tooltool-downloads: internal
        # Note: These settings are only honored by nightly (i.e. shipping) builds
        update-channel:
            by-release-type:
                nightly:
                    by-project:
                        try: nightly-try
                        default: nightly
                nightly-larch: nightly-larch
                nightly-oak: nightly-oak
                nightly-pine: nightly-pine
                beta:
                    by-shipping-product:
                        devedition: aurora
                        default: beta
                release.*: release
                esr.*: esr
                default: null
    fetches:
        toolchain:
            - android-ndk-linux
            - android-sdk-linux
            - linux64-clang
            - linux64-jdk
            - linux64-rust-android
            - linux64-rust-size
            - linux64-cbindgen
            - linux64-dump_syms
            - linux64-nasm
            - linux64-node
            - sysroot-x86_64-linux-gnu
            - sysroot-wasm32-wasi

tasks:
    android-geckoview-fat-aar-shippable/opt:
        description: "Android GeckoView multi-architecture fat AAR Shippable"
        attributes:
            shippable: true
            enable-full-crashsymbols: true
            disable-push-apk: true
            maven_packages:
                - geckoview
        shipping-phase: build
        shipping-product: fennec
        index:
            job-name: android-geckoview-fat-aar-opt
            type: shippable-with-multi-l10n
        treeherder:
            platform: android-5-0-geckoview-fat-aar-shippable/opt
            symbol: B
        dependencies:
            android-x86-shippable: build-android-x86-shippable/opt
            android-x86_64-shippable: build-android-x86_64-shippable/opt
            android-arm-shippable: build-android-arm-shippable/opt
            android-aarch64-shippable: build-android-aarch64-shippable/opt
        worker-type: b-linux-xlarge-gcp
        worker:
            env:
                PERFHERDER_EXTRA_OPTIONS: android-geckoview-fat-aar-nightly
        run:
            actions: [get-secrets, build, multi-l10n]
            config:
                - builds/releng_base_android_64_builds.py
                - taskcluster_nightly.py
            custom-build-variant-cfg: arm
        fetches:
            toolchain:
                - android-gradle-dependencies
        optimization:
            skip-unless-backstop: null

    android-geckoview-fat-aar-shippable-lite/opt:
        description: "Android GeckoView Lite multi-architecture fat AAR Shippable"
        attributes:
            shippable: true
            enable-full-crashsymbols: true
            disable-push-apk: true
            maven_packages:
                - geckoview
                - geckoview-exoplayer2
        shipping-phase: build
        shipping-product: fennec
        index:
            job-name: android-geckoview-fat-aar-opt-lite
            type: shippable-with-multi-l10n
        treeherder:
            platform: android-5-0-geckoview-fat-aar-shippable/opt
            symbol: Bl
        dependencies:
            android-x86-shippable-lite: build-android-x86-shippable-lite/opt
            android-x86_64-shippable-lite: build-android-x86_64-shippable-lite/opt
            android-arm-shippable-lite: build-android-arm-shippable-lite/opt
            android-aarch64-shippable-lite: build-android-aarch64-shippable-lite/opt
        worker-type: b-linux-xlarge-gcp
        worker:
            env:
                PERFHERDER_EXTRA_OPTIONS: android-geckoview-fat-aar-nightly-lite
        run:
            actions: [get-secrets, build, multi-l10n]
            config:
                - builds/releng_base_android_64_builds.py
                - taskcluster_nightly.py
            custom-build-variant-cfg: arm-lite
        fetches:
            toolchain:
                - android-gradle-dependencies-lite
        optimization:
            skip-unless-backstop: null

    android-geckoview-fat-aar/opt:
        description: "Android GeckoView multi-architecture fat AAR Opt"
        attributes:
            maven_packages:
                - geckoview
        index:
            job-name: android-geckoview-fat-aar-opt
        treeherder:
            platform: android-5-0-geckoview-fat-aar/opt
            symbol: B
        dependencies:
            android-x86-opt: build-android-x86/opt
            android-x86_64-opt: build-android-x86_64/opt
            android-arm-opt: build-android-arm/opt
            android-aarch64-opt: build-android-aarch64/opt
        worker:
            env:
                PERFHERDER_EXTRA_OPTIONS: android-geckoview-fat-aar-opt
                USE_ARTIFACT: '1'
                MOZ_ARTIFACT_TASK: {task-reference: '<android-arm-opt>'}
        run:
            actions: [get-secrets, build]
            config: ["builds/releng_base_android_64_builds.py"]
            custom-build-variant-cfg: arm
        fetches:
            toolchain:
                - linux64-sccache
                - android-gradle-dependencies
