xref: /aosp_15_r20/external/pigweed/pw_build/defaults.gni (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
17# Default configs and dependencies provided by the toolchain. These
18# are applied to all of the pw_* target types. These are set from a toolchain's
19# toolchain_args scope with the following argument names:
20#
21#   default_configs
22#   default_public_deps
23#   remove_default_configs
24#   remove_default_public_deps
25#
26# Because of how GN handles default vs non-default toolchains, these only apply
27# for for non-default toolchains. A non-default toolchain invocation occurs
28# when a toolchain is specified in parenthesis after the name of a build target
29# in a dependency list. For example:
30#
31#   group("foo_group") {
32#     deps = [ //pw_some_module(//pw_toolchain:not_default) ]
33#   }
34#
35# The default toolchain is never used by Pigweed to build C/C++ since
36# toolchain_args of that toolchain are ignored by GN.
37#
38# DO NOT RELY ON THIS: Use pw_build_defaults instead!
39# This is exposed as public because it is needed by both defaults.gni and
40# build_target.gni, and it helps surface the design of the GN build
41# architecture.
42pw_build_INTERNAL_DEFAULTS = {
43  # This is a little odd, but it's done for backwards compatibility. See the
44  # referenced .gni file if you want more information.
45  import("$dir_pw_build/gn_internal/defaults.gni")
46}
47
48declare_args() {
49  # Controls the default visibility of C/C++ libraries and executables
50  # (pw_source_set, pw_static_library, pw_shared_library pw_executable). This
51  # can be "*" or a list of paths.
52  #
53  # This is useful for limiting usage of Pigweed modules via an explicit
54  # allowlist. For the GN build to work, pw_build_DEFAULT_VISIBILITY must always
55  # at least include the Pigweed repository ("$dir_pigweed/*").
56  #
57  # Explicitly setting a target's visibility overrides this default.
58  pw_build_DEFAULT_VISIBILITY = [ "*" ]
59
60  # Controls whether compilers and other tools are told to use colorized output.
61  pw_build_COLORIZE_OUTPUT = true
62}
63
64# These are the default configs automatically applied to every pw_* C/C++ build
65# step regardless of toolchain. If you want to omit one of these from your
66# toolchain, add the undesired config to pw_build_REMOVE_DEFAULT_CONFIGS.
67#
68# This is not the default value of pw_build_DEFAULT_CONFIGS because it would
69# be too easy to accidentally clobber.
70pigweed_default_configs = [
71  "$dir_pw_build:colorize_output",
72  "$dir_pw_build:debugging",
73  "$dir_pw_build:reduced_size",
74  "$dir_pw_build:strict_warnings",
75  "$dir_pw_build:toolchain_cpp_standard",
76  "$dir_pw_build:relative_paths",
77  "$dir_pw_build:enable_clang_fixed_point_types",
78]
79
80# Some Projects rely on this, so it is being retained for backwards
81# compatibilty. Using these is not recommended; prefer to use the pw_* target
82# types directly.
83pw_build_defaults = {
84  configs = pw_build_INTERNAL_DEFAULTS.default_configs
85  public_deps = pw_build_INTERNAL_DEFAULTS.default_public_deps
86  if (pw_build_INTERNAL_DEFAULTS.remove_default_configs != []) {
87    # Add them first to ensure they are present to be removed.
88    configs += pw_build_INTERNAL_DEFAULTS.remove_default_configs
89    configs -= pw_build_INTERNAL_DEFAULTS.remove_default_configs
90  }
91  if (pw_build_INTERNAL_DEFAULTS.remove_default_public_deps != []) {
92    # Add them first to ensure they are present to be removed.
93    public_deps += pw_build_INTERNAL_DEFAULTS.remove_default_public_deps
94    public_deps -= pw_build_INTERNAL_DEFAULTS.remove_default_public_deps
95  }
96  if (pw_build_DEFAULT_VISIBILITY != [ "*" ]) {
97    visibility = pw_build_DEFAULT_VISIBILITY
98  }
99}
100