1# Copyright (c) 2021-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("//arkcompiler/runtime_core/static_core/ark_config.gni")
15import("//arkcompiler/runtime_core/static_vm_config.gni")
16
17if (ark_standalone_build) {
18  import("$build_root/ark.gni")
19} else {
20  import("//build/ohos.gni")
21}
22
23ohos_static_library("libarktsfile_package") {
24  deps = []
25  if (enable_static_vm) {
26    deps += [ ":libarktsfile_frontend_static" ]
27  }
28
29  part_name = ark_part_name
30  subsystem_name = "$ark_subsystem_name"
31}
32
33config("arkfile_public_config") {
34  include_dirs = [
35    "$ark_root/libpandafile",
36    "$ark_root/libziparchive",
37    "$target_gen_dir",
38    "$target_gen_dir/include",
39  ]
40  if (ark_standalone_build) {
41    include_dirs += [ "//third_party/zlib/contrib/minizip" ]
42  }
43}
44
45libarkfile_sources = [
46  "annotation_data_accessor.cpp",
47  "bytecode_emitter.cpp",
48  "class_data_accessor.cpp",
49  "code_data_accessor.cpp",
50  "debug_data_accessor.cpp",
51  "debug_helpers.cpp",
52  "debug_info_extractor.cpp",
53  "field_data_accessor.cpp",
54  "file.cpp",
55  "file_format_version.cpp",
56  "file_item_container.cpp",
57  "file_items.cpp",
58  "file_reader.cpp",
59  "file_writer.cpp",
60  "literal_data_accessor.cpp",
61  "method_data_accessor.cpp",
62  "method_handle_data_accessor.cpp",
63  "pgo.cpp",
64]
65
66libarkfile_configs = [
67  "$ark_root:ark_config",
68  "$ark_root/libpandabase:arkbase_public_config",
69  ":arkfile_public_config",
70]
71
72if (ark_static_standalone_build) {
73  libarkfile_configs += [ zlib_public_config ]
74}
75
76ohos_source_set("libarktsfile_static") {
77  sources = libarkfile_sources
78
79  public_configs = libarkfile_configs
80
81  deps = [
82    ":isa_gen_libarkfile_bytecode_emitter_def_gen_h",
83    ":isa_gen_libarkfile_bytecode_emitter_gen_h",
84    ":isa_gen_libarkfile_bytecode_instruction-inl_gen_h",
85    ":isa_gen_libarkfile_bytecode_instruction_enum_gen_h",
86    ":isa_gen_libarkfile_file_format_version_h",
87    ":isa_gen_libarkfile_tests_bytecode_emitter_tests_gen_h",
88    ":libarkfile_file_items_gen_inc",
89    ":libarkfile_type_gen_h",
90    ":source_lang_enum_h",
91    "$ark_root/libpandabase:libarktsbase",
92    "$ark_root/libziparchive:libarktsziparchive",
93  ]
94
95  external_deps = [ sdk_libc_secshared_dep ]
96
97  if (!ark_standalone_build) {
98    public_external_deps = [
99      "zlib:libz",
100      "zlib:shared_libz",
101    ]
102  } else {
103    external_deps += [
104      "zlib:libz",
105      "zlib:shared_libz",
106    ]
107  }
108
109  part_name = ark_part_name
110  subsystem_name = "$ark_subsystem_name"
111}
112
113ohos_shared_library("libarktsfile") {
114  deps = [ ":libarktsfile_static" ]
115
116  if (!is_mingw && !is_mac) {
117    output_extension = "so"
118  }
119  part_name = ark_part_name
120  subsystem_name = "$ark_subsystem_name"
121}
122
123ohos_source_set("libarktsfile_frontend_set_static") {
124  sources = libarkfile_sources
125
126  public_configs = libarkfile_configs
127
128  deps = [
129    ":isa_gen_libarkfile_bytecode_emitter_def_gen_h",
130    ":isa_gen_libarkfile_bytecode_emitter_gen_h",
131    ":isa_gen_libarkfile_bytecode_instruction-inl_gen_h",
132    ":isa_gen_libarkfile_bytecode_instruction_enum_gen_h",
133    ":isa_gen_libarkfile_file_format_version_h",
134    ":isa_gen_libarkfile_tests_bytecode_emitter_tests_gen_h",
135    ":libarkfile_file_items_gen_inc",
136    ":libarkfile_type_gen_h",
137    ":source_lang_enum_h",
138    "$ark_root/libziparchive:libarktsziparchive_frontend_static",
139  ]
140
141  external_deps = [ sdk_libc_secshared_dep ]
142
143  if (!ark_standalone_build) {
144    public_external_deps = [
145      "zlib:libz",
146      "zlib:shared_libz",
147    ]
148  } else {
149    external_deps += [
150      "zlib:libz",
151      "zlib:shared_libz",
152    ]
153  }
154
155  part_name = ark_part_name
156  subsystem_name = "$ark_subsystem_name"
157}
158
159ohos_static_library("libarktsfile_frontend_static") {
160  deps = [ ":libarktsfile_frontend_set_static" ]
161  part_name = ark_part_name
162  subsystem_name = ark_subsystem_name
163}
164
165ark_gen_file("libarkfile_type_gen_h") {
166  template_file = "templates/type.h.erb"
167  data = [ "types.yaml" ]
168  api = [ "types.rb" ]
169  output_file = "$target_gen_dir/type.h"
170}
171
172ark_isa_gen("isa_gen_libarkfile") {
173  template_files = [
174    "bytecode_instruction_enum_gen.h.erb",
175    "bytecode_instruction-inl_gen.h.erb",
176    "bytecode_emitter_def_gen.h.erb",
177    "bytecode_emitter_gen.h.erb",
178    "file_format_version.h.erb",
179    "tests/bytecode_emitter_tests_gen.h.erb",
180  ]
181  sources = "templates"  ## ark_root/templates
182  destination = "$target_gen_dir/include"  ## target_gen_dir/include
183  requires = [ "pandafile_isapi.rb" ]
184}
185
186ark_gen_file("libarkfile_file_items_gen_inc") {
187  extra_dependencies = [ "$ark_root:concat_plugins_yamls" ]
188  template_file = "templates/file_items_gen.inc.erb"
189  data = [ ark_plugin_options_yaml ]
190  api = [ "$ark_root/templates/plugin_options.rb" ]
191  output_file = "$target_gen_dir/include/file_items_gen.inc"
192}
193
194ark_gen_file("source_lang_enum_h") {
195  extra_dependencies = [ "$ark_root:concat_plugins_yamls" ]
196  template_file = "templates/source_lang_enum.h.erb"
197  data = [ ark_plugin_options_yaml ]
198  api = [ "$ark_root/templates/plugin_options.rb" ]
199  output_file = "$target_gen_dir/include/source_lang_enum.h"
200}
201