blob: 1c0cd4bd89cc0f7bfe3defae3ab85c8181054302 [file] [log] [blame]
Wyatt Hepler7abd8cc2021-01-19 16:49:33 -08001# Copyright 2021 The Pigweed Authors
Wyatt Heplerc542a5d2020-01-15 15:43:10 -08002#
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
Armando Montanezfb3d3fb2020-06-09 18:12:12 -070015import("//build_overrides/pigweed.gni")
16
Alexei Frolovedd2f142020-06-09 19:11:27 -070017import("$dir_pw_build/target_types.gni")
Wyatt Heplerc542a5d2020-01-15 15:43:10 -080018import("$dir_pw_docgen/docs.gni")
19import("$dir_pw_unit_test/test.gni")
Wyatt Heplerd49f8fe2020-10-15 10:13:47 -070020
Ewout van Bekkuma0fc38c2022-01-14 09:15:53 -080021config("public_include_path") {
Wyatt Heplerc542a5d2020-01-15 15:43:10 -080022 include_dirs = [ "public" ]
Wyatt Hepler6c331ae2020-08-04 10:05:11 -070023 visibility = [ ":*" ]
Wyatt Heplerc542a5d2020-01-15 15:43:10 -080024}
25
Alexei Frolovedd2f142020-06-09 19:11:27 -070026pw_source_set("pw_polyfill") {
Ewout van Bekkuma0fc38c2022-01-14 09:15:53 -080027 public_configs = [ ":public_include_path" ]
Alexei Frolov844ff0f2020-05-06 12:15:29 -070028 remove_public_deps = [ "*" ]
Rob Mohra0ba54f2020-02-27 11:43:49 -080029 public_deps = [ ":standard_library" ]
Wyatt Heplerc542a5d2020-01-15 15:43:10 -080030 public = [
Wyatt Hepler6c331ae2020-08-04 10:05:11 -070031 "public/pw_polyfill/language_feature_macros.h",
Wyatt Heplerc542a5d2020-01-15 15:43:10 -080032 "public/pw_polyfill/standard.h",
33 ]
Wyatt Heplerc542a5d2020-01-15 15:43:10 -080034}
35
36config("overrides_config") {
37 include_dirs = [ "public_overrides" ]
Wyatt Hepler6c331ae2020-08-04 10:05:11 -070038 visibility = [ ":*" ]
Wyatt Heplerc542a5d2020-01-15 15:43:10 -080039}
40
Ewout van Bekkuma0fc38c2022-01-14 09:15:53 -080041# TODO(pwbug/602): Remove this overrides target by migrating all users to
42# explicitly depend on the polyfill(s) they require.
43group("overrides") {
Wyatt Hepler7abd8cc2021-01-19 16:49:33 -080044 public_deps = [
Ewout van Bekkuma0fc38c2022-01-14 09:15:53 -080045 ":bit",
46 ":cstddef",
47 ":iterator",
48 ":span",
49 ":type_traits",
Wyatt Heplerc542a5d2020-01-15 15:43:10 -080050 ]
51}
52
53config("standard_library_public") {
54 include_dirs = [ "standard_library_public" ]
55}
56
Ewout van Bekkuma0fc38c2022-01-14 09:15:53 -080057# 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
Alexei Frolovedd2f142020-06-09 19:11:27 -0700112pw_source_set("standard_library") {
Wyatt Heplerc542a5d2020-01-15 15:43:10 -0800113 public_configs = [ ":standard_library_public" ]
Alexei Frolov844ff0f2020-05-06 12:15:29 -0700114 remove_public_deps = [ "*" ]
Ewout van Bekkuma0fc38c2022-01-14 09:15:53 -0800115 public =
116 [ "standard_library_public/pw_polyfill/standard_library/namespace.h" ]
117 visibility = [ ":*" ]
Wyatt Heplerc542a5d2020-01-15 15:43:10 -0800118}
119
120pw_test_group("tests") {
Wyatt Hepler818e3312020-01-16 14:19:21 -0800121 tests = [
122 ":default_cpp_test",
Wyatt Hepler818e3312020-01-16 14:19:21 -0800123 ":cpp14_test",
124 ]
Wyatt Hepler7abd8cc2021-01-19 16:49:33 -0800125 group_deps = [ "$dir_pw_span:tests" ]
Wyatt Heplerc542a5d2020-01-15 15:43:10 -0800126}
127
128pw_test("default_cpp_test") {
Rob Mohra0ba54f2020-02-27 11:43:49 -0800129 deps = [ ":pw_polyfill" ]
130 sources = [ "test.cc" ]
Wyatt Heplerc542a5d2020-01-15 15:43:10 -0800131}
132
Wyatt Hepler818e3312020-01-16 14:19:21 -0800133pw_test("cpp14_test") {
Alexei Frolov844ff0f2020-05-06 12:15:29 -0700134 remove_configs = [ "$dir_pw_build:cpp17" ]
Wyatt Hepler818e3312020-01-16 14:19:21 -0800135 configs = [ "$dir_pw_build:cpp14" ]
Rob Mohra0ba54f2020-02-27 11:43:49 -0800136 sources = [ "test.cc" ]
137 deps = [ ":pw_polyfill" ]
Wyatt Hepler818e3312020-01-16 14:19:21 -0800138}
139
Wyatt Heplerc542a5d2020-01-15 15:43:10 -0800140pw_doc_group("docs") {
Rob Mohra0ba54f2020-02-27 11:43:49 -0800141 sources = [ "docs.rst" ]
Wyatt Heplerc542a5d2020-01-15 15:43:10 -0800142}