blob: 72d2046f0665808e64c00ae2346d2a71a23e676e [file] [log] [blame]
Damien Martin-Guillerezf88f4d82015-09-25 13:56:55 +00001// Copyright 2014 The Bazel Authors. All rights reserved.
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +01002//
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
15package com.google.devtools.build.lib.testutil;
16
17import com.google.common.collect.ImmutableList;
Googler91279ec2024-03-26 11:01:16 -070018import com.google.devtools.build.lib.cmdline.Label;
wyv69be3992021-12-10 06:46:32 -080019import com.google.devtools.build.lib.cmdline.RepositoryName;
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +010020
21/**
22 * Various constants required by the tests.
23 */
24public class TestConstants {
lebac322e882018-12-20 11:02:02 -080025
Yannic Bonenberger26519702019-08-19 09:17:07 -070026 public static final String LOAD_PROTO_LIBRARY =
Googler07af4302024-10-03 07:38:34 -070027 "load('@protobuf//bazel:proto_library.bzl', 'proto_library')";
28 public static final String PROTO_TOOLCHAIN = "@protobuf//bazel/private:proto_toolchain_type";
Googlerd435c6d2023-09-21 07:05:40 -070029 public static final String LOAD_PROTO_TOOLCHAIN =
Googler07af4302024-10-03 07:38:34 -070030 "load('@protobuf//bazel/toolchains:proto_toolchain.bzl', 'proto_toolchain')";
Yannic Bonenberger26519702019-08-19 09:17:07 -070031 public static final String LOAD_PROTO_LANG_TOOLCHAIN =
Googler07af4302024-10-03 07:38:34 -070032 "load('@protobuf//bazel/toolchains:proto_lang_toolchain.bzl', 'proto_lang_toolchain')";
Yannic Bonenberger26519702019-08-19 09:17:07 -070033
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +010034 private TestConstants() {
35 }
36
Luis Fernando Pino Duquebe102182016-05-23 14:03:55 +000037 public static final String PRODUCT_NAME = "bazel";
38
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +010039 /**
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 Wollermann278814b2016-07-15 14:41:54 +000044 "linux-sandbox",
Chris Parsonsf4888182016-01-08 00:42:14 +000045 "process-wrapper",
46 "xcode-locator");
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +010047
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +010048 /**
49 * Location in the bazel repo where embedded binaries come from.
50 */
Damien Martin-Guillerezb09c97a2015-04-01 11:17:16 +000051 public static final ImmutableList<String> EMBEDDED_SCRIPTS_PATHS = ImmutableList.of(
Yun Peng136dae12023-09-08 12:39:10 -070052 "_main/src/main/tools");
Ulf Adamsff031542015-02-24 10:00:51 +000053
54 /**
Han-Wen Nienhuysceae8c52015-09-22 16:24:45 +000055 * Default workspace name.
56 */
Googler30d033c2023-10-16 09:03:02 -070057 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 Nienhuysceae8c52015-09-22 16:24:45 +000063
64 /**
Ulf Adamsd5baac02015-02-25 14:18:14 +000065 * Name of a class with an INSTANCE field of type AnalysisMock to be used for analysis tests.
66 */
Ulf Adams7c5eefb2015-03-03 14:52:46 +000067 public static final String TEST_ANALYSIS_MOCK =
Ulf Adams570c17f2015-04-23 18:12:56 +000068 "com.google.devtools.build.lib.analysis.mock.BazelAnalysisMock";
Ulf Adamsd5baac02015-02-25 14:18:14 +000069
70 /**
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +010071 * Directory where we can find bazel's Java tests, relative to a test's runfiles directory.
72 */
Yun Peng136dae12023-09-08 12:39:10 -070073 public static final String JAVATESTS_ROOT = "_main/src/test/java/";
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +010074
hlopkodb802982018-02-27 06:09:18 -080075 /** Location of the bazel repo relative to the workspace root */
76 public static final String BAZEL_REPO_PATH = "";
77
ilist2d13fdb2021-03-05 05:42:56 -080078 /** The file path in which to create files so that they end up under Bazel main repository. */
Yun Peng136dae12023-09-08 12:39:10 -070079 public static final String BAZEL_REPO_SCRATCH = "../_main/";
ilist2d13fdb2021-03-05 05:42:56 -080080
ruperts5274d8b2017-12-20 10:45:58 -080081 /** Relative path to the {@code process-wrapper} tool. */
82 public static final String PROCESS_WRAPPER_PATH =
Yun Peng136dae12023-09-08 12:39:10 -070083 "_main/src/main/tools/process-wrapper";
rupertsbec2fe82017-12-05 21:53:50 -080084
ruperts5274d8b2017-12-20 10:45:58 -080085 /** Relative path to the {@code linux-sandbox} tool. */
86 public static final String LINUX_SANDBOX_PATH =
Yun Peng136dae12023-09-08 12:39:10 -070087 "_main/src/main/tools/linux-sandbox";
ruperts5274d8b2017-12-20 10:45:58 -080088
89 /** Relative path to the {@code spend_cpu_time} testing tool. */
90 public static final String CPU_TIME_SPENDER_PATH =
Yun Peng136dae12023-09-08 12:39:10 -070091 "_main/src/test/shell/integration/spend_cpu_time";
rupertsbec2fe82017-12-05 21:53:50 -080092
arostovtsevdcf2b862022-02-16 10:14:07 -080093 /**
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 Peng136dae12023-09-08 12:39:10 -070097 public static final String BUILD_RULES_DATA_PATH = "_main/tools/build_rules/";
arostovtsevdcf2b862022-02-16 10:14:07 -080098
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +010099 public static final String TEST_RULE_CLASS_PROVIDER =
100 "com.google.devtools.build.lib.bazel.rules.BazelRuleClassProvider";
Kristina Chodorow76d94b12015-12-16 16:12:52 +0000101 public static final String TEST_RULE_MODULE =
philwo62dd1742019-06-04 05:27:37 -0700102 "com.google.devtools.build.lib.bazel.rules.BazelRulesModule";
ulfjack2f124192019-09-25 05:36:27 -0700103 public static final String TEST_STRATEGY_MODULE =
104 "com.google.devtools.build.lib.bazel.rules.BazelStrategyModule";
Lukacs Berki72c40712017-01-31 14:52:55 +0000105 public static final String TEST_REAL_UNIX_FILE_SYSTEM =
Ulf Adams8afbd3c2017-02-28 10:42:48 +0000106 "com.google.devtools.build.lib.unix.UnixFileSystem";
Ed Schouten05650ff2020-09-17 10:01:25 -0700107 public static final String TEST_UNIX_HASH_ATTRIBUTE = "";
Lukacs Berki72c40712017-01-31 14:52:55 +0000108
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +0100109 public static final ImmutableList<String> IGNORED_MESSAGE_PREFIXES = ImmutableList.<String>of();
Ulf Adamsd87465e2015-04-17 13:16:51 +0000110
cparsons81ce9e32017-08-27 19:28:32 +0200111 /** The path in which the mock cc crosstool resides. */
112 public static final String MOCK_CC_CROSSTOOL_PATH = "tools/cpp";
Dmitry Lomove0a69aa2015-11-30 16:25:40 +0000113
Googler3acab6f2023-09-20 04:33:15 -0700114 /** The path in which the mock license rule resides. */
115 public static final String MOCK_LICENSE_SCRATCH = "third_party/rules_license/";
116
cparsons81ce9e32017-08-27 19:28:32 +0200117 /** The workspace repository label under which built-in tools reside. */
wyv69be3992021-12-10 06:46:32 -0800118 public static final RepositoryName TOOLS_REPOSITORY = RepositoryName.BAZEL_TOOLS;
cparsons81ce9e32017-08-27 19:28:32 +0200119 /** The file path in which to create files so that they end up under {@link #TOOLS_REPOSITORY}. */
wyv5fad8a92021-07-30 05:29:37 -0700120 public static final String TOOLS_REPOSITORY_SCRATCH = "embedded_tools/";
Marcel Hlopko02d19662019-11-11 21:55:16 -0800121
cparsons81ce9e32017-08-27 19:28:32 +0200122 /** The output file path prefix for tool file dependencies. */
123 public static final String TOOLS_REPOSITORY_PATH_PREFIX = "external/bazel_tools/";
Ulf Adamsc934fad2015-12-22 07:42:11 +0000124
Marcel Hlopko02d19662019-11-11 21:55:16 -0800125 /** The directory in which rules_cc repo resides in execroot. */
Yun Peng136dae12023-09-08 12:39:10 -0700126 public static final String RULES_CC_REPOSITORY_EXECROOT = "external/" + RulesCcRepoName.CANONICAL_REPO_NAME + "/";
Googlerfa392212023-11-23 04:13:03 -0800127 /* Prefix for loads from rules_cc */
128 public static final String RULES_CC = "@rules_cc//cc";
Marcel Hlopko02d19662019-11-11 21:55:16 -0800129
Googler228c78d2024-10-03 09:09:48 -0700130 /**
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 Levasseur08407742023-11-20 18:16:44 -0800134
Ulf Adamsc934fad2015-12-22 07:42:11 +0000135 public static final ImmutableList<String> DOCS_RULES_PATHS = ImmutableList.of(
136 "src/main/java/com/google/devtools/build/lib/rules");
Luis Fernando Pino Duqueb1b28b62016-02-25 14:25:19 +0000137
John Cater17a1ae92017-01-25 15:18:25 +0000138 // 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
Googler49eda9f2023-11-17 09:10:43 -0800142 public static final String STARLARK_EXEC_TRANSITION =
143 "@_builtins//:common/builtin_exec_platforms.bzl%bazel_exec_transition";
144
cparsons81ce9e32017-08-27 19:28:32 +0200145 /**
John Cater13dc4f72019-08-07 11:14:40 -0700146 * Flags that must be set for Bazel to work properly, if the default values are unusable for some
147 * reason.
janakrafb5c702019-03-05 10:47:14 -0800148 */
149 public static final ImmutableList<String> PRODUCT_SPECIFIC_FLAGS =
brandjon5f5e6ad2019-03-30 10:02:03 -0700150 ImmutableList.of(
Googler74c8ca42024-03-29 12:48:51 -0700151 "--platforms=@bazel_tools//tools:host_platform",
152 "--host_platform=@bazel_tools//tools:host_platform",
cushond5219642019-04-03 17:38:12 -0700153 // TODO(#7849): Remove after flag flip.
Googler2172c542022-02-14 10:21:05 -0800154 "--incompatible_use_toolchain_resolution_for_java_rules");
Nathan Harmata3ad56452016-06-10 16:17:45 +0000155
Googlerc26bd002024-08-08 07:15:45 -0700156 public static final ImmutableList<String> PRODUCT_SPECIFIC_BUILD_LANG_OPTIONS =
Googlercca95872024-09-25 00:23:48 -0700157 ImmutableList.of(
Googler678b01a2024-10-05 23:16:32 -0700158 "--experimental_rule_extension_api",
Googlercca95872024-09-25 00:23:48 -0700159 // Don't apply autoloads in unit tests, because not all repos are available
160 "--incompatible_autoload_externally=");
Googlerc26bd002024-08-08 07:15:45 -0700161
John Cater4e6080a2019-01-29 07:18:42 -0800162 /** Partial query to filter out implicit dependencies of C/C++ rules. */
lebac322e882018-12-20 11:02:02 -0800163 public static final String CC_DEPENDENCY_CORRECTION =
Googler29e06ff2024-02-22 03:08:23 -0800164 " - deps(" + TOOLS_REPOSITORY + "//tools/cpp:current_cc_toolchain)"
Googler897edaa2023-12-18 06:40:41 -0800165 + " - deps(" + TOOLS_REPOSITORY + "//tools/cpp:grep-includes)";
lebac322e882018-12-20 11:02:02 -0800166
Googler03b86162023-08-18 07:28:53 -0700167 public static final String APPLE_PLATFORM_PATH = "build_bazel_apple_support/platforms";
Googler5881c382024-08-27 02:28:33 -0700168 public static final String APPLE_PLATFORM_PACKAGE_ROOT = "@@build_bazel_apple_support+//platforms";
hlopko3d8b5792019-06-27 00:19:19 -0700169 public static final String CONSTRAINTS_PACKAGE_ROOT = "@platforms//";
170
wyv5fad8a92021-07-30 05:29:37 -0700171 public static final String PLATFORMS_PATH = "embedded_tools/platforms";
laszlocsomore1d2e2a2020-02-09 23:15:01 -0800172 public static final String CONSTRAINTS_PATH = "platforms_workspace";
cushon85da59f2019-04-03 11:41:01 -0700173
Googler74c8ca42024-03-29 12:48:51 -0700174 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";
lebac322e882018-12-20 11:02:02 -0800177
Googler91279ec2024-03-26 11:01:16 -0700178 public static final Label ANDROID_DEFAULT_SDK =
179 Label.parseCanonicalUnchecked("@bazel_tools//tools/android:sdk");
180
gregcea64ccec2020-10-22 13:01:10 -0700181 /** 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
dacek85fc7842021-10-13 13:04:56 -0700185 /** The launcher used by Bazel. */
186 public static final String LAUNCHER_PATH = "@bazel_tools//tools/launcher:launcher";
187
dacek0409ad12022-02-10 12:57:55 -0800188 /** The target name for ProGuard's allowlister. */
arostovtsevdcf2b862022-02-16 10:14:07 -0800189 public static final String PROGUARD_ALLOWLISTER_TARGET =
190 "@bazel_tools//tools/jdk:proguard_whitelister";
dacek0409ad12022-02-10 12:57:55 -0800191
Googler4f1ab282023-02-10 07:55:27 -0800192 /** The java toolchain type. */
Googleref457ae2023-11-10 09:39:21 -0800193 public static final String JAVA_TOOLCHAIN_TYPE = "@@bazel_tools//tools/jdk:toolchain_type";
Googler4f1ab282023-02-10 07:55:27 -0800194
Googler86814372023-03-06 01:09:01 -0800195 /** The cpp toolchain type. */
Googleref457ae2023-11-10 09:39:21 -0800196 public static final String CPP_TOOLCHAIN_TYPE = "@@bazel_tools//tools/cpp:toolchain_type";
Googler86814372023-03-06 01:09:01 -0800197
Son Luong Ngocdc5ec2b2024-04-17 10:22:32 -0700198 /** Whether blake3 can be used through JNI */
199 public static final boolean BLAKE3_AVAILABLE = true;
200
janakr3d443252017-10-10 23:03:26 +0200201 /** A choice of test execution mode, only varies internally. */
202 public enum InternalTestExecutionMode {
203 NORMAL
204 }
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +0100205}