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") {
22  include_dirs = [ "public" ]
23  visibility = [ ":*" ]
24}
25
26pw_source_set("pw_polyfill") {
27  public_configs = [ ":public" ]
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  cflags_cc = [
39    # Use -include to include the language features header in dependent files,
40    # without requiring a #include. This allows the use of newer C++ language
41    # features in older C++ versions without an explicit include.
42    "-include",
43    rebase_path("language_features.h"),
44  ]
45  visibility = [ ":*" ]
46}
47
48pw_source_set("overrides") {
49  public_configs = [ ":overrides_config" ]
50  remove_public_deps = [ "*" ]
51  public_deps = [
52    ":standard_library",
53    "$dir_pw_span:polyfill",
54  ]
55  inputs = [
56    "public_overrides/array",
57    "public_overrides/assert.h",
58    "public_overrides/bit",
59    "public_overrides/cstddef",
60    "public_overrides/iterator",
61    "public_overrides/type_traits",
62    "public_overrides/utility",
63  ]
64  sources = [ "language_features.h" ]
65}
66
67config("standard_library_public") {
68  include_dirs = [ "standard_library_public" ]
69}
70
71pw_source_set("standard_library") {
72  public_configs = [ ":standard_library_public" ]
73  remove_public_deps = [ "*" ]
74  public = [
75    "standard_library_public/pw_polyfill/standard_library/array.h",
76    "standard_library_public/pw_polyfill/standard_library/assert.h",
77    "standard_library_public/pw_polyfill/standard_library/bit.h",
78    "standard_library_public/pw_polyfill/standard_library/cstddef.h",
79    "standard_library_public/pw_polyfill/standard_library/iterator.h",
80    "standard_library_public/pw_polyfill/standard_library/namespace.h",
81    "standard_library_public/pw_polyfill/standard_library/type_traits.h",
82    "standard_library_public/pw_polyfill/standard_library/utility.h",
83  ]
84  visibility = [
85    ":overrides",
86    ":pw_polyfill",
87  ]
88}
89
90pw_test_group("tests") {
91  tests = [
92    ":default_cpp_test",
93    ":cpp11_test",
94    ":cpp14_test",
95  ]
96  group_deps = [ "$dir_pw_span:tests" ]
97}
98
99pw_test("default_cpp_test") {
100  deps = [ ":pw_polyfill" ]
101  sources = [ "test.cc" ]
102}
103
104pw_test("cpp11_test") {
105  remove_configs = [ "$dir_pw_build:cpp17" ]
106  configs = [ "$dir_pw_build:cpp11" ]
107  sources = [ "test.cc" ]
108  deps = [ ":pw_polyfill" ]
109}
110
111pw_test("cpp14_test") {
112  remove_configs = [ "$dir_pw_build:cpp17" ]
113  configs = [ "$dir_pw_build:cpp14" ]
114  sources = [ "test.cc" ]
115  deps = [ ":pw_polyfill" ]
116}
117
118pw_doc_group("docs") {
119  sources = [ "docs.rst" ]
120}
121