Damien Martin-Guillerez | f88f4d8 | 2015-09-25 13:56:55 +0000 | [diff] [blame] | 1 | // Copyright 2014 The Bazel Authors. All rights reserved. |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | // you may not use this file except in compliance with the License. |
| 5 | // You may obtain a copy of the License at |
| 6 | // |
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
| 14 | |
| 15 | package com.google.devtools.build.lib.testutil; |
| 16 | |
| 17 | import com.google.common.collect.ImmutableList; |
Googler | 91279ec | 2024-03-26 11:01:16 -0700 | [diff] [blame] | 18 | import com.google.devtools.build.lib.cmdline.Label; |
wyv | 69be399 | 2021-12-10 06:46:32 -0800 | [diff] [blame] | 19 | import com.google.devtools.build.lib.cmdline.RepositoryName; |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 20 | |
| 21 | /** |
| 22 | * Various constants required by the tests. |
| 23 | */ |
| 24 | public class TestConstants { |
leba | c322e88 | 2018-12-20 11:02:02 -0800 | [diff] [blame] | 25 | |
Yannic Bonenberger | 2651970 | 2019-08-19 09:17:07 -0700 | [diff] [blame] | 26 | public static final String LOAD_PROTO_LIBRARY = |
Googler | 07af430 | 2024-10-03 07:38:34 -0700 | [diff] [blame] | 27 | "load('@protobuf//bazel:proto_library.bzl', 'proto_library')"; |
| 28 | public static final String PROTO_TOOLCHAIN = "@protobuf//bazel/private:proto_toolchain_type"; |
Googler | d435c6d | 2023-09-21 07:05:40 -0700 | [diff] [blame] | 29 | public static final String LOAD_PROTO_TOOLCHAIN = |
Googler | 07af430 | 2024-10-03 07:38:34 -0700 | [diff] [blame] | 30 | "load('@protobuf//bazel/toolchains:proto_toolchain.bzl', 'proto_toolchain')"; |
Yannic Bonenberger | 2651970 | 2019-08-19 09:17:07 -0700 | [diff] [blame] | 31 | public static final String LOAD_PROTO_LANG_TOOLCHAIN = |
Googler | 07af430 | 2024-10-03 07:38:34 -0700 | [diff] [blame] | 32 | "load('@protobuf//bazel/toolchains:proto_lang_toolchain.bzl', 'proto_lang_toolchain')"; |
Yannic Bonenberger | 2651970 | 2019-08-19 09:17:07 -0700 | [diff] [blame] | 33 | |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 34 | private TestConstants() { |
| 35 | } |
| 36 | |
Luis Fernando Pino Duque | be10218 | 2016-05-23 14:03:55 +0000 | [diff] [blame] | 37 | public static final String PRODUCT_NAME = "bazel"; |
| 38 | |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 39 | /** |
| 40 | * A list of all embedded binaries that go into the regular Bazel binary. |
| 41 | */ |
| 42 | public static final ImmutableList<String> EMBEDDED_TOOLS = ImmutableList.of( |
| 43 | "build-runfiles", |
Philipp Wollermann | 278814b | 2016-07-15 14:41:54 +0000 | [diff] [blame] | 44 | "linux-sandbox", |
Chris Parsons | f488818 | 2016-01-08 00:42:14 +0000 | [diff] [blame] | 45 | "process-wrapper", |
| 46 | "xcode-locator"); |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 47 | |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 48 | /** |
| 49 | * Location in the bazel repo where embedded binaries come from. |
| 50 | */ |
Damien Martin-Guillerez | b09c97a | 2015-04-01 11:17:16 +0000 | [diff] [blame] | 51 | public static final ImmutableList<String> EMBEDDED_SCRIPTS_PATHS = ImmutableList.of( |
Yun Peng | 136dae1 | 2023-09-08 12:39:10 -0700 | [diff] [blame] | 52 | "_main/src/main/tools"); |
Ulf Adams | ff03154 | 2015-02-24 10:00:51 +0000 | [diff] [blame] | 53 | |
| 54 | /** |
Han-Wen Nienhuys | ceae8c5 | 2015-09-22 16:24:45 +0000 | [diff] [blame] | 55 | * Default workspace name. |
| 56 | */ |
Googler | 30d033c | 2023-10-16 09:03:02 -0700 | [diff] [blame] | 57 | public static final String WORKSPACE_NAME = "_main"; |
| 58 | |
| 59 | /** |
| 60 | * Legacy default workspace name. |
| 61 | */ |
| 62 | public static final String LEGACY_WORKSPACE_NAME = "__main__"; |
Han-Wen Nienhuys | ceae8c5 | 2015-09-22 16:24:45 +0000 | [diff] [blame] | 63 | |
| 64 | /** |
Ulf Adams | d5baac0 | 2015-02-25 14:18:14 +0000 | [diff] [blame] | 65 | * Name of a class with an INSTANCE field of type AnalysisMock to be used for analysis tests. |
| 66 | */ |
Ulf Adams | 7c5eefb | 2015-03-03 14:52:46 +0000 | [diff] [blame] | 67 | public static final String TEST_ANALYSIS_MOCK = |
Ulf Adams | 570c17f | 2015-04-23 18:12:56 +0000 | [diff] [blame] | 68 | "com.google.devtools.build.lib.analysis.mock.BazelAnalysisMock"; |
Ulf Adams | d5baac0 | 2015-02-25 14:18:14 +0000 | [diff] [blame] | 69 | |
| 70 | /** |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 71 | * Directory where we can find bazel's Java tests, relative to a test's runfiles directory. |
| 72 | */ |
Yun Peng | 136dae1 | 2023-09-08 12:39:10 -0700 | [diff] [blame] | 73 | public static final String JAVATESTS_ROOT = "_main/src/test/java/"; |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 74 | |
hlopko | db80298 | 2018-02-27 06:09:18 -0800 | [diff] [blame] | 75 | /** Location of the bazel repo relative to the workspace root */ |
| 76 | public static final String BAZEL_REPO_PATH = ""; |
| 77 | |
ilist | 2d13fdb | 2021-03-05 05:42:56 -0800 | [diff] [blame] | 78 | /** The file path in which to create files so that they end up under Bazel main repository. */ |
Yun Peng | 136dae1 | 2023-09-08 12:39:10 -0700 | [diff] [blame] | 79 | public static final String BAZEL_REPO_SCRATCH = "../_main/"; |
ilist | 2d13fdb | 2021-03-05 05:42:56 -0800 | [diff] [blame] | 80 | |
ruperts | 5274d8b | 2017-12-20 10:45:58 -0800 | [diff] [blame] | 81 | /** Relative path to the {@code process-wrapper} tool. */ |
| 82 | public static final String PROCESS_WRAPPER_PATH = |
Yun Peng | 136dae1 | 2023-09-08 12:39:10 -0700 | [diff] [blame] | 83 | "_main/src/main/tools/process-wrapper"; |
ruperts | bec2fe8 | 2017-12-05 21:53:50 -0800 | [diff] [blame] | 84 | |
ruperts | 5274d8b | 2017-12-20 10:45:58 -0800 | [diff] [blame] | 85 | /** Relative path to the {@code linux-sandbox} tool. */ |
| 86 | public static final String LINUX_SANDBOX_PATH = |
Yun Peng | 136dae1 | 2023-09-08 12:39:10 -0700 | [diff] [blame] | 87 | "_main/src/main/tools/linux-sandbox"; |
ruperts | 5274d8b | 2017-12-20 10:45:58 -0800 | [diff] [blame] | 88 | |
| 89 | /** Relative path to the {@code spend_cpu_time} testing tool. */ |
| 90 | public static final String CPU_TIME_SPENDER_PATH = |
Yun Peng | 136dae1 | 2023-09-08 12:39:10 -0700 | [diff] [blame] | 91 | "_main/src/test/shell/integration/spend_cpu_time"; |
ruperts | bec2fe8 | 2017-12-05 21:53:50 -0800 | [diff] [blame] | 92 | |
arostovtsev | dcf2b86 | 2022-02-16 10:14:07 -0800 | [diff] [blame] | 93 | /** |
| 94 | * Directory where we can find Bazel's own bootstrapping rules relative to a test's runfiles |
| 95 | * directory, i.e. when //tools/build_rules:srcs is in a test's data. |
| 96 | */ |
Yun Peng | 136dae1 | 2023-09-08 12:39:10 -0700 | [diff] [blame] | 97 | public static final String BUILD_RULES_DATA_PATH = "_main/tools/build_rules/"; |
arostovtsev | dcf2b86 | 2022-02-16 10:14:07 -0800 | [diff] [blame] | 98 | |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 99 | public static final String TEST_RULE_CLASS_PROVIDER = |
| 100 | "com.google.devtools.build.lib.bazel.rules.BazelRuleClassProvider"; |
Kristina Chodorow | 76d94b1 | 2015-12-16 16:12:52 +0000 | [diff] [blame] | 101 | public static final String TEST_RULE_MODULE = |
philwo | 62dd174 | 2019-06-04 05:27:37 -0700 | [diff] [blame] | 102 | "com.google.devtools.build.lib.bazel.rules.BazelRulesModule"; |
ulfjack | 2f12419 | 2019-09-25 05:36:27 -0700 | [diff] [blame] | 103 | public static final String TEST_STRATEGY_MODULE = |
| 104 | "com.google.devtools.build.lib.bazel.rules.BazelStrategyModule"; |
Lukacs Berki | 72c4071 | 2017-01-31 14:52:55 +0000 | [diff] [blame] | 105 | public static final String TEST_REAL_UNIX_FILE_SYSTEM = |
Ulf Adams | 8afbd3c | 2017-02-28 10:42:48 +0000 | [diff] [blame] | 106 | "com.google.devtools.build.lib.unix.UnixFileSystem"; |
Ed Schouten | 05650ff | 2020-09-17 10:01:25 -0700 | [diff] [blame] | 107 | public static final String TEST_UNIX_HASH_ATTRIBUTE = ""; |
Lukacs Berki | 72c4071 | 2017-01-31 14:52:55 +0000 | [diff] [blame] | 108 | |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 109 | public static final ImmutableList<String> IGNORED_MESSAGE_PREFIXES = ImmutableList.<String>of(); |
Ulf Adams | d87465e | 2015-04-17 13:16:51 +0000 | [diff] [blame] | 110 | |
cparsons | 81ce9e3 | 2017-08-27 19:28:32 +0200 | [diff] [blame] | 111 | /** The path in which the mock cc crosstool resides. */ |
| 112 | public static final String MOCK_CC_CROSSTOOL_PATH = "tools/cpp"; |
Dmitry Lomov | e0a69aa | 2015-11-30 16:25:40 +0000 | [diff] [blame] | 113 | |
Googler | 3acab6f | 2023-09-20 04:33:15 -0700 | [diff] [blame] | 114 | /** The path in which the mock license rule resides. */ |
| 115 | public static final String MOCK_LICENSE_SCRATCH = "third_party/rules_license/"; |
| 116 | |
cparsons | 81ce9e3 | 2017-08-27 19:28:32 +0200 | [diff] [blame] | 117 | /** The workspace repository label under which built-in tools reside. */ |
wyv | 69be399 | 2021-12-10 06:46:32 -0800 | [diff] [blame] | 118 | public static final RepositoryName TOOLS_REPOSITORY = RepositoryName.BAZEL_TOOLS; |
cparsons | 81ce9e3 | 2017-08-27 19:28:32 +0200 | [diff] [blame] | 119 | /** The file path in which to create files so that they end up under {@link #TOOLS_REPOSITORY}. */ |
wyv | 5fad8a9 | 2021-07-30 05:29:37 -0700 | [diff] [blame] | 120 | public static final String TOOLS_REPOSITORY_SCRATCH = "embedded_tools/"; |
Marcel Hlopko | 02d1966 | 2019-11-11 21:55:16 -0800 | [diff] [blame] | 121 | |
cparsons | 81ce9e3 | 2017-08-27 19:28:32 +0200 | [diff] [blame] | 122 | /** The output file path prefix for tool file dependencies. */ |
| 123 | public static final String TOOLS_REPOSITORY_PATH_PREFIX = "external/bazel_tools/"; |
Ulf Adams | c934fad | 2015-12-22 07:42:11 +0000 | [diff] [blame] | 124 | |
Marcel Hlopko | 02d1966 | 2019-11-11 21:55:16 -0800 | [diff] [blame] | 125 | /** The directory in which rules_cc repo resides in execroot. */ |
Yun Peng | 136dae1 | 2023-09-08 12:39:10 -0700 | [diff] [blame] | 126 | public static final String RULES_CC_REPOSITORY_EXECROOT = "external/" + RulesCcRepoName.CANONICAL_REPO_NAME + "/"; |
Googler | fa39221 | 2023-11-23 04:13:03 -0800 | [diff] [blame] | 127 | /* Prefix for loads from rules_cc */ |
| 128 | public static final String RULES_CC = "@rules_cc//cc"; |
Marcel Hlopko | 02d1966 | 2019-11-11 21:55:16 -0800 | [diff] [blame] | 129 | |
Googler | 228c78d | 2024-10-03 09:09:48 -0700 | [diff] [blame] | 130 | /** |
| 131 | * The repo/package rules_python is rooted at. If empty, builtin rules are used. |
| 132 | */ |
| 133 | public static final String RULES_PYTHON_PACKAGE_ROOT = "@@rules_python+/"; |
Richard Levasseur | 0840774 | 2023-11-20 18:16:44 -0800 | [diff] [blame] | 134 | |
Ulf Adams | c934fad | 2015-12-22 07:42:11 +0000 | [diff] [blame] | 135 | public static final ImmutableList<String> DOCS_RULES_PATHS = ImmutableList.of( |
| 136 | "src/main/java/com/google/devtools/build/lib/rules"); |
Luis Fernando Pino Duque | b1b28b6 | 2016-02-25 14:25:19 +0000 | [diff] [blame] | 137 | |
John Cater | 17a1ae9 | 2017-01-25 15:18:25 +0000 | [diff] [blame] | 138 | // Constants used to determine how genrule pulls in the setup script. |
| 139 | public static final String GENRULE_SETUP = "@bazel_tools//tools/genrule:genrule-setup.sh"; |
| 140 | public static final String GENRULE_SETUP_PATH = "genrule-setup.sh"; |
| 141 | |
Googler | 49eda9f | 2023-11-17 09:10:43 -0800 | [diff] [blame] | 142 | public static final String STARLARK_EXEC_TRANSITION = |
| 143 | "@_builtins//:common/builtin_exec_platforms.bzl%bazel_exec_transition"; |
| 144 | |
cparsons | 81ce9e3 | 2017-08-27 19:28:32 +0200 | [diff] [blame] | 145 | /** |
John Cater | 13dc4f7 | 2019-08-07 11:14:40 -0700 | [diff] [blame] | 146 | * Flags that must be set for Bazel to work properly, if the default values are unusable for some |
| 147 | * reason. |
janakr | afb5c70 | 2019-03-05 10:47:14 -0800 | [diff] [blame] | 148 | */ |
| 149 | public static final ImmutableList<String> PRODUCT_SPECIFIC_FLAGS = |
brandjon | 5f5e6ad | 2019-03-30 10:02:03 -0700 | [diff] [blame] | 150 | ImmutableList.of( |
Googler | 74c8ca4 | 2024-03-29 12:48:51 -0700 | [diff] [blame] | 151 | "--platforms=@bazel_tools//tools:host_platform", |
| 152 | "--host_platform=@bazel_tools//tools:host_platform", |
cushon | d521964 | 2019-04-03 17:38:12 -0700 | [diff] [blame] | 153 | // TODO(#7849): Remove after flag flip. |
Googler | 2172c54 | 2022-02-14 10:21:05 -0800 | [diff] [blame] | 154 | "--incompatible_use_toolchain_resolution_for_java_rules"); |
Nathan Harmata | 3ad5645 | 2016-06-10 16:17:45 +0000 | [diff] [blame] | 155 | |
Googler | c26bd00 | 2024-08-08 07:15:45 -0700 | [diff] [blame] | 156 | public static final ImmutableList<String> PRODUCT_SPECIFIC_BUILD_LANG_OPTIONS = |
Googler | cca9587 | 2024-09-25 00:23:48 -0700 | [diff] [blame] | 157 | ImmutableList.of( |
Googler | 678b01a | 2024-10-05 23:16:32 -0700 | [diff] [blame] | 158 | "--experimental_rule_extension_api", |
Googler | cca9587 | 2024-09-25 00:23:48 -0700 | [diff] [blame] | 159 | // Don't apply autoloads in unit tests, because not all repos are available |
| 160 | "--incompatible_autoload_externally="); |
Googler | c26bd00 | 2024-08-08 07:15:45 -0700 | [diff] [blame] | 161 | |
John Cater | 4e6080a | 2019-01-29 07:18:42 -0800 | [diff] [blame] | 162 | /** Partial query to filter out implicit dependencies of C/C++ rules. */ |
leba | c322e88 | 2018-12-20 11:02:02 -0800 | [diff] [blame] | 163 | public static final String CC_DEPENDENCY_CORRECTION = |
Googler | 29e06ff | 2024-02-22 03:08:23 -0800 | [diff] [blame] | 164 | " - deps(" + TOOLS_REPOSITORY + "//tools/cpp:current_cc_toolchain)" |
Googler | 897edaa | 2023-12-18 06:40:41 -0800 | [diff] [blame] | 165 | + " - deps(" + TOOLS_REPOSITORY + "//tools/cpp:grep-includes)"; |
leba | c322e88 | 2018-12-20 11:02:02 -0800 | [diff] [blame] | 166 | |
Googler | 03b8616 | 2023-08-18 07:28:53 -0700 | [diff] [blame] | 167 | public static final String APPLE_PLATFORM_PATH = "build_bazel_apple_support/platforms"; |
Googler | 5881c38 | 2024-08-27 02:28:33 -0700 | [diff] [blame] | 168 | public static final String APPLE_PLATFORM_PACKAGE_ROOT = "@@build_bazel_apple_support+//platforms"; |
hlopko | 3d8b579 | 2019-06-27 00:19:19 -0700 | [diff] [blame] | 169 | public static final String CONSTRAINTS_PACKAGE_ROOT = "@platforms//"; |
| 170 | |
wyv | 5fad8a9 | 2021-07-30 05:29:37 -0700 | [diff] [blame] | 171 | public static final String PLATFORMS_PATH = "embedded_tools/platforms"; |
laszlocsomor | e1d2e2a | 2020-02-09 23:15:01 -0800 | [diff] [blame] | 172 | public static final String CONSTRAINTS_PATH = "platforms_workspace"; |
cushon | 85da59f | 2019-04-03 11:41:01 -0700 | [diff] [blame] | 173 | |
Googler | 74c8ca4 | 2024-03-29 12:48:51 -0700 | [diff] [blame] | 174 | public static final String PLATFORM_LABEL = "@platforms//host"; |
| 175 | public static final String PLATFORM_LABEL_ALIAS = "@bazel_tools//tools:host_platform"; |
| 176 | public static final String PIII_PLATFORM_LABEL = "@platforms//host:piii"; |
leba | c322e88 | 2018-12-20 11:02:02 -0800 | [diff] [blame] | 177 | |
Googler | 91279ec | 2024-03-26 11:01:16 -0700 | [diff] [blame] | 178 | public static final Label ANDROID_DEFAULT_SDK = |
| 179 | Label.parseCanonicalUnchecked("@bazel_tools//tools/android:sdk"); |
| 180 | |
gregce | a64ccec | 2020-10-22 13:01:10 -0700 | [diff] [blame] | 181 | /** What toolchain type do Android rules use for platform-based toolchain resolution? */ |
| 182 | public static final String ANDROID_TOOLCHAIN_TYPE_LABEL = |
| 183 | TOOLS_REPOSITORY + "//tools/android:sdk_toolchain_type"; |
| 184 | |
dacek | 85fc784 | 2021-10-13 13:04:56 -0700 | [diff] [blame] | 185 | /** The launcher used by Bazel. */ |
| 186 | public static final String LAUNCHER_PATH = "@bazel_tools//tools/launcher:launcher"; |
| 187 | |
dacek | 0409ad1 | 2022-02-10 12:57:55 -0800 | [diff] [blame] | 188 | /** The target name for ProGuard's allowlister. */ |
arostovtsev | dcf2b86 | 2022-02-16 10:14:07 -0800 | [diff] [blame] | 189 | public static final String PROGUARD_ALLOWLISTER_TARGET = |
| 190 | "@bazel_tools//tools/jdk:proguard_whitelister"; |
dacek | 0409ad1 | 2022-02-10 12:57:55 -0800 | [diff] [blame] | 191 | |
Googler | 4f1ab28 | 2023-02-10 07:55:27 -0800 | [diff] [blame] | 192 | /** The java toolchain type. */ |
Googler | ef457ae | 2023-11-10 09:39:21 -0800 | [diff] [blame] | 193 | public static final String JAVA_TOOLCHAIN_TYPE = "@@bazel_tools//tools/jdk:toolchain_type"; |
Googler | 4f1ab28 | 2023-02-10 07:55:27 -0800 | [diff] [blame] | 194 | |
Googler | 8681437 | 2023-03-06 01:09:01 -0800 | [diff] [blame] | 195 | /** The cpp toolchain type. */ |
Googler | ef457ae | 2023-11-10 09:39:21 -0800 | [diff] [blame] | 196 | public static final String CPP_TOOLCHAIN_TYPE = "@@bazel_tools//tools/cpp:toolchain_type"; |
Googler | 8681437 | 2023-03-06 01:09:01 -0800 | [diff] [blame] | 197 | |
Son Luong Ngoc | dc5ec2b | 2024-04-17 10:22:32 -0700 | [diff] [blame] | 198 | /** Whether blake3 can be used through JNI */ |
| 199 | public static final boolean BLAKE3_AVAILABLE = true; |
| 200 | |
janakr | 3d44325 | 2017-10-10 23:03:26 +0200 | [diff] [blame] | 201 | /** A choice of test execution mode, only varies internally. */ |
| 202 | public enum InternalTestExecutionMode { |
| 203 | NORMAL |
| 204 | } |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 205 | } |