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