1 /* 2 * Copyright 2023 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 17 package androidx.baselineprofile.gradle.producer 18 19 import org.gradle.api.Incubating 20 import org.gradle.api.Project 21 22 /** Allows specifying settings for the Baseline Profile Producer Plugin. */ 23 open class BaselineProfileProducerExtension { 24 25 companion object { 26 27 private const val EXTENSION_NAME = "baselineProfile" 28 registernull29 internal fun register(project: Project): BaselineProfileProducerExtension { 30 val ext = project.extensions.findByType(BaselineProfileProducerExtension::class.java) 31 if (ext != null) { 32 return ext 33 } 34 return project.extensions.create( 35 EXTENSION_NAME, 36 BaselineProfileProducerExtension::class.java 37 ) 38 } 39 } 40 41 /** 42 * Allows selecting the managed devices to use for generating baseline profiles. This should be 43 * a list of strings contained the names of the devices specified in the configuration for 44 * managed devices. For example, in the following configuration, the name is `pixel6Api31`. 45 * 46 * ``` 47 * testOptions.managedDevices.allDevices { 48 * pixel6Api31(ManagedVirtualDevice) { 49 * device = "Pixel 6" 50 * apiLevel = 31 51 * systemImageSource = "aosp" 52 * } 53 * } 54 * ``` 55 */ 56 var managedDevices = mutableListOf<String>() 57 58 /** 59 * Whether baseline profiles should be generated on connected devices. Note that in order to 60 * generate a baseline profile, the device is required to be rooted or api level >= 33. 61 */ 62 var useConnectedDevices = true 63 64 /** 65 * Whether tests with Macrobenchmark rule should be skipped when running on emulator. Note that 66 * when `automaticGenerationDuringBuild` is `true` and managed devices are used benchmark will 67 * always run on emulator, causing an exception if this flag is not enabled. 68 */ 69 var skipBenchmarksOnEmulator = true 70 71 /** Enables the emulator display for GMD devices. This is not a stable api. */ 72 @Incubating var enableEmulatorDisplay = false 73 } 74