/*
 * Copyright (C) 2022 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/**
 * This file was created using the `create_project.py` script located in the
 * `<AndroidX root>/development/project-creator` directory.
 *
 * Please use that script when creating a new project, rather than copying an existing project and
 * modifying its settings.
 */
import androidx.build.LibraryType
import androidx.build.AndroidXConfig

plugins {
    id("AndroidXPlugin")
    id("com.android.library")
    id("kotlin-android")
}

android {
    sourceSets {
        test.resources {
            // Allows for testing that tracing-perfetto-binary in the prebuilts folder matches
            // checksums in `PerfettoNative.Metadata`.
            // Note that due to `TRACING_PERFETTO_REUSE_PREBUILTS_AAR` flag in
            // `tracing:tracing-perfetto-binary`, `tracing:tracing-perfetto-binary` returns
            // prebuilts AAR instead of being built from source code. See documentation for
            // `TRACING_PERFETTO_REUSE_PREBUILTS_AAR` for more information.
            // TODO(239041710): create a test that verifies that `tracing:tracing-perfetto-binary`
            // matches its source code.
            srcDirs += AndroidXConfig
                    .getPrebuiltsRoot(project).toPath()
                    .resolve(
                            "androidx/internal/androidx/tracing/tracing-perfetto-binary/" +
                                    "${androidx.LibraryVersions.TRACING_PERFETTO}"
                    ).toFile()
        }
    }
}

dependencies {
    api("androidx.annotation:annotation:1.8.1")
    implementation("androidx.startup:startup-runtime:1.1.1")
    implementation(libs.kotlinStdlib)
    androidTestImplementation(libs.testExtJunit)
    androidTestImplementation(libs.testRunner)
    androidTestImplementation(libs.truth)
    androidTestImplementation(project(":tracing:tracing-perfetto-binary"))
    testImplementation(libs.junit)
    testImplementation(libs.kotlinStdlib)
    testImplementation(libs.truth)
}

androidx {
    name = "Tracing Perfetto"
    type = LibraryType.PUBLISHED_LIBRARY
    inceptionYear = "2022"
    description = "AndroidX Tracing: Perfetto SDK"
    legacyDisableKotlinStrictApiMode = true
    deviceTests {
        enableAlsoRunningOnPhysicalDevices = true
    }
}

android {
    buildTypes.configureEach {
        consumerProguardFiles "proguard-rules.pro"
    }
    namespace = "androidx.tracing.perfetto"
}
