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("//build/ohos.gni") 15import("//foundation/arkui/ace_engine/ace_config.gni") 16import("//foundation/arkui/ace_engine/adapter/preview/sdk/sharedlib_config.gni") 17import("//foundation/arkui/ace_engine/interfaces/napi/kits/napi_lib.gni") 18 19ace_devices = [ 20 "phone", 21 "tv", 22 "wearable", 23 "tablet", 24 "card", 25 "car", 26] 27 28foreach(device, ace_devices) { 29 ohos_executable("ace_${device}_test") { 30 ohos_test = true 31 test_output_dir = "$root_out_dir/common/samples" 32 defines = [ "USE_GLFW_WINDOW" ] 33 cflags_cc = [] 34 deps = [] 35 config = { 36 } 37 if (defined(current_platform.config)) { 38 config = current_platform.config 39 } 40 if (defined(config.defines)) { 41 defines += config.defines 42 } 43 if (defined(config.cflags_cc)) { 44 cflags_cc += config.cflags_cc 45 } 46 if (defined(config.libace_target)) { 47 deps += [ config.libace_target ] 48 } 49 include_dirs = [ 50 "$ace_root", 51 "$ace_root/frameworks", 52 "$flutter_root/glfw/include", 53 "//foundation/window/window_manager", 54 "//ide/tools/previewer", 55 ] 56 deps += [ 57 ":copy_preview_shared_library", 58 "//third_party/glfw:glfw", 59 ] 60 sources = [ 61 "ace_${device}_test.cpp", 62 "event_adapter.cpp", 63 ] 64 65 external_deps = [ 66 "graphic_2d:librender_service_client", 67 "previewer:ide_extension", 68 "window_manager:previewer_window", 69 ] 70 71 if (use_mingw_win) { 72 libs = [ "pthread" ] 73 } 74 subsystem_name = ace_engine_subsystem 75 part_name = ace_engine_part 76 } 77} 78 79# Install packages 80group("previewer_demo") { 81 if (is_wearable_product) { 82 deps = [ ":ace_wearable_test" ] 83 } else { 84 deps = [ 85 ":ace_car_test", 86 ":ace_card_test", 87 ":ace_phone_test", 88 ":ace_tablet_test", 89 ":ace_tv_test", 90 ] 91 } 92} 93 94common_bin += [ 95 # The dynamic librarys of hiviewdfx subsystem. 96 { 97 label = "//base/hiviewdfx/hilog/interfaces/native/innerkits:libhilog" 98 subsystem_name = "hiviewdfx" 99 part_name = "hilog" 100 }, 101 102 # The dynamic librarys of IDE subsystem. 103 { 104 label = "//ide/tools/previewer/util:ide_util" 105 subsystem_name = "ide" 106 part_name = "previewer" 107 }, 108 { 109 label = "//ide/tools/previewer/jsapp/rich/external:ide_extension" 110 subsystem_name = "ide" 111 part_name = "previewer" 112 }, 113 114 # The dynamic librarys of rosen window subsystem. 115 { 116 label = "//foundation/window/window_manager/previewer:previewer_window" 117 subsystem_name = "window" 118 part_name = "window_manager" 119 }, 120] 121 122if (is_mingw || is_mac) { 123 common_bin += [ 124 # The dynamic librarys of rosen window subsystem. 125 { 126 label = 127 "//foundation/window/window_manager/previewer:previewer_window_napi" 128 subsystem_name = "window" 129 part_name = "window_manager" 130 }, 131 132 # The napi dynamic librarys of ability subsystem. 133 { 134 label = "//foundation/ability/ability_runtime/frameworks/simulator/ability_simulator:ability_simulator" 135 subsystem_name = "ability" 136 part_name = "ability_runtime" 137 }, 138 { 139 label = "//foundation/ability/ability_base:string_utils" 140 subsystem_name = "ability" 141 part_name = "ability_base" 142 }, 143 ] 144 napi_modules += [ 145 { 146 prefix = "app/ability" 147 shard_libs = [ 148 # The napi dynamic librarys of ability subsystem. 149 { 150 label = "//foundation/ability/ability_runtime/frameworks/simulator/napi_module/uiability:uiability" 151 subsystem_name = "ability" 152 part_name = "ability_runtime" 153 }, 154 ] 155 }, 156 { 157 prefix = "ability" 158 159 # The napi dynamic librarys of ability subsystem. 160 shard_libs = [ 161 { 162 label = "//foundation/ability/ability_runtime/frameworks/simulator/napi_module/want_constant:wantconstant_napi" 163 subsystem_name = "ability" 164 part_name = "ability_runtime" 165 }, 166 ] 167 }, 168 { 169 prefix = "application" 170 shard_libs = [ 171 # The napi dynamic librarys of rosen window subsystem. 172 { 173 label = "//foundation/window/window_manager/previewer/window_stage_modules:windowstage" 174 subsystem_name = "window" 175 part_name = "window_manager" 176 lib_names = [ "windowstage" ] 177 }, 178 179 # The napi dynamic librarys of ability subsystem. 180 { 181 label = "//foundation/ability/ability_runtime/frameworks/simulator/napi_module/ability:ability_napi" 182 subsystem_name = "ability" 183 part_name = "ability_runtime" 184 }, 185 { 186 label = "//foundation/ability/ability_runtime/frameworks/simulator/napi_module/ability_constant:abilityconstant" 187 subsystem_name = "ability" 188 part_name = "ability_runtime" 189 }, 190 { 191 label = "//foundation/ability/ability_runtime/frameworks/simulator/napi_module/ability_context:abilitycontext_napi" 192 subsystem_name = "ability" 193 part_name = "ability_runtime" 194 }, 195 { 196 label = "//foundation/ability/ability_runtime/frameworks/simulator/napi_module/ability_stage:abilitystage" 197 subsystem_name = "ability" 198 part_name = "ability_runtime" 199 }, 200 { 201 label = "//foundation/ability/ability_runtime/frameworks/simulator/napi_module/ability_stage_context:abilitystagecontext_napi" 202 subsystem_name = "ability" 203 part_name = "ability_runtime" 204 }, 205 { 206 label = "//foundation/ability/ability_runtime/frameworks/simulator/napi_module/application_context:applicationcontext_napi" 207 subsystem_name = "ability" 208 part_name = "ability_runtime" 209 }, 210 { 211 label = "//foundation/ability/ability_runtime/frameworks/simulator/napi_module/caller:caller_napi" 212 subsystem_name = "ability" 213 part_name = "ability_runtime" 214 }, 215 { 216 label = "//foundation/ability/ability_runtime/frameworks/simulator/napi_module/callee:callee" 217 subsystem_name = "ability" 218 part_name = "ability_runtime" 219 }, 220 { 221 label = "//foundation/ability/ability_runtime/frameworks/simulator/napi_module/context:context_napi" 222 subsystem_name = "ability" 223 part_name = "ability_runtime" 224 }, 225 { 226 label = "//foundation/ability/ability_runtime/frameworks/simulator/napi_module/configuration_constant:configurationconstant" 227 subsystem_name = "ability" 228 part_name = "ability_runtime" 229 }, 230 ] 231 }, 232 ] 233} 234 235# All dynamic libraries to be copied to the path "/previewer/common/bin/module/", 236# which are called by the napi framework, can be added to this script. 237foreach(module, napi_modules) { 238 ohos_copy("copy_napi_${module.prefix}libs") { 239 deps = [] 240 sources = [] 241 foreach(shard_lib, module.shard_libs) { 242 subsystem_name = shard_lib.subsystem_name 243 part_name = shard_lib.part_name 244 deps += [ shard_lib.label ] 245 out_path = get_label_info(shard_lib.label, "root_out_dir") 246 lib_names = [] 247 if (defined(shard_lib.lib_names)) { 248 lib_names += shard_lib.lib_names 249 } else { 250 cur_lib = get_label_info(shard_lib.label, "name") 251 lib_names += [ string_replace(cur_lib, "lib", "", 1) ] 252 } 253 foreach(lib_name, lib_names) { 254 sources += [ "${out_path}/${subsystem_name}/${part_name}/lib${lib_name}${dylib_suffix}" ] 255 } 256 } 257 258 # Set the output directory for all dynamic libraries. 259 if (module.prefix == "") { 260 outputs = [ "${root_out_dir}/common/samples/module/{{source_file_part}}" ] 261 } else { 262 outputs = [ "${root_out_dir}/common/samples/module/${module.prefix}/{{source_file_part}}" ] 263 } 264 } 265} 266 267# All dynamic libraries to be copied to the path "/previewer/common/bin/", 268# which are related to the previewer, can be added to this script. 269ohos_copy("copy_preview_shared_library") { 270 deps = [] 271 foreach(module, napi_modules) { 272 deps += [ ":copy_napi_${module.prefix}libs" ] 273 } 274 275 sources = [ 276 "//base/global/system_resources/fonts", 277 "//foundation/arkui/ace_engine/adapter/preview/sdk/fontconfig.json", 278 "//third_party/icu/ohos_icu4j/data/icudt72l.dat", 279 ] 280 281 foreach(item, common_bin) { 282 subsystem_name = item.subsystem_name 283 part_name = item.part_name 284 deps += [ item.label ] 285 out_path = get_label_info(item.label, "root_out_dir") 286 lib_names = [] 287 if (defined(item.lib_names)) { 288 lib_names += item.lib_names 289 } else { 290 lib_names += 291 [ string_replace(get_label_info(item.label, "name"), "lib", "", 1) ] 292 } 293 foreach(lib_name, lib_names) { 294 sources += [ "${out_path}/${subsystem_name}/${part_name}/lib${lib_name}${dylib_suffix}" ] 295 } 296 } 297 298 outputs = [ "${root_out_dir}/common/samples/{{source_file_part}}" ] 299} 300