xref: /aosp_15_r20/external/pigweed/pw_toolchain/BUILD.gn (revision 61c4878ac05f98d0ceed94b57d316916de578985)
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
15import("//build_overrides/pigweed.gni")
16
17import("$dir_pw_docgen/docs.gni")
18import("$dir_pw_unit_test/test.gni")
19import("arm_gcc/toolchains.gni")
20import("generate_toolchain.gni")
21import("host_clang/toolchains.gni")
22import("host_gcc/toolchains.gni")
23
24# For each of the toolchains below, the toolchain GNI file has the corresponding
25# configs. This allows BUILDCONFIG.gn to set default target values on "flat"
26# lists of configs, i.e. not nested. This in turn allows individual targets
27# fine-grained control over which default configs they wise to override.
28
29# Generate ARM GCC toolchains
30generate_toolchains("arm_gcc_suite") {
31  toolchains = pw_toolchain_arm_gcc_list
32}
33
34# Generate Host GCC toolchains
35generate_toolchains("host_gcc_suite") {
36  toolchains = pw_toolchain_host_gcc_list
37}
38
39# Generate Host Clang toolchains
40generate_toolchains("host_clang_suite") {
41  toolchains = pw_toolchain_host_clang_list
42}
43
44config("public_include_path") {
45  include_dirs = [ "public" ]
46}
47
48group("builtins") {
49  deps = [ "$dir_pw_third_party/llvm_builtins" ]
50}
51
52pw_doc_group("docs") {
53  sources = [
54    "bazel.rst",
55    "docs.rst",
56    "gn.rst",
57  ]
58}
59
60pw_source_set("no_destructor") {
61  public_configs = [ ":public_include_path" ]
62  public = [ "public/pw_toolchain/no_destructor.h" ]
63}
64
65pw_source_set("sibling_cast") {
66  public_configs = [ ":public_include_path" ]
67  public = [ "public/pw_toolchain/internal/sibling_cast.h" ]
68  visibility = [ "$dir_pigweed/*" ]
69}
70
71pw_test("sibling_cast_test") {
72  sources = [ "sibling_cast_test.cc" ]
73  deps = [ ":sibling_cast" ]
74  negative_compilation_tests = true
75}
76
77config("wrap_abort_config") {
78  ldflags = [ "-Wl,--wrap=abort" ]
79  visibility = [ ":*" ]
80}
81
82pw_source_set("wrap_abort") {
83  all_dependent_configs = [ ":wrap_abort_config" ]
84  sources = [ "wrap_abort.cc" ]
85  deps = [ dir_pw_assert ]
86}
87
88pw_test_group("tests") {
89  tests = [
90    ":no_destructor_test",
91    ":sibling_cast_test",
92  ]
93}
94
95pw_test("no_destructor_test") {
96  sources = [ "no_destructor_test.cc" ]
97  deps = [
98    ":no_destructor",
99    dir_pw_assert,
100  ]
101}
102