• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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/interfaces/napi/kits/napi_lib.gni")
17
18config("ace_pc_preview_config") {
19  cflags_cc = [
20    "-std=c++17",
21    "-Wno-c99-designator",
22    "-Wno-unknown-warning-option",
23    "-Wno-thread-safety-attributes",
24  ]
25
26  include_dirs = [
27    "$ace_root",
28    "$ace_root/frameworks",
29    "$flutter_root/engine",
30    "$flutter_root/engine/flutter/shell/platform/common/cpp/public",
31    "$flutter_root/engine/ace_adapter/flutter/shell/platform/glfw/public",
32    "$flutter_root/skia",
33    "$flutter_root/glfw/include",
34  ]
35}
36
37if (use_mac) {
38  platform = "mac"
39} else if (use_linux) {
40  platform = "linux"
41} else {
42  platform = "windows"
43}
44platform_defines = []
45foreach(item, ace_platforms) {
46  if (platform == item.name) {
47    if (defined(item.config)) {
48      platform_config = item.config
49      if (defined(platform_config.defines)) {
50        platform_defines = platform_config.defines
51      }
52    }
53  }
54}
55
56ace_devices = [
57  "phone",
58  "tv",
59  "wearable",
60  "tablet",
61  "card",
62  "car",
63]
64foreach(device, ace_devices) {
65  ohos_executable("ace_${device}_test") {
66    defines = platform_defines
67    defines += [ "USE_GLFW_WINDOW" ]
68    configs = [ ":ace_pc_preview_config" ]
69    ohos_test = true
70    test_output_dir = "$root_out_dir/common/samples"
71    sources = [
72      "ace_${device}_test.cpp",
73      "key_input_handler.cpp",
74      "touch_event_handler_flutter.cpp",
75    ]
76    deps = [
77      ":copy_napi_modules_shared_library",
78      ":copy_preview_shared_library",
79      "$ace_napi:ace_napi",
80    ]
81    include_dirs = [ "//third_party/flutter/glfw/include" ]
82    if (defined(platform_config.enable_rosen_backend) &&
83        platform_config.enable_rosen_backend) {
84      sources -= [ "touch_event_handler_flutter.cpp" ]
85      sources += [ "touch_event_handler_rs.cpp" ]
86      defines += [ "ENABLE_ROSEN_BACKEND" ]
87      deps += [ "//foundation/graphic/graphic_2d/rosen/modules/glfw_render_context:libglfw_render_context" ]
88    }
89    if (use_mac) {
90      defines += [ "MAC_PLATFORM" ]
91      deps += [ "$ace_root/adapter/preview/build:libace_engine_mac" ]
92    } else if (use_mingw_win) {
93      defines += [ "WINDOWS_PLATFORM" ]
94      deps += [ "$ace_root/adapter/preview/build:libace_engine_windows" ]
95      libs = [ "pthread" ]
96    } else if (use_linux) {
97      defines += [ "LINUX_PLATFORM" ]
98      deps += [ "$ace_root/adapter/preview/build:libace_engine_linux" ]
99    }
100  }
101}
102
103# Avoid conditional judgment branches caused by dynamic library suffixes.
104if (use_mac) {
105  dylib_suffix = ".dylib"
106} else if (use_mingw_win) {
107  dylib_suffix = ".dll"
108} else if (use_linux) {
109  dylib_suffix = ".so"
110}
111
112if (is_standard_system) {
113  # All dynamic libraries to be copied to the path "/previewer/common/bin/module/",
114  # which are called by the napi framework, can be added to this script.
115  ohos_copy("copy_napi_modules_shared_library") {
116    deps = []
117    sources = []
118    foreach(module, common_napi_libs) {
119      out_path = get_label_info("$ace_root/interfaces/napi/kits:${module}",
120                                "root_out_dir")
121      deps += [ "$ace_root/interfaces/napi/kits:${module}" ]
122      sources += [ "${out_path}/arkui/ace_engine/lib${module}${dylib_suffix}" ]
123    }
124
125    # Set the output directory for all dynamic libraries.
126    outputs = [ root_out_dir + "/common/samples/module/{{source_file_part}}" ]
127  }
128
129  # All dynamic libraries to be copied to the path "/previewer/common/bin/",
130  # which are related to the previewer, can be added to this script.
131  ohos_copy("copy_preview_shared_library") {
132    deps = []
133    sources = []
134
135    # Add some resources
136    # Add ohos fonts
137    sources += [
138      "//base/global/system_resources/fonts",
139      "//foundation/arkui/ace_engine/adapter/preview/sdk/fontconfig.json",
140    ]
141
142    # Add the dynamic library with the same name on the mac and windows system here.
143    # Add dynamic library "libcurl_shared"
144    curl_path = get_label_info("//third_party/curl:curl_shared", "root_out_dir")
145    deps += [ "//third_party/curl:curl_shared" ]
146    sources += [ curl_path + "/thirdparty/curl/libcurl_shared${dylib_suffix}" ]
147
148    # Add dynamic library "libsec_shared"
149    sec_path =
150        get_label_info("//third_party/bounds_checking_function:libsec_shared",
151                       "root_out_dir")
152    deps += [ "//third_party/bounds_checking_function:libsec_shared" ]
153    sources +=
154        [ sec_path + "/thirdparty/bounds_checking_function/libsec_shared" +
155          dylib_suffix ]
156
157    # Add napi framework-related dynamic libraries
158    ace_napi_path =
159        get_label_info("//foundation/arkui/napi:ace_napi", "root_out_dir")
160    uv_path = get_label_info("//third_party/libuv:uv", "root_out_dir")
161    icu_path =
162        get_label_info("//third_party/icu/icu4c:shared_icuuc", "root_out_dir")
163    deps += [
164      "$ace_napi:ace_napi",
165      "//third_party/icu/icu4c:shared_icui18n",
166      "//third_party/icu/icu4c:shared_icuuc",
167      "//third_party/libuv:uv",
168    ]
169    sources += [
170      "$ace_napi_path/arkui/napi/libace_napi${dylib_suffix}",
171      "$icu_path/thirdparty/icu/libhmicui18n${dylib_suffix}",
172      "$icu_path/thirdparty/icu/libhmicuuc${dylib_suffix}",
173      "$uv_path/thirdparty/libuv/libuv${dylib_suffix}",
174    ]
175
176    # Add ark engine-related dynamic libraries
177    ark_js_path = get_label_info("//arkcompiler/ets_runtime:libark_jsruntime",
178                                 "root_out_dir")
179    deps += [
180      "$ace_napi:ace_napi_ark",
181      "//arkcompiler/ets_runtime:libark_jsruntime",
182    ]
183    sources += [
184      "$ace_napi_path/arkui/napi/libace_napi_ark${dylib_suffix}",
185      "$ark_js_path/arkcompiler/ets_runtime/libark_jsruntime${dylib_suffix}",
186      "//third_party/icu/ohos_icu4j/data/icudt69l.dat",
187    ]
188
189    # Add dynamic libraries with different names on mac and windows systems here.
190    if (use_mac) {
191      ace_engine_path =
192          get_label_info("$ace_root/adapter/preview/build::libace_engine_mac",
193                         "root_out_dir") + "/common/common/libace_engine_mac" +
194          dylib_suffix
195      resource_manager_path = get_label_info(
196                                  "//base/global/resource_management/frameworks/resmgr:global_resmgr_mac",
197                                  "root_out_dir") + "/global/resource_management/libglobal_resmgr_mac${dylib_suffix}"
198      deps += [
199        "$ace_root/adapter/preview/build:libace_engine_mac",
200        "//base/global/resource_management/frameworks/resmgr:global_resmgr_mac",
201      ]
202    } else if (use_mingw_win) {
203      ace_engine_path =
204          get_label_info(
205              "$ace_root/adapter/preview/build::libace_engine_windows",
206              "root_out_dir") + "/common/common/libace_engine_windows" +
207          dylib_suffix
208      resource_manager_path = get_label_info(
209                                  "//base/global/resource_management/frameworks/resmgr:global_resmgr_win",
210                                  "root_out_dir") + "/global/resource_management/libglobal_resmgr_win${dylib_suffix}"
211      deps += [
212        "$ace_root/adapter/preview/build:libace_engine_windows",
213        "//base/global/resource_management/frameworks/resmgr:global_resmgr_win",
214      ]
215    } else if (use_linux) {
216      ace_engine_path =
217          get_label_info("$ace_root/adapter/preview/build::libace_engine_linux",
218                         "root_out_dir") +
219          "/common/common/libace_engine_linux" + dylib_suffix
220      resource_manager_path = get_label_info(
221                                  "//base/global/resource_management/frameworks/resmgr:global_resmgr_linux",
222                                  "root_out_dir") + "/global/resource_management/libglobal_resmgr_linux${dylib_suffix}"
223      deps += [
224        "$ace_root/adapter/preview/build:libace_engine_linux",
225        "//base/global/resource_management/frameworks/resmgr:global_resmgr_linux",
226      ]
227    }
228    sources += [
229      ace_engine_path,
230      resource_manager_path,
231    ]
232
233    # Set the output directory for all dynamic libraries.
234    outputs = [ root_out_dir + "/common/samples/{{source_file_part}}" ]
235  }
236} else {
237  ohos_copy("copy_resource_dynamic_library") {
238    if (use_mac) {
239      sources = [
240        "//prebuilts/ace-toolkit/preview/rich/lib/mac/tv/libhmicuuc" +
241            dylib_suffix,
242        "//prebuilts/ace-toolkit/preview/rich/lib/mac/tv/libresourcemanager_mac${dylib_suffix}",
243      ]
244    } else {
245      sources = [
246        "//prebuilts/ace-toolkit/preview/rich/lib/windows/tv/libhmicuuc" +
247            dylib_suffix,
248        "//prebuilts/ace-toolkit/preview/rich/lib/windows/tv/libresourcemanager_win${dylib_suffix}",
249      ]
250    }
251    outputs = [ root_out_dir + "/common/samples/{{source_file_part}}" ]
252  }
253}
254
255# Install packages
256group("previewer_demo") {
257  if (is_wearable_product) {
258    deps = [ ":ace_wearable_test" ]
259  } else {
260    deps = [
261      ":ace_car_test",
262      ":ace_card_test",
263      ":ace_phone_test",
264      ":ace_tablet_test",
265      ":ace_tv_test",
266    ]
267  }
268}
269