• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2021 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_build/target_types.gni")
18import("$dir_pw_docgen/docs.gni")
19import("$dir_pw_unit_test/test.gni")
20
21config("public_include_path") {
22  include_dirs = [ "public" ]
23  visibility = [ ":*" ]
24}
25
26pw_source_set("pw_polyfill") {
27  public_configs = [ ":public_include_path" ]
28  remove_public_deps = [ "*" ]
29  public_deps = [ ":standard_library" ]
30  public = [
31    "public/pw_polyfill/language_feature_macros.h",
32    "public/pw_polyfill/standard.h",
33  ]
34}
35
36config("overrides_config") {
37  include_dirs = [ "public_overrides" ]
38  visibility = [ ":*" ]
39}
40
41# TODO(pwbug/602): Remove this overrides target by migrating all users to
42# explicitly depend on the polyfill(s) they require.
43group("overrides") {
44  public_deps = [
45    ":bit",
46    ":cstddef",
47    ":iterator",
48    ":span",
49    ":type_traits",
50  ]
51}
52
53config("standard_library_public") {
54  include_dirs = [ "standard_library_public" ]
55}
56
57# Provides <bit>'s std::endian.
58pw_source_set("bit") {
59  public_configs = [
60    ":standard_library_public",
61    ":overrides_config",
62  ]
63  public_deps = [ ":standard_library" ]
64  remove_public_deps = [ "*" ]
65  inputs = [ "public_overrides/bit" ]
66  public = [ "standard_library_public/pw_polyfill/standard_library/bit.h" ]
67}
68
69# Provides <cstddef>'s std::byte.
70pw_source_set("cstddef") {
71  public_configs = [
72    ":standard_library_public",
73    ":overrides_config",
74  ]
75  public_deps = [ ":standard_library" ]
76  remove_public_deps = [ "*" ]
77  inputs = [ "public_overrides/cstddef" ]
78  public = [ "standard_library_public/pw_polyfill/standard_library/cstddef.h" ]
79}
80
81# TODO(pwbug/603): Remove this polyfill.
82pw_source_set("iterator") {
83  public_configs = [
84    ":standard_library_public",
85    ":overrides_config",
86  ]
87  public_deps = [ ":standard_library" ]
88  remove_public_deps = [ "*" ]
89  inputs = [ "public_overrides/iterator" ]
90  public = [ "standard_library_public/pw_polyfill/standard_library/iterator.h" ]
91}
92
93# Provides <span>.
94pw_source_set("span") {
95  remove_public_deps = [ "*" ]
96  public_deps = [ "$dir_pw_span:polyfill" ]
97}
98
99# TODO(pwbug/603): Remove this polyfill.
100pw_source_set("type_traits") {
101  public_configs = [
102    ":standard_library_public",
103    ":overrides_config",
104  ]
105  public_deps = [ ":standard_library" ]
106  remove_public_deps = [ "*" ]
107  inputs = [ "public_overrides/type_traits" ]
108  public =
109      [ "standard_library_public/pw_polyfill/standard_library/type_traits.h" ]
110}
111
112pw_source_set("standard_library") {
113  public_configs = [ ":standard_library_public" ]
114  remove_public_deps = [ "*" ]
115  public =
116      [ "standard_library_public/pw_polyfill/standard_library/namespace.h" ]
117  visibility = [ ":*" ]
118}
119
120pw_test_group("tests") {
121  tests = [
122    ":default_cpp_test",
123    ":cpp14_test",
124  ]
125  group_deps = [ "$dir_pw_span:tests" ]
126}
127
128pw_test("default_cpp_test") {
129  deps = [ ":pw_polyfill" ]
130  sources = [ "test.cc" ]
131}
132
133pw_test("cpp14_test") {
134  remove_configs = [ "$dir_pw_build:cpp17" ]
135  configs = [ "$dir_pw_build:cpp14" ]
136  sources = [ "test.cc" ]
137  deps = [ ":pw_polyfill" ]
138}
139
140pw_doc_group("docs") {
141  sources = [ "docs.rst" ]
142}
143