blob: 0f47537877ac30e2506ee80ff442f8db021b4068 [file] [log] [blame]
Jason Jeremy Imanadffbcb2020-08-31 13:21:36 +09001# Copyright 2020 The Chromium OS 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("//common-mk/pkg_config.gni")
6import("//common-mk/proto_library.gni")
7
8group("all") {
9 deps = [ ":libpatchpanel-client" ]
10 if (use.fuzzer) {
11 deps += [ ":patchpanel_client_fuzzer" ]
12 }
13 if (use.test) {
14 deps += [ ":patchpanel-client_testrunner" ]
15 }
16}
17
18pkg_config("target_defaults") {
19 pkg_deps = [
20 "libbrillo",
Qijiang Fanb733c282020-10-23 00:19:47 +090021 "libchrome",
Jason Jeremy Imanadffbcb2020-08-31 13:21:36 +090022 "system_api",
23 ]
24 if (use.fuzzer) {
25 pkg_deps += [ "protobuf" ]
26 } else {
27 pkg_deps += [ "protobuf-lite" ]
28 }
29 defines = [ "USE_ARCVM=${use.arcvm}" ]
30}
31
32proto_library("protos") {
Jason Jeremy Imanadffbcb2020-08-31 13:21:36 +090033 proto_in_dir = ".."
34 proto_out_dir = "include/patchpanel"
35 sources = [ "${proto_in_dir}/ipc.proto" ]
Tatsuhisa Yamaguchief033192021-02-05 16:03:23 +000036 configs = [ ":target_defaults" ]
Jason Jeremy Imanadffbcb2020-08-31 13:21:36 +090037}
38
39libpatchpanel_client_sources = [
40 "../net_util.cc",
41 "client.cc",
Jie Jiang81c84db2020-09-29 17:40:16 +090042 "fake_client.cc",
Jason Jeremy Imanadffbcb2020-08-31 13:21:36 +090043]
44
45static_library("libpatchpanel-client_test") {
Tatsuhisa Yamaguchief033192021-02-05 16:03:23 +000046 sources = libpatchpanel_client_sources
Jason Jeremy Imanadffbcb2020-08-31 13:21:36 +090047 configs += [ ":target_defaults" ]
48 all_dependent_pkg_deps = [
49 "protobuf",
50 "system_api",
51 ]
Jason Jeremy Imanadffbcb2020-08-31 13:21:36 +090052 deps = [ ":protos" ]
53}
54
55shared_library("libpatchpanel-client") {
Tatsuhisa Yamaguchief033192021-02-05 16:03:23 +000056 sources = libpatchpanel_client_sources
Jason Jeremy Imanadffbcb2020-08-31 13:21:36 +090057 configs += [ ":target_defaults" ]
Yi Chou9e956f72020-11-20 21:15:23 +080058 all_dependent_pkg_deps = [ "protobuf" ]
59 libs = [ "system_api" ]
Jason Jeremy Imanadffbcb2020-08-31 13:21:36 +090060}
61
62if (use.fuzzer) {
63 pkg_config("fuzzing_config") {
Qijiang Fanb733c282020-10-23 00:19:47 +090064 pkg_deps = [ "libchrome-test" ]
Jason Jeremy Imanadffbcb2020-08-31 13:21:36 +090065 }
66
67 executable("patchpanel_client_fuzzer") {
Tatsuhisa Yamaguchief033192021-02-05 16:03:23 +000068 sources = [ "client_fuzzer.cc" ]
Jason Jeremy Imanadffbcb2020-08-31 13:21:36 +090069 configs += [
70 "//common-mk/common_fuzzer",
71 ":target_defaults",
72 ":fuzzing_config",
73 ]
Jason Jeremy Imanadffbcb2020-08-31 13:21:36 +090074 deps = [ ":libpatchpanel-client" ]
75 }
76}
77
78if (use.test) {
79 pkg_config("test_config") {
Qijiang Fanb733c282020-10-23 00:19:47 +090080 pkg_deps = [ "libchrome-test" ]
Jason Jeremy Imanadffbcb2020-08-31 13:21:36 +090081 }
82
83 executable("patchpanel-client_testrunner") {
84 sources = [ "client_test.cc" ]
85 configs += [
86 "//common-mk:test",
87 ":target_defaults",
88 ":test_config",
89 ]
90 defines = [ "UNIT_TEST" ]
91 deps = [
92 ":libpatchpanel-client_test",
93 "//common-mk/testrunner",
94 ]
95 }
96}