• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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)
132
133pw_cc_action_config(
134    name = "arm-none-eabi-ld",
135    action_names = ["@pw_toolchain//actions:all_link_actions"],
136    tools = [":arm-none-eabi-ld_tool"],
137)
138
139pw_cc_tool(
140    name = "arm-none-eabi-gcov_tool",
141    tool = select({
142        "@platforms//os:windows": "//:bin/arm-none-eabi-gcov.exe",
143        "//conditions:default": "//:bin/arm-none-eabi-gcov",
144    }),
145)
146
147pw_cc_action_config(
148    name = "arm-none-eabi-gcov",
149    action_names = ["@pw_toolchain//actions:all_coverage_actions"],
150    tools = [":arm-none-eabi-gcov_tool"],
151)
152
153pw_cc_tool(
154    name = "arm-none-eabi-objcopy_tool",
155    tool = select({
156        "@platforms//os:windows": "//:bin/arm-none-eabi-objcopy.exe",
157        "//conditions:default": "//:bin/arm-none-eabi-objcopy",
158    }),
159)
160
161pw_cc_action_config(
162    name = "arm-none-eabi-objcopy",
163    action_names = ["@pw_toolchain//actions:all_objcopy_actions"],
164    tools = [":arm-none-eabi-objcopy_tool"],
165)
166
167pw_cc_tool(
168    name = "arm-none-eabi-objdump_tool",
169    tool = select({
170        "@platforms//os:windows": "//:bin/arm-none-eabi-objdump.exe",
171        "//conditions:default": "//:bin/arm-none-eabi-objdump",
172    }),
173)
174
175pw_cc_action_config(
176    name = "arm-none-eabi-objdump",
177    action_names = ["@pw_toolchain//actions:all_objdump_actions"],
178    tools = [":arm-none-eabi-objdump_tool"],
179)
180
181pw_cc_tool(
182    name = "arm-none-eabi-strip_tool",
183    tool = select({
184        "@platforms//os:windows": "//:bin/arm-none-eabi-strip.exe",
185        "//conditions:default": "//:bin/arm-none-eabi-strip",
186    }),
187)
188
189pw_cc_action_config(
190    name = "arm-none-eabi-strip",
191    action_names = ["@pw_toolchain//actions:all_strip_actions"],
192    tools = [":arm-none-eabi-strip_tool"],
193)
194