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  branch_protector_ret = "pac_ret"
79  branch_protector_frt = "bti"
80
81  configs = [
82    ":nweb_config",
83    ":nweb_glue_interface",
84  ]
85  public_configs = [ ":nweb_public_interface" ]
86  sources = [
87    "src/nweb_enhance_surface_adapter.cpp",
88    "src/nweb_helper.cpp",
89    "src/nweb_hisysevent.cpp",
90    "src/nweb_surface_adapter.cpp",
91  ]
92
93  deps = [
94    ":alias",
95    ":context-menu",
96    ":web.para",
97    ":web.para.dac",
98    ":web_config",
99    ":web_configs",
100    "${webview_path}/ohos_glue:ohos_adapter_glue_source",
101    "${webview_path}/ohos_glue:ohos_base_glue_source",
102    "${webview_path}/ohos_glue:ohos_nweb_glue_source",
103    "${webview_path}/sa:app_fwk_update",
104  ]
105
106  external_deps = [
107    "ability_runtime:ability_manager",
108    "ability_runtime:app_context",
109    "ability_runtime:app_manager",
110    "bundle_framework:appexecfwk_base",
111    "bundle_framework:appexecfwk_core",
112    "c_utils:utils",
113    "config_policy:configpolicy_util",
114    "graphic_2d:libcomposer",
115    "graphic_2d:librender_service_client",
116    "graphic_surface:surface",
117    "hilog:libhilog",
118    "hisysevent:libhisysevent",
119    "i18n:intl_util",
120    "init:libbegetutil",
121    "input:libmmi-client",
122    "ipc:ipc_core",
123    "libxml2:libxml2",
124    "window_manager:libwm",
125  ]
126
127  innerapi_tags = [ "platformsdk" ]
128  part_name = "webview"
129  subsystem_name = "web"
130}
131
132ohos_prebuilt_etc("nweb_hap") {
133  source = web_source
134  module_install_dir = "app/${webview_package_name}"
135  part_name = "webview"
136  subsystem_name = "web"
137  license_file = "./prebuilts/NOTICE"
138}
139
140ohos_prebuilt_etc("web_config") {
141  source = "${webview_root_path}/ohos_nweb/etc/web_config.xml"
142  subsystem_name = "web"
143  part_name = "webview"
144  module_install_dir = "etc/web"
145}
146
147ohos_prebuilt_etc("web.para") {
148  source = "${webview_root_path}/ohos_nweb/etc/para/web.para"
149  subsystem_name = "web"
150  part_name = "webview"
151  module_install_dir = "etc/param"
152}
153
154ohos_prebuilt_etc("web.para.dac") {
155  source = "${webview_root_path}/ohos_nweb/etc/para/web.para.dac"
156  subsystem_name = "web"
157  part_name = "webview"
158  module_install_dir = "etc/param"
159}
160
161ohos_prebuilt_etc("alias") {
162  source = "${webview_root_path}/ohos_nweb/etc/alias.svg"
163  subsystem_name = "web"
164  part_name = "webview"
165  relative_install_dir = "webview/ohos_nweb"
166}
167
168ohos_prebuilt_etc("context-menu") {
169  source = "${webview_root_path}/ohos_nweb/etc/context-menu.svg"
170  subsystem_name = "web"
171  part_name = "webview"
172  relative_install_dir = "webview/ohos_nweb"
173}
174
175ohos_executable("chrome_crashpad_handler") {
176  output_name = "arkweb_crashpad_handler"
177
178  install_enable = true
179
180  include_dirs = [ "include" ]
181
182  sources = [ "src/nweb_crashpad_handler_main.cpp" ]
183
184  external_deps = [ "hilog:libhilog" ]
185
186  if (target_cpu == "arm64") {
187    branch_protector_ret = "pac_ret"
188    branch_protector_frt = "bti"
189    defines += [ "webview_arm64" ]
190  } else if (target_cpu == "arm") {
191    defines += [ "webview_arm" ]
192  } else if (target_cpu == "x86_64") {
193    defines += [ "webview_x86_64" ]
194  }
195
196  subsystem_name = "web"
197  part_name = "webview"
198}
199