• 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")
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 = []
40plugin_abc2program_sources = []
41
42plugin_entrypoints_yamls = []
43plugin_inst_templates_yamls = []
44plugin_option_yamls = []
45plugin_runtime_options_yamls = []
46plugin_compiler_options_yamls = []
47plugin_runtime_yamls = []
48
49plugin_irtoc_scripts = []
50plugin_irtoc_plugins = []
51
52plugin_isa_paths = []
53
54plugin_create_pipeline_paths = []
55plugin_read_profile_paths = []
56plugin_destroy_profile_paths = []
57plugin_find_method_in_profile_paths = []
58plugin_dump_profile_paths = []
59plugin_clear_profile_paths = []
60plugin_profiling_includes_paths = []
61plugin_profiling_includes_disasm_paths = []
62plugin_get_profiling_any_type_paths = []
63
64plugin_enable_bytecode_optimizer = false
65
66# All paths and labels in the exported variables should be source-absolute.
67
68foreach(plugin, ark_enabled_plugins) {
69  print("Reading plugin sources: $plugin ($current_toolchain)")
70  _plugin_dir = "$ark_root/plugins/$plugin"
71  _plugin_vars = {
72  }
73
74  # To read variables defined by plugins into a scope while avoiding conflict
75  # with the current scope, we read plugin.gn which should be a wrapper around
76  # subproject_sources.gn that simply `import`s the latter. The import command
77  # is more powerful than read_file in that it resolves paths relative to the
78  # current file and also has `current_cpu`, etc. values defined which allows to
79  # write more conventional GN code.
80  _plugin_vars = read_file("$_plugin_dir/plugin.gn", "scope")
81
82  if (defined(_plugin_vars.enable_bytecode_optimizer)) {
83    plugin_bytecodeopt_configs += [ "$_plugin_dir:bytecodeopt" ]
84    plugin_enable_bytecode_optimizer = plugin_enable_bytecode_optimizer ||
85                                       _plugin_vars.enable_bytecode_optimizer
86  }
87
88  plugin_ark_host_linux_tools_packages +=
89      [ "$_plugin_dir:ark_host_linux_tools_packages" ]
90  plugin_ark_host_windows_tools_packages +=
91      [ "$_plugin_dir:ark_host_windows_tools_packages" ]
92  plugin_ark_host_mac_tools_packages +=
93      [ "$_plugin_dir:ark_host_mac_tools_packages" ]
94  plugin_ark_packages += [ "$_plugin_dir:ark_packages" ]
95
96  plugin_ark_configs += [ "$_plugin_dir:ark_config" ]
97  plugin_libarkassembler_configs += [ "$_plugin_dir:assembler" ]
98  plugin_runtime_configs += [ "$_plugin_dir:runtime" ]
99  plugin_runtime_interpreter_impl_configs +=
100      [ "$_plugin_dir:runtime_interpreter_impl" ]
101
102  plugin_assembler_deps += [ "$_plugin_dir:assembler_deps" ]
103
104  if (defined(_plugin_vars.arkruntime_header_sub_deps)) {
105    foreach(sub_dep, _plugin_vars.arkruntime_header_sub_deps) {
106      plugin_arkruntime_header_plugin_deps += [ sub_dep ]
107    }
108  }
109  if (defined(_plugin_vars.arkruntime_stdlib_sub_deps)) {
110    foreach(sub_dep, _plugin_vars.arkruntime_stdlib_sub_deps) {
111      plugin_arkruntime_stdlib_plugin_deps += [ sub_dep ]
112    }
113  }
114  if (defined(_plugin_vars.arkbytecodeopt_deps)) {
115    foreach(sub_dep, _plugin_vars.arkbytecodeopt_deps) {
116      plugin_bytecodeopt_deps += [ sub_dep ]
117    }
118  }
119  if (defined(_plugin_vars.arkcompiler_deps)) {
120    foreach(sub_dep, _plugin_vars.arkcompiler_deps) {
121      plugin_compiler_deps += [ sub_dep ]
122    }
123  }
124  if (defined(_plugin_vars.arkruntime_deps)) {
125    foreach(sub_dep, _plugin_vars.arkruntime_deps) {
126      plugin_runtime_deps += [ sub_dep ]
127    }
128  }
129
130  if (defined(_plugin_vars.srcs_abc2program)) {
131    foreach(src, _plugin_vars.srcs_abc2program) {
132      plugin_abc2program_sources += [ "$_plugin_dir/$src" ]
133    }
134  }
135  if (defined(_plugin_vars.srcs_disassembler)) {
136    foreach(src, _plugin_vars.srcs_disassembler) {
137      plugin_arkdisassembler_sources += [ "$_plugin_dir/$src" ]
138    }
139  }
140  if (defined(_plugin_vars.srcs_assembler)) {
141    foreach(src, _plugin_vars.srcs_assembler) {
142      plugin_libarkassembler_sources += [ "$_plugin_dir/$src" ]
143    }
144  }
145  if (defined(_plugin_vars.srcs_bytecode_optimizer)) {
146    foreach(src, _plugin_vars.srcs_bytecode_optimizer) {
147      plugin_libarkbytecodeopt_sources += [ "$_plugin_dir/$src" ]
148    }
149  }
150  if (defined(_plugin_vars.srcs_compiler)) {
151    foreach(src, _plugin_vars.srcs_compiler) {
152      plugin_libarkcompiler_sources += [ "$_plugin_dir/$src" ]
153    }
154  }
155  if (defined(_plugin_vars.srcs_runtime)) {
156    foreach(src, _plugin_vars.srcs_runtime) {
157      plugin_runtime_sources += [ "$_plugin_dir/$src" ]
158    }
159  }
160  if (defined(_plugin_vars.configs_runtime)) {
161    foreach(src, _plugin_vars.configs_runtime) {
162      plugin_runtime_configs += [ "$_plugin_dir/$src" ]
163    }
164  }
165  if (defined(_plugin_vars.srcs_verification)) {
166    foreach(src, _plugin_vars.srcs_verification) {
167      plugin_verifier_sources += [ "$_plugin_dir/$src" ]
168    }
169  }
170
171  if (defined(_plugin_vars.entrypoints_yaml_path)) {
172    plugin_entrypoints_yamls +=
173        [ "$_plugin_dir/${_plugin_vars.entrypoints_yaml_path}" ]
174  }
175  if (defined(_plugin_vars.inst_templates_yaml_path)) {
176    plugin_inst_templates_yamls +=
177        [ "$_plugin_dir/${_plugin_vars.inst_templates_yaml_path}" ]
178  }
179  if (defined(_plugin_vars.option_yaml_path)) {
180    plugin_option_yamls += [ "$_plugin_dir/${_plugin_vars.option_yaml_path}" ]
181  }
182  if (defined(_plugin_vars.runtime_option_yaml_path)) {
183    foreach(src, _plugin_vars.runtime_option_yaml_path) {
184      plugin_runtime_options_yamls += [ "$_plugin_dir/$src" ]
185    }
186  }
187  if (defined(_plugin_vars.compiler_options_yaml_path)) {
188    plugin_compiler_options_yamls +=
189        [ "$_plugin_dir/${_plugin_vars.compiler_options_yaml_path}" ]
190  }
191  if (defined(_plugin_vars.runtime_yamls)) {
192    plugin_runtime_yamls +=
193        rebase_path(_plugin_vars.runtime_yamls, "", _plugin_dir)
194  }
195  if (defined(_plugin_vars.irtoc_scripts)) {
196    plugin_irtoc_scripts +=
197        rebase_path(_plugin_vars.irtoc_scripts, "", _plugin_dir)
198  }
199  if (defined(_plugin_vars.irtoc_plugins)) {
200    plugin_irtoc_plugins +=
201        rebase_path(_plugin_vars.irtoc_plugins, "", _plugin_dir)
202  }
203  if (defined(_plugin_vars.srcs_isa)) {
204    plugin_isa_paths += rebase_path(_plugin_vars.srcs_isa, "", _plugin_dir)
205  }
206
207  if (defined(_plugin_vars.create_pipeline)) {
208    plugin_create_pipeline_paths +=
209        [ rebase_path(_plugin_vars.create_pipeline, "", _plugin_dir) ]
210  }
211  if (defined(_plugin_vars.read_profile)) {
212    plugin_read_profile_paths +=
213        [ rebase_path(_plugin_vars.read_profile, "", _plugin_dir) ]
214  }
215  if (defined(_plugin_vars.destroy_profile)) {
216    plugin_destroy_profile_paths +=
217        [ rebase_path(_plugin_vars.destroy_profile, "", _plugin_dir) ]
218  }
219  if (defined(_plugin_vars.find_method_in_profile)) {
220    plugin_find_method_in_profile_paths +=
221        [ rebase_path(_plugin_vars.find_method_in_profile, "", _plugin_dir) ]
222  }
223  if (defined(_plugin_vars.dump_profile)) {
224    plugin_dump_profile_paths +=
225        [ rebase_path(_plugin_vars.dump_profile, "", _plugin_dir) ]
226  }
227  if (defined(_plugin_vars.clear_profile)) {
228    plugin_clear_profile_paths +=
229        [ rebase_path(_plugin_vars.clear_profile, "", _plugin_dir) ]
230  }
231  if (defined(_plugin_vars.profiling_includes)) {
232    plugin_profiling_includes_paths +=
233        [ rebase_path(_plugin_vars.profiling_includes, "", _plugin_dir) ]
234  }
235  if (defined(_plugin_vars.profiling_includes_disasm)) {
236    plugin_profiling_includes_disasm_paths +=
237        [ rebase_path(_plugin_vars.profiling_includes_disasm, "", _plugin_dir) ]
238  }
239  if (defined(_plugin_vars.get_profiling_any_type)) {
240    plugin_get_profiling_any_type_paths +=
241        [ rebase_path(_plugin_vars.get_profiling_any_type, "", _plugin_dir) ]
242  }
243}
244