1# Copyright (c) 2021-2023 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}", ".")
18updater_common_include = [
19  "include",
20  "ui/view",
21  "${updater_path}/utils/include",
22  "${updater_path}/interfaces/kits/include/",
23  "${updater_path}/services/common",
24  "${updater_path}/services/include/package",
25  "${updater_path}/services/package/pkg_manager",
26  "${updater_path}/services/package/pkg_verify",
27  "${updater_path}/services/include/log",
28  "${updater_path}/utils/json",
29  ".",
30  "./ui/include",
31  "./ui",
32  "./ui/control",
33]
34
35updater_common_deps = [
36  "${updater_path}/interfaces/kits/packages:libpackageExt",
37  "${updater_path}/services/applypatch:libapplypatch",
38  "${updater_path}/services/diffpatch/patch:libpatch",
39  "${updater_path}/services/flashd:libflashd",
40  "${updater_path}/services/fs_manager:libfsmanager",
41  "${updater_path}/services/log:libupdaterlog",
42  "${updater_path}/services/package:libupdaterpackage",
43  "${updater_path}/services/write_state:libwritestate",
44]
45
46updater_gen("updater") {
47  deps = [ "${updater_path}/services:libupdater_static" ]
48  external_deps = [ "hilog:libhilog" ]
49
50  # force link flashd library
51  ldflags = [
52    "-Wl,--whole-archive",
53    rebase_path("${target_out_dir}/flashd/libflashd.a"),
54    "-Wl,--no-whole-archive",
55  ]
56
57  part_name = "updater"
58  subsystem_name = "updater"
59}
60
61ohos_static_library("libupdater_static") {
62  defines = [ "BUILD_OHOS" ]
63  sources = [
64    "factory_reset/factory_reset.cpp",
65    "hwfault_retry/hwfault_retry.cpp",
66    "main.cpp",
67    "updater.cpp",
68    "updater_main.cpp",
69    "updater_preprocess.cpp",
70    "updater_utils.cpp",
71  ]
72
73  if (updater_ui_support) {
74    sources += [ "updater_ui.cpp" ]
75  }
76
77  include_dirs = updater_common_include
78
79  deps = updater_common_deps
80  deps += [
81    "${updater_path}/interfaces/kits/misc_info:libmiscinfo",
82    "${updater_path}/services/sdcard_update:libsdupdate",
83  ]
84
85  if (defined(use_ptable)) {
86    include_dirs += [ "${updater_path}/services/ptable_parse" ]
87    deps += [ "${updater_path}/services/ptable_parse:libptableparse" ]
88    defines += [ "UPDATER_USE_PTABLE" ]
89  }
90
91  external_deps = [
92    "bounds_checking_function:libsec_shared",
93    "bounds_checking_function:libsec_static",
94    "bzip2:libbz2",
95    "cJSON:cjson",
96    "init:libbegetutil_static",
97    "libdrm:libdrm",
98    "openssl:libcrypto_shared",
99    "openssl:libssl_shared",
100    "zlib:libz",
101  ]
102  if (updater_ui_support) {
103    external_deps += [ "drivers_peripheral_input:hdi_input_udriver" ]
104  }
105
106  if (updater_ui_support) {
107    external_deps += [ "ui_lite:libupdater_layout" ]
108    deps += [ "${updater_path}/services/ui:libui" ]
109  }
110
111  if (build_selinux) {
112    external_deps += [
113      "selinux:libselinux_static",
114      "selinux_adapter:librestorecon_static",
115    ]
116    cflags = [ "-DWITH_SELINUX" ]
117  }
118
119  if (build_variant == "user") {
120    defines += [ "UPDATER_BUILD_VARIANT_USER" ]
121  }
122
123  part_name = "updater"
124  subsystem_name = "updater"
125}
126
127config("libupdater_exported_headers") {
128  visibility = [ ":*" ]
129  include_dirs = [
130    "${updater_path}/services/include",
131    "${updater_path}/interfaces/kits/include",
132    "${updater_path}/services",
133  ]
134}
135
136ohos_static_library("libupdater") {
137  defines = [ "BUILD_OHOS" ]
138  sources = [
139    "factory_reset/factory_reset.cpp",
140    "hwfault_retry/hwfault_retry.cpp",
141    "updater.cpp",
142    "updater_preprocess.cpp",
143    "updater_utils.cpp",
144  ]
145
146  include_dirs = updater_common_include
147
148  deps = updater_common_deps
149
150  public_configs = [ ":libupdater_exported_headers" ]
151
152  if (defined(use_ptable)) {
153    include_dirs += [ "${updater_path}/services/ptable_parse" ]
154    deps += [ "${updater_path}/services/ptable_parse:libptableparse" ]
155    defines += [ "UPDATER_USE_PTABLE" ]
156  }
157
158  ldflags = []
159
160  # force link invisible function
161  if (defined(updater_force_link_libs)) {
162    ldflags += [ "-Wl,--whole-archive" ]
163    foreach(lib, updater_force_link_libs) {
164      ldflags += [ "${lib}" ]
165    }
166    ldflags += [ "-Wl,--no-whole-archive" ]
167  }
168
169  external_deps = [
170    "bounds_checking_function:libsec_shared",
171    "bounds_checking_function:libsec_static",
172    "bzip2:libbz2",
173    "cJSON:cjson",
174    "init:libbegetutil_static",
175    "openssl:libcrypto_shared",
176    "openssl:libssl_shared",
177    "zlib:libz",
178  ]
179
180  # add updater custom library
181  if (defined(updater_custom_external_deps)) {
182    external_deps += updater_custom_external_deps
183  }
184
185  if (updater_ui_support) {
186    external_deps += [ "drivers_peripheral_input:hdi_input_udriver" ]
187  }
188
189  if (updater_ui_support) {
190    external_deps += [ "ui_lite:libupdater_layout" ]
191  }
192
193  if (build_selinux) {
194    external_deps += [
195      "selinux:libselinux_static",
196      "selinux_adapter:librestorecon_static",
197    ]
198    cflags = [ "-DWITH_SELINUX" ]
199  }
200
201  subsystem_name = "updater"
202  part_name = "updater"
203}
204