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