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 76group("arktsfile_header_deps") { 77 deps = [ 78 ":isa_gen_libarkfile_bytecode_emitter_def_gen_h", 79 ":isa_gen_libarkfile_bytecode_emitter_gen_h", 80 ":isa_gen_libarkfile_bytecode_instruction-inl_gen_h", 81 ":isa_gen_libarkfile_bytecode_instruction_enum_gen_h", 82 ":isa_gen_libarkfile_file_format_version_h", 83 ":isa_gen_libarkfile_tests_bytecode_emitter_tests_gen_h", 84 ":libarkfile_file_items_gen_inc", 85 ":libarkfile_type_gen_h", 86 ":source_lang_enum_h", 87 ] 88} 89 90ohos_source_set("libarktsfile_static") { 91 sources = libarkfile_sources 92 93 public_configs = libarkfile_configs 94 95 deps = [ 96 ":arktsfile_header_deps", 97 "$ark_root/libpandabase:libarktsbase", 98 "$ark_root/libziparchive:libarktsziparchive", 99 ] 100 101 external_deps = [ sdk_libc_secshared_dep ] 102 103 if (!ark_standalone_build) { 104 public_external_deps = [ 105 "zlib:libz", 106 "zlib:shared_libz", 107 ] 108 } else { 109 external_deps += [ 110 "zlib:libz", 111 "zlib:shared_libz", 112 ] 113 } 114 115 part_name = ark_part_name 116 subsystem_name = "$ark_subsystem_name" 117} 118 119ohos_shared_library("libarktsfile") { 120 deps = [ ":libarktsfile_static" ] 121 122 if (is_mingw || is_win) { 123 output_extension = "dll" 124 } else { 125 output_extension = "so" 126 } 127 part_name = ark_part_name 128 subsystem_name = "$ark_subsystem_name" 129} 130 131ohos_source_set("libarktsfile_frontend_set_static") { 132 sources = libarkfile_sources 133 134 public_configs = libarkfile_configs 135 136 deps = [ 137 ":arktsfile_header_deps", 138 ":source_lang_enum_h", 139 "$ark_root/libziparchive:libarktsziparchive_frontend_static", 140 ] 141 142 external_deps = [ sdk_libc_secshared_dep ] 143 144 if (!ark_standalone_build) { 145 public_external_deps = [ 146 "zlib:libz", 147 "zlib:shared_libz", 148 ] 149 } else { 150 external_deps += [ 151 "zlib:libz", 152 "zlib:shared_libz", 153 ] 154 } 155 156 part_name = ark_part_name 157 subsystem_name = "$ark_subsystem_name" 158} 159 160ohos_static_library("libarktsfile_frontend_static") { 161 deps = [ ":libarktsfile_frontend_set_static" ] 162 part_name = ark_part_name 163 subsystem_name = ark_subsystem_name 164} 165 166ark_gen_file("libarkfile_type_gen_h") { 167 template_file = "templates/type.h.erb" 168 data = [ "types.yaml" ] 169 api = [ "types.rb" ] 170 output_file = "$target_gen_dir/type.h" 171} 172 173ark_isa_gen("isa_gen_libarkfile") { 174 template_files = [ 175 "bytecode_instruction_enum_gen.h.erb", 176 "bytecode_instruction-inl_gen.h.erb", 177 "bytecode_emitter_def_gen.h.erb", 178 "bytecode_emitter_gen.h.erb", 179 "file_format_version.h.erb", 180 "tests/bytecode_emitter_tests_gen.h.erb", 181 ] 182 sources = "templates" ## ark_root/templates 183 destination = "$target_gen_dir/include" ## target_gen_dir/include 184 requires = [ "pandafile_isapi.rb" ] 185} 186 187ark_gen_file("libarkfile_file_items_gen_inc") { 188 extra_dependencies = [ "$ark_root:concat_plugins_yamls" ] 189 template_file = "templates/file_items_gen.inc.erb" 190 data = [ ark_plugin_options_yaml ] 191 api = [ "$ark_root/templates/plugin_options.rb" ] 192 output_file = "$target_gen_dir/include/file_items_gen.inc" 193} 194 195ark_gen_file("source_lang_enum_h") { 196 extra_dependencies = [ "$ark_root:concat_plugins_yamls" ] 197 template_file = "templates/source_lang_enum.h.erb" 198 data = [ ark_plugin_options_yaml ] 199 api = [ "$ark_root/templates/plugin_options.rb" ] 200 output_file = "$target_gen_dir/include/source_lang_enum.h" 201} 202