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 ".", 30 "./ui/include", 31 "./ui", 32 "./ui/control", 33] 34 35updater_common_deps = [ 36 "${updater_path}/interfaces/kits/packages:libpackageExt", 37 "${updater_path}/services/applypatch:libapplypatch", 38 "${updater_path}/services/diffpatch/patch:libpatch", 39 "${updater_path}/services/fs_manager:libfsmanager", 40 "${updater_path}/services/log:libupdaterlog", 41 "${updater_path}/services/package:libupdaterpackage", 42 "${updater_path}/services/write_state:libwritestate", 43] 44 45updater_gen("updater") { 46 deps = [ "${updater_path}/services:libupdater_static" ] 47 external_deps = [ "hilog:libhilog" ] 48 49 # force link flashd library 50 ldflags = [ 51 "-Wl,--whole-archive", 52 "-Wl,--no-whole-archive", 53 ] 54 55 if (!ohos_indep_compiler_enable) { 56 ldflags += [ rebase_path("${target_out_dir}/flashd/libflashd.a"), ] 57 } 58 59 part_name = "updater" 60 subsystem_name = "updater" 61} 62 63ohos_static_library("libupdater_static") { 64 defines = [ "BUILD_OHOS" ] 65 sources = [ 66 "factory_reset/factory_reset.cpp", 67 "hardware_fault/hardware_fault_retry.cpp", 68 "main.cpp", 69 "updater.cpp", 70 "updater_main.cpp", 71 "updater_preprocess.cpp", 72 "updater_utils.cpp", 73 ] 74 75 if (updater_ui_support) { 76 sources += [ "updater_ui.cpp" ] 77 } 78 79 include_dirs = updater_common_include 80 81 deps = updater_common_deps 82 deps += [ 83 "${updater_path}/interfaces/kits/misc_info:libmiscinfo", 84 "${updater_path}/services/sdcard_update:libsdupdate", 85 "${updater_path}/interfaces/kits/slot_info:libslotinfo", 86 ] 87 88 if (!ohos_indep_compiler_enable) { 89 deps += [ "${updater_path}/services/flashd:libflashd", ] 90 } 91 92 if (defined(use_ptable)) { 93 include_dirs += [ "${updater_path}/services/ptable_parse" ] 94 deps += [ "${updater_path}/services/ptable_parse:libptableparse" ] 95 defines += [ "UPDATER_USE_PTABLE" ] 96 } 97 98 external_deps = [ 99 "bounds_checking_function:libsec_shared", 100 "bounds_checking_function:libsec_static", 101 "bzip2:libbz2", 102 "cJSON:cjson", 103 "init:libbegetutil_static", 104 "libdrm:libdrm", 105 "openssl:libcrypto_shared", 106 "openssl:libssl_shared", 107 "zlib:libz", 108 "drivers_peripheral_partitionslot:libpartition_slot_manager", 109 ] 110 if (updater_ui_support) { 111 external_deps += [ "drivers_interface_input:libinput_proxy_1.0" ] 112 } 113 114 if (updater_ui_support) { 115 external_deps += [ 116 "ui_lite:libupdater_layout", 117 "graphic_utils_lite:utils_lite", 118 ] 119 deps += [ "${updater_path}/services/ui:libui" ] 120 } 121 122 if (build_selinux) { 123 external_deps += [ 124 "selinux:libselinux_static", 125 "selinux_adapter:librestorecon_static", 126 ] 127 cflags = [ "-DWITH_SELINUX" ] 128 } 129 130 if (build_variant == "user") { 131 defines += [ "UPDATER_BUILD_VARIANT_USER" ] 132 } 133 134 part_name = "updater" 135 subsystem_name = "updater" 136} 137 138config("libupdater_exported_headers") { 139 visibility = [ ":*" ] 140 include_dirs = [ 141 "${updater_path}/services/common", 142 "${updater_path}/services/include", 143 "${updater_path}/interfaces/kits/include", 144 "${updater_path}/services", 145 ] 146} 147 148ohos_static_library("libupdater") { 149 defines = [ "BUILD_OHOS" ] 150 sources = [ 151 "factory_reset/factory_reset.cpp", 152 "hardware_fault/hardware_fault_retry.cpp", 153 "updater.cpp", 154 "updater_preprocess.cpp", 155 "updater_utils.cpp", 156 ] 157 158 include_dirs = updater_common_include 159 160 deps = updater_common_deps 161 162 if (!ohos_indep_compiler_enable) { 163 deps += [ "${updater_path}/services/flashd:libflashd", ] 164 } 165 166 public_configs = [ ":libupdater_exported_headers" ] 167 168 if (defined(use_ptable)) { 169 include_dirs += [ "${updater_path}/services/ptable_parse" ] 170 deps += [ "${updater_path}/services/ptable_parse:libptableparse" ] 171 defines += [ "UPDATER_USE_PTABLE" ] 172 } 173 174 ldflags = [] 175 176 # force link invisible function 177 if (defined(updater_force_link_libs)) { 178 ldflags += [ "-Wl,--whole-archive" ] 179 foreach(lib, updater_force_link_libs) { 180 ldflags += [ "${lib}" ] 181 } 182 ldflags += [ "-Wl,--no-whole-archive" ] 183 } 184 185 external_deps = [ 186 "bounds_checking_function:libsec_shared", 187 "bounds_checking_function:libsec_static", 188 "bzip2:libbz2", 189 "cJSON:cjson", 190 "init:libbegetutil_static", 191 "openssl:libcrypto_shared", 192 "openssl:libssl_shared", 193 "zlib:libz", 194 "drivers_peripheral_partitionslot:libpartition_slot_manager", 195 ] 196 197 if (updater_ui_support) { 198 external_deps += [ "drivers_interface_input:libinput_proxy_1.0" ] 199 } 200 201 if (updater_ui_support) { 202 external_deps += [ 203 "ui_lite:libupdater_layout", 204 "graphic_utils_lite:utils_lite", 205 ] 206 } 207 208 if (build_selinux) { 209 external_deps += [ 210 "selinux:libselinux_static", 211 "selinux_adapter:librestorecon_static", 212 ] 213 cflags = [ "-DWITH_SELINUX" ] 214 } 215 216 subsystem_name = "updater" 217 part_name = "updater" 218} 219