• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (C) 2021 Huawei Device Co., Ltd.
2# Licensed under the Apache License, Version 2.0 (the "License");
3# you may not use this file except in compliance with the License.
4# You may obtain a copy of the License at
5#
6#     http://www.apache.org/licenses/LICENSE-2.0
7#
8# Unless required by applicable law or agreed to in writing, software
9# distributed under the License is distributed on an "AS IS" BASIS,
10# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11# See the License for the specific language governing permissions and
12# limitations under the License.
13import("//build/test.gni")
14import("//developtools/hdc/hdc.gni")
15hdc_path = "//developtools/hdc/"
16module_output_path = "developtools/hdc/"
17declare_args() {
18  hdc_unit_test = true
19}
20
21hdc_common_sources = [
22  "${hdc_path}/src/common/async_cmd.cpp",
23  "${hdc_path}/src/common/auth.cpp",
24  "${hdc_path}/src/common/base.cpp",
25  "${hdc_path}/src/common/channel.cpp",
26  "${hdc_path}/src/common/debug.cpp",
27  "${hdc_path}/src/common/file.cpp",
28  "${hdc_path}/src/common/file_descriptor.cpp",
29  "${hdc_path}/src/common/forward.cpp",
30  "${hdc_path}/src/common/session.cpp",
31  "${hdc_path}/src/common/task.cpp",
32  "${hdc_path}/src/common/tcp.cpp",
33  "${hdc_path}/src/common/transfer.cpp",
34  "${hdc_path}/src/common/usb.cpp",
35]
36
37hdc_daemon_sources = [
38  "${hdc_path}/src/daemon/daemon.cpp",
39  "${hdc_path}/src/daemon/daemon_app.cpp",
40  "${hdc_path}/src/daemon/daemon_forward.cpp",
41  "${hdc_path}/src/daemon/daemon_tcp.cpp",
42  "${hdc_path}/src/daemon/daemon_unity.cpp",
43  "${hdc_path}/src/daemon/daemon_usb.cpp",
44  "${hdc_path}/src/daemon/jdwp.cpp",
45  "${hdc_path}/src/daemon/shell.cpp",
46  "${hdc_path}/src/daemon/system_depend.cpp",
47]
48
49hdc_host_sources = [
50  "${hdc_path}/src/host/client.cpp",
51  "${hdc_path}/src/host/host_app.cpp",
52  "${hdc_path}/src/host/host_forward.cpp",
53  "${hdc_path}/src/host/host_tcp.cpp",
54  "${hdc_path}/src/host/host_unity.cpp",
55  "${hdc_path}/src/host/host_usb.cpp",
56  "${hdc_path}/src/host/server.cpp",
57  "${hdc_path}/src/host/server_for_client.cpp",
58  "${hdc_path}/src/host/translate.cpp",
59]
60
61common_deps = [
62  "//third_party/bounds_checking_function:libsec_static",
63  "//third_party/libusb:libusb",
64  "//third_party/libuv:uv",
65  "//third_party/lz4:liblz4_static",
66  "//third_party/openssl:libcrypto_static",
67]
68
69config("hdc_ut_code_flag") {
70  cflags = code_check_flag
71}
72
73config("hdc_ut_config") {
74  defines = []
75  include_dirs = [ "${hdc_path}/src/common" ]
76
77  cflags = [
78    "-std=c++17",
79    "-fno-access-control",
80    "-g",
81  ]
82  ldflags = []
83
84  if (hdc_test_coverage && is_ohos) {
85    cflags += [
86      "-fprofile-arcs",
87      "-ftest-coverage",
88    ]
89    ldflags += [ "--coverage" ]
90  }
91}
92
93config("hdc_common_config") {
94  defines = []
95  include_dirs = [
96    "${hdc_path}/src/common",
97    "${hdc_path}/src/daemon",
98    "${hdc_path}/src/host",
99    "${hdc_path}/test/unittest/common/include",
100    "//third_party/libuv",  # used in common.h
101    "//third_party/lz4/lib",  # used in transfer.cpp
102    "//base/startup/init/interfaces/innerkits/include",  #daemon_unity.cpp
103  ]
104
105  if (hdc_support_uart) {
106    defines += [ "HDC_SUPPORT_UART" ]
107  }
108
109  defines += [ "HDC_UT" ]
110}
111
112config("hdc_host_common_config") {
113  defines = [ "HDC_HOST" ]
114
115  # both linux and ohos is same linux syscall
116  defines += [ "HOST_LINUX" ]
117  defines += [ "HARMONY_PROJECT" ]
118}
119
120ohos_source_set("hdc_common") {
121  use_exceptions = true
122  sources = hdc_common_sources
123  if (hdc_support_uart) {
124    sources += [ "${hdc_path}/src/common/uart.cpp" ]
125  }
126  public_deps = common_deps
127  public_configs = [
128    ":hdc_common_config",
129    ":hdc_ut_config",
130  ]
131}
132
133ohos_source_set("hdc_daemon") {
134  use_exceptions = true
135  sources = hdc_common_sources
136  sources += hdc_daemon_sources
137  if (hdc_support_uart) {
138    include_dirs = [ "//commonlibrary/c_utils/base/include" ]
139    sources += [ "${hdc_path}/src/common/uart.cpp" ]
140    sources += [ "${hdc_path}/src/daemon/daemon_uart.cpp" ]
141  }
142  public_deps = common_deps
143  public_configs = [
144    ":hdc_common_config",
145    ":hdc_ut_config",
146  ]
147}
148
149ohos_source_set("hdc_host") {
150  use_exceptions = true
151  sources = hdc_common_sources
152  sources += hdc_host_sources
153  if (hdc_support_uart) {
154    sources += [ "${hdc_path}/src/common/uart.cpp" ]
155    sources += [ "${hdc_path}/src/host/host_uart.cpp" ]
156  }
157  public_deps = common_deps
158  public_configs = [
159    ":hdc_common_config",
160    ":hdc_host_common_config",
161    ":hdc_ut_config",
162  ]
163}
164
165ohos_source_set("hdc_daemon_platform") {
166  public_configs = [ ":hdc_ut_config" ]
167  public_configs += [ "//third_party/googletest:gtest_config" ]
168
169  #defines = [ "HARMONY_PROJECT" ]
170  defines = []
171  if (hdc_test_coverage && is_ohos) {
172    defines += [ "TEST_COVERAGE" ]
173  }
174
175  if (hdc_unit_test) {
176    defines += [ "HDC_UNIT_TEST" ]
177  }
178  if (js_jdwp_connect) {
179    defines += [ "JS_JDWP_CONNECT" ]
180  }
181
182  sources = [
183    "${hdc_path}/src/daemon/daemon_unity.cpp",
184    "${hdc_path}/src/daemon/jdwp.cpp",
185  ]
186
187  public_deps = [
188    "//third_party/bounds_checking_function:libsec_static",
189    "//third_party/libuv:uv",
190    "//third_party/openssl:libcrypto_static",
191  ]
192
193  external_deps = [ "init:libbegetutil" ]
194
195  include_dirs = [
196    "${hdc_path}/daemon",
197    "//third_party/bounds_checking_function/include",
198    "//third_party/openssl/include",
199    "//third_party/libuv",
200  ]
201}
202
203ohos_unittest("hdc_jdwp_unittest") {
204  module_out_path = module_output_path
205  public_configs = [ ":hdc_ut_config" ]
206  defines = [ "HARMONY_PROJECT" ]
207  if (hdc_test_coverage && is_ohos) {
208    defines += [ "TEST_COVERAGE" ]
209  }
210  if (hdc_unit_test) {
211    defines += [ "HDC_UNIT_TEST" ]
212  }
213  if (js_jdwp_connect) {
214    defines += [ "JS_JDWP_CONNECT" ]
215  }
216  public_deps = [ ":hdc_daemon_platform" ]
217
218  deps = [
219    "//third_party/googletest:gmock_main",
220    "//third_party/googletest:gtest_main",
221  ]
222
223  sources = [ "unittest/common/HdcJdwpTest.cpp" ]
224  deps += [ ":hdc_common" ]
225
226  include_dirs = [
227    "${hdc_path}/test/unittest/common/include",
228    "${hdc_path}/src/daemon",
229    "${hdc_path}/src/common",
230    "//third_party/bounds_checking_function/include",
231    "//third_party/libuv",
232  ]
233
234  if (is_linux) {
235    static_link = false
236  }
237  subsystem_name = "developtools"
238}
239
240ohos_unittest("hdc_uart_unittest") {
241  use_exceptions = true
242  module_out_path = module_output_path
243  resource_config_file = "unittest/resource/ohos_test.xml"
244  sources = [
245    "unittest/common/daemon_uart_test.cpp",
246    "unittest/common/uart_test.cpp",
247  ]
248
249  configs = [ ":hdc_common_config" ]
250  configs += [ ":hdc_ut_code_flag" ]
251  deps = [ ":hdc_daemon" ]
252
253  deps += [
254    "//third_party/googletest:gmock_main",
255    "//third_party/googletest:gtest_main",
256  ]
257}
258
259ohos_unittest("hdc_host_uart_unittest") {
260  use_exceptions = true
261  module_out_path = module_output_path
262  resource_config_file = "unittest/resource/ohos_test.xml"
263  sources = [
264    "unittest/common/host_uart_test.cpp",
265    "unittest/common/uart_test.cpp",
266  ]
267
268  configs = [
269    ":hdc_common_config",
270    ":hdc_host_common_config",
271    ":hdc_ut_code_flag",
272  ]
273
274  deps = [ ":hdc_host" ]
275
276  deps += [
277    "//third_party/googletest:gmock_main",
278    "//third_party/googletest:gtest_main",
279  ]
280}
281
282group("HdcJdwpTest") {
283  testonly = true
284  deps = [ ":hdc_jdwp_unittest" ]
285}
286
287group("hdc_unittest") {
288  testonly = true
289  deps = [
290    ":hdc_host_uart_unittest",
291    ":hdc_host_uart_unittest(${host_toolchain})",
292    ":hdc_jdwp_unittest",
293    ":hdc_uart_unittest",
294    ":hdc_uart_unittest(${host_toolchain})",
295  ]
296}
297