1# Copyright (C) 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("//build/ohos.gni") 15 16ohos_static_library("serialize_structs") { 17 sources = [ 18 "src/cffi/bridge.cpp", 19 "src/cffi/cmd.cpp", 20 "src/cffi/getparameter.cpp", 21 "src/cffi/log.cpp", 22 "src/cffi/mount.cpp", 23 "src/cffi/mount_wrapper.cpp", 24 "src/cffi/oh_usb.cpp", 25 "src/cffi/sendmsg.cpp", 26 "src/cffi/serial_struct.cpp", 27 "src/cffi/sys_para.cpp", 28 "src/cffi/transfer.cpp", 29 "src/cffi/uart.cpp", 30 "src/cffi/uart_wrapper.cpp", 31 "src/cffi/usb_util.cpp", 32 "src/cffi/usb_wrapper.cpp", 33 "src/cffi/utils.cpp", 34 ] 35 36 external_deps = [ 37 "bounds_checking_function:libsec_static", 38 "hilog:libhilog", 39 "init:libbegetutil", 40 "lz4:liblz4_static", 41 ] 42 43 defines = [ "HDC_HILOG" ] 44 45 if (is_mac) { 46 defines = [ "HOST_MAC" ] 47 } 48 49 if (build_selinux) { 50 external_deps += [ "selinux:libselinux" ] 51 defines += [ "SURPPORT_SELINUX" ] 52 } 53 54 subsystem_name = "developtools" 55 part_name = "hdc" 56} 57 58ohos_rust_shared_library("lib") { 59 crate_name = "hdc" 60 crate_type = "dylib" 61 crate_root = "src/lib.rs" 62 sources = [ "src/lib.rs" ] 63 64 if (is_emulator && product_name != "ohos-sdk") { 65 features = [ "emulator" ] 66 } 67 68 deps = [ 69 ":serialize_structs", 70 "//third_party/rust/crates/humantime:lib", 71 "//third_party/rust/crates/libc:lib", 72 "//third_party/rust/crates/log:lib", 73 "//third_party/rust/crates/rust-openssl/openssl:lib", 74 ] 75 external_deps = [ 76 "hilog:hilog_rust", 77 "ylong_runtime:ylong_runtime", 78 ] 79 subsystem_name = "developtools" 80 part_name = "hdc" 81} 82 83ohos_rust_executable("hdcd") { 84 sources = [ "src/daemon/main.rs" ] 85 deps = [ 86 ":lib", 87 ":serialize_structs", 88 "//third_party/rust/crates/env_logger:lib", 89 "//third_party/rust/crates/humantime:lib", 90 "//third_party/rust/crates/libc:lib", 91 "//third_party/rust/crates/log:lib", 92 "//third_party/rust/crates/nix:lib", 93 "//third_party/rust/crates/rust-openssl/openssl:lib", 94 ] 95 external_deps = [ 96 "hilog:hilog_rust", 97 "ylong_runtime:ylong_runtime", 98 ] 99 100 if (!defined(ohos_lite)) { 101 external_deps += [ "faultloggerd:panic_handler" ] 102 } 103 104 output_name = "hdcd" 105 install_enable = true 106 module_install_dir = "bin" 107 install_images = [ "system" ] 108 features = [ "daemon" ] 109 if (is_emulator) { 110 features += [ "emulator" ] 111 } 112 subsystem_name = "developtools" 113 part_name = "hdc" 114} 115 116# hdc_rust compile begin 117ohos_static_library("cffi_host") { 118 sources = [ 119 "src/cffi/host/ctimer.cpp", 120 "src/cffi/host/host_usb.cpp", 121 "src/cffi/host/host_usb_wrapper.cpp", 122 "src/cffi/serial_struct.cpp", 123 "src/cffi/transfer.cpp", 124 "src/cffi/uart.cpp", 125 "src/cffi/uart_wrapper.cpp", 126 "src/cffi/usb_util.cpp", 127 "src/cffi/utils.cpp", 128 ] 129 130 if (!is_mingw) { 131 sources += [ 132 "src/cffi/oh_usb.cpp", 133 "src/cffi/sendmsg.cpp", 134 "src/cffi/usb_wrapper.cpp", 135 ] 136 } 137 138 include_dirs = [ 139 "//third_party/bounds_checking_function/include", 140 "//third_party/lz4/lib", 141 "src/cffi", 142 ] 143 144 external_deps = [ 145 "bounds_checking_function:libsec_static", 146 "libusb:libusb", 147 "lz4:liblz4_static", 148 ] 149 150 defines = [ "HDC_HOST" ] 151 if (is_mingw) { 152 defines += [ "HOST_MINGW" ] 153 } 154 155 if (is_mac) { 156 defines = [ "HOST_MAC" ] 157 } 158 159 cflags = [ "-std=c++17" ] 160 161 subsystem_name = "developtools" 162 part_name = "hdc" 163} 164 165ohos_static_library("hdc_win_dep") { 166 sources = [ "src/cffi/win_dep.cpp" ] 167 include_dirs = [ "//prebuilts/mingw-w64/ohos/linux-x86_64/clang-mingw/x86_64-w64-mingw32/include" ] 168 169 subsystem_name = "developtools" 170 part_name = "hdc" 171} 172 173ohos_rust_static_library("hdc_library_host") { 174 crate_name = "hdc" 175 crate_type = "rlib" 176 crate_root = "src/lib.rs" 177 sources = [ "src/lib.rs" ] 178 179 deps = [ 180 ":cffi_host", 181 "//third_party/rust/crates/humantime:lib", 182 "//third_party/rust/crates/libc:lib", 183 "//third_party/rust/crates/log:lib", 184 "//third_party/rust/crates/rust-openssl/openssl:lib", 185 ] 186 external_deps = [ "ylong_runtime:ylong_runtime_static" ] 187 188 features = [ "host" ] 189 190 subsystem_name = "developtools" 191 part_name = "hdc" 192} 193 194ohos_rust_executable("hdc_rust") { 195 sources = [ "src/host/main.rs" ] 196 deps = [ 197 ":cffi_host", 198 ":hdc_library_host", 199 "//third_party/rust/crates/humantime:lib", 200 "//third_party/rust/crates/lazy-static.rs:lib", 201 "//third_party/rust/crates/libc:lib", 202 "//third_party/rust/crates/log:lib", 203 "//third_party/rust/crates/rust-openssl/openssl:lib", 204 ] 205 206 if (is_mingw) { 207 deps += [ ":hdc_win_dep" ] 208 } 209 210 # config to link libc++.a 211 rust_static_link = true 212 213 external_deps = [ "ylong_runtime:ylong_runtime_static" ] 214 215 features = [ "host" ] 216 subsystem_name = "developtools" 217 part_name = "hdc" 218} 219