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("//build/ohos.gni") 15HDC_PATH = "//developtools/hdc_standard" 16import("//developtools/hdc_standard/hdc.gni") 17 18hdc_common_sources = [ 19 "${HDC_PATH}/src/common/async_cmd.cpp", 20 "${HDC_PATH}/src/common/auth.cpp", 21 "${HDC_PATH}/src/common/base.cpp", 22 "${HDC_PATH}/src/common/channel.cpp", 23 "${HDC_PATH}/src/common/debug.cpp", 24 "${HDC_PATH}/src/common/file.cpp", 25 "${HDC_PATH}/src/common/file_descriptor.cpp", 26 "${HDC_PATH}/src/common/forward.cpp", 27 "${HDC_PATH}/src/common/session.cpp", 28 "${HDC_PATH}/src/common/task.cpp", 29 "${HDC_PATH}/src/common/tcp.cpp", 30 "${HDC_PATH}/src/common/transfer.cpp", 31 "${HDC_PATH}/src/common/usb.cpp", 32] 33if (hdc_support_uart) { 34 hdc_common_sources += [ "${HDC_PATH}/src/common/uart.cpp" ] 35} 36config("hdc_config") { 37 include_dirs = [ "${HDC_PATH}/src/common" ] 38 cflags_cc = [ "-std=c++17" ] 39 if (is_mingw) { 40 cflags_cc += [ "-Wno-inconsistent-dllimport" ] # in mingw some sec api will 41 # overwrite by utilsecurec 42 } 43} 44 45ohos_executable("hdcd") { 46 use_exceptions = true 47 sources = [ 48 "src/daemon/daemon.cpp", 49 "src/daemon/daemon_app.cpp", 50 "src/daemon/daemon_forward.cpp", 51 "src/daemon/daemon_tcp.cpp", 52 "src/daemon/daemon_unity.cpp", 53 "src/daemon/daemon_usb.cpp", 54 "src/daemon/jdwp.cpp", 55 "src/daemon/main.cpp", 56 "src/daemon/shell.cpp", 57 "src/daemon/system_depend.cpp", 58 ] 59 sources += hdc_common_sources 60 61 defines = [ "HARMONY_PROJECT" ] 62 63 if (hdc_debug) { 64 defines += [ "HDC_DEBUG" ] 65 } 66 if (hdc_support_uart) { 67 defines += [ "HDC_SUPPORT_UART" ] 68 sources += [ "src/daemon/daemon_uart.cpp" ] 69 } 70 if (js_jdwp_connect) { 71 defines += [ "JS_JDWP_CONNECT" ] 72 } 73 configs = [ ":hdc_config" ] 74 75 deps = [ 76 "//third_party/libuv:uv_static", 77 "//third_party/lz4:liblz4_static", 78 "//third_party/openssl:libcrypto_static", 79 "//utils/native/base:utils", 80 ] 81 82 if (hdc_jdwp_test) { 83 defines += [ "SIMULATE_JDWP" ] 84 deps += [ "${HDC_PATH}/src/test/jdwp:jdwp_test" ] 85 } 86 87 external_deps = [ 88 "init:libbegetutil", 89 "startup_l2:syspara", 90 ] 91 92 include_dirs = [ 93 "${HDC_PATH}/daemon", 94 "//utils/native/base/include", 95 "//third_party/lz4/lib", 96 "//third_party/openssl/include", 97 "//third_party/libuv", 98 ] 99 install_images = [ 100 "system", 101 "updater", 102 ] 103 104 install_enable = true 105 subsystem_name = "developtools" 106 part_name = "hdc_standard" 107} 108 109ohos_executable("hdc_std") { 110 use_exceptions = true 111 ldflags = [] 112 libs = [] 113 configs = [ ":hdc_config" ] 114 defines = [ 115 "HDC_HOST", 116 "HARMONY_PROJECT", 117 ] 118 if (is_mac) { 119 defines += [ "HOST_MAC" ] 120 } 121 if (hdc_debug) { 122 defines += [ "HDC_DEBUG" ] 123 } 124 sources = [ 125 "src/host/client.cpp", 126 "src/host/host_app.cpp", 127 "src/host/host_forward.cpp", 128 "src/host/host_tcp.cpp", 129 "src/host/host_unity.cpp", 130 "src/host/host_usb.cpp", 131 "src/host/main.cpp", 132 "src/host/server.cpp", 133 "src/host/server_for_client.cpp", 134 "src/host/translate.cpp", 135 ] 136 sources += hdc_common_sources 137 if (hdc_support_uart) { 138 defines += [ "HDC_SUPPORT_UART" ] 139 sources += [ "src/host/host_uart.cpp" ] 140 } 141 142 deps = [ 143 "//third_party/libusb:libusb", 144 "//third_party/libuv:uv_static", 145 "//third_party/lz4:liblz4_static", 146 "//third_party/openssl:libcrypto_static", 147 "//utils/native/base:utilsecurec", 148 ] 149 150 include_dirs = [ 151 "${HDC_PATH}/daemon", 152 "//utils/native/base/include", 153 "//third_party/lz4/lib", 154 "//third_party/openssl/include", 155 "//third_party/libuv", 156 ] 157 158 if (is_mingw) { 159 static_link = false 160 161 # we should use something we define , not just _WIN32 (this will defined in some windows header) 162 defines += [ "HOST_MINGW" ] # we define this for mingw 163 defines += [ "WIN32_LEAN_AND_MEAN" ] 164 libs += [ "setupapi" ] 165 ldflags += [ 166 "-Wl,--whole-archive", 167 "-lpthread", 168 "-Wl,--no-whole-archive", 169 ] 170 } 171 172 if (is_linux) { 173 static_link = false 174 defines += [ "HOST_LINUX" ] 175 ldflags += [ 176 "-Wl,--whole-archive", 177 "-lpthread", 178 "-latomic", 179 "-ldl", 180 "-lrt", 181 "-Wl,--no-whole-archive", 182 ] 183 } 184 185 subsystem_name = "developtools" 186 part_name = "hdc_standard" 187} 188 189group("hdc_target_standard") { 190 deps = [ 191 ":hdc_std", 192 ":hdcd", 193 ] 194} 195 196group("hdc_target_standard_linux") { 197 deps = [ ":hdc_std(//build/toolchain/linux:clang_x64)" ] 198} 199 200group("hdc_target_standard_mingw") { 201 deps = [ ":hdc_std(//build/toolchain/mingw:mingw_x86_64)" ] 202} 203 204group("hdc_target_standard_all") { 205 deps = [ 206 ":hdc_target_standard", 207 ":hdc_target_standard_linux", 208 ":hdc_target_standard_mingw", 209 ] 210} 211 212group("hdc_target_standard_windows") { 213 deps = [ 214 ":hdc_target_standard", 215 ":hdc_target_standard_mingw", 216 ] 217} 218 219group("hdc_all") { 220 testonly = true 221 deps = [ ":hdc_target_standard_all" ] 222} 223