• 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")
16import("$dir_pw_build/facade.gni")
17import("$dir_pw_build/target_types.gni")
18import("$dir_pw_docgen/docs.gni")
19import("$dir_pw_third_party/boringssl/boringssl.gni")
20import("$dir_pw_tls_client/configs.gni")
21import("$dir_pw_unit_test/test.gni")
22
23config("public_includes") {
24  include_dirs = [ "public" ]
25}
26
27pw_facade("pw_tls_client") {
28  backend = pw_tls_client_BACKEND
29  public_configs = [ ":public_includes" ]
30  public = [
31    "public/pw_tls_client/options.h",
32    "public/pw_tls_client/session.h",
33    "public/pw_tls_client/status.h",
34  ]
35  public_deps = [
36    "$dir_pw_assert",
37    "$dir_pw_bytes",
38    "$dir_pw_result",
39    "$dir_pw_status",
40    "$dir_pw_stream",
41    "$dir_pw_string",
42  ]
43}
44
45pw_facade("tls_entropy") {
46  backend = pw_tls_client_ENTROPY_BACKEND
47  public_configs = [ ":public_includes" ]
48  public = [ "public/pw_tls_client/entropy.h" ]
49  public_deps = [
50    "$dir_pw_bytes",
51    "$dir_pw_status",
52  ]
53}
54
55# A fake entropy source that does nothing. It should only be used for
56# demo and test purpose only. Production code shall not use it.
57pw_source_set("fake_entropy") {
58  public_deps = [ ":tls_entropy.facade" ]
59  sources = [ "fake_entropy.cc" ]
60  deps = [ "$dir_pw_log" ]
61}
62
63# The ":time" target wraps the time() and gettimeofday(), which are
64# commonly used by TLS libraries for expiration check.
65config("time_wrap") {
66  # Link options that wrap C time calls.
67  ldflags = [
68    "-Wl,--wrap=time",
69    "-Wl,--wrap=gettimeofday",
70  ]
71}
72
73pw_facade("time") {
74  backend = pw_tls_client_TIME_BACKEND
75  public_configs = [ ":time_wrap" ]
76  public = []
77
78  # The target should only be used by TLS libraries to obtain date time
79  visibility = [
80    ":*",
81    "$dir_pw_third_party/boringssl",
82    "$dir_pw_third_party/mbedtls",
83  ]
84}
85
86# The build time is obtained with a python script and put in a generated header
87# file. The header file is included in build_time.cc
88pw_python_action("generate_build_time_header") {
89  header_output = "$target_gen_dir/$target_name/build_time.h"
90  script = "generate_build_time_header.py"
91  outputs = [ header_output ]
92  args = [ rebase_path(header_output) ]
93}
94
95# The target provides a backend to :time that returns build time.
96pw_source_set("build_time") {
97  time_injection_outputs = get_target_outputs(":generate_build_time_header")
98  include_dirs = [ get_path_info(time_injection_outputs[0], "dir") ]
99  sources = [ "build_time.cc" ]
100  deps = [
101    ":generate_build_time_header",
102    ":time.facade",
103  ]
104}
105
106# TODO(b/235290724): Add a python target to generate source file from the
107# specified CRLSet file in `pw_tls_client_CRLSET_FILE`
108
109pw_source_set("crlset") {
110  public_configs = [ ":public_includes" ]
111  public = [ "public/pw_tls_client/crlset.h" ]
112  public_deps = [ dir_pw_bytes ]
113
114  # TODO(b/235290724): Add sources generated from a CRLSet file to build.
115}
116
117pw_source_set("test_server") {
118  sources = [ "test_server.cc" ]
119  public_configs = [ ":public_includes" ]
120  public = [ "public/pw_tls_client/test/test_server.h" ]
121  public_deps = [
122    "$dir_pw_bytes",
123    "$dir_pw_log",
124    "$dir_pw_stream",
125    "$dir_pw_third_party/boringssl",
126  ]
127}
128
129pw_test("test_server_test") {
130  enable_if = dir_pw_third_party_boringssl != ""
131  public_deps = [
132    ":test_data",
133    ":test_server",
134  ]
135  sources = [ "test_server_test.cc" ]
136}
137
138pw_python_action("generate_test_data") {
139  header_output = "$target_gen_dir/$target_name/test_certs_and_keys.h"
140  script = "py/pw_tls_client/generate_test_data.py"
141  python_deps = [ "py" ]
142  outputs = [ header_output ]
143  args = [ rebase_path(header_output) ]
144}
145
146config("test_data_includes") {
147  test_header_out = get_target_outputs(":generate_test_data")
148  include_dirs = [ get_path_info(test_header_out[0], "dir") ]
149}
150
151group("test_data") {
152  public_deps = [ ":generate_test_data" ]
153  public_configs = [ ":test_data_includes" ]
154}
155
156pw_test_group("tests") {
157  tests = [ ":test_server_test" ]
158}
159
160pw_doc_group("docs") {
161  sources = [ "docs.rst" ]
162}
163