• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (c) 2021-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("//arkcompiler/runtime_core/ark_config.gni")
15
16config("arkfile_public_config") {
17  include_dirs = [
18    "$ark_root/libpandafile",
19    "$ark_root/libziparchive",
20    "$target_gen_dir",
21    "$target_gen_dir/include",
22  ]
23
24  defines = []
25  if (is_ohos && !is_standard_system) {
26    defines += [ "ENABLE_FULL_FILE_FIELDS" ]
27  }
28
29  if (use_libfuzzer || (!ark_standalone_build && use_clang_coverage)) {
30    defines += [ "FATAL_AS_ERROR" ]
31  }
32}
33
34config("data_protect_configs") {
35  cflags_cc = [ "-march=armv8.4-a" ]
36  defines = [ "PANDA_ENABLE_DATA_PROTECT" ]
37}
38
39config("arkfile_fuzz_config") {
40  configs = [ "$build_root/config/compiler:exceptions" ]
41  defines = [ "SUPPORT_KNOWN_EXCEPTION" ]
42}
43
44config("arkfile_verifier_config") {
45  include_dirs = [
46    "$ark_root/libpandafile",
47    "$ark_root/libziparchive",
48    "$target_gen_dir",
49    "$target_gen_dir/include",
50  ]
51
52  defines = []
53  if (is_ohos && !is_standard_system) {
54    defines += [ "ENABLE_FULL_FILE_FIELDS" ]
55  }
56
57  defines += [ "FATAL_AS_ERROR" ]
58}
59
60libarkfile_sources = [
61  "annotation_data_accessor.cpp",
62  "bytecode_emitter.cpp",
63  "class_data_accessor.cpp",
64  "code_data_accessor.cpp",
65  "debug_data_accessor.cpp",
66  "debug_info_extractor.cpp",
67  "field_data_accessor.cpp",
68  "file.cpp",
69  "file_format_version.cpp",
70  "file_item_container.cpp",
71  "file_items.cpp",
72  "file_writer.cpp",
73  "literal_data_accessor.cpp",
74  "method_data_accessor.cpp",
75  "method_handle_data_accessor.cpp",
76  "module_data_accessor.cpp",
77  "pgo.cpp",
78]
79
80libarkfile_configs = [
81  "$ark_root:ark_config",
82  "$ark_root/libpandabase:arkbase_public_config",
83  ":arkfile_public_config",
84]
85
86ohos_static_library("arkfile_header_deps") {
87  deps = [
88    ":isa_gen_libarkfile_bytecode_emitter_def_gen_h",
89    ":isa_gen_libarkfile_bytecode_emitter_gen_h",
90    ":isa_gen_libarkfile_bytecode_instruction-inl_gen_h",
91    ":isa_gen_libarkfile_bytecode_instruction_enum_gen_h",
92    ":isa_gen_libarkfile_file_format_version_h",
93    ":isa_gen_libarkfile_tests_bytecode_emitter_tests_gen_h",
94    ":libarkfile_type_gen_h",
95    ":source_lang_enum_h",
96    "$ark_root/libpandabase:arkbase_header_deps",
97  ]
98  part_name = "runtime_core"
99  subsystem_name = "arkcompiler"
100}
101
102ohos_static_library("libarkfile_static") {
103  sources = libarkfile_sources
104
105  public_configs = libarkfile_configs
106
107  if (enabled_pac_data_protect) {
108    configs = libarkfile_configs
109    configs += [ ":data_protect_configs" ]
110  }
111
112  deps = [
113    ":arkfile_header_deps",
114    "$ark_root/libpandabase:libarkbase_static",
115    "$ark_root/libziparchive:libarkziparchive_static",
116  ]
117
118  if (is_arkui_x) {
119    deps += [
120      "$ark_third_party_root/bounds_checking_function:libsec_static",
121      "$ark_third_party_root/zlib:libz",
122    ]
123  } else if (ark_standalone_build) {
124    external_deps = [
125      "zlib:shared_libz",
126      sdk_libc_secshared_dep,
127    ]
128  } else {
129    public_external_deps = [
130      "zlib:shared_libz",
131      sdk_libc_secshared_dep,
132    ]
133  }
134
135  if (enable_hilog) {
136    public_external_deps += [ "hilog:libhilog" ]
137  }
138
139  part_name = "runtime_core"
140  subsystem_name = "arkcompiler"
141}
142
143ohos_source_set("libarkfile_static_fuzz") {
144  sources = libarkfile_sources
145
146  public_configs = libarkfile_configs
147  public_configs += [ ":arkfile_fuzz_config" ]
148
149  deps = [
150    ":arkfile_header_deps",
151    "$ark_root/libpandabase:libarkbase_static",
152    "$ark_root/libziparchive:libarkziparchive_static",
153  ]
154
155  if (!ark_standalone_build) {
156    public_external_deps = [
157      "zlib:libz",
158      sdk_libc_secshared_dep,
159    ]
160  } else {
161    external_deps = [
162      "zlib:libz",
163      sdk_libc_secshared_dep,
164    ]
165  }
166
167  if (enable_hilog) {
168    public_external_deps += [ "hilog:libhilog" ]
169  }
170
171  part_name = "runtime_core"
172  subsystem_name = "arkcompiler"
173}
174
175source_set("libarkfile_static_verifier") {
176  sources = libarkfile_sources
177
178  public_configs = [
179    "$ark_root:ark_config",
180    "$ark_root/libpandabase:arkbase_public_config",
181    ":arkfile_verifier_config",
182  ]
183
184  deps = [
185    ":arkfile_header_deps",
186    "$ark_root/libpandabase:libarkbase_static",
187    "$ark_root/libziparchive:libarkziparchive_static",
188  ]
189  external_deps = []
190  external_deps += [
191    "zlib:shared_libz",
192    sdk_libc_secshared_dep,
193  ]
194}
195
196ohos_shared_library("libarkfile") {
197  stack_protector_ret = false
198  deps = [ ":libarkfile_static" ]
199
200  if (!is_standard_system) {
201    relative_install_dir = "ark"
202  }
203  if (!is_mingw && !is_mac) {
204    output_extension = "so"
205  }
206
207  part_name = "runtime_core"
208  subsystem_name = "arkcompiler"
209}
210
211ohos_source_set("libarkfile_frontend_set_static") {
212  sources = libarkfile_sources
213
214  public_configs = libarkfile_configs
215
216  deps = [
217    ":arkfile_header_deps",
218    "$ark_root/libpandabase:libarkbase_frontend_static",
219    "$ark_root/libziparchive:libarkziparchive_frontend_static",
220  ]
221
222  if (is_arkui_x) {
223    deps += [
224      "$ark_third_party_root/bounds_checking_function:libsec_static",
225      "$ark_third_party_root/zlib:libz",
226    ]
227  } else if (ark_standalone_build) {
228    external_deps = [
229      "zlib:libz",
230      sdk_libc_secshared_dep,
231    ]
232  } else {
233    public_external_deps = [
234      "zlib:libz",
235      sdk_libc_secshared_dep,
236    ]
237  }
238
239  part_name = "runtime_core"
240  subsystem_name = "arkcompiler"
241}
242
243ohos_static_library("libarkfile_frontend_static") {
244  stack_protector_ret = false
245  deps = [ ":libarkfile_frontend_set_static" ]
246
247  part_name = "runtime_core"
248  subsystem_name = "arkcompiler"
249}
250
251ark_gen_file("libarkfile_type_gen_h") {
252  template_file = "templates/type.h.erb"
253  data_file = "types.yaml"
254  requires = [ "types.rb" ]
255  output_file = "$target_gen_dir/type.h"
256}
257
258ark_isa_gen("isa_gen_libarkfile") {
259  template_files = [
260    "arkcompiler.para.erb",
261    "bytecode_instruction_enum_gen.h.erb",
262    "bytecode_instruction-inl_gen.h.erb",
263    "bytecode_emitter_def_gen.h.erb",
264    "bytecode_emitter_gen.h.erb",
265    "file_format_version.h.erb",
266    "tests/bytecode_emitter_tests_gen.h.erb",
267  ]
268  sources = "templates"  ## ark_root/templates
269  destination = "$target_gen_dir/include"  ## target_gen_dir/include
270  requires = [ "pandafile_isapi.rb" ]
271}
272
273ark_gen_file("source_lang_enum_h") {
274  extra_dependencies = [ "$ark_root:concat_plugins_yamls" ]
275  template_file = "templates/source_lang_enum.h.erb"
276  data_file = "$target_gen_dir/../plugin_options.yaml"
277  requires = [ "$ark_root/templates/plugin_options.rb" ]
278  output_file = "$target_gen_dir/include/source_lang_enum.h"
279}
280
281group("arkcompiler_params") {
282  deps = []
283
284  if (!ark_standalone_build) {
285    deps += [ ":arkcompiler.para" ]
286  }
287}
288
289if (!ark_standalone_build) {
290  ohos_prebuilt_etc("arkcompiler.para") {
291    deps = [ ":isa_gen_libarkfile_arkcompiler_para" ]
292    source = "$target_gen_dir/include/arkcompiler.para"
293    relative_install_dir = "param"
294    part_name = "runtime_core"
295    subsystem_name = "arkcompiler"
296  }
297}
298