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/session.cpp", 70 "${HDC_PATH}/common/task.cpp", 71 "${HDC_PATH}/common/tcp.cpp", 72 "${HDC_PATH}/common/tlv.cpp", 73 "${HDC_PATH}/common/transfer.cpp", 74 "${HDC_PATH}/common/usb.cpp", 75] 76 77config("flashd_hdc_config") { 78 include_dirs = [ "./common" ] 79 cflags_cc = [ "-std=c++17" ] 80} 81 82ohos_static_library("flashd_deamon") { 83 sources = [ 84 "${HDC_PATH}/daemon/daemon_app.cpp", 85 "${HDC_PATH}/daemon/daemon_forward.cpp", 86 "${HDC_PATH}/daemon/daemon_tcp.cpp", 87 "${HDC_PATH}/daemon/daemon_unity.cpp", 88 "${HDC_PATH}/daemon/daemon_usb.cpp", 89 "${HDC_PATH}/daemon/jdwp.cpp", 90 "${HDC_PATH}/daemon/shell.cpp", 91 "daemon/daemon.cpp", 92 "daemon/system_depend.cpp", 93 ] 94 95 sources += common_sources 96 97 defines = [ 98 "HARMONY_PROJECT", 99 "OPENSSL_SUPPRESS_DEPRECATED", 100 ] 101 102 configs = [ ":flashd_hdc_config" ] 103 104 external_deps = [ 105 "bounds_checking_function:libsec_static", 106 "c_utils:utils", 107 "libuv:uv", 108 "lz4:liblz4_static", 109 "openssl:libcrypto_shared", 110 ] 111 112 deps = [ "${updater_path}/services/flashd:hdc_hash_gen" ] 113 114 if (updater_hdc_depend) { 115 external_deps += [ "hdc:hdc_updater" ] 116 } 117 118 if (use_musl) { 119 external_deps += [ "init:libbegetutil_static" ] 120 } 121 122 include_dirs = [ 123 "${updater_path}/services/common", 124 "${updater_path}/services/flashd", 125 "${updater_path}/services/flashd/daemon", 126 "${updater_path}/services/flashd/common", 127 "${updater_path}/services/flashd/host", 128 "${updater_path}/services/include", 129 "${updater_path}/services/include/fs_manager", 130 "${updater_path}/services/include/package", 131 "${updater_path}/services/include/applypatch", 132 "${updater_path}/services/include/script", 133 "${updater_path}/services/include/log", 134 "${updater_path}/interfaces/kits/include", 135 "${updater_path}/utils/include", 136 ] 137 138 if (build_selinux) { 139 external_deps += [ "selinux:libselinux_static" ] 140 defines += [ 141 "SURPPORT_SELINUX", 142 "UPDATER_MODE", 143 ] 144 } 145 146 if (build_variant == "user") { 147 defines += [ "UPDATER_BUILD_VARIANT_USER" ] 148 } 149 150 subsystem_name = "updater" 151 part_name = "updater" 152} 153 154ohos_static_library("libflashd") { 155 sources = [ 156 "${updater_path}/services/flashd/daemon/commander.cpp", 157 "${updater_path}/services/flashd/daemon/commander_factory.cpp", 158 "${updater_path}/services/flashd/daemon/daemon_updater.cpp", 159 "${updater_path}/services/flashd/daemon/erase_commander.cpp", 160 "${updater_path}/services/flashd/daemon/flash_commander.cpp", 161 "${updater_path}/services/flashd/daemon/flashd_main.cpp", 162 "${updater_path}/services/flashd/daemon/flashd_utils.cpp", 163 "${updater_path}/services/flashd/daemon/format_commander.cpp", 164 "${updater_path}/services/flashd/daemon/update_commander.cpp", 165 "${updater_path}/services/flashd/image_writer/image_writer.cpp", 166 "${updater_path}/services/flashd/partition.cpp", 167 "${updater_path}/services/hdi/client/update_hdi_client.cpp", 168 "${updater_path}/services/updater_binary/update_image_block.cpp", 169 "${updater_path}/services/updater_binary/update_image_patch.cpp", 170 "${updater_path}/services/updater_binary/update_partitions.cpp", 171 "${updater_path}/services/updater_binary/update_processor.cpp", 172 ] 173 174 defines = [ 175 "HARMONY_PROJECT", 176 "OPENSSL_SUPPRESS_DEPRECATED", 177 ] 178 179 deps = [ 180 ":flashd_deamon", 181 "${updater_path}/interfaces/kits/misc_info:libmiscinfo", 182 "${updater_path}/interfaces/kits/slot_info:libslotinfo", 183 "${updater_path}/interfaces/kits/updaterkits:libupdaterkits", 184 "${updater_path}/services/applypatch:libapplypatch", 185 "${updater_path}/services/common/ring_buffer:libringbuffer", 186 "${updater_path}/services/diffpatch/patch:libpatch", 187 "${updater_path}/services/flashd:hdc_hash_gen", 188 "${updater_path}/services/flow_update/update_bin:libBinFlowUpdate", 189 "${updater_path}/services/fs_manager:libfsmanager", 190 "${updater_path}/services/hdi/server:libupdate_hdi_impl", 191 "${updater_path}/services/log:libupdaterlog", 192 "${updater_path}/services/package:libupdaterpackage", 193 "${updater_path}/services/script:libupdaterscript", 194 "${updater_path}/utils:libutils", 195 ] 196 197 include_dirs = [ 198 "${updater_path}/services", 199 "${updater_path}/services/common", 200 "${updater_path}/services/flashd", 201 "${updater_path}/services/flashd/daemon", 202 "${updater_path}/services/flashd/common", 203 "${updater_path}/services/flow_update", 204 "${updater_path}/interfaces/kits/include", 205 "${updater_path}/services/include/package", 206 "${updater_path}/services/include/ptable_parse", 207 "${updater_path}/services/include/script", 208 "${updater_path}/services/include/log", 209 "${updater_path}/services/include", 210 "${updater_path}/services/ptable_parse", 211 "${updater_path}/utils/include", 212 "${updater_path}/utils/json", 213 ] 214 215 if (defined(use_ptable)) { 216 include_dirs += [ "${updater_path}/services/ptable_parse" ] 217 deps += [ "${updater_path}/services/ptable_parse:libptableparse" ] 218 defines += [ "UPDATER_USE_PTABLE" ] 219 } 220 221 external_deps = [ 222 "bounds_checking_function:libsec_static", 223 "bzip2:libbz2", 224 "cJSON:cjson", 225 "c_utils:utils", 226 "init:libbegetutil_static", 227 "libuv:uv", 228 "lz4:liblz4_static", 229 "openssl:libcrypto_shared", 230 "zlib:libz", 231 ] 232 233 if (updater_hdc_depend) { 234 external_deps += [ "hdc:hdc_updater" ] 235 } 236 237 if (build_selinux) { 238 external_deps += [ "selinux:libselinux_static" ] 239 defines += [ "SURPPORT_SELINUX" ] 240 } 241 242 if (defined(binary_custom_external_deps)) { 243 external_deps += binary_custom_external_deps 244 } 245 246 part_name = "updater" 247 subsystem_name = "updater" 248} 249 250group("updater_flashd") { 251 deps = [ ":libflashd" ] 252} 253