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