blob: 6292b2d09bface373b8ec0b4aaf67ef4e770d38c [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
Wyatt Heplerc542a5d2020-01-15 15:43:10 -080021config("public") {
22 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") {
Wyatt Heplerc542a5d2020-01-15 15:43:10 -080027 public_configs = [ ":public" ]
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 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",
Michael Spangc8b93902021-05-30 15:53:56 -040043 rebase_path("language_features.h", root_build_dir),
Wyatt Hepler6c331ae2020-08-04 10:05:11 -070044 ]
45 visibility = [ ":*" ]
Wyatt Heplerc542a5d2020-01-15 15:43:10 -080046}
47
Alexei Frolovedd2f142020-06-09 19:11:27 -070048pw_source_set("overrides") {
Wyatt Heplerc542a5d2020-01-15 15:43:10 -080049 public_configs = [ ":overrides_config" ]
Alexei Frolov844ff0f2020-05-06 12:15:29 -070050 remove_public_deps = [ "*" ]
Wyatt Hepler7abd8cc2021-01-19 16:49:33 -080051 public_deps = [
52 ":standard_library",
Wyatt Hepler97a068c2021-01-19 16:50:04 -080053 "$dir_pw_span:polyfill",
Wyatt Hepler7abd8cc2021-01-19 16:49:33 -080054 ]
Wyatt Heplerc542a5d2020-01-15 15:43:10 -080055 inputs = [
Wyatt Hepler8e59f4d2020-08-27 10:34:21 -070056 "public_overrides/array",
Wyatt Heplerac6cdf22020-01-24 13:35:09 -080057 "public_overrides/assert.h",
Wyatt Heplerecf19232020-09-02 14:35:09 -070058 "public_overrides/bit",
Wyatt Heplerc542a5d2020-01-15 15:43:10 -080059 "public_overrides/cstddef",
60 "public_overrides/iterator",
61 "public_overrides/type_traits",
Wyatt Hepler8e59f4d2020-08-27 10:34:21 -070062 "public_overrides/utility",
Wyatt Heplerc542a5d2020-01-15 15:43:10 -080063 ]
Wyatt Hepler6c331ae2020-08-04 10:05:11 -070064 sources = [ "language_features.h" ]
Wyatt Heplerc542a5d2020-01-15 15:43:10 -080065}
66
67config("standard_library_public") {
68 include_dirs = [ "standard_library_public" ]
69}
70
Alexei Frolovedd2f142020-06-09 19:11:27 -070071pw_source_set("standard_library") {
Wyatt Heplerc542a5d2020-01-15 15:43:10 -080072 public_configs = [ ":standard_library_public" ]
Alexei Frolov844ff0f2020-05-06 12:15:29 -070073 remove_public_deps = [ "*" ]
Wyatt Heplerc542a5d2020-01-15 15:43:10 -080074 public = [
Wyatt Hepler8e59f4d2020-08-27 10:34:21 -070075 "standard_library_public/pw_polyfill/standard_library/array.h",
Wyatt Heplerac6cdf22020-01-24 13:35:09 -080076 "standard_library_public/pw_polyfill/standard_library/assert.h",
Wyatt Heplerecf19232020-09-02 14:35:09 -070077 "standard_library_public/pw_polyfill/standard_library/bit.h",
Wyatt Heplerc542a5d2020-01-15 15:43:10 -080078 "standard_library_public/pw_polyfill/standard_library/cstddef.h",
79 "standard_library_public/pw_polyfill/standard_library/iterator.h",
Wyatt Hepler023f35b2020-07-01 09:40:50 -070080 "standard_library_public/pw_polyfill/standard_library/namespace.h",
Wyatt Heplerc542a5d2020-01-15 15:43:10 -080081 "standard_library_public/pw_polyfill/standard_library/type_traits.h",
Wyatt Hepler8e59f4d2020-08-27 10:34:21 -070082 "standard_library_public/pw_polyfill/standard_library/utility.h",
Wyatt Heplerc542a5d2020-01-15 15:43:10 -080083 ]
Wyatt Heplerc542a5d2020-01-15 15:43:10 -080084 visibility = [
85 ":overrides",
86 ":pw_polyfill",
87 ]
88}
89
90pw_test_group("tests") {
Wyatt Hepler818e3312020-01-16 14:19:21 -080091 tests = [
92 ":default_cpp_test",
93 ":cpp11_test",
94 ":cpp14_test",
95 ]
Wyatt Hepler7abd8cc2021-01-19 16:49:33 -080096 group_deps = [ "$dir_pw_span:tests" ]
Wyatt Heplerc542a5d2020-01-15 15:43:10 -080097}
98
99pw_test("default_cpp_test") {
Rob Mohra0ba54f2020-02-27 11:43:49 -0800100 deps = [ ":pw_polyfill" ]
101 sources = [ "test.cc" ]
Wyatt Heplerc542a5d2020-01-15 15:43:10 -0800102}
103
Wyatt Hepler818e3312020-01-16 14:19:21 -0800104pw_test("cpp11_test") {
Alexei Frolov844ff0f2020-05-06 12:15:29 -0700105 remove_configs = [ "$dir_pw_build:cpp17" ]
Wyatt Hepler818e3312020-01-16 14:19:21 -0800106 configs = [ "$dir_pw_build:cpp11" ]
Rob Mohra0ba54f2020-02-27 11:43:49 -0800107 sources = [ "test.cc" ]
108 deps = [ ":pw_polyfill" ]
Wyatt Hepler818e3312020-01-16 14:19:21 -0800109}
110
111pw_test("cpp14_test") {
Alexei Frolov844ff0f2020-05-06 12:15:29 -0700112 remove_configs = [ "$dir_pw_build:cpp17" ]
Wyatt Hepler818e3312020-01-16 14:19:21 -0800113 configs = [ "$dir_pw_build:cpp14" ]
Rob Mohra0ba54f2020-02-27 11:43:49 -0800114 sources = [ "test.cc" ]
115 deps = [ ":pw_polyfill" ]
Wyatt Hepler818e3312020-01-16 14:19:21 -0800116}
117
Wyatt Heplerc542a5d2020-01-15 15:43:10 -0800118pw_doc_group("docs") {
Rob Mohra0ba54f2020-02-27 11:43:49 -0800119 sources = [ "docs.rst" ]
Wyatt Heplerc542a5d2020-01-15 15:43:10 -0800120}