blob: e602a993f5b0af83a4d2638b5f21b781a682ce6f [file] [log] [blame]
Rahul Ravikumar105c68c2020-09-14 15:13:44 -07001/*
2 * Copyright (C) 2020 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
Tiem Songee0da742024-01-03 14:08:46 -080017/**
18 * This file was created using the `create_project.py` script located in the
19 * `<AndroidX root>/development/project-creator` directory.
20 *
21 * Please use that script when creating a new project, rather than copying an existing project and
22 * modifying its settings.
23 */
Omar Ismail8c545f72024-08-21 17:45:15 +010024
25import androidx.build.KotlinTarget
Omar Ismail86e66062024-05-03 16:10:50 +010026import androidx.build.LibraryType
Alan Viverette7ef42b62023-06-26 11:04:08 -040027import androidx.build.AndroidXConfig
Rahul Ravikumar6da9b7f272021-10-20 13:52:42 -070028import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
Rahul Ravikumar105c68c2020-09-14 15:13:44 -070029
30plugins {
31 id("AndroidXPlugin")
32 id("com.android.library")
33 id("kotlin-android")
34}
35
36android {
37 defaultConfig {
Aurimas Liutikas77952822024-12-04 18:00:17 -080038 minSdk = 23
Chris Craik695d64d2024-10-11 11:00:51 -070039
40 // We don't care about perf from these correctness tests, so suppress
41 // anything that may otherwise block these tests
42 testInstrumentationRunnerArguments["androidx.benchmark.suppressErrors"] =
43 "CODE-COVERAGE,DEBUGGABLE,EMULATOR,LOW-BATTERY,UNLOCKED"
Chris Craikfbfc7212021-01-27 11:54:18 -080044 }
45 sourceSets {
Chris Craik266c4e02021-02-02 17:13:44 +000046 main.assets.srcDirs += new File(
Alan Viverette7ef42b62023-06-26 11:04:08 -040047 AndroidXConfig.getPrebuiltsRoot(project),
Chris Craik266c4e02021-02-02 17:13:44 +000048 "androidx/traceprocessor/trace_processor_shell"
49 )
Chris Craikf7ea2632021-04-08 16:36:43 -070050 androidTest.assets.srcDirs += new File(
Alan Viverette7ef42b62023-06-26 11:04:08 -040051 AndroidXConfig.getPrebuiltsRoot(project),
Chris Craikf7ea2632021-04-08 16:36:43 -070052 "androidx/traceprocessor/testdata"
53 )
Jakub Gielzak6fb1f922022-09-26 19:07:53 +010054 // PerfettoHandshake supports both AAR and APK as libtracing_perfetto.so sources:
55 // - AAR is used when e.g. tooling downloads tracing-perfetto-binary AAR files from Maven
56 // - APK is when an APK that contains tracing binaries is used
57 //
58 // Adding the AAR as a test asset below allows us to test the AAR scenario
Jakub Gielzaka51a8962022-06-21 13:36:49 +010059 androidTest.assets.srcDirs += new File(
Alan Viverette7ef42b62023-06-26 11:04:08 -040060 AndroidXConfig.getPrebuiltsRoot(project),
Jakub Gielzakc2d95632022-08-15 16:00:14 +010061 "androidx/internal/androidx/tracing/tracing-perfetto-binary/" +
62 "${androidx.LibraryVersions.TRACING_PERFETTO}"
Jakub Gielzaka51a8962022-06-21 13:36:49 +010063 )
Rahul Ravikumar105c68c2020-09-14 15:13:44 -070064 }
Jakub Gielzak2abe5582022-03-02 17:53:14 +000065
Aurimas Liutikas77952822024-12-04 18:00:17 -080066 namespace = "androidx.benchmark.macro"
Rahul Ravikumar105c68c2020-09-14 15:13:44 -070067}
68
69dependencies {
Julia McClellan4e641972024-11-20 13:47:51 -050070 api(libs.jspecify)
Chris Craik00346a82024-05-21 13:32:20 -070071 api(project(":benchmark:benchmark-common"))
Aurimas Liutikas2c1a81e2021-05-24 16:43:05 -070072 api(libs.junit)
73 api(libs.kotlinStdlib)
Aurimas Liutikas96f0b302024-07-25 15:49:23 -070074 api("androidx.annotation:annotation:1.8.1")
Chris Craikeba03a52020-11-16 09:43:49 -080075
Chris Craik89b4c452023-02-08 13:41:13 -080076 implementation("androidx.core:core:1.9.0")
Prajakta Patil375e7682024-09-24 15:56:11 +000077 implementation("androidx.profileinstaller:profileinstaller:1.4.1")
Aurimas Liutikasd02fb062023-11-10 17:18:40 -080078 implementation("androidx.tracing:tracing-ktx:1.1.0")
Chris Craik0da65ce2024-02-02 15:16:34 -080079 implementation("androidx.tracing:tracing-perfetto:1.0.0")
80 implementation("androidx.tracing:tracing-perfetto-binary:1.0.0")
81 implementation("androidx.tracing:tracing-perfetto-handshake:1.0.0")
Jakub Gielzak2b57ade2023-07-13 18:53:42 +010082 implementation("androidx.test:core:1.5.0")
Aurimas Liutikas2c1a81e2021-05-24 16:43:05 -070083 implementation(libs.testUiautomator)
Marcello Albanoeeae7532022-08-23 11:41:07 -070084 implementation(libs.wireRuntime)
Marcello Albano0c2ddcd2024-08-13 15:44:14 -070085 implementation(libs.testExtJunit)
Chris Craikfbfc7212021-01-27 11:54:18 -080086
Chris Craik3dbcaa92022-11-04 12:44:13 -070087 androidTestImplementation(project(":benchmark:benchmark-junit4"))
Chris Craikfbfc7212021-01-27 11:54:18 -080088 androidTestImplementation(project(":internal-testutils-ktx"))
Ian Lake6b595b52021-08-25 22:09:26 -070089 androidTestImplementation("androidx.activity:activity-ktx:1.3.1")
Jakub Gielzakab40c142022-11-23 15:44:36 +000090 androidTestImplementation(project(":tracing:tracing-perfetto"))
Aurimas Liutikas2c1a81e2021-05-24 16:43:05 -070091 androidTestImplementation(libs.testExtJunit)
92 androidTestImplementation(libs.testRules)
93 androidTestImplementation(libs.testRunner)
94 androidTestImplementation(libs.kotlinTest)
Jakub Gielzak2abe5582022-03-02 17:53:14 +000095 androidTestImplementation(libs.truth)
Rahul Ravikumar105c68c2020-09-14 15:13:44 -070096}
97
98androidx {
Alan Viverettec9e1fd72023-05-08 17:36:59 -040099 name = "Benchmark - Macrobenchmark"
Omar Ismail86e66062024-05-03 16:10:50 +0100100 type = LibraryType.PUBLISHED_LIBRARY
Rahul Ravikumar105c68c2020-09-14 15:13:44 -0700101 inceptionYear = "2020"
102 description = "Android Benchmark - Macrobenchmark"
Aurimas Liutikas5c5419a2024-05-29 15:26:58 -0700103 legacyDisableKotlinStrictApiMode = true
Aurimas Liutikas962925f2024-09-11 11:14:37 -0700104 deviceTests {
105 enableAlsoRunningOnPhysicalDevices = true
106 }
Rahul Ravikumar105c68c2020-09-14 15:13:44 -0700107}
Marcello Albanoeeae7532022-08-23 11:41:07 -0700108
Marcello Albanoeeae7532022-08-23 11:41:07 -0700109tasks.withType(KotlinCompile).configureEach {
110 kotlinOptions {
Chris Craik80d9e8a2023-02-20 10:06:57 -0800111 // Enable using experimental APIs from within same version group
112 freeCompilerArgs += [
Jakub Gielzakd0728092024-09-23 15:47:25 +0100113 "-opt-in=androidx.benchmark.ExperimentalBenchmarkConfigApi",
Chris Craika1afb0d2023-03-09 16:43:42 -0800114 "-opt-in=androidx.benchmark.macro.ExperimentalMetricApi",
Jakub Gielzakd0728092024-09-23 15:47:25 +0100115 "-opt-in=androidx.benchmark.perfetto.ExperimentalPerfettoCaptureApi",
Chris Craika13168a2024-12-12 09:48:11 -0800116 "-opt-in=androidx.benchmark.traceprocessor.ExperimentalTraceProcessorApi",
Chris Craik80d9e8a2023-02-20 10:06:57 -0800117 ]
Marcello Albanoeeae7532022-08-23 11:41:07 -0700118 }
119}
120
Marcello Albano6a8f6862022-10-27 12:59:16 -0700121// Define a task dependency so the app is installed before we run macro benchmarks.
122afterEvaluate {
123 // `:benchmark:integration-tests:macrobenchmark-target:installRelease` is not in the compose
124 // build, so it may fail the compose build job.
125 def installTask = tasks.findByPath(
126 ":benchmark:integration-tests:macrobenchmark-target:installRelease")
127 if (installTask != null) {
Aurimas Liutikas289bb902024-08-15 15:34:13 -0700128 tasks.getByPath(":benchmark:benchmark-macro:connectedReleaseAndroidTest")
Marcello Albano6a8f6862022-10-27 12:59:16 -0700129 .dependsOn(installTask)
130 }
131}
Yigit Boyar129f6da2023-05-05 10:09:07 -0700132
133androidx {
134 deviceTests {
135 targetAppProject = project(":benchmark:integration-tests:macrobenchmark-target")
136 targetAppVariant = "release"
137 }
Omar Ismail8c545f72024-08-21 17:45:15 +0100138 kotlinTarget = KotlinTarget.KOTLIN_1_9
Jakub Gielzak5b090bf2023-06-14 20:08:33 +0100139}