• 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.
13
14import("//base/update/updater/updater_default_cfg.gni")
15import("//build/ohos.gni")
16
17HDC_PATH = "//developtools/hdc/src"
18updater_path = rebase_path("${updater_absolutely_path}", ".")
19
20hash_sources = [
21  "${hdc_base}/scripts/hdc_hash_gen.py",
22  "${hdc_base}/src/common/base.cpp",
23  "${hdc_base}/src/common/channel.h",
24  "${hdc_base}/src/common/session.h",
25  "${hdc_base}/src/common/transfer.h",
26]
27
28py_out_dir = "$root_build_dir/gen/" + rebase_path(".", "//")
29
30config("hdc_config") {
31  include_dirs = [
32    "${hdc_base}/src/common",
33    "${py_out_dir}",
34  ]
35  cflags_cc = [ "-std=c++17" ]
36  if (is_mingw) {
37    cflags_cc += [ "-Wno-inconsistent-dllimport" ]  # in mingw some sec api will
38                                                    # overwrite by utilsecurec
39  }
40}
41
42action("hdc_hash_gen") {
43  script = "${hdc_base}/scripts/hdc_hash_gen.py"
44  sources = hash_sources
45  outputs = [ "$py_out_dir" ]
46  args = [
47    "-f",
48    "hdc_hash_gen.h",
49    "-i",
50    rebase_path("${hdc_base}", root_build_dir),
51    "-o",
52    rebase_path("$py_out_dir" + "/", root_build_dir),
53  ]
54  public_configs = [ ":hdc_config" ]
55}
56
57common_sources = [
58  "${HDC_PATH}/common/async_cmd.cpp",
59  "${HDC_PATH}/common/auth.cpp",
60  "${HDC_PATH}/common/base.cpp",
61  "${HDC_PATH}/common/channel.cpp",
62  "${HDC_PATH}/common/circle_buffer.cpp",
63  "${HDC_PATH}/common/debug.cpp",
64  "${HDC_PATH}/common/file.cpp",
65  "${HDC_PATH}/common/file_descriptor.cpp",
66  "${HDC_PATH}/common/forward.cpp",
67  "${HDC_PATH}/common/session.cpp",
68  "${HDC_PATH}/common/task.cpp",
69  "${HDC_PATH}/common/tcp.cpp",
70  "${HDC_PATH}/common/transfer.cpp",
71  "${HDC_PATH}/common/usb.cpp",
72]
73
74config("flashd_hdc_config") {
75  include_dirs = [ "./common" ]
76  cflags_cc = [ "-std=c++17" ]
77}
78
79ohos_source_set("flashd_deamon") {
80  sources = [
81    "${HDC_PATH}/daemon/daemon_app.cpp",
82    "${HDC_PATH}/daemon/daemon_forward.cpp",
83    "${HDC_PATH}/daemon/daemon_tcp.cpp",
84    "${HDC_PATH}/daemon/daemon_unity.cpp",
85    "${HDC_PATH}/daemon/daemon_usb.cpp",
86    "${HDC_PATH}/daemon/jdwp.cpp",
87    "${HDC_PATH}/daemon/shell.cpp",
88    "daemon/daemon.cpp",
89    "daemon/system_depend.cpp",
90  ]
91
92  sources += common_sources
93
94  defines = [
95    "HARMONY_PROJECT",
96    "OPENSSL_SUPPRESS_DEPRECATED",
97  ]
98
99  configs = [ ":flashd_hdc_config" ]
100
101  external_deps = [ "c_utils:utils" ]
102  deps = [
103    "//third_party/libuv:uv",
104    "//third_party/lz4:liblz4_static",
105    "//third_party/openssl:libcrypto_shared",
106  ]
107
108  deps += [ "${updater_path}/services/flashd:hdc_hash_gen" ]
109
110  if (use_musl) {
111    external_deps += [ "init:libbegetutil" ]
112  }
113
114  include_dirs = [
115    "${HDC_PATH}/daemon",
116    "${HDC_PATH}/common",
117    "${updater_path}/services/common",
118    "${updater_path}/services/flashd",
119    "${updater_path}/services/flashd/daemon",
120    "${updater_path}/services/flashd/common",
121    "${updater_path}/services/flashd/host",
122    "${updater_path}/services/include",
123    "${updater_path}/services/include/fs_manager",
124    "${updater_path}/services/include/package",
125    "${updater_path}/services/include/applypatch",
126    "${updater_path}/services/include/script",
127    "${updater_path}/services/include/log",
128    "${updater_path}/interfaces/kits/include",
129    "${updater_path}/utils/include",
130    "//base/startup/init/services/include/param",
131    "//third_party/bounds_checking_function/include",
132    "//third_party/lz4/lib",
133    "//third_party/libuv",
134  ]
135
136  if (build_selinux) {
137    deps += [ "//third_party/selinux:libselinux" ]
138    include_dirs += [ "//third_party/selinux/libselinux/include" ]
139    defines += [
140      "SURPPORT_SELINUX",
141      "UPDATER_MODE",
142    ]
143  }
144
145  subsystem_name = "updater"
146  part_name = "updater"
147}
148
149ohos_static_library("libflashd") {
150  sources = [
151    "${updater_path}/services/flashd/daemon/commander.cpp",
152    "${updater_path}/services/flashd/daemon/commander_factory.cpp",
153    "${updater_path}/services/flashd/daemon/daemon_updater.cpp",
154    "${updater_path}/services/flashd/daemon/erase_commander.cpp",
155    "${updater_path}/services/flashd/daemon/flash_commander.cpp",
156    "${updater_path}/services/flashd/daemon/flashd_main.cpp",
157    "${updater_path}/services/flashd/daemon/flashd_utils.cpp",
158    "${updater_path}/services/flashd/daemon/format_commander.cpp",
159    "${updater_path}/services/flashd/daemon/update_commander.cpp",
160    "${updater_path}/services/flashd/image_writer/image_writer.cpp",
161    "${updater_path}/services/flashd/partition.cpp",
162    "${updater_path}/services/hdi/client/update_hdi_client.cpp",
163    "${updater_path}/services/updater_binary/update_image_block.cpp",
164    "${updater_path}/services/updater_binary/update_image_patch.cpp",
165    "${updater_path}/services/updater_binary/update_partitions.cpp",
166    "${updater_path}/services/updater_binary/update_processor.cpp",
167  ]
168
169  defines = [
170    "HARMONY_PROJECT",
171    "OPENSSL_SUPPRESS_DEPRECATED",
172  ]
173
174  deps = [
175    ":flashd_deamon",
176    "${updater_path}/interfaces/kits/misc_info:libmiscinfo",
177    "${updater_path}/interfaces/kits/slot_info:libslotinfo",
178    "${updater_path}/interfaces/kits/updaterkits:libupdaterkits",
179    "${updater_path}/services/applypatch:libapplypatch",
180    "${updater_path}/services/common/ring_buffer:libringbuffer",
181    "${updater_path}/services/diffpatch/patch:libpatch",
182    "${updater_path}/services/flashd:hdc_hash_gen",
183    "${updater_path}/services/flow_update/update_bin:libBinFlowUpdate",
184    "${updater_path}/services/fs_manager:libfsmanager",
185    "${updater_path}/services/hdi/server:libupdate_hdi_impl",
186    "${updater_path}/services/log:libupdaterlog",
187    "${updater_path}/services/package:libupdaterpackage",
188    "${updater_path}/services/script:libupdaterscript",
189    "${updater_path}/utils:libutils",
190    "//third_party/bzip2:libbz2",
191    "//third_party/cJSON:cjson",
192    "//third_party/libuv:uv",
193    "//third_party/lz4:liblz4_static",
194    "//third_party/openssl:libcrypto_shared",
195    "//third_party/zlib:libz",
196  ]
197
198  if (defined(binary_custom_lib)) {
199    deps += binary_custom_lib
200  }
201
202  include_dirs = [
203    "${HDC_PATH}/daemon",
204    "${HDC_PATH}/common",
205    "${updater_path}/services",
206    "${updater_path}/services/common",
207    "${updater_path}/services/flashd",
208    "${updater_path}/services/flashd/daemon",
209    "${updater_path}/services/flashd/common",
210    "${updater_path}/services/flow_update",
211    "${updater_path}/interfaces/kits/include",
212    "${updater_path}/services/include/package",
213    "${updater_path}/services/include/ptable_parse",
214    "${updater_path}/services/include/script",
215    "${updater_path}/services/include/log",
216    "${updater_path}/services/include",
217    "${updater_path}/services/ptable_parse",
218    "${updater_path}/utils/include",
219    "${updater_path}/utils/json",
220    "//base/startup/init/services/include/param",
221    "//drivers/peripheral/partitionslot/hal/include",
222    "//third_party/bounds_checking_function/include",
223    "//third_party/cJSON",
224    "//third_party/lz4/lib",
225    "//third_party/libuv",
226  ]
227
228  if (build_selinux) {
229    deps += [ "//third_party/selinux:libselinux" ]
230    include_dirs += [ "//third_party/selinux/libselinux/include" ]
231    defines += [ "SURPPORT_SELINUX" ]
232  }
233
234  if (defined(use_ptable)) {
235    include_dirs += [ "${updater_path}/services/ptable_parse" ]
236    deps += [ "${updater_path}/services/ptable_parse:libptableparse" ]
237    defines += [ "UPDATER_USE_PTABLE" ]
238  }
239
240  external_deps = [
241    "c_utils:utils",
242    "init:libbegetutil",
243  ]
244
245  part_name = "updater"
246  subsystem_name = "updater"
247}
248
249group("updater_flashd") {
250  deps = [ ":libflashd" ]
251}
252