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] 27foreach(device, ace_devices) { 28 ohos_executable("ace_${device}_test") { 29 ohos_test = true 30 test_output_dir = "$root_out_dir/common/samples" 31 defines = [ "USE_GLFW_WINDOW" ] 32 cflags_cc = [] 33 include_dirs = [ 34 "$ace_root", 35 "$ace_root/frameworks", 36 "$flutter_root/engine", 37 "$flutter_root/engine/flutter/shell/platform/common/cpp/public", 38 "$flutter_root/engine/ace_adapter/flutter/shell/platform/glfw/public", 39 "$flutter_root/skia", 40 "$flutter_root/glfw/include", 41 ] 42 deps = [ ":copy_preview_shared_library" ] 43 sources = [ 44 "ace_${device}_test.cpp", 45 "key_input_handler.cpp", 46 "touch_event_handler_flutter.cpp", 47 ] 48 config = { 49 } 50 if (defined(current_platform.config)) { 51 config = current_platform.config 52 } 53 if (defined(config.defines)) { 54 defines += config.defines 55 } 56 if (defined(config.cflags_cc)) { 57 cflags_cc += config.cflags_cc 58 } 59 if (defined(config.libace_target)) { 60 deps += [ config.libace_target ] 61 } 62 63 if (defined(config.enable_rosen_backend) && config.enable_rosen_backend) { 64 sources -= [ "touch_event_handler_flutter.cpp" ] 65 sources += [ "touch_event_handler_rs.cpp" ] 66 deps += [ "//foundation/graphic/graphic_2d/rosen/modules/glfw_render_context:libglfw_render_context" ] 67 } 68 if (use_mingw_win) { 69 libs = [ "pthread" ] 70 } 71 } 72} 73 74if (is_standard_system) { 75 # All dynamic libraries to be copied to the path "/previewer/common/bin/module/", 76 # which are called by the napi framework, can be added to this script. 77 foreach(module, napi_modules) { 78 ohos_copy("copy_napi_${module.prefix}libs") { 79 deps = [] 80 sources = [] 81 foreach(shard_lib, module.shard_libs) { 82 subsystem_name = shard_lib.subsystem_name 83 part_name = shard_lib.part_name 84 deps += [ shard_lib.label ] 85 out_path = get_label_info(shard_lib.label, "root_out_dir") 86 lib_names = [] 87 if (defined(shard_lib.lib_names)) { 88 lib_names += shard_lib.lib_names 89 } else { 90 cur_lib = get_label_info(shard_lib.label, "name") 91 lib_names += [ string_replace(cur_lib, "lib", "", 1) ] 92 } 93 foreach(lib_name, lib_names) { 94 sources += [ "${out_path}/${subsystem_name}/${part_name}/lib${lib_name}${dylib_suffix}" ] 95 } 96 } 97 98 # Set the output directory for all dynamic libraries. 99 if (module.prefix == "") { 100 outputs = 101 [ "${root_out_dir}/common/samples/module/{{source_file_part}}" ] 102 } else { 103 outputs = [ "${root_out_dir}/common/samples/module/${module.prefix}/{{source_file_part}}" ] 104 } 105 } 106 } 107 108 # All dynamic libraries to be copied to the path "/previewer/common/bin/", 109 # which are related to the previewer, can be added to this script. 110 ohos_copy("copy_preview_shared_library") { 111 deps = [] 112 foreach(module, napi_modules) { 113 deps += [ ":copy_napi_${module.prefix}libs" ] 114 } 115 116 sources = [ 117 "//base/global/system_resources/fonts", 118 "//foundation/arkui/ace_engine/adapter/preview/sdk/fontconfig.json", 119 "//third_party/icu/ohos_icu4j/data/icudt69l.dat", 120 ] 121 122 foreach(item, common_bin) { 123 subsystem_name = item.subsystem_name 124 part_name = item.part_name 125 deps += [ item.label ] 126 out_path = get_label_info(item.label, "root_out_dir") 127 lib_names = [] 128 if (defined(item.lib_names)) { 129 lib_names += item.lib_names 130 } else { 131 lib_names += 132 [ string_replace(get_label_info(item.label, "name"), "lib", "", 1) ] 133 } 134 foreach(lib_name, lib_names) { 135 sources += [ "${out_path}/${subsystem_name}/${part_name}/lib${lib_name}${dylib_suffix}" ] 136 } 137 } 138 139 outputs = [ "${root_out_dir}/common/samples/{{source_file_part}}" ] 140 } 141} else { 142 ohos_copy("copy_resource_dynamic_library") { 143 if (use_mac) { 144 sources = [ 145 "//prebuilts/ace-toolkit/preview/rich/lib/mac/tv/libhmicuuc${dylib_suffix}", 146 "//prebuilts/ace-toolkit/preview/rich/lib/mac/tv/libresourcemanager_mac${dylib_suffix}", 147 ] 148 } else { 149 sources = [ 150 "//prebuilts/ace-toolkit/preview/rich/lib/windows/tv/libhmicuuc${dylib_suffix}", 151 "//prebuilts/ace-toolkit/preview/rich/lib/windows/tv/libresourcemanager_win${dylib_suffix}", 152 ] 153 } 154 outputs = [ "${root_out_dir}/common/samples/{{source_file_part}}" ] 155 } 156} 157 158# Install packages 159group("previewer_demo") { 160 if (is_wearable_product) { 161 deps = [ ":ace_wearable_test" ] 162 } else { 163 deps = [ 164 ":ace_car_test", 165 ":ace_card_test", 166 ":ace_phone_test", 167 ":ace_tablet_test", 168 ":ace_tv_test", 169 ] 170 } 171} 172