• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (c) 2024 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/config/clang/clang.gni")
15import("//build/ohos.gni")
16import("jsvm.gni")
17
18ohos_prebuilt_etc("jit_enable_list_appid") {
19  relative_install_dir = "jsvm"
20  source = "./jit_enable_list_appid.conf"
21  part_name = "jsvm"
22  subsystem_name = "arkcompiler"
23}
24
25dependency_tag = "default"
26js_engine_url = "//vendor/${dependency_tag}/binary/artifacts/js_engine_url/"
27
28action("copy_v8") {
29  external_deps = []
30  deps = []
31  script = "copy_v8.sh"
32  sources = []
33  outputs = [
34    "$target_gen_dir/libv8_shared.so",
35    "$target_gen_dir/v8-include",
36  ]
37  args = [
38    "--target_gen_dir",
39    rebase_path("$target_gen_dir"),
40    rebase_path("${js_engine_url}"),
41    target_cpu,
42  ]
43}
44
45action("copy_llhttp") {
46  external_deps = []
47  deps = []
48  script = "copy_llhttp.sh"
49  sources = []
50  outputs = [
51    "$target_gen_dir/llhttp/src/api.c",
52    "$target_gen_dir/llhttp/src/http.c",
53    "$target_gen_dir/llhttp/src/llhttp.c",
54    "$target_gen_dir/llhttp/include",
55  ]
56  args = [
57    "--target_gen_dir",
58    rebase_path("$target_gen_dir"),
59  ]
60}
61
62config("libv8_config") {
63  include_dirs = [ "$target_gen_dir/v8-include" ]
64}
65
66ohos_prebuilt_shared_library("libv8") {
67  deps = [ ":copy_v8" ]
68  source = "$target_gen_dir/libv8_shared.so"
69  output = "libv8_shared.so"
70  public_configs = [ ":libv8_config" ]
71
72  subsystem_name = "arkcompiler"
73  part_name = "jsvm"
74
75  install_enable = true
76  install_images = [ "system" ]
77}
78
79config("llhttp_config") {
80  include_dirs = [ "$target_gen_dir/llhttp/include" ]
81}
82
83ohos_static_library("llhttp") {
84  deps = [ ":copy_llhttp" ]
85  sources = [
86    "$target_gen_dir/llhttp/src/api.c",
87    "$target_gen_dir/llhttp/src/http.c",
88    "$target_gen_dir/llhttp/src/llhttp.c",
89  ]
90
91  public_configs = [ ":llhttp_config" ]
92
93  subsystem_name = "arkcompiler"
94  part_name = "jsvm"
95}
96
97config("public_jsvm_config") {
98  include_dirs = [ "interface/kits" ]
99}
100
101ohos_prebuilt_shared_library("libjsvm") {
102  deps = [
103    ":jit_enable_list_appid",
104    ":build_libjsvm",
105  ]
106
107  public_configs = [ ":public_jsvm_config" ]
108  if (is_asan && support_hwasan && use_hwasan) {
109    source = "$target_gen_dir/asan/libjsvm.so"
110  } else {
111    source = "$target_gen_dir/libjsvm.so"
112  }
113  subsystem_name = "arkcompiler"
114  part_name = "jsvm"
115
116  install_enable = true
117  install_images = [ "system" ]
118  innerapi_tags = [ "ndk" ]
119}
120
121action("build_libjsvm") {
122  external_deps = [
123    "bounds_checking_function:libsec_static",
124    "hilog:libhilog",
125    "hisysevent:libhisysevent",
126    "hitrace:hitrace_meter",
127    "icu:shared_icui18n",
128    "icu:shared_icuuc",
129    "init:libbegetutil",
130    "libuv:uv",
131    "openssl:libcrypto_shared",
132    "openssl:libssl_shared",
133    "resource_schedule_service:ressched_client",
134    "zlib:libz",
135  ]
136
137  deps = [
138    ":libv8",
139    ":llhttp",
140  ]
141  configs = []
142  script = "build_jsvm.sh"
143  sources = []
144  support_and_use_hwasan = support_hwasan && use_hwasan
145  if (is_asan && support_and_use_hwasan) {
146    outputs = [ "$target_gen_dir/asan/libjsvm.so" ]
147  } else {
148    outputs = [ "$target_gen_dir/libjsvm.so" ]
149  }
150  args = [
151    "--target_gen_dir",
152    rebase_path("$target_gen_dir"),
153    "--target_out_dir",
154    rebase_path("$root_out_dir"),
155    "--target_cpu",
156    "$target_cpu",
157    "--target_platform",
158    "$target_platform",
159    "--prefix",
160    rebase_path("${js_engine_url}/llvm/bin"),
161    "--sysroot",
162    rebase_path("$musl_sysroot"),
163    "--is_asan",
164    "$is_asan",
165    "--use_hwasan",
166    "$support_and_use_hwasan",
167    "{{include_dirs}}",
168    "--cmake_path",
169    rebase_path("//prebuilts/cmake/linux-x86/bin/cmake"),
170    "--dependency_tag",
171    "${dependency_tag}",
172    "--jsvm_path",
173    rebase_path("."),
174  ]
175  if (use_clang_coverage) {
176    args += [
177      "--target_clang_coverage",
178      "$use_clang_coverage",
179    ]
180  }
181}
182
183group("jsvm_packages") {
184  deps = [ ":libjsvm" ]
185}
186