1b1994897Sopenharmony_ci# Copyright (c) 2021-2022 Huawei Device Co., Ltd.
2b1994897Sopenharmony_ci# Licensed under the Apache License, Version 2.0 (the "License");
3b1994897Sopenharmony_ci# you may not use this file except in compliance with the License.
4b1994897Sopenharmony_ci# You may obtain a copy of the License at
5b1994897Sopenharmony_ci#
6b1994897Sopenharmony_ci# http://www.apache.org/licenses/LICENSE-2.0
7b1994897Sopenharmony_ci#
8b1994897Sopenharmony_ci# Unless required by applicable law or agreed to in writing, software
9b1994897Sopenharmony_ci# distributed under the License is distributed on an "AS IS" BASIS,
10b1994897Sopenharmony_ci# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11b1994897Sopenharmony_ci# See the License for the specific language governing permissions and
12b1994897Sopenharmony_ci# limitations under the License.
13b1994897Sopenharmony_ci
14b1994897Sopenharmony_ciimport("//arkcompiler/runtime_core/ark_config.gni")
15b1994897Sopenharmony_ci
16b1994897Sopenharmony_ciconfig("arkfile_public_config") {
17b1994897Sopenharmony_ci  include_dirs = [
18b1994897Sopenharmony_ci    "$ark_root/libpandafile",
19b1994897Sopenharmony_ci    "$ark_root/libziparchive",
20b1994897Sopenharmony_ci    "$target_gen_dir",
21b1994897Sopenharmony_ci    "$target_gen_dir/include",
22b1994897Sopenharmony_ci  ]
23b1994897Sopenharmony_ci
24b1994897Sopenharmony_ci  defines = []
25b1994897Sopenharmony_ci  if (is_ohos && !is_standard_system) {
26b1994897Sopenharmony_ci    defines += [ "ENABLE_FULL_FILE_FIELDS" ]
27b1994897Sopenharmony_ci  }
28b1994897Sopenharmony_ci}
29b1994897Sopenharmony_ci
30b1994897Sopenharmony_ciconfig("arkfile_runtime_public_config") {
31b1994897Sopenharmony_ci  include_dirs = [
32b1994897Sopenharmony_ci    "$ark_root/libpandafile",
33b1994897Sopenharmony_ci    "$ark_root/libziparchive",
34b1994897Sopenharmony_ci    "$target_gen_dir",
35b1994897Sopenharmony_ci    "$target_gen_dir/include",
36b1994897Sopenharmony_ci  ]
37b1994897Sopenharmony_ci
38b1994897Sopenharmony_ci  defines = [ "ERROR_AS_FATAL" ]
39b1994897Sopenharmony_ci  if (is_ohos && !is_standard_system) {
40b1994897Sopenharmony_ci    defines += [ "ENABLE_FULL_FILE_FIELDS" ]
41b1994897Sopenharmony_ci  }
42b1994897Sopenharmony_ci}
43b1994897Sopenharmony_ci
44b1994897Sopenharmony_ciconfig("data_protect_configs") {
45b1994897Sopenharmony_ci  cflags_cc = [ "-march=armv8.4-a" ]
46b1994897Sopenharmony_ci  defines = [ "PANDA_ENABLE_DATA_PROTECT" ]
47b1994897Sopenharmony_ci}
48b1994897Sopenharmony_ci
49b1994897Sopenharmony_ciconfig("arkfile_fuzz_config") {
50b1994897Sopenharmony_ci  configs = [ "$build_root/config/compiler:exceptions" ]
51b1994897Sopenharmony_ci  defines = [ "SUPPORT_KNOWN_EXCEPTION" ]
52b1994897Sopenharmony_ci}
53b1994897Sopenharmony_ci
54b1994897Sopenharmony_ciconfig("arkfile_verifier_config") {
55b1994897Sopenharmony_ci  include_dirs = [
56b1994897Sopenharmony_ci    "$ark_root/libpandafile",
57b1994897Sopenharmony_ci    "$ark_root/libziparchive",
58b1994897Sopenharmony_ci    "$target_gen_dir",
59b1994897Sopenharmony_ci    "$target_gen_dir/include",
60b1994897Sopenharmony_ci  ]
61b1994897Sopenharmony_ci
62b1994897Sopenharmony_ci  defines = []
63b1994897Sopenharmony_ci  if (is_ohos && !is_standard_system) {
64b1994897Sopenharmony_ci    defines += [ "ENABLE_FULL_FILE_FIELDS" ]
65b1994897Sopenharmony_ci  }
66b1994897Sopenharmony_ci
67b1994897Sopenharmony_ci  defines += [ "FATAL_AS_ERROR" ]
68b1994897Sopenharmony_ci}
69b1994897Sopenharmony_ci
70b1994897Sopenharmony_cilibarkfile_sources = [
71b1994897Sopenharmony_ci  "annotation_data_accessor.cpp",
72b1994897Sopenharmony_ci  "bytecode_emitter.cpp",
73b1994897Sopenharmony_ci  "class_data_accessor.cpp",
74b1994897Sopenharmony_ci  "code_data_accessor.cpp",
75b1994897Sopenharmony_ci  "debug_data_accessor.cpp",
76b1994897Sopenharmony_ci  "debug_info_extractor.cpp",
77b1994897Sopenharmony_ci  "field_data_accessor.cpp",
78b1994897Sopenharmony_ci  "file.cpp",
79b1994897Sopenharmony_ci  "file_format_version.cpp",
80b1994897Sopenharmony_ci  "file_item_container.cpp",
81b1994897Sopenharmony_ci  "file_items.cpp",
82b1994897Sopenharmony_ci  "file_writer.cpp",
83b1994897Sopenharmony_ci  "literal_data_accessor.cpp",
84b1994897Sopenharmony_ci  "method_data_accessor.cpp",
85b1994897Sopenharmony_ci  "method_handle_data_accessor.cpp",
86b1994897Sopenharmony_ci  "module_data_accessor.cpp",
87b1994897Sopenharmony_ci  "pgo.cpp",
88b1994897Sopenharmony_ci  "util/collect_util.cpp",
89b1994897Sopenharmony_ci]
90b1994897Sopenharmony_ci
91b1994897Sopenharmony_cilibarkfile_configs = [
92b1994897Sopenharmony_ci  "$ark_root:ark_config",
93b1994897Sopenharmony_ci  "$ark_root/libpandabase:arkbase_public_config",
94b1994897Sopenharmony_ci  ":arkfile_public_config",
95b1994897Sopenharmony_ci]
96b1994897Sopenharmony_ci
97b1994897Sopenharmony_cilibarkfile_runtime_configs = [
98b1994897Sopenharmony_ci  "$ark_root:ark_config",
99b1994897Sopenharmony_ci  "$ark_root/libpandabase:arkbase_public_config",
100b1994897Sopenharmony_ci  ":arkfile_runtime_public_config",
101b1994897Sopenharmony_ci]
102b1994897Sopenharmony_ci
103b1994897Sopenharmony_ciohos_static_library("arkfile_header_deps") {
104b1994897Sopenharmony_ci  deps = [
105b1994897Sopenharmony_ci    ":isa_gen_libarkfile_bytecode_emitter_def_gen_h",
106b1994897Sopenharmony_ci    ":isa_gen_libarkfile_bytecode_emitter_gen_h",
107b1994897Sopenharmony_ci    ":isa_gen_libarkfile_bytecode_instruction-inl_gen_h",
108b1994897Sopenharmony_ci    ":isa_gen_libarkfile_bytecode_instruction_enum_gen_h",
109b1994897Sopenharmony_ci    ":isa_gen_libarkfile_file_format_version_h",
110b1994897Sopenharmony_ci    ":isa_gen_libarkfile_tests_bytecode_emitter_tests_gen_h",
111b1994897Sopenharmony_ci    ":libarkfile_type_gen_h",
112b1994897Sopenharmony_ci    ":source_lang_enum_h",
113b1994897Sopenharmony_ci    "$ark_root/libpandabase:arkbase_header_deps",
114b1994897Sopenharmony_ci  ]
115b1994897Sopenharmony_ci  part_name = "runtime_core"
116b1994897Sopenharmony_ci  subsystem_name = "arkcompiler"
117b1994897Sopenharmony_ci}
118b1994897Sopenharmony_ci
119b1994897Sopenharmony_ciohos_static_library("libarkfile_static") {
120b1994897Sopenharmony_ci  sources = libarkfile_sources
121b1994897Sopenharmony_ci
122b1994897Sopenharmony_ci  public_configs = libarkfile_configs
123b1994897Sopenharmony_ci
124b1994897Sopenharmony_ci  if (enabled_pac_data_protect) {
125b1994897Sopenharmony_ci    configs = libarkfile_configs
126b1994897Sopenharmony_ci    configs += [ ":data_protect_configs" ]
127b1994897Sopenharmony_ci  }
128b1994897Sopenharmony_ci
129b1994897Sopenharmony_ci  deps = [
130b1994897Sopenharmony_ci    ":arkfile_header_deps",
131b1994897Sopenharmony_ci    "$ark_root/libpandabase:libarkbase_static",
132b1994897Sopenharmony_ci    "$ark_root/libziparchive:libarkziparchive_static",
133b1994897Sopenharmony_ci  ]
134b1994897Sopenharmony_ci
135b1994897Sopenharmony_ci  if (is_arkui_x) {
136b1994897Sopenharmony_ci    deps += [
137b1994897Sopenharmony_ci      "$ark_third_party_root/bounds_checking_function:libsec_static",
138b1994897Sopenharmony_ci      "$ark_third_party_root/zlib:libz",
139b1994897Sopenharmony_ci    ]
140b1994897Sopenharmony_ci  } else if (ark_standalone_build) {
141b1994897Sopenharmony_ci    external_deps = [
142b1994897Sopenharmony_ci      "zlib:shared_libz",
143b1994897Sopenharmony_ci      sdk_libc_secshared_dep,
144b1994897Sopenharmony_ci    ]
145b1994897Sopenharmony_ci  } else {
146b1994897Sopenharmony_ci    public_external_deps = [
147b1994897Sopenharmony_ci      "zlib:shared_libz",
148b1994897Sopenharmony_ci      sdk_libc_secshared_dep,
149b1994897Sopenharmony_ci    ]
150b1994897Sopenharmony_ci  }
151b1994897Sopenharmony_ci
152b1994897Sopenharmony_ci  if (enable_hilog) {
153b1994897Sopenharmony_ci    public_external_deps += [ "hilog:libhilog" ]
154b1994897Sopenharmony_ci  }
155b1994897Sopenharmony_ci
156b1994897Sopenharmony_ci  part_name = "runtime_core"
157b1994897Sopenharmony_ci  subsystem_name = "arkcompiler"
158b1994897Sopenharmony_ci}
159b1994897Sopenharmony_ci
160b1994897Sopenharmony_ciohos_static_library("libarkfile_runtime_static") {
161b1994897Sopenharmony_ci  sources = libarkfile_sources
162b1994897Sopenharmony_ci
163b1994897Sopenharmony_ci  public_configs = libarkfile_runtime_configs
164b1994897Sopenharmony_ci
165b1994897Sopenharmony_ci  if (enabled_pac_data_protect) {
166b1994897Sopenharmony_ci    configs = libarkfile_runtime_configs
167b1994897Sopenharmony_ci    configs += [ ":data_protect_configs" ]
168b1994897Sopenharmony_ci  }
169b1994897Sopenharmony_ci
170b1994897Sopenharmony_ci  deps = [
171b1994897Sopenharmony_ci    ":arkfile_header_deps",
172b1994897Sopenharmony_ci    "$ark_root/libpandabase:libarkbase_static",
173b1994897Sopenharmony_ci    "$ark_root/libziparchive:libarkziparchive_static",
174b1994897Sopenharmony_ci  ]
175b1994897Sopenharmony_ci
176b1994897Sopenharmony_ci  if (is_arkui_x) {
177b1994897Sopenharmony_ci    deps += [
178b1994897Sopenharmony_ci      "$ark_third_party_root/bounds_checking_function:libsec_static",
179b1994897Sopenharmony_ci      "$ark_third_party_root/zlib:libz",
180b1994897Sopenharmony_ci    ]
181b1994897Sopenharmony_ci  } else if (ark_standalone_build) {
182b1994897Sopenharmony_ci    external_deps = [
183b1994897Sopenharmony_ci      "zlib:shared_libz",
184b1994897Sopenharmony_ci      sdk_libc_secshared_dep,
185b1994897Sopenharmony_ci    ]
186b1994897Sopenharmony_ci  } else {
187b1994897Sopenharmony_ci    public_external_deps = [
188b1994897Sopenharmony_ci      "zlib:shared_libz",
189b1994897Sopenharmony_ci      sdk_libc_secshared_dep,
190b1994897Sopenharmony_ci    ]
191b1994897Sopenharmony_ci  }
192b1994897Sopenharmony_ci
193b1994897Sopenharmony_ci  if (enable_hilog) {
194b1994897Sopenharmony_ci    public_external_deps += [ "hilog:libhilog" ]
195b1994897Sopenharmony_ci  }
196b1994897Sopenharmony_ci
197b1994897Sopenharmony_ci  part_name = "runtime_core"
198b1994897Sopenharmony_ci  subsystem_name = "arkcompiler"
199b1994897Sopenharmony_ci}
200b1994897Sopenharmony_ci
201b1994897Sopenharmony_ciohos_source_set("libarkfile_static_fuzz") {
202b1994897Sopenharmony_ci  sources = libarkfile_sources
203b1994897Sopenharmony_ci
204b1994897Sopenharmony_ci  public_configs = libarkfile_configs
205b1994897Sopenharmony_ci  public_configs += [ ":arkfile_fuzz_config" ]
206b1994897Sopenharmony_ci
207b1994897Sopenharmony_ci  deps = [
208b1994897Sopenharmony_ci    ":arkfile_header_deps",
209b1994897Sopenharmony_ci    "$ark_root/libpandabase:libarkbase_static",
210b1994897Sopenharmony_ci    "$ark_root/libziparchive:libarkziparchive_static",
211b1994897Sopenharmony_ci  ]
212b1994897Sopenharmony_ci
213b1994897Sopenharmony_ci  if (!ark_standalone_build) {
214b1994897Sopenharmony_ci    public_external_deps = [
215b1994897Sopenharmony_ci      "zlib:libz",
216b1994897Sopenharmony_ci      sdk_libc_secshared_dep,
217b1994897Sopenharmony_ci    ]
218b1994897Sopenharmony_ci  } else {
219b1994897Sopenharmony_ci    external_deps = [
220b1994897Sopenharmony_ci      "zlib:libz",
221b1994897Sopenharmony_ci      sdk_libc_secshared_dep,
222b1994897Sopenharmony_ci    ]
223b1994897Sopenharmony_ci  }
224b1994897Sopenharmony_ci
225b1994897Sopenharmony_ci  if (enable_hilog) {
226b1994897Sopenharmony_ci    public_external_deps += [ "hilog:libhilog" ]
227b1994897Sopenharmony_ci  }
228b1994897Sopenharmony_ci
229b1994897Sopenharmony_ci  part_name = "runtime_core"
230b1994897Sopenharmony_ci  subsystem_name = "arkcompiler"
231b1994897Sopenharmony_ci}
232b1994897Sopenharmony_ci
233b1994897Sopenharmony_cisource_set("libarkfile_static_verifier") {
234b1994897Sopenharmony_ci  sources = libarkfile_sources
235b1994897Sopenharmony_ci
236b1994897Sopenharmony_ci  public_configs = [
237b1994897Sopenharmony_ci    "$ark_root:ark_config",
238b1994897Sopenharmony_ci    "$ark_root/libpandabase:arkbase_public_config",
239b1994897Sopenharmony_ci    ":arkfile_verifier_config",
240b1994897Sopenharmony_ci  ]
241b1994897Sopenharmony_ci
242b1994897Sopenharmony_ci  deps = [
243b1994897Sopenharmony_ci    ":arkfile_header_deps",
244b1994897Sopenharmony_ci    "$ark_root/libpandabase:libarkbase_static",
245b1994897Sopenharmony_ci    "$ark_root/libziparchive:libarkziparchive_static",
246b1994897Sopenharmony_ci  ]
247b1994897Sopenharmony_ci  external_deps = []
248b1994897Sopenharmony_ci  external_deps += [
249b1994897Sopenharmony_ci    "zlib:shared_libz",
250b1994897Sopenharmony_ci    sdk_libc_secshared_dep,
251b1994897Sopenharmony_ci  ]
252b1994897Sopenharmony_ci}
253b1994897Sopenharmony_ci
254b1994897Sopenharmony_ciohos_shared_library("libarkfile") {
255b1994897Sopenharmony_ci  stack_protector_ret = false
256b1994897Sopenharmony_ci  deps = [ ":libarkfile_static" ]
257b1994897Sopenharmony_ci
258b1994897Sopenharmony_ci  if (!is_standard_system) {
259b1994897Sopenharmony_ci    relative_install_dir = "ark"
260b1994897Sopenharmony_ci  }
261b1994897Sopenharmony_ci  if (!is_mingw && !is_mac) {
262b1994897Sopenharmony_ci    output_extension = "so"
263b1994897Sopenharmony_ci  }
264b1994897Sopenharmony_ci
265b1994897Sopenharmony_ci  part_name = "runtime_core"
266b1994897Sopenharmony_ci  subsystem_name = "arkcompiler"
267b1994897Sopenharmony_ci}
268b1994897Sopenharmony_ci
269b1994897Sopenharmony_ciohos_source_set("libarkfile_frontend_set_static") {
270b1994897Sopenharmony_ci  sources = libarkfile_sources
271b1994897Sopenharmony_ci
272b1994897Sopenharmony_ci  public_configs = libarkfile_configs
273b1994897Sopenharmony_ci
274b1994897Sopenharmony_ci  deps = [
275b1994897Sopenharmony_ci    ":arkfile_header_deps",
276b1994897Sopenharmony_ci    "$ark_root/libpandabase:libarkbase_frontend_static",
277b1994897Sopenharmony_ci    "$ark_root/libziparchive:libarkziparchive_frontend_static",
278b1994897Sopenharmony_ci  ]
279b1994897Sopenharmony_ci
280b1994897Sopenharmony_ci  if (is_arkui_x) {
281b1994897Sopenharmony_ci    deps += [
282b1994897Sopenharmony_ci      "$ark_third_party_root/bounds_checking_function:libsec_static",
283b1994897Sopenharmony_ci      "$ark_third_party_root/zlib:libz",
284b1994897Sopenharmony_ci    ]
285b1994897Sopenharmony_ci  } else if (ark_standalone_build) {
286b1994897Sopenharmony_ci    external_deps = [
287b1994897Sopenharmony_ci      "zlib:libz",
288b1994897Sopenharmony_ci      sdk_libc_secshared_dep,
289b1994897Sopenharmony_ci    ]
290b1994897Sopenharmony_ci  } else {
291b1994897Sopenharmony_ci    public_external_deps = [
292b1994897Sopenharmony_ci      "zlib:libz",
293b1994897Sopenharmony_ci      sdk_libc_secshared_dep,
294b1994897Sopenharmony_ci    ]
295b1994897Sopenharmony_ci  }
296b1994897Sopenharmony_ci
297b1994897Sopenharmony_ci  part_name = "runtime_core"
298b1994897Sopenharmony_ci  subsystem_name = "arkcompiler"
299b1994897Sopenharmony_ci}
300b1994897Sopenharmony_ci
301b1994897Sopenharmony_ciohos_static_library("libarkfile_frontend_static") {
302b1994897Sopenharmony_ci  stack_protector_ret = false
303b1994897Sopenharmony_ci  deps = [ ":libarkfile_frontend_set_static" ]
304b1994897Sopenharmony_ci
305b1994897Sopenharmony_ci  part_name = "runtime_core"
306b1994897Sopenharmony_ci  subsystem_name = "arkcompiler"
307b1994897Sopenharmony_ci}
308b1994897Sopenharmony_ci
309b1994897Sopenharmony_ciark_gen_file("libarkfile_type_gen_h") {
310b1994897Sopenharmony_ci  template_file = "templates/type.h.erb"
311b1994897Sopenharmony_ci  data_file = "types.yaml"
312b1994897Sopenharmony_ci  requires = [ "types.rb" ]
313b1994897Sopenharmony_ci  output_file = "$target_gen_dir/type.h"
314b1994897Sopenharmony_ci}
315b1994897Sopenharmony_ci
316b1994897Sopenharmony_ciark_isa_gen("isa_gen_libarkfile") {
317b1994897Sopenharmony_ci  template_files = [
318b1994897Sopenharmony_ci    "arkcompiler.para.erb",
319b1994897Sopenharmony_ci    "bytecode_instruction_enum_gen.h.erb",
320b1994897Sopenharmony_ci    "bytecode_instruction-inl_gen.h.erb",
321b1994897Sopenharmony_ci    "bytecode_emitter_def_gen.h.erb",
322b1994897Sopenharmony_ci    "bytecode_emitter_gen.h.erb",
323b1994897Sopenharmony_ci    "file_format_version.h.erb",
324b1994897Sopenharmony_ci    "tests/bytecode_emitter_tests_gen.h.erb",
325b1994897Sopenharmony_ci  ]
326b1994897Sopenharmony_ci  sources = "templates"  ## ark_root/templates
327b1994897Sopenharmony_ci  destination = "$target_gen_dir/include"  ## target_gen_dir/include
328b1994897Sopenharmony_ci  requires = [ "pandafile_isapi.rb" ]
329b1994897Sopenharmony_ci}
330b1994897Sopenharmony_ci
331b1994897Sopenharmony_ciark_gen_file("source_lang_enum_h") {
332b1994897Sopenharmony_ci  extra_dependencies = [ "$ark_root:concat_plugins_yamls" ]
333b1994897Sopenharmony_ci  template_file = "templates/source_lang_enum.h.erb"
334b1994897Sopenharmony_ci  data_file = "$target_gen_dir/../plugin_options.yaml"
335b1994897Sopenharmony_ci  requires = [ "$ark_root/templates/plugin_options.rb" ]
336b1994897Sopenharmony_ci  output_file = "$target_gen_dir/include/source_lang_enum.h"
337b1994897Sopenharmony_ci}
338b1994897Sopenharmony_ci
339b1994897Sopenharmony_cigroup("arkcompiler_params") {
340b1994897Sopenharmony_ci  deps = []
341b1994897Sopenharmony_ci
342b1994897Sopenharmony_ci  if (!ark_standalone_build) {
343b1994897Sopenharmony_ci    deps += [ ":arkcompiler.para" ]
344b1994897Sopenharmony_ci  }
345b1994897Sopenharmony_ci}
346b1994897Sopenharmony_ci
347b1994897Sopenharmony_ciif (!ark_standalone_build) {
348b1994897Sopenharmony_ci  ohos_prebuilt_etc("arkcompiler.para") {
349b1994897Sopenharmony_ci    deps = [ ":isa_gen_libarkfile_arkcompiler_para" ]
350b1994897Sopenharmony_ci    source = "$target_gen_dir/include/arkcompiler.para"
351b1994897Sopenharmony_ci    relative_install_dir = "param"
352b1994897Sopenharmony_ci    part_name = "runtime_core"
353b1994897Sopenharmony_ci    subsystem_name = "arkcompiler"
354b1994897Sopenharmony_ci  }
355b1994897Sopenharmony_ci}
356