xref: /aosp_15_r20/external/pigweed/pw_build/cc_library.gni (revision 61c4878ac05f98d0ceed94b57d316916de578985)
1*61c4878aSAndroid Build Coastguard Worker# Copyright 2021 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_build/gn_internal/build_target.gni")
18*61c4878aSAndroid Build Coastguard Worker
19*61c4878aSAndroid Build Coastguard Worker# Note: In general, prefer to import target_types.gni rather than this file.
20*61c4878aSAndroid Build Coastguard Worker# cc_executable.gni and cc_library.gni are both provided by target_types.gni.
21*61c4878aSAndroid Build Coastguard Worker#
22*61c4878aSAndroid Build Coastguard Worker# cc_library.gni is split out from cc_executable.gni because pw_executable
23*61c4878aSAndroid Build Coastguard Worker# templates may need to create pw_source_set targets internally, and can't
24*61c4878aSAndroid Build Coastguard Worker# import target_types.gni because it creates a circular import path.
25*61c4878aSAndroid Build Coastguard Worker
26*61c4878aSAndroid Build Coastguard Worker# These templates are wrappers for GN's built-in source_set, static_library,
27*61c4878aSAndroid Build Coastguard Worker# and shared_library targets.
28*61c4878aSAndroid Build Coastguard Worker#
29*61c4878aSAndroid Build Coastguard Worker# For more information on the features provided by these templates, see the full
30*61c4878aSAndroid Build Coastguard Worker# docs at https://pigweed.dev/pw_build/?highlight=pw_executable#target-types.
31*61c4878aSAndroid Build Coastguard Worker#
32*61c4878aSAndroid Build Coastguard Worker# In addition to the arguments supported by the underlying native target types,
33*61c4878aSAndroid Build Coastguard Worker# these templates introduce the following arguments:
34*61c4878aSAndroid Build Coastguard Worker#
35*61c4878aSAndroid Build Coastguard Worker#  remove_configs: (optional) A list of configs to remove from the set of
36*61c4878aSAndroid Build Coastguard Worker#    default configs specified by the current toolchain configuration.
37*61c4878aSAndroid Build Coastguard Worker#  remove_public_deps: (optional) A list of targets to remove from the set of
38*61c4878aSAndroid Build Coastguard Worker#    default public_deps specified by the current toolchain configuration.
39*61c4878aSAndroid Build Coastguard Worker
40*61c4878aSAndroid Build Coastguard Workertemplate("pw_source_set") {
41*61c4878aSAndroid Build Coastguard Worker  pw_internal_build_target(target_name) {
42*61c4878aSAndroid Build Coastguard Worker    forward_variables_from(invoker, "*")
43*61c4878aSAndroid Build Coastguard Worker    if (!defined(add_global_link_deps)) {
44*61c4878aSAndroid Build Coastguard Worker      add_global_link_deps = false
45*61c4878aSAndroid Build Coastguard Worker    }
46*61c4878aSAndroid Build Coastguard Worker    underlying_target_type = "source_set"
47*61c4878aSAndroid Build Coastguard Worker  }
48*61c4878aSAndroid Build Coastguard Worker}
49*61c4878aSAndroid Build Coastguard Worker
50*61c4878aSAndroid Build Coastguard Workertemplate("pw_static_library") {
51*61c4878aSAndroid Build Coastguard Worker  pw_internal_build_target(target_name) {
52*61c4878aSAndroid Build Coastguard Worker    forward_variables_from(invoker, "*")
53*61c4878aSAndroid Build Coastguard Worker    if (!defined(add_global_link_deps)) {
54*61c4878aSAndroid Build Coastguard Worker      add_global_link_deps = false
55*61c4878aSAndroid Build Coastguard Worker    }
56*61c4878aSAndroid Build Coastguard Worker    underlying_target_type = "static_library"
57*61c4878aSAndroid Build Coastguard Worker  }
58*61c4878aSAndroid Build Coastguard Worker}
59*61c4878aSAndroid Build Coastguard Worker
60*61c4878aSAndroid Build Coastguard Workertemplate("pw_shared_library") {
61*61c4878aSAndroid Build Coastguard Worker  pw_internal_build_target(target_name) {
62*61c4878aSAndroid Build Coastguard Worker    forward_variables_from(invoker, "*")
63*61c4878aSAndroid Build Coastguard Worker    if (!defined(add_global_link_deps)) {
64*61c4878aSAndroid Build Coastguard Worker      add_global_link_deps = false
65*61c4878aSAndroid Build Coastguard Worker    }
66*61c4878aSAndroid Build Coastguard Worker    underlying_target_type = "shared_library"
67*61c4878aSAndroid Build Coastguard Worker  }
68*61c4878aSAndroid Build Coastguard Worker}
69