1 # Copyright 2020 The Pigweed Authors
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
7 # https://www.apache.org/licenses/LICENSE-2.0
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
14 """Emits an error telling the user not to use the default toolchain."""
19 Error: trying to build a target with the default toolchain
21 This occurs when a GN target is listed as a dependency outside of a toolchain
22 group (such as host_clang or stm32f429i) in the root BUILD.gn file.
24 Make sure that your top-level targets are always instantiated with a toolchain
25 and that no dependencies are pulled in through the default toolchain.
27 group("my_target_wrapper") {
28 deps = [ ":my_target(//path/to/my/toolchain)" ]
33 if (current_toolchain != default_toolchain) {
34 deps += [ "//my_application:image" ]
38 If you are developing in Pigweed itself, list your build target under one of
39 the predefined groups in //BUILD.gn. For example,
41 # apps is an existing group intended for building application images.
49 Other predefined groups include host_tools, pw_modules, and pw_module_tests.
51 If you want to add a custom group instead of using an existing one, it must be
52 defined alongside the predefined groups, within the toolchain condition block:
54 if (current_toolchain != default_toolchain) {
59 # Other predefined groups...
61 group("my_custom_group") {
62 deps = [ "//path/to:my_target" ]
66 To include your custom group in the build, add it to the pigweed_default group
67 to have it compile for every supported Pigweed target.
69 group("pigweed_default") {
72 if (current_toolchain != default_toolchain) {
73 # Standard Pigweed dependencies...
75 # Add your group here.
76 deps += [ ":my_custom_group" ]
80 For more details on the Pigweed build structure and how to configure custom
81 build targets or toolchains, please refer to "Build system" in the Pigweed
87 print(_ERROR_MESSAGE, file=sys.stderr)
91 if __name__ == '__main__':