xref: /aosp_15_r20/external/pigweed/pw_toolchain/BUILD.gn (revision 61c4878ac05f98d0ceed94b57d316916de578985)
1*61c4878aSAndroid Build Coastguard Worker# Copyright 2020 The Pigweed Authors
2*61c4878aSAndroid Build Coastguard Worker#
3*61c4878aSAndroid Build Coastguard Worker# Licensed under the Apache License, Version 2.0 (the "License"); you may not
4*61c4878aSAndroid Build Coastguard Worker# use this file except in compliance with the License. You may obtain a copy of
5*61c4878aSAndroid Build Coastguard Worker# the License at
6*61c4878aSAndroid Build Coastguard Worker#
7*61c4878aSAndroid Build Coastguard Worker#     https://www.apache.org/licenses/LICENSE-2.0
8*61c4878aSAndroid Build Coastguard Worker#
9*61c4878aSAndroid Build Coastguard Worker# Unless required by applicable law or agreed to in writing, software
10*61c4878aSAndroid Build Coastguard Worker# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11*61c4878aSAndroid Build Coastguard Worker# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12*61c4878aSAndroid Build Coastguard Worker# License for the specific language governing permissions and limitations under
13*61c4878aSAndroid Build Coastguard Worker# the License.
14*61c4878aSAndroid Build Coastguard Worker
15*61c4878aSAndroid Build Coastguard Workerimport("//build_overrides/pigweed.gni")
16*61c4878aSAndroid Build Coastguard Worker
17*61c4878aSAndroid Build Coastguard Workerimport("$dir_pw_docgen/docs.gni")
18*61c4878aSAndroid Build Coastguard Workerimport("$dir_pw_unit_test/test.gni")
19*61c4878aSAndroid Build Coastguard Workerimport("arm_gcc/toolchains.gni")
20*61c4878aSAndroid Build Coastguard Workerimport("generate_toolchain.gni")
21*61c4878aSAndroid Build Coastguard Workerimport("host_clang/toolchains.gni")
22*61c4878aSAndroid Build Coastguard Workerimport("host_gcc/toolchains.gni")
23*61c4878aSAndroid Build Coastguard Worker
24*61c4878aSAndroid Build Coastguard Worker# For each of the toolchains below, the toolchain GNI file has the corresponding
25*61c4878aSAndroid Build Coastguard Worker# configs. This allows BUILDCONFIG.gn to set default target values on "flat"
26*61c4878aSAndroid Build Coastguard Worker# lists of configs, i.e. not nested. This in turn allows individual targets
27*61c4878aSAndroid Build Coastguard Worker# fine-grained control over which default configs they wise to override.
28*61c4878aSAndroid Build Coastguard Worker
29*61c4878aSAndroid Build Coastguard Worker# Generate ARM GCC toolchains
30*61c4878aSAndroid Build Coastguard Workergenerate_toolchains("arm_gcc_suite") {
31*61c4878aSAndroid Build Coastguard Worker  toolchains = pw_toolchain_arm_gcc_list
32*61c4878aSAndroid Build Coastguard Worker}
33*61c4878aSAndroid Build Coastguard Worker
34*61c4878aSAndroid Build Coastguard Worker# Generate Host GCC toolchains
35*61c4878aSAndroid Build Coastguard Workergenerate_toolchains("host_gcc_suite") {
36*61c4878aSAndroid Build Coastguard Worker  toolchains = pw_toolchain_host_gcc_list
37*61c4878aSAndroid Build Coastguard Worker}
38*61c4878aSAndroid Build Coastguard Worker
39*61c4878aSAndroid Build Coastguard Worker# Generate Host Clang toolchains
40*61c4878aSAndroid Build Coastguard Workergenerate_toolchains("host_clang_suite") {
41*61c4878aSAndroid Build Coastguard Worker  toolchains = pw_toolchain_host_clang_list
42*61c4878aSAndroid Build Coastguard Worker}
43*61c4878aSAndroid Build Coastguard Worker
44*61c4878aSAndroid Build Coastguard Workerconfig("public_include_path") {
45*61c4878aSAndroid Build Coastguard Worker  include_dirs = [ "public" ]
46*61c4878aSAndroid Build Coastguard Worker}
47*61c4878aSAndroid Build Coastguard Worker
48*61c4878aSAndroid Build Coastguard Workergroup("builtins") {
49*61c4878aSAndroid Build Coastguard Worker  deps = [ "$dir_pw_third_party/llvm_builtins" ]
50*61c4878aSAndroid Build Coastguard Worker}
51*61c4878aSAndroid Build Coastguard Worker
52*61c4878aSAndroid Build Coastguard Workerpw_doc_group("docs") {
53*61c4878aSAndroid Build Coastguard Worker  sources = [
54*61c4878aSAndroid Build Coastguard Worker    "bazel.rst",
55*61c4878aSAndroid Build Coastguard Worker    "docs.rst",
56*61c4878aSAndroid Build Coastguard Worker    "gn.rst",
57*61c4878aSAndroid Build Coastguard Worker  ]
58*61c4878aSAndroid Build Coastguard Worker}
59*61c4878aSAndroid Build Coastguard Worker
60*61c4878aSAndroid Build Coastguard Workerpw_source_set("no_destructor") {
61*61c4878aSAndroid Build Coastguard Worker  public_configs = [ ":public_include_path" ]
62*61c4878aSAndroid Build Coastguard Worker  public = [ "public/pw_toolchain/no_destructor.h" ]
63*61c4878aSAndroid Build Coastguard Worker}
64*61c4878aSAndroid Build Coastguard Worker
65*61c4878aSAndroid Build Coastguard Workerpw_source_set("sibling_cast") {
66*61c4878aSAndroid Build Coastguard Worker  public_configs = [ ":public_include_path" ]
67*61c4878aSAndroid Build Coastguard Worker  public = [ "public/pw_toolchain/internal/sibling_cast.h" ]
68*61c4878aSAndroid Build Coastguard Worker  visibility = [ "$dir_pigweed/*" ]
69*61c4878aSAndroid Build Coastguard Worker}
70*61c4878aSAndroid Build Coastguard Worker
71*61c4878aSAndroid Build Coastguard Workerpw_test("sibling_cast_test") {
72*61c4878aSAndroid Build Coastguard Worker  sources = [ "sibling_cast_test.cc" ]
73*61c4878aSAndroid Build Coastguard Worker  deps = [ ":sibling_cast" ]
74*61c4878aSAndroid Build Coastguard Worker  negative_compilation_tests = true
75*61c4878aSAndroid Build Coastguard Worker}
76*61c4878aSAndroid Build Coastguard Worker
77*61c4878aSAndroid Build Coastguard Workerconfig("wrap_abort_config") {
78*61c4878aSAndroid Build Coastguard Worker  ldflags = [ "-Wl,--wrap=abort" ]
79*61c4878aSAndroid Build Coastguard Worker  visibility = [ ":*" ]
80*61c4878aSAndroid Build Coastguard Worker}
81*61c4878aSAndroid Build Coastguard Worker
82*61c4878aSAndroid Build Coastguard Workerpw_source_set("wrap_abort") {
83*61c4878aSAndroid Build Coastguard Worker  all_dependent_configs = [ ":wrap_abort_config" ]
84*61c4878aSAndroid Build Coastguard Worker  sources = [ "wrap_abort.cc" ]
85*61c4878aSAndroid Build Coastguard Worker  deps = [ dir_pw_assert ]
86*61c4878aSAndroid Build Coastguard Worker}
87*61c4878aSAndroid Build Coastguard Worker
88*61c4878aSAndroid Build Coastguard Workerpw_test_group("tests") {
89*61c4878aSAndroid Build Coastguard Worker  tests = [
90*61c4878aSAndroid Build Coastguard Worker    ":no_destructor_test",
91*61c4878aSAndroid Build Coastguard Worker    ":sibling_cast_test",
92*61c4878aSAndroid Build Coastguard Worker  ]
93*61c4878aSAndroid Build Coastguard Worker}
94*61c4878aSAndroid Build Coastguard Worker
95*61c4878aSAndroid Build Coastguard Workerpw_test("no_destructor_test") {
96*61c4878aSAndroid Build Coastguard Worker  sources = [ "no_destructor_test.cc" ]
97*61c4878aSAndroid Build Coastguard Worker  deps = [
98*61c4878aSAndroid Build Coastguard Worker    ":no_destructor",
99*61c4878aSAndroid Build Coastguard Worker    dir_pw_assert,
100*61c4878aSAndroid Build Coastguard Worker  ]
101*61c4878aSAndroid Build Coastguard Worker}
102