1# Copyright 2023 The Pigweed Authors 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); you may not 4# use this file except in compliance with the License. You may obtain a copy of 5# the License at 6# 7# https://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, WITHOUT 11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12# License for the specific language governing permissions and limitations under 13# the License. 14 15load( 16 "@pw_toolchain//cc_toolchain:defs.bzl", 17 "pw_cc_action_config", 18 "pw_cc_action_files", 19 "pw_cc_tool", 20) 21 22package(default_visibility = ["//visibility:public"]) 23 24licenses(["notice"]) 25 26# This build file defines a complete set of tools for an arm-none-eabi GNU 27# binutils-based toolchain. 28 29exports_files(glob(["**"])) 30 31pw_cc_action_files( 32 name = "all", 33 actions = ["@pw_toolchain//actions:all_actions"], 34 srcs = glob(["**"]), 35 visibility = ["//visibility:public"], 36) 37 38pw_cc_tool( 39 name = "arm-none-eabi-ar_tool", 40 tool = select({ 41 "@platforms//os:windows": "//:bin/arm-none-eabi-ar.exe", 42 "//conditions:default": "//:bin/arm-none-eabi-ar", 43 }), 44) 45 46pw_cc_action_config( 47 name = "arm-none-eabi-ar", 48 action_names = ["@pw_toolchain//actions:all_ar_actions"], 49 # Unlike most legacy features required to compile code, these features 50 # aren't enabled by default, and are instead only implied by the built-in 51 # action configs. We imply the features here to match the behavior of the 52 # built-in action configs so flags are actually passed to `ar`. 53 implies = [ 54 "@pw_toolchain//features/legacy:archiver_flags", 55 "@pw_toolchain//features/legacy:linker_param_file", 56 ], 57 tools = [":arm-none-eabi-ar_tool"], 58) 59 60pw_cc_tool( 61 name = "arm-none-eabi-g++_tool", 62 tool = select({ 63 "@platforms//os:windows": "//:bin/arm-none-eabi-g++.exe", 64 "//conditions:default": "//:bin/arm-none-eabi-g++", 65 }), 66 additional_files = glob([ 67 "**/*.spec", 68 "**/*.specs", 69 "arm-none-eabi/include/**", 70 "lib/gcc/arm-none-eabi/*/include/**", 71 "lib/gcc/arm-none-eabi/*/include-fixed/**", 72 "libexec/**", 73 ]), 74) 75 76pw_cc_action_config( 77 name = "arm-none-eabi-g++", 78 action_names = ["@pw_toolchain//actions:all_cpp_compiler_actions"], 79 tools = [":arm-none-eabi-g++_tool"], 80) 81 82pw_cc_tool( 83 name = "arm-none-eabi-gcc_tool", 84 tool = select({ 85 "@platforms//os:windows": "//:bin/arm-none-eabi-gcc.exe", 86 "//conditions:default": "//:bin/arm-none-eabi-gcc", 87 }), 88 additional_files = glob([ 89 "**/*.spec", 90 "**/*.specs", 91 "arm-none-eabi/include/**", 92 "lib/gcc/arm-none-eabi/*/include/**", 93 "lib/gcc/arm-none-eabi/*/include-fixed/**", 94 "libexec/**", 95 ]) + 96 # The assembler needs to be explicilty added. Note that the path is 97 # intentionally different here as `as` is called from arm-none-eabi-gcc. 98 # `arm-none-eabi-as` will not suffice for this context. 99 select({ 100 "@platforms//os:windows": ["//:arm-none-eabi/bin/as.exe"], 101 "//conditions:default": ["//:arm-none-eabi/bin/as"], 102 }), 103) 104 105pw_cc_action_config( 106 name = "arm-none-eabi-gcc", 107 action_names = [ 108 "@pw_toolchain//actions:all_asm_actions", 109 "@pw_toolchain//actions:all_c_compiler_actions", 110 ], 111 tools = [":arm-none-eabi-gcc_tool"], 112) 113 114# This tool is actually just g++ under the hood, we just enumerate this 115# tool differently to specify a different set of additional files. 116pw_cc_tool( 117 name = "arm-none-eabi-ld_tool", 118 tool = select({ 119 "@platforms//os:windows": "//:bin/arm-none-eabi-g++.exe", 120 "//conditions:default": "//:bin/arm-none-eabi-g++", 121 }), 122 additional_files = glob([ 123 "**/*.a", 124 "**/*.ld", 125 "**/*.o", 126 "**/*.spec", 127 "**/*.specs", 128 "**/*.so", 129 "libexec/**", 130 ]) + [ 131 "//:arm-none-eabi/bin/ld", 132 ], 133) 134 135pw_cc_action_config( 136 name = "arm-none-eabi-ld", 137 action_names = ["@pw_toolchain//actions:all_link_actions"], 138 tools = [":arm-none-eabi-ld_tool"], 139) 140 141pw_cc_tool( 142 name = "arm-none-eabi-gcov_tool", 143 tool = select({ 144 "@platforms//os:windows": "//:bin/arm-none-eabi-gcov.exe", 145 "//conditions:default": "//:bin/arm-none-eabi-gcov", 146 }), 147) 148 149pw_cc_action_config( 150 name = "arm-none-eabi-gcov", 151 action_names = ["@pw_toolchain//actions:all_coverage_actions"], 152 tools = [":arm-none-eabi-gcov_tool"], 153) 154 155pw_cc_tool( 156 name = "arm-none-eabi-objcopy_tool", 157 tool = select({ 158 "@platforms//os:windows": "//:bin/arm-none-eabi-objcopy.exe", 159 "//conditions:default": "//:bin/arm-none-eabi-objcopy", 160 }), 161) 162 163pw_cc_action_config( 164 name = "arm-none-eabi-objcopy", 165 action_names = ["@pw_toolchain//actions:all_objcopy_actions"], 166 tools = [":arm-none-eabi-objcopy_tool"], 167) 168 169pw_cc_tool( 170 name = "arm-none-eabi-objdump_tool", 171 tool = select({ 172 "@platforms//os:windows": "//:bin/arm-none-eabi-objdump.exe", 173 "//conditions:default": "//:bin/arm-none-eabi-objdump", 174 }), 175) 176 177pw_cc_action_config( 178 name = "arm-none-eabi-objdump", 179 action_names = ["@pw_toolchain//actions:all_objdump_actions"], 180 tools = [":arm-none-eabi-objdump_tool"], 181) 182 183pw_cc_tool( 184 name = "arm-none-eabi-strip_tool", 185 tool = select({ 186 "@platforms//os:windows": "//:bin/arm-none-eabi-strip.exe", 187 "//conditions:default": "//:bin/arm-none-eabi-strip", 188 }), 189) 190 191pw_cc_action_config( 192 name = "arm-none-eabi-strip", 193 action_names = ["@pw_toolchain//actions:all_strip_actions"], 194 tools = [":arm-none-eabi-strip_tool"], 195) 196