| /* |
| * 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") |
| } |
| |
| /** |
| * When `reusePrebuiltsAar` is set to `true` reuses the AAR file from the ../../prebuilts directory. |
| * When `reusePrebuiltsAar` is set to `false` builds the project from scratch (from CXX) files. |
| * |
| * This was introduced to address the following issues that occurred when always building |
| * the project from scratch: |
| * - no stripping of debug symbols in 'test' configurations resulting in very large |
| * files (200+ MB total) being added to e.g. each Benchmark project (b/228627720). |
| * - no caching due to the way CMake builds are currently handled in Android Gradle Plugin |
| * resulting in always building the CXX files from scratch, which is very slow due to the |
| * size of Perfetto SDK (b/230790969). |
| * |
| * Additionally, using the prebuilts reference directly (instead of the project reference) |
| * resulted in the project not getting published to Maven or Snapshot Builds (androidx.dev). |
| */ |
| |
| def reusePrebuiltsAar = Boolean.parseBoolean( |
| System.getProperty("TRACING_PERFETTO_REUSE_PREBUILTS_AAR", "true") |
| ) |
| def prebuiltsAarVersion = androidx.LibraryVersions.TRACING_PERFETTO |
| def unzippedPrebuiltsAarDir = "$buildDir/unzipped-aar" |
| |
| if (reusePrebuiltsAar) { |
| def unzipTask = tasks.register("unzipPrebuiltsAarDir", Copy) { |
| def zipFile = AndroidXConfig.getPrebuiltsRoot(project).toPath().resolve( |
| "androidx/internal/androidx/tracing/tracing-perfetto-binary/$prebuiltsAarVersion/" + |
| "tracing-perfetto-binary-${prebuiltsAarVersion}.aar" |
| ) |
| from zipTree(zipFile) |
| into file(unzippedPrebuiltsAarDir) |
| } |
| |
| tasks.findByName("preBuild").dependsOn(unzipTask) |
| } |
| |
| android { |
| if (reusePrebuiltsAar) { |
| sourceSets { |
| main.jniLibs.srcDirs += new File(unzippedPrebuiltsAarDir, "jni") |
| } |
| } else { // build .so files from scratch |
| externalNativeBuild { |
| cmake { |
| path "src/main/cpp/CMakeLists.txt" |
| version = libs.versions.cmake.get() |
| } |
| } |
| } |
| namespace = "androidx.tracing.perfetto.binary" |
| } |
| |
| dependencies { |
| androidTestImplementation(libs.kotlinStdlib) |
| androidTestImplementation(libs.testExtJunit) |
| androidTestImplementation(libs.testRunner) |
| androidTestImplementation(project(":benchmark:benchmark-common")) // for supported ABI checks |
| } |
| |
| androidx { |
| name = "Tracing Perfetto Binary" |
| type = LibraryType.PUBLISHED_LIBRARY |
| inceptionYear = "2022" |
| description = "Provides native binaries required by AndroidX Tracing: Perfetto SDK " + |
| "and is not intended to be used outside of that context." |
| doNotDocumentReason = "No public API" |
| deviceTests { |
| enableAlsoRunningOnPhysicalDevices = true |
| } |
| } |