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.
13
14import("//base/update/updater/updater_default_cfg.gni")
15import("//build/ohos.gni")
16
17updater_path = rebase_path("${updater_absolutely_path}", ".")
18
19config("libutils_exported_headers") {
20  visibility = [ ":*" ]
21  if (updater_sign_on_server) {
22    defines = [ "SIGN_ON_SERVER" ]
23  }
24  include_dirs = [
25    "${updater_path}/services/include",
26    "${updater_path}/utils/include",
27    "${updater_path}/utils/json",
28  ]
29}
30
31ohos_static_library("libutils") {
32  sources = [
33    "json/json_node.cpp",
34    "partition_utils.cpp",
35    "utils.cpp",
36    "utils_common.cpp",
37    "utils_fs.cpp",
38  ]
39
40  include_dirs = [
41    "include",
42    "${updater_path}/interfaces/kits/include/",
43    "${updater_path}/services/common/",
44    "${updater_path}/services/include/",
45  ]
46
47  public_configs = [ ":libutils_exported_headers" ]
48
49  deps = []
50  external_deps = [
51    "bounds_checking_function:libsec_static",
52    "cJSON:cjson_static",
53    "init:libbegetutil_static",
54    "init:libfsmanager_static_real",
55  ]
56
57  if (build_selinux) {
58    external_deps += [
59      "selinux:libselinux_static",
60      "selinux_adapter:librestorecon_static",
61    ]
62    cflags = [ "-DWITH_SELINUX" ]
63  }
64
65  subsystem_name = "updater"
66  part_name = "updater"
67}
68
69ohos_static_library("libutils_fs") {
70  sources = [ "utils_fs.cpp" ]
71
72  include_dirs = [
73    "include",
74    "${updater_path}/services/include/",
75  ]
76
77  public_configs = [ ":libutils_exported_headers" ]
78
79  subsystem_name = "updater"
80  part_name = "updater"
81}
82
83ohos_static_library("libutils_json") {
84  sources = [ "json/json_node.cpp" ]
85
86  include_dirs = [
87    "include",
88    "${updater_path}/services/include/",
89  ]
90
91  public_configs = [ ":libutils_exported_headers" ]
92
93  external_deps = [ "cJSON:cjson" ]
94
95  subsystem_name = "updater"
96  part_name = "updater"
97}
98
99ohos_static_library("libutils_common") {
100  sources = [ "utils_common.cpp" ]
101
102  include_dirs = [
103    "include",
104    "${updater_path}/services/include/",
105  ]
106
107  subsystem_name = "updater"
108  part_name = "updater"
109}
110
111ohos_executable("updater_reboot") {
112  sources = [ "updater_reboot.cpp" ]
113
114  include_dirs = [
115    "include",
116    "${updater_path}/interfaces/kits/include/",
117    "${updater_path}/services/include/",
118  ]
119
120  deps = [
121    "${updater_path}/interfaces/kits/misc_info:libmiscinfo",
122    "${updater_path}/services/fs_manager:libfsmanager",
123    "${updater_path}/utils:libutils",
124  ]
125  install_images = [ "updater" ]
126  install_enable = true
127  part_name = "updater"
128  subsystem_name = "updater"
129}
130
131ohos_executable("write_updater") {
132  sources = [ "write_updater.cpp" ]
133
134  include_dirs = [
135    "include",
136    "${updater_path}/interfaces/kits/include/",
137    "${updater_path}/services/include/",
138  ]
139
140  deps = [ "${updater_path}/interfaces/kits/misc_info:libmiscinfo" ]
141  external_deps = [
142    "bounds_checking_function:libsec_static",
143    "init:libbegetutil_static",
144  ]
145
146  install_enable = true
147  part_name = "updater"
148  subsystem_name = "updater"
149}
150