• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
45if (!ark_static_standalone_build) {
46  ohos_shared_headers("libpandafile_headers") {
47    include_dirs = [
48      "$ark_root/libpandafile",
49      "$ark_root/libziparchive",
50      "$target_gen_dir",
51      "$target_gen_dir/include",
52    ]
53    if (ark_standalone_build) {
54      include_dirs += [ "//third_party/zlib/contrib/minizip" ]
55    }
56    part_name = ark_part_name
57    subsystem_name = "$ark_subsystem_name"
58  }
59}
60
61libarkfile_sources = [
62  "annotation_data_accessor.cpp",
63  "bytecode_emitter.cpp",
64  "class_data_accessor.cpp",
65  "code_data_accessor.cpp",
66  "debug_data_accessor.cpp",
67  "debug_helpers.cpp",
68  "debug_info_extractor.cpp",
69  "field_data_accessor.cpp",
70  "file.cpp",
71  "file_format_version.cpp",
72  "file_item_container.cpp",
73  "file_items.cpp",
74  "file_reader.cpp",
75  "file_writer.cpp",
76  "literal_data_accessor.cpp",
77  "method_data_accessor.cpp",
78  "method_handle_data_accessor.cpp",
79  "pgo.cpp",
80]
81
82libarkfile_configs = [
83  "$ark_root:ark_config",
84  "$ark_root/libpandabase:arkbase_public_config",
85  ":arkfile_public_config",
86]
87
88if (ark_static_standalone_build) {
89  libarkfile_configs += [ zlib_public_config ]
90}
91
92group("arktsfile_header_deps") {
93  deps = [
94    ":isa_gen_libarkfile_bytecode_emitter_def_gen_h",
95    ":isa_gen_libarkfile_bytecode_emitter_gen_h",
96    ":isa_gen_libarkfile_bytecode_instruction-inl_gen_h",
97    ":isa_gen_libarkfile_bytecode_instruction_enum_gen_h",
98    ":isa_gen_libarkfile_file_format_version_h",
99    ":isa_gen_libarkfile_tests_bytecode_emitter_tests_gen_h",
100    ":libarkfile_file_items_gen_inc",
101    ":libarkfile_type_gen_h",
102    ":source_lang_enum_h",
103  ]
104}
105
106ohos_source_set("libarktsfile_static") {
107  sources = libarkfile_sources
108
109  public_configs = libarkfile_configs
110
111  deps = [
112    ":arktsfile_header_deps",
113    "$ark_root/libpandabase:libarktsbase",
114    "$ark_root/libziparchive:libarktsziparchive",
115  ]
116
117  external_deps = [ sdk_libc_secshared_dep ]
118
119  if (!ark_standalone_build) {
120    public_external_deps = [
121      "zlib:libz",
122      "zlib:shared_libz",
123    ]
124  } else {
125    external_deps += [
126      "zlib:libz",
127      "zlib:shared_libz",
128    ]
129  }
130
131  part_name = ark_part_name
132  subsystem_name = "$ark_subsystem_name"
133}
134
135ohos_shared_library("libarktsfile") {
136  deps = [ ":libarktsfile_static" ]
137
138  if (is_mingw || is_win) {
139    output_extension = "dll"
140  } else {
141    output_extension = "so"
142  }
143  part_name = ark_part_name
144  subsystem_name = "$ark_subsystem_name"
145}
146
147ohos_source_set("libarktsfile_frontend_set_static") {
148  sources = libarkfile_sources
149
150  public_configs = libarkfile_configs
151
152  deps = [
153    ":arktsfile_header_deps",
154    ":source_lang_enum_h",
155    "$ark_root/libziparchive:libarktsziparchive_frontend_static",
156  ]
157
158  external_deps = [ sdk_libc_secshared_dep ]
159
160  if (!ark_standalone_build) {
161    public_external_deps = [ "zlib:libz" ]
162    if (!is_mac) {
163      public_external_deps += [ "zlib:shared_libz" ]
164    }
165  } else {
166    external_deps += [ "zlib:libz" ]
167    if (!is_mac) {
168      external_deps += [ "zlib:shared_libz" ]
169    }
170  }
171
172  part_name = ark_part_name
173  subsystem_name = "$ark_subsystem_name"
174}
175
176ohos_static_library("libarktsfile_frontend_static") {
177  deps = [ ":libarktsfile_frontend_set_static" ]
178  part_name = ark_part_name
179  subsystem_name = ark_subsystem_name
180}
181
182ark_gen_file("libarkfile_type_gen_h") {
183  template_file = "templates/type.h.erb"
184  data = [ "types.yaml" ]
185  api = [ "types.rb" ]
186  output_file = "$target_gen_dir/type.h"
187}
188
189ark_isa_gen("isa_gen_libarkfile") {
190  template_files = [
191    "bytecode_instruction_enum_gen.h.erb",
192    "bytecode_instruction-inl_gen.h.erb",
193    "bytecode_emitter_def_gen.h.erb",
194    "bytecode_emitter_gen.h.erb",
195    "file_format_version.h.erb",
196    "tests/bytecode_emitter_tests_gen.h.erb",
197  ]
198  sources = "templates"  ## ark_root/templates
199  destination = "$target_gen_dir/include"  ## target_gen_dir/include
200  requires = [ "pandafile_isapi.rb" ]
201}
202
203ark_gen_file("libarkfile_file_items_gen_inc") {
204  extra_dependencies = [ "$ark_root:concat_plugins_yamls" ]
205  template_file = "templates/file_items_gen.inc.erb"
206  data = [ ark_plugin_options_yaml ]
207  api = [ "$ark_root/templates/plugin_options.rb" ]
208  output_file = "$target_gen_dir/include/file_items_gen.inc"
209}
210
211ark_gen_file("source_lang_enum_h") {
212  extra_dependencies = [ "$ark_root:concat_plugins_yamls" ]
213  template_file = "templates/source_lang_enum.h.erb"
214  data = [ ark_plugin_options_yaml ]
215  api = [ "$ark_root/templates/plugin_options.rb" ]
216  output_file = "$target_gen_dir/include/source_lang_enum.h"
217}
218