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