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 androidx.baselineprofile.gradle.utils.INSTRUMENTATION_ARG_TARGET_PACKAGE_NAME
20 
21 private const val PROP_PREFIX_ANDROID_TEST_INSTRUMENTATION_RUNNER_ARG =
22     "android.testInstrumentationRunnerArguments."
23 
24 /**
25  * This property determines whether the test task should actually run to generate the baseline
26  * profile artifacts. When this property is set, the test tasks will be disabled and baseline
27  * profile won't be generated. This property is useful for Github CI, as default ubuntu runners
28  * cannot run android emulators.
29  *
30  * An example of how to configure baseline profile generation on Github CI is in the project
31  * NowInAndroid:
32  * https://github.com/android/nowinandroid/blob/main/.github/workflows/AndroidCIWithGmd.yaml#L42
33  * It's necessary to set `runs-on: macos-12` and properties -Dorg.gradle.workers.max=1
34  * -Pandroid.testoptions.manageddevices.emulator.gpu="swiftshader_indirect.
35  */
36 internal const val PROP_SKIP_GENERATION = "androidx.baselineprofile.skipgeneration"
37 
38 /**
39  * This property determines whether the baselineProfile dsl specification for `managedDevices` and
40  * `useConnectedDevices` is respected. When this property is set to to true only connected devices
41  * are used and managed devices are ignored.
42  */
43 internal const val PROP_FORCE_ONLY_CONNECTED_DEVICES =
44     "androidx.baselineprofile.forceonlyconnecteddevices"
45 
46 /**
47  * This property determines whether the testInstrumentationRunnerArguments
48  * `androidx.benchmark.enabledRules` is set depending on which variants the tests are invoked on.
49  * When this flag IS NOT SPECIFIED, the plugin injects the `enabledRules` argument in order to
50  * enable tests with a specific rule, depending on the variant. For example, when running tests on a
51  * `nonMinified` build type such as `connectedNonMinifiedReleaseAndroidTest`, the plugin injects
52  * `android.testInstrumentationRunnerArguments.androidx.benchmark.enabledRules=baselineprofile`.
53  * When this flag IS SPECIFIED, the plugin will not inject any `enabledRules` argument and all the
54  * tests, independent from the rule applied, will be run.
55  */
56 internal const val PROP_DONT_DISABLE_RULES = "androidx.baselineprofile.dontdisablerules"
57 
58 /**
59  * This property specifies the target package name of the app to start when running the baseline
60  * profile generator. Normally this is passed by the baseline profile gradle plugin and it's
61  * specific per variant. It's possible to override this property manually directly specifying the
62  * test instrumentation runner argument.
63  */
64 internal const val PROP_SEND_TARGET_PACKAGE_NAME =
65     "$PROP_PREFIX_ANDROID_TEST_INSTRUMENTATION_RUNNER_ARG$INSTRUMENTATION_ARG_TARGET_PACKAGE_NAME"
66