Fix for x86_64 build fail
[platform/upstream/connectedhomeip.git] / third_party / pigweed / repo / pw_toolchain / py / pw_toolchain / bad_toolchain.py
1 # Copyright 2020 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 """Emits an error telling the user not to use the default toolchain."""
15
16 import sys
17
18 _ERROR_MESSAGE = """
19 Error: trying to build a target with the default toolchain
20
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.
23
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.
26
27   group("my_target_wrapper") {
28     deps = [ ":my_target(//path/to/my/toolchain)" ]
29   }
30
31   group("my_target") {
32     deps = []
33     if (current_toolchain != default_toolchain) {
34       deps += [ "//my_application:image" ]
35     }
36   }
37
38   If you are developing in Pigweed itself, list your build target under one of
39   the predefined groups in //BUILD.gn. For example,
40
41     # apps is an existing group intended for building application images.
42     group("apps") {
43       deps = [
44         ...
45         "your_target:here",
46       ]
47     }
48
49   Other predefined groups include host_tools, pw_modules, and pw_module_tests.
50
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:
53
54     if (current_toolchain != default_toolchain) {
55       group("apps") {
56         ...
57       }
58
59       # Other predefined groups...
60
61       group("my_custom_group") {
62         deps = [ "//path/to:my_target" ]
63       }
64     }
65
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.
68
69     group("pigweed_default") {
70       deps = []
71
72       if (current_toolchain != default_toolchain) {
73         # Standard Pigweed dependencies...
74
75         # Add your group here.
76         deps += [ ":my_custom_group" ]
77       }
78     }
79
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
82   documentation.
83 """
84
85
86 def main() -> int:
87     print(_ERROR_MESSAGE, file=sys.stderr)
88     return 1
89
90
91 if __name__ == '__main__':
92     sys.exit(main())