1# Copyright (c) 2022 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("../config.gni")
16import("../web_aafwk.gni")
17
18webview_root_path = webview_path
19if (target_cpu == "arm64") {
20  web_source = "prebuilts/arm64/ArkWebCore.hap"
21  defines = [ "webview_arm64" ]
22} else if (target_cpu == "arm") {
23  web_source = "prebuilts/arm/ArkWebCore.hap"
24  defines = []
25} else if (target_cpu == "x86_64") {
26  web_source = "prebuilts/arm64/ArkWebCore.hap"
27  defines = [ "webview_x86_64" ]
28}
29
30defines += [
31  "WEBVIEW_PACKAGE_NAME=\"${webview_package_name}\"",
32  "WEBVIEW_SANDBOX_LIB_PATH=\"${webview_sandbox_lib_path}\"",
33  "WEBVIEW_CRASHPAD_HANDLER_SO=\"${webview_crashpad_handler_so}\"",
34  "WEBVIEW_SANDBOX_RELATIVE_LIB_PATH=\"${webview_sandbox_relative_lib_path}\"",
35  "WEBVIEW_ENGINE_SO=\"${webview_engine_so}\"",
36]
37
38config("nweb_config") {
39  include_dirs = [ "include" ]
40
41  cflags = [
42    "-Wall",
43    "-Werror",
44    "-g3",
45  ]
46}
47
48config("nweb_public_interface") {
49  include_dirs = [ "include" ]
50}
51
52config("nweb_glue_interface") {
53  include_dirs = [
54    "${target_gen_dir}/../ohos_glue",
55    "${target_gen_dir}/../ohos_glue/ohos_nweb/bridge",
56  ]
57}
58
59ohos_shared_library("web_configs") {
60  include_dirs = [ "include" ]
61  sources = [ "src/nweb_config_helper.cpp" ]
62
63  deps = [ ":web_config" ]
64
65  external_deps = [
66    "config_policy:configpolicy_util",
67    "hilog:libhilog",
68    "init:libbegetutil",
69    "libxml2:libxml2",
70  ]
71
72  part_name = "webview"
73  subsystem_name = "web"
74}
75
76ohos_shared_library("libnweb") {
77  output_name = "arkweb_core_loader"
78  if (target_cpu == "arm64") {
79    branch_protector_ret = "pac_ret"
80    branch_protector_frt = "bti"
81  }
82
83  configs = [
84    ":nweb_config",
85    ":nweb_glue_interface",
86  ]
87  public_configs = [ ":nweb_public_interface" ]
88  sources = [
89    "src/nweb_enhance_surface_adapter.cpp",
90    "src/nweb_helper.cpp",
91    "src/nweb_hisysevent.cpp",
92    "src/nweb_surface_adapter.cpp",
93  ]
94
95  deps = [
96    ":alias",
97    ":context-menu",
98    ":web.para",
99    ":web.para.dac",
100    ":web_config",
101    ":web_configs",
102    "${webview_path}/ohos_glue:ohos_adapter_glue_source",
103    "${webview_path}/ohos_glue:ohos_base_glue_source",
104    "${webview_path}/ohos_glue:ohos_nweb_glue_source",
105    "${webview_path}/sa:app_fwk_update",
106  ]
107
108  external_deps = [
109    "ability_runtime:ability_manager",
110    "ability_runtime:app_context",
111    "ability_runtime:app_manager",
112    "bundle_framework:appexecfwk_base",
113    "bundle_framework:appexecfwk_core",
114    "c_utils:utils",
115    "config_policy:configpolicy_util",
116    "graphic_2d:libcomposer",
117    "graphic_2d:librender_service_client",
118    "graphic_surface:surface",
119    "hilog:libhilog",
120    "hisysevent:libhisysevent",
121    "i18n:intl_util",
122    "init:libbegetutil",
123    "input:libmmi-client",
124    "ipc:ipc_core",
125    "libxml2:libxml2",
126    "window_manager:libwm",
127  ]
128
129  innerapi_tags = [ "platformsdk" ]
130  part_name = "webview"
131  subsystem_name = "web"
132}
133
134ohos_prebuilt_etc("nweb_hap") {
135  source = web_source
136  module_install_dir = "app/${webview_package_name}"
137  part_name = "webview"
138  subsystem_name = "web"
139  license_file = "./prebuilts/NOTICE"
140}
141
142ohos_prebuilt_etc("web_config") {
143  source = "${webview_root_path}/ohos_nweb/etc/web_config.xml"
144  subsystem_name = "web"
145  part_name = "webview"
146  module_install_dir = "etc/web"
147}
148
149ohos_prebuilt_etc("web.para") {
150  source = "${webview_root_path}/ohos_nweb/etc/para/web.para"
151  subsystem_name = "web"
152  part_name = "webview"
153  module_install_dir = "etc/param"
154}
155
156ohos_prebuilt_etc("web.para.dac") {
157  source = "${webview_root_path}/ohos_nweb/etc/para/web.para.dac"
158  subsystem_name = "web"
159  part_name = "webview"
160  module_install_dir = "etc/param"
161}
162
163ohos_prebuilt_etc("alias") {
164  source = "${webview_root_path}/ohos_nweb/etc/alias.svg"
165  subsystem_name = "web"
166  part_name = "webview"
167  relative_install_dir = "webview/ohos_nweb"
168}
169
170ohos_prebuilt_etc("context-menu") {
171  source = "${webview_root_path}/ohos_nweb/etc/context-menu.svg"
172  subsystem_name = "web"
173  part_name = "webview"
174  relative_install_dir = "webview/ohos_nweb"
175}
176
177ohos_executable("chrome_crashpad_handler") {
178  output_name = "arkweb_crashpad_handler"
179
180  install_enable = true
181
182  include_dirs = [ "include" ]
183
184  sources = [ "src/nweb_crashpad_handler_main.cpp" ]
185
186  external_deps = [ "hilog:libhilog" ]
187
188  if (target_cpu == "arm64") {
189    branch_protector_ret = "pac_ret"
190    branch_protector_frt = "bti"
191    defines += [ "webview_arm64" ]
192  } else if (target_cpu == "arm") {
193    defines += [ "webview_arm" ]
194  } else if (target_cpu == "x86_64") {
195    defines += [ "webview_x86_64" ]
196  }
197
198  subsystem_name = "web"
199  part_name = "webview"
200}
201