1# Copyright (c) 2021 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/ets_frontend/ets_frontend_config.gni") 15 16es2abc_root = "//arkcompiler/ets_frontend/es2panda" 17es2abc_build_path = "" 18es2abc_build_deps = "" 19es2abc_out_root = "" 20 21if (host_toolchain == toolchain_mac) { 22 es2abc_out_root = 23 get_label_info("$es2abc_root:es2panda($toolchain_mac)", "root_out_dir") 24 es2abc_build_deps = [ "$es2abc_root:es2panda($toolchain_mac)" ] 25} else if (host_toolchain == toolchain_win) { 26 es2abc_out_root = 27 get_label_info("$es2abc_root:es2panda($toolchain_win)", "root_out_dir") 28 es2abc_build_deps = [ "$es2abc_root:es2panda($toolchain_win)" ] 29} else { 30 es2abc_out_root = 31 get_label_info("$es2abc_root:es2panda($toolchain_linux)", "root_out_dir") 32 es2abc_build_deps = [ "$es2abc_root:es2panda($toolchain_linux)" ] 33} 34es2abc_build_path = es2abc_out_root + "/arkcompiler/ets_frontend" 35 36# Generate abc. 37# 38# Mandatory arguments: 39# plugin_path -- plugin js file path 40# plugin_name -- name of js file, ex: BatteryPlugin.js 41# generat_file -- name of generated file 42# package_name -- name of generated file's package 43# extra_dependencies -- a list of files that should be considered as dependencies, must be label 44# out_puts 45template("es2abc_gen_abc") { 46 assert(defined(invoker.src_js), "src_js is required!") 47 assert(defined(invoker.dst_file), "dst_file is required!") 48 assert(defined(invoker.out_puts), "out_puts is required!") 49 50 extra_dependencies = [] 51 if (defined(invoker.extra_dependencies)) { 52 extra_dependencies += invoker.extra_dependencies 53 } 54 55 action("$target_name") { 56 if (defined(invoker.extra_visibility)) { 57 visibility = invoker.extra_visibility 58 } 59 60 script = "${es2abc_root}/scripts/generate_js_bytecode.py" 61 62 deps = extra_dependencies 63 deps += es2abc_build_deps 64 65 args = [ 66 "--src-js", 67 invoker.src_js, 68 "--dst-file", 69 invoker.dst_file, 70 "--frontend-tool-path", 71 rebase_path("${es2abc_build_path}"), 72 ] 73 74 if (defined(invoker.extension)) { 75 args += [ 76 "--extension", 77 invoker.extension, 78 ] 79 } 80 81 if (defined(invoker.dump_symbol_table)) { 82 args += [ 83 "--dump-symbol-table", 84 invoker.dump_symbol_table, 85 ] 86 } 87 if (defined(invoker.input_symbol_table)) { 88 args += [ 89 "--input-symbol-table", 90 invoker.input_symbol_table, 91 ] 92 } 93 94 if (defined(invoker.extra_args)) { 95 args += invoker.extra_args 96 } 97 98 if (defined(invoker.in_puts)) { 99 inputs = invoker.in_puts 100 } 101 102 outputs = invoker.out_puts 103 } 104} 105