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/static_core/ark_config.gni") 15 16plugin_ark_host_linux_tools_packages = [] 17plugin_ark_host_mac_tools_packages = [] 18plugin_ark_host_windows_tools_packages = [] 19plugin_ark_packages = [] 20 21plugin_ark_configs = [] 22plugin_libarkassembler_configs = [] 23plugin_runtime_configs = [] 24plugin_runtime_interpreter_impl_configs = [] 25plugin_bytecodeopt_configs = [] 26 27plugin_arkruntime_header_plugin_deps = [] 28plugin_arkruntime_stdlib_plugin_deps = [] 29plugin_assembler_deps = [] 30plugin_bytecodeopt_deps = [] 31plugin_compiler_deps = [] 32plugin_runtime_deps = [] 33 34plugin_arkdisassembler_sources = [] 35plugin_libarkassembler_sources = [] 36plugin_libarkbytecodeopt_sources = [] 37plugin_libarkcompiler_sources = [] 38plugin_runtime_sources = [] 39plugin_verifier_sources = [] 40 41plugin_entrypoints_yamls = [] 42plugin_inst_templates_yamls = [] 43plugin_option_yamls = [] 44plugin_runtime_options_yamls = [] 45plugin_compiler_options_yamls = [] 46plugin_runtime_yamls = [] 47 48plugin_irtoc_scripts = [] 49plugin_irtoc_plugins = [] 50 51plugin_isa_paths = [] 52 53plugin_enable_bytecode_optimizer = false 54 55# All paths and labels in the exported variables should be source-absolute. 56 57foreach(plugin, ark_enabled_plugins) { 58 print("Reading plugin sources: $plugin ($current_toolchain)") 59 _plugin_dir = "$ark_root/plugins/$plugin" 60 _plugin_vars = { 61 } 62 63 # To read variables defined by plugins into a scope while avoiding conflict 64 # with the current scope, we read plugin.gn which should be a wrapper around 65 # subproject_sources.gn that simply `import`s the latter. The import command 66 # is more powerful than read_file in that it resolves paths relative to the 67 # current file and also has `current_cpu`, etc. values defined which allows to 68 # write more conventional GN code. 69 _plugin_vars = read_file("$_plugin_dir/plugin.gn", "scope") 70 71 if (defined(_plugin_vars.enable_bytecode_optimizer)) { 72 plugin_bytecodeopt_configs += [ "$_plugin_dir:bytecodeopt" ] 73 plugin_enable_bytecode_optimizer = plugin_enable_bytecode_optimizer || 74 _plugin_vars.enable_bytecode_optimizer 75 } 76 77 plugin_ark_host_linux_tools_packages += 78 [ "$_plugin_dir:ark_host_linux_tools_packages" ] 79 plugin_ark_host_windows_tools_packages += 80 [ "$_plugin_dir:ark_host_windows_tools_packages" ] 81 plugin_ark_host_mac_tools_packages += 82 [ "$_plugin_dir:ark_host_mac_tools_packages" ] 83 plugin_ark_packages += [ "$_plugin_dir:ark_packages" ] 84 85 plugin_ark_configs += [ "$_plugin_dir:ark_config" ] 86 plugin_libarkassembler_configs += [ "$_plugin_dir:assembler" ] 87 plugin_runtime_configs += [ "$_plugin_dir:runtime" ] 88 plugin_runtime_interpreter_impl_configs += 89 [ "$_plugin_dir:runtime_interpreter_impl" ] 90 91 plugin_assembler_deps += [ "$_plugin_dir:assembler_deps" ] 92 93 if (defined(_plugin_vars.arkruntime_header_sub_deps)) { 94 foreach(sub_dep, _plugin_vars.arkruntime_header_sub_deps) { 95 plugin_arkruntime_header_plugin_deps += [ sub_dep ] 96 } 97 } 98 if (defined(_plugin_vars.arkruntime_stdlib_sub_deps)) { 99 foreach(sub_dep, _plugin_vars.arkruntime_stdlib_sub_deps) { 100 plugin_arkruntime_stdlib_plugin_deps += [ sub_dep ] 101 } 102 } 103 if (defined(_plugin_vars.arkbytecodeopt_deps)) { 104 foreach(sub_dep, _plugin_vars.arkbytecodeopt_deps) { 105 plugin_bytecodeopt_deps += [ sub_dep ] 106 } 107 } 108 if (defined(_plugin_vars.arkcompiler_deps)) { 109 foreach(sub_dep, _plugin_vars.arkcompiler_deps) { 110 plugin_compiler_deps += [ sub_dep ] 111 } 112 } 113 if (defined(_plugin_vars.arkruntime_deps)) { 114 foreach(sub_dep, _plugin_vars.arkruntime_deps) { 115 plugin_runtime_deps += [ sub_dep ] 116 } 117 } 118 119 if (defined(_plugin_vars.srcs_disassembler)) { 120 foreach(src, _plugin_vars.srcs_disassembler) { 121 plugin_arkdisassembler_sources += [ "$_plugin_dir/$src" ] 122 } 123 } 124 if (defined(_plugin_vars.srcs_assembler)) { 125 foreach(src, _plugin_vars.srcs_assembler) { 126 plugin_libarkassembler_sources += [ "$_plugin_dir/$src" ] 127 } 128 } 129 if (defined(_plugin_vars.srcs_bytecode_optimizer)) { 130 foreach(src, _plugin_vars.srcs_bytecode_optimizer) { 131 plugin_libarkbytecodeopt_sources += [ "$_plugin_dir/$src" ] 132 } 133 } 134 if (defined(_plugin_vars.srcs_compiler)) { 135 foreach(src, _plugin_vars.srcs_compiler) { 136 plugin_libarkcompiler_sources += [ "$_plugin_dir/$src" ] 137 } 138 } 139 if (defined(_plugin_vars.srcs_runtime)) { 140 foreach(src, _plugin_vars.srcs_runtime) { 141 plugin_runtime_sources += [ "$_plugin_dir/$src" ] 142 } 143 } 144 if (defined(_plugin_vars.srcs_verification)) { 145 foreach(src, _plugin_vars.srcs_verification) { 146 plugin_verifier_sources += [ "$_plugin_dir/$src" ] 147 } 148 } 149 150 if (defined(_plugin_vars.entrypoints_yaml_path)) { 151 plugin_entrypoints_yamls += 152 [ "$_plugin_dir/${_plugin_vars.entrypoints_yaml_path}" ] 153 } 154 if (defined(_plugin_vars.inst_templates_yaml_path)) { 155 plugin_inst_templates_yamls += 156 [ "$_plugin_dir/${_plugin_vars.inst_templates_yaml_path}" ] 157 } 158 if (defined(_plugin_vars.option_yaml_path)) { 159 plugin_option_yamls += [ "$_plugin_dir/${_plugin_vars.option_yaml_path}" ] 160 } 161 if (defined(_plugin_vars.runtime_option_yaml_path)) { 162 plugin_runtime_options_yamls += 163 [ "$_plugin_dir/${_plugin_vars.runtime_option_yaml_path}" ] 164 } 165 if (defined(_plugin_vars.compiler_options_yaml_path)) { 166 plugin_compiler_options_yamls += 167 [ "$_plugin_dir/${_plugin_vars.compiler_options_yaml_path}" ] 168 } 169 if (defined(_plugin_vars.runtime_yamls)) { 170 foreach(runtime_yaml, _plugin_vars.runtime_yamls) { 171 plugin_runtime_yamls += [ "$_plugin_dir/$runtime_yaml" ] 172 } 173 } 174 175 if (defined(_plugin_vars.irtoc_scripts)) { 176 foreach(irtoc_script, _plugin_vars.irtoc_scripts) { 177 plugin_irtoc_scripts += [ "$_plugin_dir/$irtoc_script" ] 178 } 179 } 180 181 if (defined(_plugin_vars.irtoc_plugins)) { 182 foreach(irtoc_plugin, _plugin_vars.irtoc_plugins) { 183 plugin_irtoc_plugins += [ "$_plugin_dir/$irtoc_plugin" ] 184 } 185 } 186 187 if (defined(_plugin_vars.srcs_isa)) { 188 foreach(src, _plugin_vars.srcs_isa) { 189 plugin_isa_paths += [ "$_plugin_dir/$src" ] 190 } 191 } 192} 193