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