1# Copyright (c) 2022-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("//arkcompiler/ets_frontend/es2panda/es2abc_config.gni")
15import("//build/ohos.gni")
16import("//foundation/ability/ability_runtime/ability_runtime.gni")
17import("//foundation/arkui/ace_engine/build/ace_gen_obj.gni")
18
19es2abc_gen_abc("gen_abc_js_mock") {
20  js_mock_path =
21      get_label_info("${previewer_path}/automock:gen_snapshot_jsmock",
22                     "target_out_dir") + "/dist/jsMockSystemPlugin.js"
23  src_js = rebase_path(js_mock_path)
24  dst_file = rebase_path(target_out_dir + "/jsMockSystemPlugin.abc")
25  in_puts = [ js_mock_path ]
26  out_puts = [ target_out_dir + "/jsMockSystemPlugin.abc" ]
27  extra_dependencies = [ "${previewer_path}/automock:gen_snapshot_jsmock" ]
28}
29
30gen_obj("js_mock_abc") {
31  input = get_label_info(":gen_abc_js_mock", "target_out_dir") +
32          "/jsMockSystemPlugin.abc"
33
34  if (is_mac || is_mingw) {
35    output = target_out_dir + "/js_mock_abc.c"
36  } else {
37    output = target_out_dir + "/js_mock_abc.o"
38  }
39
40  snapshot_dep = [ ":gen_abc_js_mock" ]
41}
42
43config("ability_simulator_public_config") {
44  include_dirs = [ "include" ]
45  cflags_cc = [ "-Wno-unused-variable" ]
46}
47
48ohos_shared_library("ability_simulator_inner") {
49  if (is_mingw || is_mac) {
50    if (is_mingw) {
51      defines = [
52        "WINDOWS_PLATFORM",
53        "NOGDI",
54      ]
55    }
56
57    cflags = [ "-std=c++17" ]
58
59    include_dirs = [
60      "${ability_runtime_path}/interfaces/kits/native/ability/native/ability_business_error",
61      "${ability_runtime_native_path}/runtime",
62      "${ability_runtime_innerkits_path}/ability_manager/include",
63      "${ability_runtime_innerkits_path}/runtime/include",
64      "${windowmanager_path}/previewer/include",
65      "${windowmanager_path}/previewer/mock",
66      "${windowmanager_path}/previewer/mock/transaction",
67      "${windowmanager_path}/previewer/mock/ui",
68      "${windowmanager_path}/interfaces/innerkits/wm",
69      "${windowmanager_path}/interfaces/kits/napi/window_runtime/window_stage_napi",
70      "include/bundle_parser",
71    ]
72
73    sources = [
74      "${ability_runtime_native_path}/ability/native/ability_business_error/ability_business_error.cpp",
75      "${ability_runtime_native_path}/runtime/js_module_searcher.cpp",
76      "src/ability_context.cpp",
77      "src/ability_stage_context.cpp",
78      "src/bundle_parser/ability_info.cpp",
79      "src/bundle_parser/application_info.cpp",
80      "src/bundle_parser/bundle_container.cpp",
81      "src/bundle_parser/extension_ability_info.cpp",
82      "src/bundle_parser/hap_module_info.cpp",
83      "src/bundle_parser/inner_bundle_info.cpp",
84      "src/bundle_parser/module_info.cpp",
85      "src/bundle_parser/module_profile.cpp",
86      "src/common_func.cpp",
87      "src/js_ability_context.cpp",
88      "src/js_ability_stage_context.cpp",
89      "src/js_application_context_utils.cpp",
90      "src/js_console_log.cpp",
91      "src/js_context_utils.cpp",
92      "src/js_data_converter.cpp",
93      "src/js_resource_manager_utils.cpp",
94      "src/js_runtime_utils.cpp",
95      "src/js_timer.cpp",
96      "src/resource_manager_addon.cpp",
97      "src/simulator.cpp",
98    ]
99
100    public_configs = [
101      ":ability_simulator_public_config",
102      "${simulator_path}/common:ability_simulator_common_config",
103    ]
104
105    configs = [ "${windowmanager_path}/previewer:previewer_window_config" ]
106
107    deps = [ ":gen_obj_src_js_mock_abc" ]
108
109    external_deps = [
110      "ability_base:string_utils",
111      "ets_runtime:libark_jsruntime",
112      "ets_utils:console",
113      "ets_utils:timer",
114      "hilog:libhilog",
115      "json:nlohmann_json_static",
116      "jsoncpp:jsoncpp_static",
117      "napi:ace_napi",
118      "window_manager:previewer_window",
119      "window_manager:previewer_window_napi",
120    ]
121
122    if (is_mingw) {
123      external_deps += [ "resource_management:win_resmgr" ]
124    } else {
125      external_deps += [ "resource_management:mac_resmgr" ]
126    }
127  }
128
129  output_name = "ability_simulator"
130  innerapi_tags = [ "platformsdk" ]
131  part_name = "ability_runtime"
132  subsystem_name = "ability"
133}
134
135group("ability_simulator") {
136  if (is_mingw || is_mac) {
137    public_deps = [ ":ability_simulator_inner" ]
138  }
139}
140