1# Copyright 2019 The Chromium Authors. All rights reserved.
2# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4
5import("//build_overrides/build.gni")
6
7declare_args() {
8  # Enables trace logging in build. This is true by default, unless
9  # we are built against Chrome--we have no way to link their platform
10  # implementation into our binaries so trace logging is not possible.
11  enable_trace_logging = !build_with_chromium
12}
13
14config("trace_logging_config") {
15  if (enable_trace_logging) {
16    defines = [ "ENABLE_TRACE_LOGGING" ]
17  }
18}
19
20source_set("util") {
21  sources = [
22    "alarm.cc",
23    "alarm.h",
24    "base64.cc",
25    "base64.h",
26    "big_endian.cc",
27    "big_endian.h",
28    "chrono_helpers.h",
29    "crypto/certificate_utils.cc",
30    "crypto/certificate_utils.h",
31    "crypto/digest_sign.cc",
32    "crypto/digest_sign.h",
33    "crypto/openssl_util.cc",
34    "crypto/openssl_util.h",
35    "crypto/pem_helpers.cc",
36    "crypto/pem_helpers.h",
37    "crypto/random_bytes.cc",
38    "crypto/random_bytes.h",
39    "crypto/rsa_private_key.cc",
40    "crypto/rsa_private_key.h",
41    "crypto/secure_hash.cc",
42    "crypto/secure_hash.h",
43    "crypto/sha2.cc",
44    "crypto/sha2.h",
45    "enum_name_table.h",
46    "flat_map.h",
47    "hashing.h",
48    "integer_division.h",
49    "json/json_helpers.h",
50    "json/json_serialization.cc",
51    "json/json_serialization.h",
52    "json/json_value.cc",
53    "json/json_value.h",
54    "osp_logging.h",
55    "saturate_cast.h",
56    "simple_fraction.cc",
57    "simple_fraction.h",
58    "std_util.cc",
59    "std_util.h",
60    "stringprintf.cc",
61    "stringprintf.h",
62    "trace_logging.h",
63    "trace_logging/macro_support.h",
64    "trace_logging/scoped_trace_operations.cc",
65    "trace_logging/scoped_trace_operations.h",
66    "url.cc",
67    "url.h",
68    "weak_ptr.h",
69    "yet_another_bit_vector.cc",
70    "yet_another_bit_vector.h",
71  ]
72
73  public_deps = [
74    "../platform:api",
75    "../platform:base",
76    "../third_party/abseil",
77    "../third_party/jsoncpp",
78  ]
79
80  deps = [
81    "../third_party/boringssl",
82    "../third_party/mozilla",
83
84    # We do a clone of Chrome's modp_b64 in order to share their BUILD.gn
85    # and license files, so this should always be an absolute reference.
86    "//third_party/modp_b64",
87  ]
88
89  public_configs = [
90    "../build:openscreen_include_dirs",
91    ":trace_logging_config",
92  ]
93}
94
95source_set("unittests") {
96  testonly = true
97
98  sources = [
99    "alarm_unittest.cc",
100    "base64_unittest.cc",
101    "big_endian_unittest.cc",
102    "crypto/certificate_utils_unittest.cc",
103    "crypto/random_bytes_unittest.cc",
104    "crypto/rsa_private_key_unittest.cc",
105    "crypto/secure_hash_unittest.cc",
106    "crypto/sha2_unittest.cc",
107    "enum_name_table_unittest.cc",
108    "flat_map_unittest.cc",
109    "integer_division_unittest.cc",
110    "json/json_helpers_unittest.cc",
111    "json/json_serialization_unittest.cc",
112    "json/json_value_unittest.cc",
113    "saturate_cast_unittest.cc",
114    "simple_fraction_unittest.cc",
115    "stringprintf_unittest.cc",
116    "trace_logging/scoped_trace_operations_unittest.cc",
117    "url_unittest.cc",
118    "weak_ptr_unittest.cc",
119    "yet_another_bit_vector_unittest.cc",
120  ]
121
122  # The trace logging unittests depend on macros only defined
123  # when trace logging is enabled.
124  if (enable_trace_logging) {
125    sources += [ "trace_logging_unittest.cc" ]
126  }
127
128  deps = [
129    ":util",
130    "../platform:test",
131    "../third_party/abseil",
132    "../third_party/boringssl",
133    "../third_party/googletest:gmock",
134    "../third_party/googletest:gtest",
135    "../third_party/jsoncpp",
136  ]
137}
138