1/* 2 * Copyright 2024 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 17import androidx.build.AndroidXConfig 18import androidx.build.SoftwareType 19import androidx.build.PlatformIdentifier 20import androidx.build.ProjectLayoutType 21import org.jetbrains.kotlin.gradle.tasks.KotlinCompile 22 23/** 24 * This file was created using the `create_project.py` script located in the 25 * `<AndroidX root>/development/project-creator` directory. 26 * 27 * Please use that script when creating a new project, rather than copying an existing project and 28 * modifying its settings. 29 */ 30plugins { 31 id("AndroidXPlugin") 32 id("com.squareup.wire") 33} 34 35androidXMultiplatform { 36 jvm() 37 androidLibrary { 38 namespace = "androidx.benchmark.traceprocessor" 39 withAndroidTestOnDeviceBuilder { 40 it.compilationName = "instrumentedTest" 41 it.defaultSourceSetName = "androidInstrumentedTest" 42 it.sourceSetTreeName = "test" 43 } 44 } 45 46 defaultPlatform(PlatformIdentifier.JVM) 47 48 sourceSets { 49 commonMain { 50 dependencies { 51 api(libs.kotlinStdlib) 52 api("androidx.annotation:annotation:1.8.1") 53 implementation(libs.wireRuntime) 54 } 55 } 56 androidMain { 57 dependsOn(commonMain) 58 } 59 } 60} 61 62tasks.withType(KotlinCompile).configureEach { 63 kotlinOptions { 64 // Enable using experimental APIs from within same version group 65 freeCompilerArgs += [ 66 "-opt-in=androidx.benchmark.traceprocessor.ExperimentalTraceProcessorApi", 67 "-opt-in=androidx.benchmark.traceprocessor.ExperimentalInsightApi", 68 ] 69 } 70} 71 72// Workarounds for Wire's plugin not setting code generation directory as task output correctly 73// See https://github.com/square/wire/issues/3199 74tasks.named("multiplatformSourceJar").configure { 75 dependsOn(tasks.named("generateCommonMainProtos")) 76} 77afterEvaluate { 78 if (!ProjectLayoutType.isPlayground(project)) { 79 tasks.named("generateJavaKzip").configure { 80 dependsOn(tasks.named("generateCommonMainProtos")) 81 } 82 } 83} 84 85wire { 86 kotlin {} 87 sourcePath { 88 srcDir AndroidXConfig.getPrebuiltsRoot(project).absolutePath + '/androidx/traceprocessor' 89 90 // currently, all protos are at same tree depth 91 // can add further includes if this stops working 92 include 'protos/perfetto/*/*.proto' 93 } 94 95 prune 'perfetto.protos.AndroidBatteryMetric' 96 prune 'perfetto.protos.AndroidBinderMetric' 97 prune 'perfetto.protos.AndroidCameraMetric' 98 prune 'perfetto.protos.AndroidCameraUnaggregatedMetric' 99 prune 'perfetto.protos.AndroidCpuMetric' 100 prune 'perfetto.protos.AndroidDisplayMetrics' 101 prune 'perfetto.protos.AndroidDmaHeapMetric' 102 prune 'perfetto.protos.AndroidDvfsMetric' 103 prune 'perfetto.protos.AndroidFastrpcMetric' 104 prune 'perfetto.protos.AndroidFrameTimelineMetric' 105 prune 'perfetto.protos.AndroidGpuMetric' 106 prune 'perfetto.protos.AndroidHwcomposerMetrics' 107 prune 'perfetto.protos.AndroidHwuiMetric' 108 prune 'perfetto.protos.AndroidIonMetric' 109 prune 'perfetto.protos.AndroidIrqRuntimeMetric' 110 prune 'perfetto.protos.AndroidJankCujMetric' 111 prune 'perfetto.protos.AndroidLmkMetric' 112 prune 'perfetto.protos.AndroidLmkReasonMetric' 113 prune 'perfetto.protos.AndroidMemoryMetric' 114 prune 'perfetto.protos.AndroidMemoryUnaggregatedMetric' 115 prune 'perfetto.protos.AndroidMultiuserMetric' 116 prune 'perfetto.protos.AndroidNetworkMetric' 117 prune 'perfetto.protos.AndroidPackageList' 118 prune 'perfetto.protos.AndroidPowerRails' 119 prune 'perfetto.protos.AndroidProcessMetadata' 120 prune 'perfetto.protos.AndroidRtRuntimeMetric' 121 prune 'perfetto.protos.AndroidSimpleperfMetric' 122 prune 'perfetto.protos.AndroidSurfaceflingerMetric' 123 prune 'perfetto.protos.AndroidTaskNames' 124 prune 'perfetto.protos.AndroidTraceQualityMetric' 125 prune 'perfetto.protos.G2dMetrics' 126 prune 'perfetto.protos.JavaHeapHistogram' 127 prune 'perfetto.protos.JavaHeapStats' 128 prune 'perfetto.protos.ProcessRenderInfo' 129 prune 'perfetto.protos.ProfilerSmaps' 130 prune 'perfetto.protos.TraceAnalysisStats' 131 prune 'perfetto.protos.TraceMetadata' 132 prune 'perfetto.protos.UnsymbolizedFrames' 133} 134 135androidx { 136 name = "Benchmark TraceProcessor" 137 type = SoftwareType.PUBLISHED_LIBRARY 138 inceptionYear = "2024" 139 description = "AndroidX Benchmark TraceProcessor" 140 metalavaK2UastEnabled = false 141 samples(project(":benchmark:benchmark-samples")) 142}