Austin Schuh | a2503a7 | 2020-12-15 20:57:57 -0800 | [diff] [blame] | 1 | load( |
| 2 | "@bazel_tools//tools/cpp:cc_toolchain_config_lib.bzl", |
Austin Schuh | da9d060 | 2019-09-15 17:29:38 -0700 | [diff] [blame] | 3 | "action_config", |
Austin Schuh | da9d060 | 2019-09-15 17:29:38 -0700 | [diff] [blame] | 4 | "feature", |
Austin Schuh | da9d060 | 2019-09-15 17:29:38 -0700 | [diff] [blame] | 5 | "flag_group", |
| 6 | "flag_set", |
Austin Schuh | da9d060 | 2019-09-15 17:29:38 -0700 | [diff] [blame] | 7 | "tool", |
| 8 | "tool_path", |
Austin Schuh | da9d060 | 2019-09-15 17:29:38 -0700 | [diff] [blame] | 9 | "with_feature_set", |
| 10 | ) |
| 11 | load("@bazel_tools//tools/build_defs/cc:action_names.bzl", "ACTION_NAMES") |
| 12 | |
| 13 | def _impl(ctx): |
Brian Silverman | 4c7235a | 2021-11-17 19:04:37 -0800 | [diff] [blame^] | 14 | if ctx.attr.cpu == "rp2040": |
Austin Schuh | 0a96ea3 | 2022-01-01 22:29:30 -0800 | [diff] [blame] | 15 | toolchain_identifier = "rp2040" |
Brian Silverman | 94cab07 | 2022-01-02 23:50:03 -0800 | [diff] [blame] | 16 | elif ctx.attr.cpu == "cortex-m4f": |
Austin Schuh | da9d060 | 2019-09-15 17:29:38 -0700 | [diff] [blame] | 17 | toolchain_identifier = "cortex-m4f" |
Brian Silverman | 94cab07 | 2022-01-02 23:50:03 -0800 | [diff] [blame] | 18 | elif ctx.attr.cpu == "cortex-m4f-k22": |
Austin Schuh | da9d060 | 2019-09-15 17:29:38 -0700 | [diff] [blame] | 19 | toolchain_identifier = "cortex-m4f-k22" |
Brian Silverman | 94cab07 | 2022-01-02 23:50:03 -0800 | [diff] [blame] | 20 | elif ctx.attr.cpu == "roborio": |
Austin Schuh | da9d060 | 2019-09-15 17:29:38 -0700 | [diff] [blame] | 21 | toolchain_identifier = "roborio_linux" |
Brian Silverman | 94cab07 | 2022-01-02 23:50:03 -0800 | [diff] [blame] | 22 | elif ctx.attr.cpu == "armeabi-v7a": |
Austin Schuh | da9d060 | 2019-09-15 17:29:38 -0700 | [diff] [blame] | 23 | toolchain_identifier = "stub_armeabi-v7a" |
| 24 | else: |
| 25 | fail("Unreachable") |
| 26 | |
Brian Silverman | 94cab07 | 2022-01-02 23:50:03 -0800 | [diff] [blame] | 27 | if ctx.attr.cpu == "armeabi-v7a": |
Austin Schuh | da9d060 | 2019-09-15 17:29:38 -0700 | [diff] [blame] | 28 | host_system_name = "armeabi-v7a" |
Austin Schuh | 0a96ea3 | 2022-01-01 22:29:30 -0800 | [diff] [blame] | 29 | elif (ctx.attr.cpu == "rp2040" or |
| 30 | ctx.attr.cpu == "cortex-m4f" or |
Brian Silverman | 4c7235a | 2021-11-17 19:04:37 -0800 | [diff] [blame^] | 31 | ctx.attr.cpu == "cortex-m4f-k22"): |
Austin Schuh | da9d060 | 2019-09-15 17:29:38 -0700 | [diff] [blame] | 32 | host_system_name = "local" |
Brian Silverman | 94cab07 | 2022-01-02 23:50:03 -0800 | [diff] [blame] | 33 | elif ctx.attr.cpu == "roborio": |
Austin Schuh | da9d060 | 2019-09-15 17:29:38 -0700 | [diff] [blame] | 34 | host_system_name = "roborio" |
| 35 | else: |
| 36 | fail("Unreachable") |
| 37 | |
Brian Silverman | 4c7235a | 2021-11-17 19:04:37 -0800 | [diff] [blame^] | 38 | if ctx.attr.cpu == "armeabi-v7a": |
Austin Schuh | da9d060 | 2019-09-15 17:29:38 -0700 | [diff] [blame] | 39 | target_system_name = "armeabi-v7a" |
Brian Silverman | 94cab07 | 2022-01-02 23:50:03 -0800 | [diff] [blame] | 40 | elif ctx.attr.cpu == "rp2040": |
Austin Schuh | 0a96ea3 | 2022-01-01 22:29:30 -0800 | [diff] [blame] | 41 | target_system_name = "rp2040" |
Brian Silverman | 94cab07 | 2022-01-02 23:50:03 -0800 | [diff] [blame] | 42 | elif ctx.attr.cpu == "cortex-m4f": |
Austin Schuh | da9d060 | 2019-09-15 17:29:38 -0700 | [diff] [blame] | 43 | target_system_name = "cortex-m4f" |
Brian Silverman | 94cab07 | 2022-01-02 23:50:03 -0800 | [diff] [blame] | 44 | elif ctx.attr.cpu == "cortex-m4f-k22": |
Austin Schuh | da9d060 | 2019-09-15 17:29:38 -0700 | [diff] [blame] | 45 | target_system_name = "cortex-m4f-k22" |
Brian Silverman | 94cab07 | 2022-01-02 23:50:03 -0800 | [diff] [blame] | 46 | elif ctx.attr.cpu == "roborio": |
Austin Schuh | da9d060 | 2019-09-15 17:29:38 -0700 | [diff] [blame] | 47 | target_system_name = "roborio" |
| 48 | else: |
| 49 | fail("Unreachable") |
| 50 | |
Brian Silverman | 94cab07 | 2022-01-02 23:50:03 -0800 | [diff] [blame] | 51 | if ctx.attr.cpu == "armeabi-v7a": |
Austin Schuh | da9d060 | 2019-09-15 17:29:38 -0700 | [diff] [blame] | 52 | target_cpu = "armeabi-v7a" |
Brian Silverman | 94cab07 | 2022-01-02 23:50:03 -0800 | [diff] [blame] | 53 | elif ctx.attr.cpu == "rp2040": |
Austin Schuh | 0a96ea3 | 2022-01-01 22:29:30 -0800 | [diff] [blame] | 54 | target_cpu = "rp2040" |
Brian Silverman | 94cab07 | 2022-01-02 23:50:03 -0800 | [diff] [blame] | 55 | elif ctx.attr.cpu == "cortex-m4f": |
Austin Schuh | da9d060 | 2019-09-15 17:29:38 -0700 | [diff] [blame] | 56 | target_cpu = "cortex-m4f" |
Brian Silverman | 94cab07 | 2022-01-02 23:50:03 -0800 | [diff] [blame] | 57 | elif ctx.attr.cpu == "cortex-m4f-k22": |
Austin Schuh | da9d060 | 2019-09-15 17:29:38 -0700 | [diff] [blame] | 58 | target_cpu = "cortex-m4f-k22" |
Brian Silverman | 94cab07 | 2022-01-02 23:50:03 -0800 | [diff] [blame] | 59 | elif ctx.attr.cpu == "roborio": |
Austin Schuh | da9d060 | 2019-09-15 17:29:38 -0700 | [diff] [blame] | 60 | target_cpu = "roborio" |
| 61 | else: |
| 62 | fail("Unreachable") |
| 63 | |
Brian Silverman | 94cab07 | 2022-01-02 23:50:03 -0800 | [diff] [blame] | 64 | if ctx.attr.cpu == "armeabi-v7a": |
Austin Schuh | da9d060 | 2019-09-15 17:29:38 -0700 | [diff] [blame] | 65 | target_libc = "armeabi-v7a" |
Brian Silverman | 94cab07 | 2022-01-02 23:50:03 -0800 | [diff] [blame] | 66 | elif ctx.attr.cpu == "rp2040": |
Austin Schuh | 0a96ea3 | 2022-01-01 22:29:30 -0800 | [diff] [blame] | 67 | target_libc = "rp2040" |
Brian Silverman | 94cab07 | 2022-01-02 23:50:03 -0800 | [diff] [blame] | 68 | elif ctx.attr.cpu == "cortex-m4f": |
Austin Schuh | da9d060 | 2019-09-15 17:29:38 -0700 | [diff] [blame] | 69 | target_libc = "cortex-m4f" |
Brian Silverman | 94cab07 | 2022-01-02 23:50:03 -0800 | [diff] [blame] | 70 | elif ctx.attr.cpu == "cortex-m4f-k22": |
Austin Schuh | da9d060 | 2019-09-15 17:29:38 -0700 | [diff] [blame] | 71 | target_libc = "cortex-m4f-k22" |
Brian Silverman | 94cab07 | 2022-01-02 23:50:03 -0800 | [diff] [blame] | 72 | elif ctx.attr.cpu == "roborio": |
Austin Schuh | da9d060 | 2019-09-15 17:29:38 -0700 | [diff] [blame] | 73 | target_libc = "roborio" |
| 74 | else: |
| 75 | fail("Unreachable") |
| 76 | |
Brian Silverman | 4c7235a | 2021-11-17 19:04:37 -0800 | [diff] [blame^] | 77 | if ctx.attr.cpu == "armeabi-v7a": |
Austin Schuh | da9d060 | 2019-09-15 17:29:38 -0700 | [diff] [blame] | 78 | compiler = "compiler" |
Austin Schuh | 0a96ea3 | 2022-01-01 22:29:30 -0800 | [diff] [blame] | 79 | elif (ctx.attr.cpu == "rp2040" or |
| 80 | ctx.attr.cpu == "cortex-m4f" or |
Austin Schuh | a2503a7 | 2020-12-15 20:57:57 -0800 | [diff] [blame] | 81 | ctx.attr.cpu == "cortex-m4f-k22" or |
| 82 | ctx.attr.cpu == "roborio"): |
Austin Schuh | da9d060 | 2019-09-15 17:29:38 -0700 | [diff] [blame] | 83 | compiler = "gcc" |
| 84 | else: |
| 85 | fail("Unreachable") |
| 86 | |
Brian Silverman | 94cab07 | 2022-01-02 23:50:03 -0800 | [diff] [blame] | 87 | if ctx.attr.cpu == "armeabi-v7a": |
Austin Schuh | da9d060 | 2019-09-15 17:29:38 -0700 | [diff] [blame] | 88 | abi_version = "armeabi-v7a" |
Brian Silverman | 94cab07 | 2022-01-02 23:50:03 -0800 | [diff] [blame] | 89 | elif ctx.attr.cpu == "rp2040": |
Austin Schuh | 0a96ea3 | 2022-01-01 22:29:30 -0800 | [diff] [blame] | 90 | abi_version = "rp2040" |
Brian Silverman | 94cab07 | 2022-01-02 23:50:03 -0800 | [diff] [blame] | 91 | elif ctx.attr.cpu == "cortex-m4f": |
Austin Schuh | da9d060 | 2019-09-15 17:29:38 -0700 | [diff] [blame] | 92 | abi_version = "cortex-m4f" |
Brian Silverman | 94cab07 | 2022-01-02 23:50:03 -0800 | [diff] [blame] | 93 | elif ctx.attr.cpu == "cortex-m4f-k22": |
Austin Schuh | da9d060 | 2019-09-15 17:29:38 -0700 | [diff] [blame] | 94 | abi_version = "cortex-m4f-k22" |
Brian Silverman | 94cab07 | 2022-01-02 23:50:03 -0800 | [diff] [blame] | 95 | elif ctx.attr.cpu == "roborio": |
Austin Schuh | da9d060 | 2019-09-15 17:29:38 -0700 | [diff] [blame] | 96 | abi_version = "roborio" |
| 97 | else: |
| 98 | fail("Unreachable") |
| 99 | |
Brian Silverman | 94cab07 | 2022-01-02 23:50:03 -0800 | [diff] [blame] | 100 | if ctx.attr.cpu == "armeabi-v7a": |
Austin Schuh | da9d060 | 2019-09-15 17:29:38 -0700 | [diff] [blame] | 101 | abi_libc_version = "armeabi-v7a" |
Brian Silverman | 94cab07 | 2022-01-02 23:50:03 -0800 | [diff] [blame] | 102 | elif ctx.attr.cpu == "rp2040": |
Austin Schuh | 0a96ea3 | 2022-01-01 22:29:30 -0800 | [diff] [blame] | 103 | abi_libc_version = "rp2040" |
Brian Silverman | 94cab07 | 2022-01-02 23:50:03 -0800 | [diff] [blame] | 104 | elif ctx.attr.cpu == "cortex-m4f": |
Austin Schuh | da9d060 | 2019-09-15 17:29:38 -0700 | [diff] [blame] | 105 | abi_libc_version = "cortex-m4f" |
Brian Silverman | 94cab07 | 2022-01-02 23:50:03 -0800 | [diff] [blame] | 106 | elif ctx.attr.cpu == "cortex-m4f-k22": |
Austin Schuh | da9d060 | 2019-09-15 17:29:38 -0700 | [diff] [blame] | 107 | abi_libc_version = "cortex-m4f-k22" |
Brian Silverman | 94cab07 | 2022-01-02 23:50:03 -0800 | [diff] [blame] | 108 | elif ctx.attr.cpu == "roborio": |
Austin Schuh | da9d060 | 2019-09-15 17:29:38 -0700 | [diff] [blame] | 109 | abi_libc_version = "roborio" |
| 110 | else: |
| 111 | fail("Unreachable") |
| 112 | |
| 113 | cc_target_os = None |
| 114 | |
| 115 | builtin_sysroot = None |
| 116 | |
| 117 | all_compile_actions = [ |
| 118 | ACTION_NAMES.c_compile, |
| 119 | ACTION_NAMES.cpp_compile, |
| 120 | ACTION_NAMES.linkstamp_compile, |
| 121 | ACTION_NAMES.assemble, |
| 122 | ACTION_NAMES.preprocess_assemble, |
| 123 | ACTION_NAMES.cpp_header_parsing, |
| 124 | ACTION_NAMES.cpp_module_compile, |
| 125 | ACTION_NAMES.cpp_module_codegen, |
| 126 | ACTION_NAMES.clif_match, |
| 127 | ACTION_NAMES.lto_backend, |
| 128 | ] |
| 129 | |
| 130 | all_cpp_compile_actions = [ |
| 131 | ACTION_NAMES.cpp_compile, |
| 132 | ACTION_NAMES.linkstamp_compile, |
| 133 | ACTION_NAMES.cpp_header_parsing, |
| 134 | ACTION_NAMES.cpp_module_compile, |
| 135 | ACTION_NAMES.cpp_module_codegen, |
| 136 | ACTION_NAMES.clif_match, |
| 137 | ] |
| 138 | |
| 139 | preprocessor_compile_actions = [ |
| 140 | ACTION_NAMES.c_compile, |
| 141 | ACTION_NAMES.cpp_compile, |
| 142 | ACTION_NAMES.linkstamp_compile, |
| 143 | ACTION_NAMES.preprocess_assemble, |
| 144 | ACTION_NAMES.cpp_header_parsing, |
| 145 | ACTION_NAMES.cpp_module_compile, |
| 146 | ACTION_NAMES.clif_match, |
| 147 | ] |
| 148 | |
| 149 | codegen_compile_actions = [ |
| 150 | ACTION_NAMES.c_compile, |
| 151 | ACTION_NAMES.cpp_compile, |
| 152 | ACTION_NAMES.linkstamp_compile, |
| 153 | ACTION_NAMES.assemble, |
| 154 | ACTION_NAMES.preprocess_assemble, |
| 155 | ACTION_NAMES.cpp_module_codegen, |
| 156 | ACTION_NAMES.lto_backend, |
| 157 | ] |
| 158 | |
| 159 | all_link_actions = [ |
| 160 | ACTION_NAMES.cpp_link_executable, |
| 161 | ACTION_NAMES.cpp_link_dynamic_library, |
| 162 | ACTION_NAMES.cpp_link_nodeps_dynamic_library, |
| 163 | ] |
| 164 | |
Brian Silverman | 94cab07 | 2022-01-02 23:50:03 -0800 | [diff] [blame] | 165 | if ctx.attr.cpu == "roborio": |
Austin Schuh | da9d060 | 2019-09-15 17:29:38 -0700 | [diff] [blame] | 166 | objcopy_embed_data_action = action_config( |
| 167 | action_name = "objcopy_embed_data", |
| 168 | enabled = True, |
| 169 | tools = [ |
| 170 | tool( |
| 171 | path = "arm-frc-linux-gnueabi/arm-frc-linux-gnueabi-objcopy", |
| 172 | ), |
| 173 | ], |
| 174 | ) |
Austin Schuh | 0a96ea3 | 2022-01-01 22:29:30 -0800 | [diff] [blame] | 175 | elif (ctx.attr.cpu == "rp2040" or |
| 176 | ctx.attr.cpu == "cortex-m4f" or |
Austin Schuh | a2503a7 | 2020-12-15 20:57:57 -0800 | [diff] [blame] | 177 | ctx.attr.cpu == "cortex-m4f-k22"): |
Austin Schuh | da9d060 | 2019-09-15 17:29:38 -0700 | [diff] [blame] | 178 | objcopy_embed_data_action = action_config( |
| 179 | action_name = "objcopy_embed_data", |
| 180 | enabled = True, |
| 181 | tools = [tool(path = "gcc_arm_none_eabi/arm-none-eabi-objcopy")], |
| 182 | ) |
| 183 | else: |
| 184 | objcopy_embed_data_action = None |
| 185 | |
Brian Silverman | 94cab07 | 2022-01-02 23:50:03 -0800 | [diff] [blame] | 186 | if ctx.attr.cpu == "armeabi-v7a": |
Austin Schuh | da9d060 | 2019-09-15 17:29:38 -0700 | [diff] [blame] | 187 | action_configs = [] |
Brian Silverman | 4c7235a | 2021-11-17 19:04:37 -0800 | [diff] [blame^] | 188 | elif (ctx.attr.cpu == "rp2040" or |
Austin Schuh | a2503a7 | 2020-12-15 20:57:57 -0800 | [diff] [blame] | 189 | ctx.attr.cpu == "cortex-m4f" or |
| 190 | ctx.attr.cpu == "cortex-m4f-k22" or |
Austin Schuh | a2503a7 | 2020-12-15 20:57:57 -0800 | [diff] [blame] | 191 | ctx.attr.cpu == "roborio"): |
Austin Schuh | da9d060 | 2019-09-15 17:29:38 -0700 | [diff] [blame] | 192 | action_configs = [objcopy_embed_data_action] |
| 193 | else: |
| 194 | fail("Unreachable") |
| 195 | |
| 196 | opt_post_feature = feature( |
| 197 | name = "opt_post", |
| 198 | flag_sets = [ |
| 199 | flag_set( |
| 200 | actions = [ |
| 201 | ACTION_NAMES.preprocess_assemble, |
| 202 | ACTION_NAMES.c_compile, |
| 203 | ACTION_NAMES.cpp_compile, |
| 204 | ACTION_NAMES.cpp_header_parsing, |
| 205 | "c++-header-preprocessing", |
| 206 | ACTION_NAMES.cpp_module_compile, |
| 207 | ], |
| 208 | flag_groups = [flag_group(flags = ["-DAOS_DEBUG=0"])], |
| 209 | ), |
| 210 | ], |
| 211 | ) |
| 212 | |
| 213 | supports_pic_feature = feature(name = "supports_pic", enabled = True) |
| 214 | |
Brian Silverman | 4c7235a | 2021-11-17 19:04:37 -0800 | [diff] [blame^] | 215 | if ctx.attr.cpu == "cortex-m4f-k22": |
Austin Schuh | da9d060 | 2019-09-15 17:29:38 -0700 | [diff] [blame] | 216 | default_compile_flags_feature = feature( |
| 217 | name = "default_compile_flags", |
| 218 | enabled = True, |
| 219 | flag_sets = [ |
| 220 | flag_set( |
| 221 | actions = [ |
| 222 | ACTION_NAMES.assemble, |
| 223 | ACTION_NAMES.preprocess_assemble, |
| 224 | ACTION_NAMES.linkstamp_compile, |
| 225 | ACTION_NAMES.c_compile, |
| 226 | ACTION_NAMES.cpp_compile, |
| 227 | ACTION_NAMES.cpp_header_parsing, |
| 228 | ACTION_NAMES.cpp_module_compile, |
| 229 | ACTION_NAMES.cpp_module_codegen, |
| 230 | ACTION_NAMES.lto_backend, |
| 231 | ACTION_NAMES.clif_match, |
| 232 | ], |
| 233 | flag_groups = [ |
| 234 | flag_group( |
| 235 | flags = [ |
| 236 | "-D__STDC_FORMAT_MACROS", |
| 237 | "-D__STDC_CONSTANT_MACROS", |
| 238 | "-D__STDC_LIMIT_MACROS", |
| 239 | "-D__MK22FX512__", |
| 240 | "-DF_CPU=120000000", |
| 241 | "-Wl,--gc-sections", |
| 242 | "-D__have_long32", |
| 243 | "-fstack-protector", |
| 244 | "-mcpu=cortex-m4", |
| 245 | "-mfpu=fpv4-sp-d16", |
| 246 | "-mthumb", |
| 247 | "-mfloat-abi=hard", |
| 248 | "-fno-strict-aliasing", |
| 249 | "-fmessage-length=80", |
| 250 | "-fmax-errors=20", |
| 251 | "-Wall", |
| 252 | "-Wextra", |
| 253 | "-Wpointer-arith", |
| 254 | "-Wcast-qual", |
| 255 | "-Wwrite-strings", |
| 256 | "-Wtype-limits", |
| 257 | "-Wsign-compare", |
| 258 | "-Wformat=2", |
| 259 | "-Werror", |
| 260 | "-Wstrict-aliasing=2", |
| 261 | "-Wno-misleading-indentation", |
| 262 | "-Wno-int-in-bool-context", |
| 263 | "-Wdouble-promotion", |
| 264 | "-pipe", |
| 265 | "-g", |
| 266 | "-fno-common", |
| 267 | "-ffreestanding", |
| 268 | "-fbuiltin", |
| 269 | ], |
| 270 | ), |
| 271 | ], |
| 272 | ), |
| 273 | flag_set( |
| 274 | actions = [ |
| 275 | ACTION_NAMES.assemble, |
| 276 | ACTION_NAMES.preprocess_assemble, |
| 277 | ACTION_NAMES.linkstamp_compile, |
| 278 | ACTION_NAMES.c_compile, |
| 279 | ACTION_NAMES.cpp_compile, |
| 280 | ACTION_NAMES.cpp_header_parsing, |
| 281 | ACTION_NAMES.cpp_module_compile, |
| 282 | ACTION_NAMES.cpp_module_codegen, |
| 283 | ACTION_NAMES.lto_backend, |
| 284 | ACTION_NAMES.clif_match, |
| 285 | ], |
| 286 | flag_groups = [ |
| 287 | flag_group( |
| 288 | flags = [ |
| 289 | "-O2", |
| 290 | "-finline-functions", |
| 291 | "-ffast-math", |
| 292 | "-funroll-loops", |
| 293 | "-DNDEBUG", |
| 294 | "-ffunction-sections", |
| 295 | ], |
| 296 | ), |
| 297 | ], |
| 298 | with_features = [with_feature_set(features = ["opt"])], |
| 299 | ), |
| 300 | ], |
| 301 | ) |
Brian Silverman | 94cab07 | 2022-01-02 23:50:03 -0800 | [diff] [blame] | 302 | elif ctx.attr.cpu == "cortex-m4f": |
Austin Schuh | da9d060 | 2019-09-15 17:29:38 -0700 | [diff] [blame] | 303 | default_compile_flags_feature = feature( |
| 304 | name = "default_compile_flags", |
| 305 | enabled = True, |
| 306 | flag_sets = [ |
| 307 | flag_set( |
| 308 | actions = [ |
| 309 | ACTION_NAMES.assemble, |
| 310 | ACTION_NAMES.preprocess_assemble, |
| 311 | ACTION_NAMES.linkstamp_compile, |
| 312 | ACTION_NAMES.c_compile, |
| 313 | ACTION_NAMES.cpp_compile, |
| 314 | ACTION_NAMES.cpp_header_parsing, |
| 315 | ACTION_NAMES.cpp_module_compile, |
| 316 | ACTION_NAMES.cpp_module_codegen, |
| 317 | ACTION_NAMES.lto_backend, |
| 318 | ACTION_NAMES.clif_match, |
| 319 | ], |
| 320 | flag_groups = [ |
| 321 | flag_group( |
| 322 | flags = [ |
| 323 | "-D__STDC_FORMAT_MACROS", |
| 324 | "-D__STDC_CONSTANT_MACROS", |
| 325 | "-D__STDC_LIMIT_MACROS", |
| 326 | "-D__MK64FX512__", |
| 327 | "-DF_CPU=120000000", |
| 328 | "-Wl,--gc-sections", |
| 329 | "-D__have_long32", |
| 330 | "-fstack-protector", |
| 331 | "-mcpu=cortex-m4", |
| 332 | "-mfpu=fpv4-sp-d16", |
| 333 | "-mthumb", |
| 334 | "-mfloat-abi=hard", |
| 335 | "-fno-strict-aliasing", |
| 336 | "-fmessage-length=80", |
| 337 | "-fmax-errors=20", |
| 338 | "-Wall", |
| 339 | "-Wextra", |
| 340 | "-Wpointer-arith", |
| 341 | "-Wcast-qual", |
| 342 | "-Wwrite-strings", |
| 343 | "-Wtype-limits", |
| 344 | "-Wsign-compare", |
| 345 | "-Wformat=2", |
| 346 | "-Werror", |
| 347 | "-Wstrict-aliasing=2", |
| 348 | "-Wno-misleading-indentation", |
| 349 | "-Wno-int-in-bool-context", |
| 350 | "-Wdouble-promotion", |
| 351 | "-pipe", |
| 352 | "-g", |
| 353 | "-fno-common", |
| 354 | "-ffreestanding", |
| 355 | "-fbuiltin", |
| 356 | ], |
| 357 | ), |
| 358 | ], |
| 359 | ), |
| 360 | flag_set( |
| 361 | actions = [ |
| 362 | ACTION_NAMES.assemble, |
| 363 | ACTION_NAMES.preprocess_assemble, |
| 364 | ACTION_NAMES.linkstamp_compile, |
| 365 | ACTION_NAMES.c_compile, |
| 366 | ACTION_NAMES.cpp_compile, |
| 367 | ACTION_NAMES.cpp_header_parsing, |
| 368 | ACTION_NAMES.cpp_module_compile, |
| 369 | ACTION_NAMES.cpp_module_codegen, |
| 370 | ACTION_NAMES.lto_backend, |
| 371 | ACTION_NAMES.clif_match, |
| 372 | ], |
| 373 | flag_groups = [ |
| 374 | flag_group( |
| 375 | flags = [ |
| 376 | "-O2", |
| 377 | "-finline-functions", |
| 378 | "-ffast-math", |
| 379 | "-funroll-loops", |
| 380 | "-DNDEBUG", |
| 381 | "-ffunction-sections", |
| 382 | ], |
| 383 | ), |
| 384 | ], |
| 385 | with_features = [with_feature_set(features = ["opt"])], |
| 386 | ), |
| 387 | ], |
| 388 | ) |
Brian Silverman | 94cab07 | 2022-01-02 23:50:03 -0800 | [diff] [blame] | 389 | elif ctx.attr.cpu == "rp2040": |
Austin Schuh | 0a96ea3 | 2022-01-01 22:29:30 -0800 | [diff] [blame] | 390 | default_compile_flags_feature = feature( |
| 391 | name = "default_compile_flags", |
| 392 | enabled = True, |
| 393 | flag_sets = [ |
| 394 | flag_set( |
| 395 | actions = [ |
| 396 | ACTION_NAMES.assemble, |
| 397 | ACTION_NAMES.preprocess_assemble, |
| 398 | ACTION_NAMES.linkstamp_compile, |
| 399 | ACTION_NAMES.c_compile, |
| 400 | ACTION_NAMES.cpp_compile, |
| 401 | ACTION_NAMES.cpp_header_parsing, |
| 402 | ACTION_NAMES.cpp_module_compile, |
| 403 | ACTION_NAMES.cpp_module_codegen, |
| 404 | ACTION_NAMES.lto_backend, |
| 405 | ACTION_NAMES.clif_match, |
| 406 | ], |
| 407 | flag_groups = [ |
| 408 | flag_group( |
| 409 | flags = [ |
| 410 | "-DPICO_BOARD=\"pico\"", |
| 411 | "-DPICO_BUILD=1", |
| 412 | "-DPICO_NO_HARDWARE=0", |
| 413 | "-DPICO_ON_DEVICE=1", |
| 414 | "-D__STDC_FORMAT_MACROS", |
| 415 | "-D__STDC_CONSTANT_MACROS", |
| 416 | "-D__STDC_LIMIT_MACROS", |
| 417 | "-Wl,--gc-sections", |
| 418 | "-fstack-protector", |
| 419 | "-mcpu=cortex-m0plus", |
| 420 | "-mthumb", |
| 421 | "-fno-strict-aliasing", |
| 422 | "-fmessage-length=80", |
| 423 | "-fmax-errors=20", |
| 424 | "-Wall", |
| 425 | "-Wextra", |
| 426 | "-Wpointer-arith", |
| 427 | "-Wcast-qual", |
| 428 | "-Wwrite-strings", |
| 429 | "-Wtype-limits", |
| 430 | "-Wsign-compare", |
| 431 | "-Wformat=2", |
| 432 | "-Werror", |
| 433 | "-Wstrict-aliasing=2", |
| 434 | "-Wno-misleading-indentation", |
| 435 | "-Wno-int-in-bool-context", |
| 436 | "-Wdouble-promotion", |
| 437 | "-pipe", |
| 438 | "-g", |
| 439 | ], |
| 440 | ), |
| 441 | ], |
| 442 | ), |
| 443 | flag_set( |
| 444 | actions = [ |
| 445 | ACTION_NAMES.assemble, |
| 446 | ACTION_NAMES.preprocess_assemble, |
| 447 | ACTION_NAMES.linkstamp_compile, |
| 448 | ACTION_NAMES.c_compile, |
| 449 | ACTION_NAMES.cpp_compile, |
| 450 | ACTION_NAMES.cpp_header_parsing, |
| 451 | ACTION_NAMES.cpp_module_compile, |
| 452 | ACTION_NAMES.cpp_module_codegen, |
| 453 | ACTION_NAMES.lto_backend, |
| 454 | ACTION_NAMES.clif_match, |
| 455 | ], |
| 456 | flag_groups = [ |
| 457 | flag_group( |
| 458 | flags = [ |
| 459 | "-O3", |
| 460 | "-finline-functions", |
| 461 | "-funroll-loops", |
| 462 | "-DNDEBUG", |
| 463 | "-ffunction-sections", |
| 464 | ], |
| 465 | ), |
| 466 | ], |
| 467 | with_features = [with_feature_set(features = ["opt"])], |
| 468 | ), |
| 469 | ], |
| 470 | ) |
Austin Schuh | da9d060 | 2019-09-15 17:29:38 -0700 | [diff] [blame] | 471 | else: |
| 472 | default_compile_flags_feature = None |
| 473 | |
Brian Silverman | 4c7235a | 2021-11-17 19:04:37 -0800 | [diff] [blame^] | 474 | if ctx.attr.cpu == "roborio": |
Austin Schuh | da9d060 | 2019-09-15 17:29:38 -0700 | [diff] [blame] | 475 | dbg_feature = feature( |
| 476 | name = "dbg", |
| 477 | flag_sets = [ |
| 478 | flag_set( |
| 479 | actions = [ |
| 480 | ACTION_NAMES.preprocess_assemble, |
| 481 | ACTION_NAMES.c_compile, |
| 482 | ACTION_NAMES.cpp_compile, |
| 483 | ACTION_NAMES.cpp_header_parsing, |
| 484 | "c++-header-preprocessing", |
| 485 | ACTION_NAMES.cpp_module_compile, |
| 486 | ], |
| 487 | flag_groups = [ |
| 488 | flag_group(flags = ["-DAOS_DEBUG=1"]), |
| 489 | flag_group(flags = ["-fno-omit-frame-pointer"]), |
| 490 | ], |
| 491 | ), |
| 492 | ], |
| 493 | ) |
Austin Schuh | 0a96ea3 | 2022-01-01 22:29:30 -0800 | [diff] [blame] | 494 | elif (ctx.attr.cpu == "rp2040" or |
| 495 | ctx.attr.cpu == "cortex-m4f" or |
Austin Schuh | a2503a7 | 2020-12-15 20:57:57 -0800 | [diff] [blame] | 496 | ctx.attr.cpu == "cortex-m4f-k22"): |
Austin Schuh | da9d060 | 2019-09-15 17:29:38 -0700 | [diff] [blame] | 497 | dbg_feature = feature( |
| 498 | name = "dbg", |
| 499 | flag_sets = [ |
| 500 | flag_set( |
| 501 | actions = [ |
| 502 | ACTION_NAMES.preprocess_assemble, |
| 503 | ACTION_NAMES.c_compile, |
| 504 | ACTION_NAMES.cpp_compile, |
| 505 | ACTION_NAMES.cpp_header_parsing, |
| 506 | "c++-header-preprocessing", |
| 507 | ACTION_NAMES.cpp_module_compile, |
| 508 | ], |
| 509 | flag_groups = [flag_group(flags = ["-fno-omit-frame-pointer"])], |
| 510 | ), |
| 511 | ], |
| 512 | implies = ["all_modes"], |
| 513 | ) |
| 514 | else: |
| 515 | dbg_feature = None |
| 516 | |
Brian Silverman | 4c7235a | 2021-11-17 19:04:37 -0800 | [diff] [blame^] | 517 | if ctx.attr.cpu == "roborio": |
Austin Schuh | da9d060 | 2019-09-15 17:29:38 -0700 | [diff] [blame] | 518 | fastbuild_feature = feature( |
| 519 | name = "fastbuild", |
| 520 | flag_sets = [ |
| 521 | flag_set( |
| 522 | actions = [ |
| 523 | ACTION_NAMES.preprocess_assemble, |
| 524 | ACTION_NAMES.c_compile, |
| 525 | ACTION_NAMES.cpp_compile, |
| 526 | ACTION_NAMES.cpp_header_parsing, |
| 527 | "c++-header-preprocessing", |
| 528 | ACTION_NAMES.cpp_module_compile, |
| 529 | ], |
| 530 | flag_groups = [flag_group(flags = ["-DAOS_DEBUG=0"])], |
| 531 | ), |
| 532 | ], |
| 533 | ) |
Austin Schuh | 0a96ea3 | 2022-01-01 22:29:30 -0800 | [diff] [blame] | 534 | elif (ctx.attr.cpu == "rp2040" or |
| 535 | ctx.attr.cpu == "cortex-m4f" or |
Austin Schuh | a2503a7 | 2020-12-15 20:57:57 -0800 | [diff] [blame] | 536 | ctx.attr.cpu == "cortex-m4f-k22"): |
Austin Schuh | da9d060 | 2019-09-15 17:29:38 -0700 | [diff] [blame] | 537 | fastbuild_feature = feature(name = "fastbuild", implies = ["all_modes"]) |
| 538 | else: |
| 539 | fastbuild_feature = None |
| 540 | |
| 541 | pie_for_linking_feature = feature( |
| 542 | name = "pie_for_linking", |
| 543 | enabled = True, |
| 544 | flag_sets = [ |
| 545 | flag_set( |
| 546 | actions = [ACTION_NAMES.cpp_link_executable], |
| 547 | flag_groups = [flag_group(flags = ["-pie"])], |
| 548 | ), |
| 549 | ], |
| 550 | ) |
| 551 | |
Brian Silverman | 94cab07 | 2022-01-02 23:50:03 -0800 | [diff] [blame] | 552 | if ctx.attr.cpu == "roborio": |
Austin Schuh | da9d060 | 2019-09-15 17:29:38 -0700 | [diff] [blame] | 553 | opt_feature = feature( |
| 554 | name = "opt", |
| 555 | flag_sets = [ |
| 556 | flag_set( |
| 557 | actions = [ |
| 558 | ACTION_NAMES.assemble, |
| 559 | ACTION_NAMES.preprocess_assemble, |
| 560 | ACTION_NAMES.c_compile, |
| 561 | ACTION_NAMES.cpp_compile, |
| 562 | ACTION_NAMES.cpp_module_compile, |
| 563 | ACTION_NAMES.objc_compile, |
| 564 | ACTION_NAMES.objcpp_compile, |
| 565 | ACTION_NAMES.cpp_header_parsing, |
| 566 | ACTION_NAMES.linkstamp_compile, |
| 567 | ], |
| 568 | flag_groups = [ |
| 569 | flag_group( |
| 570 | flags = [ |
| 571 | "-O2", |
| 572 | "-DNDEBUG", |
| 573 | "-D_FORTIFY_SOURCE=1", |
| 574 | "-ffunction-sections", |
| 575 | "-fdata-sections", |
| 576 | ], |
| 577 | ), |
| 578 | ], |
| 579 | ), |
| 580 | flag_set( |
| 581 | actions = [ |
| 582 | ACTION_NAMES.cpp_link_executable, |
| 583 | ACTION_NAMES.cpp_link_nodeps_dynamic_library, |
| 584 | ACTION_NAMES.cpp_link_dynamic_library, |
| 585 | ], |
| 586 | flag_groups = [flag_group(flags = ["-Wl,--gc-sections"])], |
| 587 | ), |
| 588 | ], |
| 589 | implies = ["opt_post"], |
| 590 | ) |
Austin Schuh | 0a96ea3 | 2022-01-01 22:29:30 -0800 | [diff] [blame] | 591 | elif (ctx.attr.cpu == "rp2040" or |
| 592 | ctx.attr.cpu == "cortex-m4f" or |
Austin Schuh | a2503a7 | 2020-12-15 20:57:57 -0800 | [diff] [blame] | 593 | ctx.attr.cpu == "cortex-m4f-k22"): |
Austin Schuh | da9d060 | 2019-09-15 17:29:38 -0700 | [diff] [blame] | 594 | opt_feature = feature(name = "opt", implies = ["all_modes"]) |
| 595 | else: |
| 596 | opt_feature = None |
| 597 | |
| 598 | pic_feature = feature( |
| 599 | name = "pic", |
| 600 | enabled = True, |
| 601 | flag_sets = [ |
| 602 | flag_set( |
| 603 | actions = [ |
| 604 | ACTION_NAMES.assemble, |
| 605 | ACTION_NAMES.preprocess_assemble, |
| 606 | ACTION_NAMES.linkstamp_compile, |
| 607 | ACTION_NAMES.c_compile, |
| 608 | ACTION_NAMES.cpp_compile, |
| 609 | ACTION_NAMES.cpp_module_codegen, |
| 610 | ACTION_NAMES.cpp_module_compile, |
| 611 | ], |
| 612 | flag_groups = [ |
| 613 | flag_group(flags = ["-fPIC"], expand_if_available = "pic"), |
| 614 | ], |
| 615 | ), |
| 616 | ], |
| 617 | ) |
| 618 | |
Austin Schuh | 0a96ea3 | 2022-01-01 22:29:30 -0800 | [diff] [blame] | 619 | if (ctx.attr.cpu == "rp2040" or |
| 620 | ctx.attr.cpu == "cortex-m4f" or |
Austin Schuh | a2503a7 | 2020-12-15 20:57:57 -0800 | [diff] [blame] | 621 | ctx.attr.cpu == "cortex-m4f-k22"): |
Austin Schuh | da9d060 | 2019-09-15 17:29:38 -0700 | [diff] [blame] | 622 | include_paths_feature = feature( |
| 623 | name = "include_paths", |
| 624 | enabled = True, |
| 625 | flag_sets = [ |
| 626 | flag_set( |
| 627 | actions = [ |
| 628 | ACTION_NAMES.preprocess_assemble, |
| 629 | ACTION_NAMES.c_compile, |
| 630 | ACTION_NAMES.cpp_compile, |
| 631 | ACTION_NAMES.cpp_header_parsing, |
| 632 | "c++-header-preprocessing", |
| 633 | ACTION_NAMES.cpp_module_compile, |
| 634 | ], |
| 635 | flag_groups = [ |
| 636 | flag_group( |
| 637 | flags = ["-iquote", "%{quote_include_paths}"], |
| 638 | iterate_over = "quote_include_paths", |
| 639 | ), |
| 640 | flag_group( |
| 641 | flags = ["-I%{include_paths}"], |
| 642 | iterate_over = "include_paths", |
| 643 | ), |
| 644 | flag_group( |
| 645 | flags = ["-I", "%{system_include_paths}"], |
| 646 | iterate_over = "system_include_paths", |
| 647 | ), |
| 648 | ], |
| 649 | ), |
| 650 | ], |
| 651 | ) |
Brian Silverman | 94cab07 | 2022-01-02 23:50:03 -0800 | [diff] [blame] | 652 | elif ctx.attr.cpu == "roborio": |
Austin Schuh | da9d060 | 2019-09-15 17:29:38 -0700 | [diff] [blame] | 653 | include_paths_feature = feature( |
| 654 | name = "include_paths", |
| 655 | enabled = True, |
| 656 | flag_sets = [ |
| 657 | flag_set( |
| 658 | actions = [ |
| 659 | ACTION_NAMES.preprocess_assemble, |
| 660 | ACTION_NAMES.c_compile, |
| 661 | ACTION_NAMES.cpp_compile, |
| 662 | ACTION_NAMES.cpp_header_parsing, |
| 663 | "c++-header-preprocessing", |
| 664 | ACTION_NAMES.cpp_module_compile, |
| 665 | ], |
| 666 | flag_groups = [ |
| 667 | flag_group( |
| 668 | flags = ["-iquote", "%{quote_include_paths}"], |
| 669 | iterate_over = "quote_include_paths", |
| 670 | ), |
| 671 | flag_group( |
| 672 | flags = ["-I%{include_paths}"], |
| 673 | iterate_over = "include_paths", |
| 674 | ), |
| 675 | flag_group( |
| 676 | flags = ["-isystem", "%{system_include_paths}"], |
| 677 | iterate_over = "system_include_paths", |
| 678 | ), |
| 679 | ], |
| 680 | ), |
| 681 | ], |
| 682 | ) |
| 683 | else: |
| 684 | include_paths_feature = None |
| 685 | |
| 686 | random_seed_feature = feature( |
| 687 | name = "random_seed", |
| 688 | enabled = True, |
| 689 | flag_sets = [ |
| 690 | flag_set( |
| 691 | actions = [ |
| 692 | ACTION_NAMES.cpp_compile, |
| 693 | ACTION_NAMES.cpp_module_codegen, |
| 694 | ACTION_NAMES.cpp_module_compile, |
| 695 | ], |
| 696 | flag_groups = [ |
| 697 | flag_group( |
| 698 | flags = ["-frandom-seed=%{output_file}"], |
| 699 | expand_if_available = "output_file", |
| 700 | ), |
| 701 | ], |
| 702 | ), |
| 703 | ], |
| 704 | ) |
| 705 | |
Brian Silverman | 94cab07 | 2022-01-02 23:50:03 -0800 | [diff] [blame] | 706 | if ctx.attr.cpu == "roborio": |
Austin Schuh | da9d060 | 2019-09-15 17:29:38 -0700 | [diff] [blame] | 707 | default_link_flags_feature = feature( |
| 708 | name = "default_link_flags", |
| 709 | enabled = True, |
| 710 | flag_sets = [ |
| 711 | flag_set( |
| 712 | actions = all_link_actions, |
| 713 | flag_groups = [ |
| 714 | flag_group( |
| 715 | flags = [ |
| 716 | "-lstdc++", |
| 717 | "-Ltools/cpp/arm-frc-linux-gnueabi/libs", |
| 718 | "-no-canonical-prefixes", |
| 719 | "-Wl,-z,relro,-z,now", |
| 720 | "-lm", |
| 721 | "-pass-exit-codes", |
| 722 | "-Wl,--build-id=md5", |
| 723 | "-Wl,--hash-style=gnu", |
| 724 | ], |
| 725 | ), |
| 726 | ], |
| 727 | ), |
| 728 | ], |
| 729 | ) |
Brian Silverman | 94cab07 | 2022-01-02 23:50:03 -0800 | [diff] [blame] | 730 | elif ctx.attr.cpu == "cortex-m4f-k22": |
Austin Schuh | da9d060 | 2019-09-15 17:29:38 -0700 | [diff] [blame] | 731 | default_link_flags_feature = feature( |
| 732 | name = "default_link_flags", |
| 733 | enabled = True, |
| 734 | flag_sets = [ |
| 735 | flag_set( |
| 736 | actions = all_link_actions, |
| 737 | flag_groups = [ |
| 738 | flag_group( |
| 739 | flags = [ |
| 740 | "-no-canonical-prefixes", |
| 741 | "-mcpu=cortex-m4", |
| 742 | "-mfpu=fpv4-sp-d16", |
| 743 | "-mthumb", |
| 744 | "-mfloat-abi=hard", |
| 745 | "-fno-strict-aliasing", |
| 746 | "--specs=nano.specs", |
| 747 | "-lgcc", |
| 748 | "-lstdc++_nano", |
| 749 | "-lm", |
| 750 | "-lc_nano", |
| 751 | "-Tmotors/core/kinetis_512_128.ld", |
| 752 | "-Tmotors/core/kinetis_sections.ld", |
| 753 | ], |
| 754 | ), |
| 755 | ], |
| 756 | ), |
| 757 | flag_set( |
| 758 | actions = all_link_actions, |
| 759 | flag_groups = [flag_group(flags = ["-Wl,--gc-sections"])], |
| 760 | with_features = [with_feature_set(features = ["opt"])], |
| 761 | ), |
| 762 | ], |
| 763 | ) |
Brian Silverman | 94cab07 | 2022-01-02 23:50:03 -0800 | [diff] [blame] | 764 | elif ctx.attr.cpu == "cortex-m4f": |
Austin Schuh | da9d060 | 2019-09-15 17:29:38 -0700 | [diff] [blame] | 765 | default_link_flags_feature = feature( |
| 766 | name = "default_link_flags", |
| 767 | enabled = True, |
| 768 | flag_sets = [ |
| 769 | flag_set( |
| 770 | actions = all_link_actions, |
| 771 | flag_groups = [ |
| 772 | flag_group( |
| 773 | flags = [ |
| 774 | "-no-canonical-prefixes", |
| 775 | "-mcpu=cortex-m4", |
| 776 | "-mfpu=fpv4-sp-d16", |
| 777 | "-mthumb", |
| 778 | "-mfloat-abi=hard", |
| 779 | "-fno-strict-aliasing", |
| 780 | "--specs=nano.specs", |
| 781 | "-lgcc", |
| 782 | "-lstdc++_nano", |
| 783 | "-lm", |
| 784 | "-lc_nano", |
| 785 | "-Tmotors/core/kinetis_512_256.ld", |
| 786 | "-Tmotors/core/kinetis_sections.ld", |
| 787 | ], |
| 788 | ), |
| 789 | ], |
| 790 | ), |
| 791 | flag_set( |
| 792 | actions = all_link_actions, |
| 793 | flag_groups = [flag_group(flags = ["-Wl,--gc-sections"])], |
| 794 | with_features = [with_feature_set(features = ["opt"])], |
| 795 | ), |
| 796 | ], |
| 797 | ) |
Brian Silverman | 94cab07 | 2022-01-02 23:50:03 -0800 | [diff] [blame] | 798 | elif ctx.attr.cpu == "rp2040": |
Austin Schuh | 0a96ea3 | 2022-01-01 22:29:30 -0800 | [diff] [blame] | 799 | default_link_flags_feature = feature( |
| 800 | name = "default_link_flags", |
| 801 | enabled = True, |
| 802 | flag_sets = [ |
| 803 | flag_set( |
| 804 | actions = all_link_actions, |
| 805 | flag_groups = [ |
| 806 | flag_group( |
| 807 | flags = [ |
| 808 | "-no-canonical-prefixes", |
| 809 | "-mcpu=cortex-m0plus", |
| 810 | "-mthumb", |
| 811 | "-fno-strict-aliasing", |
| 812 | "-Wl,--build-id=none", |
| 813 | "--specs=nosys.specs", |
| 814 | "-nostartfiles", |
| 815 | ], |
| 816 | ), |
| 817 | ], |
| 818 | ), |
| 819 | # TODO(austin): I'd love to turn --gc-sections on, but that breaks things. |
| 820 | ], |
| 821 | ) |
Austin Schuh | da9d060 | 2019-09-15 17:29:38 -0700 | [diff] [blame] | 822 | else: |
| 823 | default_link_flags_feature = None |
| 824 | |
Brian Silverman | 94cab07 | 2022-01-02 23:50:03 -0800 | [diff] [blame] | 825 | if ctx.attr.cpu == "roborio": |
Austin Schuh | da9d060 | 2019-09-15 17:29:38 -0700 | [diff] [blame] | 826 | all_modes_feature = feature( |
| 827 | name = "all_modes", |
| 828 | enabled = True, |
| 829 | flag_sets = [ |
| 830 | flag_set( |
| 831 | actions = [ |
| 832 | ACTION_NAMES.preprocess_assemble, |
| 833 | ACTION_NAMES.assemble, |
| 834 | ACTION_NAMES.c_compile, |
| 835 | ], |
| 836 | flag_groups = [flag_group(flags = ["-std=gnu99"])], |
| 837 | ), |
| 838 | flag_set( |
| 839 | actions = [ |
| 840 | ACTION_NAMES.cpp_compile, |
| 841 | ACTION_NAMES.cpp_header_parsing, |
| 842 | "c++-header-preprocessing", |
| 843 | ACTION_NAMES.cpp_module_compile, |
| 844 | ], |
| 845 | flag_groups = [ |
| 846 | flag_group( |
| 847 | flags = ["-std=gnu++1z", "-fno-sized-deallocation"], |
| 848 | ), |
| 849 | ], |
| 850 | ), |
| 851 | flag_set( |
| 852 | actions = [ |
| 853 | ACTION_NAMES.preprocess_assemble, |
| 854 | ACTION_NAMES.assemble, |
| 855 | "c++-link", |
| 856 | ACTION_NAMES.cpp_compile, |
| 857 | ACTION_NAMES.cpp_header_parsing, |
| 858 | "c++-header-preprocessing", |
| 859 | ACTION_NAMES.cpp_module_compile, |
| 860 | ACTION_NAMES.c_compile, |
| 861 | ], |
| 862 | flag_groups = [flag_group(flags = ["-pthread"])], |
| 863 | ), |
| 864 | ], |
| 865 | ) |
Austin Schuh | 0a96ea3 | 2022-01-01 22:29:30 -0800 | [diff] [blame] | 866 | elif (ctx.attr.cpu == "rp2040" or |
| 867 | ctx.attr.cpu == "cortex-m4f" or |
Austin Schuh | a2503a7 | 2020-12-15 20:57:57 -0800 | [diff] [blame] | 868 | ctx.attr.cpu == "cortex-m4f-k22"): |
Austin Schuh | da9d060 | 2019-09-15 17:29:38 -0700 | [diff] [blame] | 869 | all_modes_feature = feature( |
| 870 | name = "all_modes", |
| 871 | flag_sets = [ |
| 872 | flag_set( |
| 873 | actions = [ |
| 874 | ACTION_NAMES.preprocess_assemble, |
| 875 | ACTION_NAMES.assemble, |
| 876 | ACTION_NAMES.c_compile, |
| 877 | ], |
Austin Schuh | 0a96ea3 | 2022-01-01 22:29:30 -0800 | [diff] [blame] | 878 | flag_groups = [flag_group(flags = ["--std=gnu11"])], |
Austin Schuh | da9d060 | 2019-09-15 17:29:38 -0700 | [diff] [blame] | 879 | ), |
| 880 | flag_set( |
| 881 | actions = [ |
| 882 | ACTION_NAMES.cpp_compile, |
| 883 | ACTION_NAMES.cpp_header_parsing, |
| 884 | "c++-header-preprocessing", |
| 885 | ACTION_NAMES.cpp_module_compile, |
| 886 | ], |
| 887 | flag_groups = [ |
| 888 | flag_group( |
| 889 | flags = ["--std=gnu++1z", "-fno-exceptions", "-fno-rtti"], |
| 890 | ), |
| 891 | ], |
| 892 | ), |
| 893 | ], |
| 894 | ) |
Austin Schuh | da9d060 | 2019-09-15 17:29:38 -0700 | [diff] [blame] | 895 | else: |
| 896 | all_modes_feature = None |
| 897 | |
| 898 | supports_dynamic_linker_feature = feature(name = "supports_dynamic_linker", enabled = True) |
| 899 | |
Brian Silverman | 4c7235a | 2021-11-17 19:04:37 -0800 | [diff] [blame^] | 900 | if (ctx.attr.cpu == "rp2040" or |
| 901 | ctx.attr.cpu == "cortex-m4f" or |
| 902 | ctx.attr.cpu == "cortex-m4f-k22" or |
| 903 | ctx.attr.cpu == "roborio"): |
Austin Schuh | da9d060 | 2019-09-15 17:29:38 -0700 | [diff] [blame] | 904 | unfiltered_compile_flags_feature = feature( |
| 905 | name = "unfiltered_compile_flags", |
| 906 | enabled = True, |
| 907 | flag_sets = [ |
| 908 | flag_set( |
| 909 | actions = [ |
| 910 | ACTION_NAMES.assemble, |
| 911 | ACTION_NAMES.preprocess_assemble, |
| 912 | ACTION_NAMES.linkstamp_compile, |
| 913 | ACTION_NAMES.c_compile, |
| 914 | ACTION_NAMES.cpp_compile, |
| 915 | ACTION_NAMES.cpp_header_parsing, |
| 916 | ACTION_NAMES.cpp_module_compile, |
| 917 | ACTION_NAMES.cpp_module_codegen, |
| 918 | ACTION_NAMES.lto_backend, |
| 919 | ACTION_NAMES.clif_match, |
| 920 | ], |
| 921 | flag_groups = [ |
| 922 | flag_group( |
| 923 | flags = [ |
| 924 | "-no-canonical-prefixes", |
| 925 | "-Wno-builtin-macro-redefined", |
| 926 | "-D__DATE__=\"redacted\"", |
| 927 | "-D__TIMESTAMP__=\"redacted\"", |
| 928 | "-D__TIME__=\"redacted\"", |
Austin Schuh | da9d060 | 2019-09-15 17:29:38 -0700 | [diff] [blame] | 929 | ], |
| 930 | ), |
| 931 | ], |
| 932 | ), |
| 933 | ], |
| 934 | ) |
| 935 | else: |
| 936 | unfiltered_compile_flags_feature = None |
| 937 | |
| 938 | dependency_file_feature = feature( |
| 939 | name = "dependency_file", |
| 940 | enabled = True, |
| 941 | flag_sets = [ |
| 942 | flag_set( |
| 943 | actions = [ |
| 944 | ACTION_NAMES.assemble, |
| 945 | ACTION_NAMES.preprocess_assemble, |
| 946 | ACTION_NAMES.c_compile, |
| 947 | ACTION_NAMES.cpp_compile, |
| 948 | ACTION_NAMES.cpp_module_compile, |
| 949 | ACTION_NAMES.objc_compile, |
| 950 | ACTION_NAMES.objcpp_compile, |
| 951 | ACTION_NAMES.cpp_header_parsing, |
| 952 | ACTION_NAMES.clif_match, |
| 953 | ], |
| 954 | flag_groups = [ |
| 955 | flag_group( |
| 956 | flags = ["-MD", "-MF", "%{dependency_file}"], |
| 957 | expand_if_available = "dependency_file", |
| 958 | ), |
| 959 | ], |
| 960 | ), |
| 961 | ], |
| 962 | ) |
| 963 | |
Austin Schuh | da9d060 | 2019-09-15 17:29:38 -0700 | [diff] [blame] | 964 | user_compile_flags_feature = feature( |
| 965 | name = "user_compile_flags", |
| 966 | enabled = True, |
| 967 | flag_sets = [ |
| 968 | flag_set( |
| 969 | actions = [ |
| 970 | ACTION_NAMES.assemble, |
| 971 | ACTION_NAMES.preprocess_assemble, |
| 972 | ACTION_NAMES.linkstamp_compile, |
| 973 | ACTION_NAMES.c_compile, |
| 974 | ACTION_NAMES.cpp_compile, |
| 975 | ACTION_NAMES.cpp_header_parsing, |
| 976 | ACTION_NAMES.cpp_module_compile, |
| 977 | ACTION_NAMES.cpp_module_codegen, |
| 978 | ACTION_NAMES.lto_backend, |
| 979 | ACTION_NAMES.clif_match, |
| 980 | ], |
| 981 | flag_groups = [ |
| 982 | flag_group( |
| 983 | flags = ["%{user_compile_flags}"], |
| 984 | iterate_over = "user_compile_flags", |
| 985 | expand_if_available = "user_compile_flags", |
| 986 | ), |
| 987 | ], |
| 988 | ), |
| 989 | ], |
| 990 | ) |
| 991 | |
| 992 | sysroot_feature = feature( |
| 993 | name = "sysroot", |
| 994 | enabled = True, |
| 995 | flag_sets = [ |
| 996 | flag_set( |
| 997 | actions = [ |
| 998 | ACTION_NAMES.preprocess_assemble, |
| 999 | ACTION_NAMES.linkstamp_compile, |
| 1000 | ACTION_NAMES.c_compile, |
| 1001 | ACTION_NAMES.cpp_compile, |
| 1002 | ACTION_NAMES.cpp_header_parsing, |
| 1003 | ACTION_NAMES.cpp_module_compile, |
| 1004 | ACTION_NAMES.cpp_module_codegen, |
| 1005 | ACTION_NAMES.lto_backend, |
| 1006 | ACTION_NAMES.clif_match, |
| 1007 | ACTION_NAMES.cpp_link_executable, |
| 1008 | ACTION_NAMES.cpp_link_dynamic_library, |
| 1009 | ACTION_NAMES.cpp_link_nodeps_dynamic_library, |
| 1010 | ], |
| 1011 | flag_groups = [ |
| 1012 | flag_group( |
| 1013 | flags = ["--sysroot=%{sysroot}"], |
| 1014 | expand_if_available = "sysroot", |
| 1015 | ), |
| 1016 | ], |
| 1017 | ), |
| 1018 | ], |
| 1019 | ) |
| 1020 | |
| 1021 | compile_flags1_feature = feature( |
| 1022 | name = "compile_flags1", |
| 1023 | enabled = True, |
| 1024 | flag_sets = [ |
| 1025 | flag_set( |
| 1026 | actions = [ |
| 1027 | ACTION_NAMES.assemble, |
| 1028 | ACTION_NAMES.preprocess_assemble, |
| 1029 | ACTION_NAMES.c_compile, |
| 1030 | ACTION_NAMES.cpp_compile, |
| 1031 | ACTION_NAMES.cpp_header_parsing, |
| 1032 | ACTION_NAMES.cpp_module_compile, |
| 1033 | ACTION_NAMES.cpp_module_codegen, |
| 1034 | ACTION_NAMES.lto_backend, |
| 1035 | ACTION_NAMES.clif_match, |
| 1036 | ], |
| 1037 | flag_groups = [ |
| 1038 | flag_group( |
| 1039 | flags = [ |
| 1040 | "--sysroot=external/arm_frc_linux_gnueabi_repo/arm-frc2020-linux-gnueabi", |
| 1041 | "-nostdinc", |
| 1042 | "-isystem", |
| 1043 | "external/arm_frc_linux_gnueabi_repo/arm-frc2020-linux-gnueabi/usr/lib/gcc/arm-frc2020-linux-gnueabi/7.3.0/include", |
| 1044 | "-isystem", |
| 1045 | "external/arm_frc_linux_gnueabi_repo/arm-frc2020-linux-gnueabi/usr/lib/gcc/arm-frc2020-linux-gnueabi/7.3.0/include-fixed", |
| 1046 | ], |
| 1047 | ), |
| 1048 | ], |
| 1049 | ), |
| 1050 | flag_set( |
| 1051 | actions = [ |
| 1052 | ACTION_NAMES.assemble, |
| 1053 | ACTION_NAMES.preprocess_assemble, |
| 1054 | ACTION_NAMES.cpp_compile, |
| 1055 | ACTION_NAMES.cpp_header_parsing, |
| 1056 | "c++-header-preprocessing", |
| 1057 | ], |
| 1058 | flag_groups = [flag_group(flags = ["-fno-canonical-system-headers"])], |
| 1059 | ), |
| 1060 | flag_set( |
| 1061 | actions = [ |
| 1062 | ACTION_NAMES.cpp_compile, |
| 1063 | ACTION_NAMES.cpp_header_parsing, |
| 1064 | ACTION_NAMES.cpp_module_compile, |
| 1065 | ACTION_NAMES.cpp_module_codegen, |
| 1066 | ], |
| 1067 | flag_groups = [ |
| 1068 | flag_group( |
| 1069 | flags = [ |
| 1070 | "-isystem", |
| 1071 | "external/arm_frc_linux_gnueabi_repo/arm-frc2020-linux-gnueabi/usr/include/c++/7.3.0", |
| 1072 | "-isystem", |
| 1073 | "external/arm_frc_linux_gnueabi_repo/arm-frc2020-linux-gnueabi/usr/include/c++/7.3.0/arm-frc2020-linux-gnueabi", |
| 1074 | "-isystem", |
| 1075 | "external/arm_frc_linux_gnueabi_repo/arm-frc2020-linux-gnueabi/usr/include/c++/7.3.0/backward", |
| 1076 | ], |
| 1077 | ), |
| 1078 | ], |
| 1079 | ), |
| 1080 | flag_set( |
| 1081 | actions = [ |
| 1082 | ACTION_NAMES.assemble, |
| 1083 | ACTION_NAMES.preprocess_assemble, |
| 1084 | ACTION_NAMES.c_compile, |
| 1085 | ACTION_NAMES.cpp_compile, |
| 1086 | ACTION_NAMES.cpp_header_parsing, |
| 1087 | ACTION_NAMES.cpp_module_compile, |
| 1088 | ACTION_NAMES.cpp_module_codegen, |
| 1089 | ACTION_NAMES.lto_backend, |
| 1090 | ACTION_NAMES.clif_match, |
| 1091 | ], |
| 1092 | flag_groups = [ |
| 1093 | flag_group( |
| 1094 | flags = [ |
| 1095 | "-isystem", |
| 1096 | "external/arm_frc_linux_gnueabi_repo/arm-frc2020-linux-gnueabi/usr/include", |
| 1097 | "-mfpu=neon", |
| 1098 | "-D__STDC_FORMAT_MACROS", |
| 1099 | "-D__STDC_CONSTANT_MACROS", |
| 1100 | "-D__STDC_LIMIT_MACROS", |
| 1101 | "-D_FILE_OFFSET_BITS=64", |
| 1102 | "-DAOS_ARCHITECTURE_arm_frc", |
| 1103 | "-U_FORTIFY_SOURCE", |
| 1104 | "-fstack-protector", |
| 1105 | "-fPIE", |
| 1106 | "-fdiagnostics-color=always", |
| 1107 | "-Wall", |
| 1108 | "-Wextra", |
| 1109 | "-Wpointer-arith", |
| 1110 | "-Wstrict-aliasing", |
| 1111 | "-Wcast-qual", |
| 1112 | "-Wwrite-strings", |
| 1113 | "-Wtype-limits", |
| 1114 | "-Wsign-compare", |
| 1115 | "-Wformat=2", |
| 1116 | "-Werror", |
| 1117 | "-Wunused-local-typedefs", |
| 1118 | "-Wno-psabi", |
| 1119 | "-fno-omit-frame-pointer", |
| 1120 | "-D__has_feature(x)=0", |
| 1121 | "-pipe", |
| 1122 | "-ggdb3", |
| 1123 | ], |
| 1124 | ), |
| 1125 | ], |
| 1126 | ), |
| 1127 | ], |
| 1128 | ) |
| 1129 | |
Austin Schuh | 0a96ea3 | 2022-01-01 22:29:30 -0800 | [diff] [blame] | 1130 | if (ctx.attr.cpu == "rp2040" or |
| 1131 | ctx.attr.cpu == "cortex-m4f" or |
Austin Schuh | a2503a7 | 2020-12-15 20:57:57 -0800 | [diff] [blame] | 1132 | ctx.attr.cpu == "cortex-m4f-k22"): |
Austin Schuh | da9d060 | 2019-09-15 17:29:38 -0700 | [diff] [blame] | 1133 | features = [ |
Austin Schuh | a2503a7 | 2020-12-15 20:57:57 -0800 | [diff] [blame] | 1134 | default_compile_flags_feature, |
| 1135 | default_link_flags_feature, |
| 1136 | dbg_feature, |
| 1137 | opt_feature, |
| 1138 | fastbuild_feature, |
| 1139 | all_modes_feature, |
| 1140 | include_paths_feature, |
Austin Schuh | a2503a7 | 2020-12-15 20:57:57 -0800 | [diff] [blame] | 1141 | user_compile_flags_feature, |
| 1142 | sysroot_feature, |
| 1143 | unfiltered_compile_flags_feature, |
| 1144 | ] |
Brian Silverman | 94cab07 | 2022-01-02 23:50:03 -0800 | [diff] [blame] | 1145 | elif ctx.attr.cpu == "roborio": |
Austin Schuh | da9d060 | 2019-09-15 17:29:38 -0700 | [diff] [blame] | 1146 | features = [ |
Austin Schuh | a2503a7 | 2020-12-15 20:57:57 -0800 | [diff] [blame] | 1147 | default_link_flags_feature, |
| 1148 | compile_flags1_feature, |
| 1149 | opt_feature, |
| 1150 | dependency_file_feature, |
| 1151 | random_seed_feature, |
| 1152 | pic_feature, |
| 1153 | include_paths_feature, |
| 1154 | opt_post_feature, |
| 1155 | dbg_feature, |
| 1156 | fastbuild_feature, |
| 1157 | all_modes_feature, |
| 1158 | pie_for_linking_feature, |
| 1159 | supports_dynamic_linker_feature, |
| 1160 | supports_pic_feature, |
Austin Schuh | a2503a7 | 2020-12-15 20:57:57 -0800 | [diff] [blame] | 1161 | user_compile_flags_feature, |
| 1162 | sysroot_feature, |
| 1163 | unfiltered_compile_flags_feature, |
| 1164 | ] |
Brian Silverman | 94cab07 | 2022-01-02 23:50:03 -0800 | [diff] [blame] | 1165 | elif ctx.attr.cpu == "armeabi-v7a": |
Austin Schuh | da9d060 | 2019-09-15 17:29:38 -0700 | [diff] [blame] | 1166 | features = [supports_pic_feature] |
| 1167 | else: |
| 1168 | fail("Unreachable") |
| 1169 | |
Brian Silverman | 94cab07 | 2022-01-02 23:50:03 -0800 | [diff] [blame] | 1170 | if ctx.attr.cpu == "armeabi-v7a": |
Austin Schuh | da9d060 | 2019-09-15 17:29:38 -0700 | [diff] [blame] | 1171 | cxx_builtin_include_directories = [] |
Brian Silverman | 94cab07 | 2022-01-02 23:50:03 -0800 | [diff] [blame] | 1172 | elif ctx.attr.cpu == "roborio": |
Austin Schuh | da9d060 | 2019-09-15 17:29:38 -0700 | [diff] [blame] | 1173 | cxx_builtin_include_directories = [ |
Austin Schuh | a2503a7 | 2020-12-15 20:57:57 -0800 | [diff] [blame] | 1174 | "%package(@arm_frc_linux_gnueabi_repo//arm-frc2020-linux-gnueabi/usr/lib/gcc/arm-frc2020-linux-gnueabi/7.3.0/include)%", |
| 1175 | "%package(@arm_frc_linux_gnueabi_repo//arm-frc2020-linux-gnueabi/usr/lib/gcc/arm-frc2020-linux-gnueabi/7.3.0/include-fixed)%", |
| 1176 | "%package(@arm_frc_linux_gnueabi_repo//arm-frc2020-linux-gnueabi/usr/include/c++/7.3.0/arm-frc2020-linux-gnueabi)%", |
| 1177 | "%package(@arm_frc_linux_gnueabi_repo//arm-frc2020-linux-gnueabi/usr/include/c++/7.3.0/backward)%", |
| 1178 | ] |
Austin Schuh | 0a96ea3 | 2022-01-01 22:29:30 -0800 | [diff] [blame] | 1179 | elif (ctx.attr.cpu == "rp2040" or |
| 1180 | ctx.attr.cpu == "cortex-m4f" or |
Austin Schuh | a2503a7 | 2020-12-15 20:57:57 -0800 | [diff] [blame] | 1181 | ctx.attr.cpu == "cortex-m4f-k22"): |
Austin Schuh | da9d060 | 2019-09-15 17:29:38 -0700 | [diff] [blame] | 1182 | cxx_builtin_include_directories = [ |
Austin Schuh | a2503a7 | 2020-12-15 20:57:57 -0800 | [diff] [blame] | 1183 | "/usr/lib/gcc/arm-none-eabi/4.8/include", |
| 1184 | "/usr/lib/gcc/arm-none-eabi/4.8/include-fixed", |
| 1185 | "/usr/lib/arm-none-eabi/include", |
| 1186 | "/usr/include/newlib", |
| 1187 | ] |
Austin Schuh | da9d060 | 2019-09-15 17:29:38 -0700 | [diff] [blame] | 1188 | else: |
| 1189 | fail("Unreachable") |
| 1190 | |
| 1191 | artifact_name_patterns = [] |
| 1192 | |
| 1193 | make_variables = [] |
| 1194 | |
Brian Silverman | 94cab07 | 2022-01-02 23:50:03 -0800 | [diff] [blame] | 1195 | if ctx.attr.cpu == "roborio": |
Austin Schuh | da9d060 | 2019-09-15 17:29:38 -0700 | [diff] [blame] | 1196 | tool_paths = [ |
| 1197 | tool_path( |
| 1198 | name = "ar", |
| 1199 | path = "arm-frc-linux-gnueabi/arm-frc-linux-gnueabi-ar", |
| 1200 | ), |
| 1201 | tool_path( |
| 1202 | name = "as", |
| 1203 | path = "arm-frc-linux-gnueabi/arm-frc-linux-gnueabi-as", |
| 1204 | ), |
| 1205 | tool_path( |
| 1206 | name = "compat-ld", |
| 1207 | path = "arm-frc-linux-gnueabi/arm-frc-linux-gnueabi-ld", |
| 1208 | ), |
| 1209 | tool_path( |
| 1210 | name = "cpp", |
| 1211 | path = "arm-frc-linux-gnueabi/arm-frc-linux-gnueabi-cpp", |
| 1212 | ), |
| 1213 | tool_path(name = "dwp", path = "/bin/false"), |
| 1214 | tool_path( |
| 1215 | name = "gcc", |
| 1216 | path = "arm-frc-linux-gnueabi/arm-frc-linux-gnueabi-gcc", |
| 1217 | ), |
| 1218 | tool_path( |
| 1219 | name = "gcov", |
| 1220 | path = "arm-frc-linux-gnueabi/arm-frc-linux-gnueabi-gcov-4.9", |
| 1221 | ), |
| 1222 | tool_path( |
| 1223 | name = "ld", |
| 1224 | path = "arm-frc-linux-gnueabi/arm-frc-linux-gnueabi-ld", |
| 1225 | ), |
| 1226 | tool_path( |
| 1227 | name = "nm", |
| 1228 | path = "arm-frc-linux-gnueabi/arm-frc-linux-gnueabi-nm", |
| 1229 | ), |
| 1230 | tool_path( |
| 1231 | name = "objcopy", |
| 1232 | path = "arm-frc-linux-gnueabi/arm-frc-linux-gnueabi-objcopy", |
| 1233 | ), |
| 1234 | tool_path( |
| 1235 | name = "objdump", |
| 1236 | path = "arm-frc-linux-gnueabi/arm-frc-linux-gnueabi-objdump", |
| 1237 | ), |
| 1238 | tool_path( |
| 1239 | name = "strip", |
| 1240 | path = "arm-frc-linux-gnueabi/arm-frc-linux-gnueabi-strip", |
| 1241 | ), |
| 1242 | ] |
Austin Schuh | 0a96ea3 | 2022-01-01 22:29:30 -0800 | [diff] [blame] | 1243 | elif (ctx.attr.cpu == "rp2040" or |
| 1244 | ctx.attr.cpu == "cortex-m4f" or |
Austin Schuh | a2503a7 | 2020-12-15 20:57:57 -0800 | [diff] [blame] | 1245 | ctx.attr.cpu == "cortex-m4f-k22"): |
Austin Schuh | da9d060 | 2019-09-15 17:29:38 -0700 | [diff] [blame] | 1246 | tool_paths = [ |
| 1247 | tool_path( |
| 1248 | name = "ar", |
| 1249 | path = "gcc_arm_none_eabi/arm-none-eabi-ar", |
| 1250 | ), |
| 1251 | tool_path( |
| 1252 | name = "compat-ld", |
| 1253 | path = "gcc_arm_none_eabi/arm-none-eabi-ld", |
| 1254 | ), |
| 1255 | tool_path( |
| 1256 | name = "cpp", |
| 1257 | path = "gcc_arm_none_eabi/arm-none-eabi-cpp", |
| 1258 | ), |
| 1259 | tool_path( |
| 1260 | name = "dwp", |
| 1261 | path = "gcc_arm_none_eabi/arm-none-eabi-dwp", |
| 1262 | ), |
| 1263 | tool_path( |
| 1264 | name = "gcc", |
| 1265 | path = "gcc_arm_none_eabi/arm-none-eabi-gcc", |
| 1266 | ), |
| 1267 | tool_path( |
| 1268 | name = "gcov", |
| 1269 | path = "gcc_arm_none_eabi/arm-none-eabi-gcov", |
| 1270 | ), |
| 1271 | tool_path( |
| 1272 | name = "ld", |
| 1273 | path = "gcc_arm_none_eabi/arm-none-eabi-ld", |
| 1274 | ), |
| 1275 | tool_path( |
| 1276 | name = "nm", |
| 1277 | path = "gcc_arm_none_eabi/arm-none-eabi-nm", |
| 1278 | ), |
| 1279 | tool_path( |
| 1280 | name = "objcopy", |
| 1281 | path = "gcc_arm_none_eabi/arm-none-eabi-objcopy", |
| 1282 | ), |
| 1283 | tool_path( |
| 1284 | name = "objdump", |
| 1285 | path = "gcc_arm_none_eabi/arm-none-eabi-objdump", |
| 1286 | ), |
| 1287 | tool_path( |
| 1288 | name = "strip", |
| 1289 | path = "gcc_arm_none_eabi/arm-none-eabi-strip", |
| 1290 | ), |
| 1291 | ] |
Brian Silverman | 94cab07 | 2022-01-02 23:50:03 -0800 | [diff] [blame] | 1292 | elif ctx.attr.cpu == "armeabi-v7a": |
Austin Schuh | da9d060 | 2019-09-15 17:29:38 -0700 | [diff] [blame] | 1293 | tool_paths = [ |
| 1294 | tool_path(name = "ar", path = "/bin/false"), |
| 1295 | tool_path(name = "compat-ld", path = "/bin/false"), |
| 1296 | tool_path(name = "cpp", path = "/bin/false"), |
| 1297 | tool_path(name = "dwp", path = "/bin/false"), |
| 1298 | tool_path(name = "gcc", path = "/bin/false"), |
| 1299 | tool_path(name = "gcov", path = "/bin/false"), |
| 1300 | tool_path(name = "ld", path = "/bin/false"), |
| 1301 | tool_path(name = "nm", path = "/bin/false"), |
| 1302 | tool_path(name = "objcopy", path = "/bin/false"), |
| 1303 | tool_path(name = "objdump", path = "/bin/false"), |
| 1304 | tool_path(name = "strip", path = "/bin/false"), |
| 1305 | ] |
| 1306 | else: |
| 1307 | fail("Unreachable") |
| 1308 | |
Austin Schuh | da9d060 | 2019-09-15 17:29:38 -0700 | [diff] [blame] | 1309 | out = ctx.actions.declare_file(ctx.label.name) |
| 1310 | ctx.actions.write(out, "Fake executable") |
| 1311 | return [ |
| 1312 | cc_common.create_cc_toolchain_config_info( |
| 1313 | ctx = ctx, |
| 1314 | features = features, |
| 1315 | action_configs = action_configs, |
| 1316 | artifact_name_patterns = artifact_name_patterns, |
| 1317 | cxx_builtin_include_directories = cxx_builtin_include_directories, |
| 1318 | toolchain_identifier = toolchain_identifier, |
| 1319 | host_system_name = host_system_name, |
| 1320 | target_system_name = target_system_name, |
| 1321 | target_cpu = target_cpu, |
| 1322 | target_libc = target_libc, |
| 1323 | compiler = compiler, |
| 1324 | abi_version = abi_version, |
| 1325 | abi_libc_version = abi_libc_version, |
| 1326 | tool_paths = tool_paths, |
| 1327 | make_variables = make_variables, |
| 1328 | builtin_sysroot = builtin_sysroot, |
Austin Schuh | a2503a7 | 2020-12-15 20:57:57 -0800 | [diff] [blame] | 1329 | cc_target_os = cc_target_os, |
Austin Schuh | da9d060 | 2019-09-15 17:29:38 -0700 | [diff] [blame] | 1330 | ), |
| 1331 | DefaultInfo( |
| 1332 | executable = out, |
| 1333 | ), |
| 1334 | ] |
Austin Schuh | a2503a7 | 2020-12-15 20:57:57 -0800 | [diff] [blame] | 1335 | |
| 1336 | cc_toolchain_config = rule( |
Austin Schuh | da9d060 | 2019-09-15 17:29:38 -0700 | [diff] [blame] | 1337 | implementation = _impl, |
| 1338 | attrs = { |
Brian Silverman | 4c7235a | 2021-11-17 19:04:37 -0800 | [diff] [blame^] | 1339 | "cpu": attr.string(mandatory = True, values = ["armeabi-v7a", "cortex-m4f", "cortex-m4f-k22", "roborio", "rp2040"]), |
Austin Schuh | da9d060 | 2019-09-15 17:29:38 -0700 | [diff] [blame] | 1340 | }, |
| 1341 | provides = [CcToolchainConfigInfo], |
| 1342 | executable = True, |
| 1343 | ) |