Philipp Schrader | dada107 | 2020-11-24 11:34:46 -0800 | [diff] [blame] | 1 | # Use platforms to build our code. |
| 2 | build --incompatible_enable_cc_toolchain_resolution |
| 3 | |
Austin Schuh | c26a290 | 2022-01-14 16:34:25 -0800 | [diff] [blame] | 4 | # Rewrite all URLs to be on software.frc971.org |
| 5 | common --experimental_downloader_config=tools/dependency_rewrite |
| 6 | |
Austin Schuh | 085eab9 | 2020-11-26 13:54:51 -0800 | [diff] [blame] | 7 | # Default to py3 since that's all we support |
| 8 | build --python_version=PY3 |
Philipp Schrader | ebb658f | 2022-09-17 17:31:09 -0700 | [diff] [blame] | 9 | build --incompatible_default_to_explicit_init_py |
Austin Schuh | 085eab9 | 2020-11-26 13:54:51 -0800 | [diff] [blame] | 10 | |
Philipp Schrader | dada107 | 2020-11-24 11:34:46 -0800 | [diff] [blame] | 11 | # For now we only support building on x86 Linux so we can hard-code the host |
| 12 | # platform. |
| 13 | build --host_platform=//tools/platforms:linux_x86 |
Brian Silverman | fbe4fd5 | 2015-10-26 10:40:55 -0400 | [diff] [blame] | 14 | |
Brian Silverman | 5bc5434 | 2015-11-26 22:57:46 -0500 | [diff] [blame] | 15 | # Always include debug information in the non-.stripped binaries. |
| 16 | build --strip=never |
| 17 | |
Austin Schuh | da9d060 | 2019-09-15 17:29:38 -0700 | [diff] [blame] | 18 | build --noincompatible_disable_nocopts |
Austin Schuh | da9d060 | 2019-09-15 17:29:38 -0700 | [diff] [blame] | 19 | |
Brian Silverman | 516ceb2 | 2015-11-27 01:29:05 -0500 | [diff] [blame] | 20 | # Use the malloc we want. |
| 21 | build --custom_malloc=//tools/cpp:malloc |
| 22 | |
Philipp Schrader | dada107 | 2020-11-24 11:34:46 -0800 | [diff] [blame] | 23 | # Shortcuts for selecting the target platform. |
| 24 | build:k8 --platforms=//tools/platforms:linux_x86 |
| 25 | build:roborio --platforms=//tools/platforms:linux_roborio |
Philipp Schrader | 33b5e80 | 2022-02-06 22:17:41 -0800 | [diff] [blame] | 26 | build:roborio --platform_suffix=-roborio |
Philipp Schrader | f1bbf34 | 2022-02-05 14:30:15 -0800 | [diff] [blame] | 27 | build:arm64 --platforms=//tools/platforms:linux_arm64 |
Philipp Schrader | 33b5e80 | 2022-02-06 22:17:41 -0800 | [diff] [blame] | 28 | build:arm64 --platform_suffix=-arm64 |
Philipp Schrader | dada107 | 2020-11-24 11:34:46 -0800 | [diff] [blame] | 29 | build:cortex-m4f --platforms=//tools/platforms:cortex_m4f |
Philipp Schrader | 33b5e80 | 2022-02-06 22:17:41 -0800 | [diff] [blame] | 30 | build:cortex-m4f --platform_suffix=-cortex-m4f |
Austin Schuh | 0a96ea3 | 2022-01-01 22:29:30 -0800 | [diff] [blame] | 31 | build:rp2040 --platforms=//tools/platforms:rp2040 |
Philipp Schrader | 33b5e80 | 2022-02-06 22:17:41 -0800 | [diff] [blame] | 32 | build:rp2040 --platform_suffix=-rp2040 |
James Kuszmaul | 5a72856 | 2023-12-28 21:45:01 -0800 | [diff] [blame] | 33 | build:cortex-m4f-imu --platforms=//tools/platforms:cortex-m4f-imu |
| 34 | build:cortex-m4f-imu --platform_suffix=-cortex-m4f-imu |
Austin Schuh | c4788d1 | 2021-01-23 17:23:37 -0800 | [diff] [blame] | 35 | |
Brian Silverman | 63889f9 | 2015-11-27 01:33:56 -0500 | [diff] [blame] | 36 | build:asan --copt -fsanitize=address |
| 37 | build:asan --linkopt -fsanitize=address --linkopt -ldl |
| 38 | build:asan --platform_suffix=-asan |
| 39 | build:asan --test_env ASAN_SYMBOLIZER_PATH=/usr/bin/llvm-symbolizer-3.6 |
| 40 | build:asan --test_env ASAN_OPTIONS=detect_leaks=1:check_initialization_order=1:strict_init_order=1:detect_stack_use_after_return=1:detect_odr_violation=2:allow_user_segv_handler=1 |
Brian Silverman | b466eef | 2015-11-28 20:33:44 -0500 | [diff] [blame] | 41 | build:asan --copt -fsanitize-blacklist=tools/cpp/asan-blacklist |
Brian Silverman | 7dc6adb | 2017-02-19 17:04:36 -0800 | [diff] [blame] | 42 | build:asan --define have_asan=true |
Brian Silverman | 63889f9 | 2015-11-27 01:33:56 -0500 | [diff] [blame] | 43 | |
| 44 | build:tsan --copt -fsanitize=thread --copt -DAOS_SANITIZER_thread |
| 45 | build:tsan --linkopt -fsanitize=thread |
| 46 | build:tsan --platform_suffix=-tsan |
| 47 | build:tsan --test_env TSAN_OPTIONS=external_symbolizer_path=/usr/bin/llvm-symbolizer-3.6:detect_deadlocks=1:second_deadlock_stack=1 |
Brian Silverman | 7dc6adb | 2017-02-19 17:04:36 -0800 | [diff] [blame] | 48 | build:tsan --define have_tsan=true |
Brian Silverman | 63889f9 | 2015-11-27 01:33:56 -0500 | [diff] [blame] | 49 | |
| 50 | build:isan --copt -fsanitize=integer |
| 51 | build:isan --linkopt -fsanitize=integer |
| 52 | build:isan --platform_suffix=-isan |
| 53 | build:isan --test_env LLVM_SYMBOLIZER=/usr/bin/llvm-symbolizer-3.6 |
Brian Silverman | 7dc6adb | 2017-02-19 17:04:36 -0800 | [diff] [blame] | 54 | build:isan --define have_isan=true |
Brian Silverman | 63889f9 | 2015-11-27 01:33:56 -0500 | [diff] [blame] | 55 | |
Brian Silverman | a4a4ea6 | 2015-11-27 10:27:53 -0500 | [diff] [blame] | 56 | build:ubsan --copt -fsanitize=undefined --copt -fno-sanitize-recover |
| 57 | # Bad alignment is just slow on x86 and traps on ARM, so we'll find |
| 58 | # it other ways, and some x86 code does it on purpose. |
| 59 | build:ubsan --copt -fno-sanitize=alignment |
Brian Silverman | 63889f9 | 2015-11-27 01:33:56 -0500 | [diff] [blame] | 60 | build:ubsan --linkopt -fsanitize=undefined |
Brian Silverman | b466eef | 2015-11-28 20:33:44 -0500 | [diff] [blame] | 61 | # TOOD(Brian): Remove this once Clang adds it itself like it should. |
| 62 | build:ubsan --linkopt /usr/lib/llvm-3.6/lib/clang/3.6.2/lib/linux/libclang_rt.ubsan_cxx-x86_64.a |
Brian Silverman | 63889f9 | 2015-11-27 01:33:56 -0500 | [diff] [blame] | 63 | build:ubsan --platform_suffix=-ubsan |
Brian Silverman | b466eef | 2015-11-28 20:33:44 -0500 | [diff] [blame] | 64 | build:ubsan --test_env UBSAN_OPTIONS=external_symbolizer_path=/usr/bin/llvm-symbolizer-3.6:color=always:print_stacktrace=1 |
| 65 | build:ubsan --copt -fsanitize-blacklist=tools/cpp/ubsan-blacklist |
Brian Silverman | 7dc6adb | 2017-02-19 17:04:36 -0800 | [diff] [blame] | 66 | build:ubsan --define have_ubsan=true |
Brian Silverman | 63889f9 | 2015-11-27 01:33:56 -0500 | [diff] [blame] | 67 | |
Brian Silverman | a4a4ea6 | 2015-11-27 10:27:53 -0500 | [diff] [blame] | 68 | build:msan --copt -fsanitize=memory --copt -fsanitize-memory-track-origins |
Brian Silverman | b466eef | 2015-11-28 20:33:44 -0500 | [diff] [blame] | 69 | build:msan --linkopt -fsanitize=memory --linkopt -fsanitize-memory-track-origins |
Brian Silverman | 63889f9 | 2015-11-27 01:33:56 -0500 | [diff] [blame] | 70 | build:msan --platform_suffix=-msan |
| 71 | build:msan --test_env MSAN_SYMBOLIZER_PATH=/usr/bin/llvm-symbolizer-3.6 |
Brian Silverman | 7dc6adb | 2017-02-19 17:04:36 -0800 | [diff] [blame] | 72 | build:msan --define have_msan=true |
Brian Silverman | 63889f9 | 2015-11-27 01:33:56 -0500 | [diff] [blame] | 73 | |
James Kuszmaul | 2af1ba8 | 2019-02-09 22:16:53 -0800 | [diff] [blame] | 74 | # Sometime, we want to be able to have eigen assertions run so that we can |
| 75 | # catch potential issues (e.g., accessing invalid indices). |
| 76 | build:eigen --copt -UNDEBUG |
| 77 | |
Brian Silverman | 12b3fc5 | 2015-10-11 19:38:33 -0400 | [diff] [blame] | 78 | # Show paths to a few more than just 1 target. |
Austin Schuh | 00bc093 | 2016-02-14 21:05:34 -0800 | [diff] [blame] | 79 | build --show_result 5 |
Brian Silverman | 12b3fc5 | 2015-10-11 19:38:33 -0400 | [diff] [blame] | 80 | # Dump the output of the failing test to stdout. |
Eric Schmiedeberg | ef44b8a | 2022-02-28 17:30:38 -0700 | [diff] [blame] | 81 | # Keep the default test timeouts except make 'eternal'=4500 secs |
Austin Schuh | 493ee9f | 2023-01-04 16:52:15 -0800 | [diff] [blame] | 82 | test --test_output=errors --test_timeout=-1,-1,-1,5500 |
Brian Silverman | b200c17 | 2017-01-02 17:35:35 -0800 | [diff] [blame] | 83 | |
Philipp Schrader | 6efe573 | 2022-02-12 15:11:13 -0800 | [diff] [blame] | 84 | build --sandbox_base=/dev/shm/ |
Austin Schuh | 9d92e6b | 2017-10-17 01:19:38 -0700 | [diff] [blame] | 85 | |
| 86 | build --sandbox_fake_hostname=true |
| 87 | build --sandbox_fake_username=true |
| 88 | |
Austin Schuh | 9d92e6b | 2017-10-17 01:19:38 -0700 | [diff] [blame] | 89 | startup --host_jvm_args=-Dbazel.DigestFunction=SHA1 |
| 90 | |
| 91 | common --watchfs |
Austin Schuh | e18baff | 2018-10-20 17:40:42 -0700 | [diff] [blame] | 92 | |
| 93 | # Switch to SHA256 for compatibility with distributed caching. |
| 94 | startup --host_jvm_args=-Dbazel.DigestFunction=SHA256 |
| 95 | |
Austin Schuh | f148eb9 | 2023-11-05 12:37:07 -0800 | [diff] [blame] | 96 | build --spawn_strategy=sandboxed |
Philipp Schrader | 6efe573 | 2022-02-12 15:11:13 -0800 | [diff] [blame] | 97 | build --sandbox_default_allow_network=false |
Philipp Schrader | 94a14dc | 2024-02-25 20:13:11 -0800 | [diff] [blame] | 98 | build --incompatible_exclusive_test_sandboxed |
Austin Schuh | e18baff | 2018-10-20 17:40:42 -0700 | [diff] [blame] | 99 | |
Austin Schuh | f148eb9 | 2023-11-05 12:37:07 -0800 | [diff] [blame] | 100 | build --strategy=TsProject=sandboxed |
| 101 | build --strategy=CopyFile=standalone |
| 102 | build --strategy=CopyDirectory=standalone |
Austin Schuh | 8f99c82 | 2024-05-05 22:43:40 -0700 | [diff] [blame^] | 103 | build --strategy=CopyToDirectory=standalone |
Austin Schuh | 89a9505 | 2019-04-14 14:51:14 -0700 | [diff] [blame] | 104 | |
Philipp Schrader | ba072d9 | 2024-02-21 17:00:37 -0800 | [diff] [blame] | 105 | # Honor the setting of `skipLibCheck` in the tsconfig.json file. |
| 106 | # https://www.typescriptlang.org/tsconfig#skipLibCheck |
| 107 | build --@aspect_rules_ts//ts:skipLibCheck=honor_tsconfig |
| 108 | fetch --@aspect_rules_ts//ts:skipLibCheck=honor_tsconfig |
| 109 | query --@aspect_rules_ts//ts:skipLibCheck=honor_tsconfig |
| 110 | |
| 111 | # Use "tsc" as the transpiler when ts_project has no `transpiler` set. |
| 112 | # For now this is an acceptable default, but it would be nice to switch to swc in the future. |
| 113 | # https://docs.aspect.build/rulesets/aspect_rules_ts/docs/transpiler/ |
| 114 | build --@aspect_rules_ts//ts:default_to_tsc_transpiler |
| 115 | fetch --@aspect_rules_ts//ts:default_to_tsc_transpiler |
| 116 | query --@aspect_rules_ts//ts:default_to_tsc_transpiler |
| 117 | |
Austin Schuh | e18baff | 2018-10-20 17:40:42 -0700 | [diff] [blame] | 118 | # Use our hermetic JDK. |
| 119 | # Note that this doesn't quite work fully, but it should. See |
| 120 | # https://github.com/bazelbuild/bazel/issues/6341 for ongoing discussion with |
| 121 | # upstream about this. |
Tyler Chatow | fba5782 | 2022-03-22 19:38:41 -0700 | [diff] [blame] | 122 | build --java_runtime_version=openjdk_11 --tool_java_runtime_version=openjdk_11 |
Philipp Schrader | d64e130 | 2020-12-12 18:53:00 -0800 | [diff] [blame] | 123 | |
| 124 | # Prevent falling back to the host JDK. |
| 125 | startup --noautodetect_server_javabase |
Philipp Schrader | 7365d32 | 2022-03-06 16:40:08 -0800 | [diff] [blame] | 126 | |
| 127 | # Give each build action and test its own /tmp. |
| 128 | build --sandbox_tmpfs_path=/tmp |
Philipp Schrader | 175a93c | 2023-02-19 13:13:40 -0800 | [diff] [blame] | 129 | |
| 130 | # Prevent cypress from using its own binary. We want to use the hermetic one. |
| 131 | build --action_env=CYPRESS_INSTALL_BINARY=0 |
Philipp Schrader | 4502b25 | 2023-08-23 20:15:39 -0700 | [diff] [blame] | 132 | |
Adam Snaider | 13d48d9 | 2023-08-03 12:20:15 -0700 | [diff] [blame] | 133 | # From our one and only phil.schrader: https://groups.google.com/g/bazel-discuss/c/5cbRuLuTwNg :) |
| 134 | # Enable -Werror and warnings for our code |
| 135 | # TODO: It would be nice to enable Wcast-align and Wcast-qual. |
| 136 | build --per_file_copt=-third_party/.*,-external/.*@-Werror,-Wextra,-Wpointer-arith,-Wstrict-aliasing,-Wwrite-strings,-Wtype-limits,-Wsign-compare,-Wformat=2 |
| 137 | # NOTE: Explicitly disable -Werror because the `-external/.*` filter does not work |
| 138 | build --per_file_copt=third_party/.*,external/.*@-Wno-sign-compare,-Wno-cast-align,-Wno-error,-Wno-unused-parameter,-Wno-cast-qual,-Wno-format-nonliteral,-Wno-tautological-type-limit-compare,-Wno-missing-field-initializers,-Wno-unused-function,-Wno-cast-function-type,-Wno-comment,-Wno-typedef-redefinition,-Wno-tautological-unsigned-enum-zero-compare,-Wno-extra,-Wno-type-limits,-Wno-attributes,-Wno-deprecated |
| 139 | |
Austin Schuh | 8f99c82 | 2024-05-05 22:43:40 -0700 | [diff] [blame^] | 140 | # bzlmod breaks our code base right now, deal with this later. |
| 141 | common --enable_bzlmod=false |
| 142 | |
| 143 | # Disable warnings about using directories in Bazel. |
| 144 | startup --host_jvm_args=-DBAZEL_TRACK_SOURCE_DIRECTORIES=1 |
| 145 | |
Philipp Schrader | 4502b25 | 2023-08-23 20:15:39 -0700 | [diff] [blame] | 146 | # Load a local file that users can use to customize bazel invocations. This |
| 147 | # should stay the last line in this file so users can override things when they |
| 148 | # want. |
| 149 | try-import %workspace%/.bazelrc.user |