13af6ab5fSopenharmony_ci# Copyright (c) 2021 Huawei Device Co., Ltd. 23af6ab5fSopenharmony_ci# Licensed under the Apache License, Version 2.0 (the "License"); 33af6ab5fSopenharmony_ci# you may not use this file except in compliance with the License. 43af6ab5fSopenharmony_ci# You may obtain a copy of the License at 53af6ab5fSopenharmony_ci# 63af6ab5fSopenharmony_ci# http://www.apache.org/licenses/LICENSE-2.0 73af6ab5fSopenharmony_ci# 83af6ab5fSopenharmony_ci# Unless required by applicable law or agreed to in writing, software 93af6ab5fSopenharmony_ci# distributed under the License is distributed on an "AS IS" BASIS, 103af6ab5fSopenharmony_ci# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 113af6ab5fSopenharmony_ci# See the License for the specific language governing permissions and 123af6ab5fSopenharmony_ci# limitations under the License. 133af6ab5fSopenharmony_ci 143af6ab5fSopenharmony_ciimport("//arkcompiler/ets_frontend/ets_frontend_config.gni") 153af6ab5fSopenharmony_ci 163af6ab5fSopenharmony_cies2abc_root = "//arkcompiler/ets_frontend/es2panda" 173af6ab5fSopenharmony_cies2abc_build_path = "" 183af6ab5fSopenharmony_cies2abc_build_deps = "" 193af6ab5fSopenharmony_cies2abc_out_root = "" 203af6ab5fSopenharmony_ci 213af6ab5fSopenharmony_ciif (host_toolchain == toolchain_mac) { 223af6ab5fSopenharmony_ci es2abc_out_root = 233af6ab5fSopenharmony_ci get_label_info("$es2abc_root:es2panda($toolchain_mac)", "root_out_dir") 243af6ab5fSopenharmony_ci es2abc_build_deps = [ "$es2abc_root:es2panda($toolchain_mac)" ] 253af6ab5fSopenharmony_ci} else if (host_toolchain == toolchain_win) { 263af6ab5fSopenharmony_ci es2abc_out_root = 273af6ab5fSopenharmony_ci get_label_info("$es2abc_root:es2panda($toolchain_win)", "root_out_dir") 283af6ab5fSopenharmony_ci es2abc_build_deps = [ "$es2abc_root:es2panda($toolchain_win)" ] 293af6ab5fSopenharmony_ci} else if (!ark_standalone_build && host_toolchain == toolchain_ohos) { 303af6ab5fSopenharmony_ci es2abc_out_root = 313af6ab5fSopenharmony_ci get_label_info("$es2abc_root:es2panda($toolchain_ohos)", "root_out_dir") 323af6ab5fSopenharmony_ci es2abc_build_deps = [ "$es2abc_root:es2panda($toolchain_ohos)" ] 333af6ab5fSopenharmony_ci} else { 343af6ab5fSopenharmony_ci es2abc_out_root = 353af6ab5fSopenharmony_ci get_label_info("$es2abc_root:es2panda($toolchain_linux)", "root_out_dir") 363af6ab5fSopenharmony_ci es2abc_build_deps = [ "$es2abc_root:es2panda($toolchain_linux)" ] 373af6ab5fSopenharmony_ci} 383af6ab5fSopenharmony_cies2abc_build_path = es2abc_out_root + "/arkcompiler/ets_frontend" 393af6ab5fSopenharmony_ci 403af6ab5fSopenharmony_ci# Generate abc. 413af6ab5fSopenharmony_ci# 423af6ab5fSopenharmony_ci# Mandatory arguments: 433af6ab5fSopenharmony_ci# plugin_path -- plugin js file path 443af6ab5fSopenharmony_ci# plugin_name -- name of js file, ex: BatteryPlugin.js 453af6ab5fSopenharmony_ci# generat_file -- name of generated file 463af6ab5fSopenharmony_ci# package_name -- name of generated file's package 473af6ab5fSopenharmony_ci# extra_dependencies -- a list of files that should be considered as dependencies, must be label 483af6ab5fSopenharmony_ci# out_puts 493af6ab5fSopenharmony_citemplate("es2abc_gen_abc") { 503af6ab5fSopenharmony_ci assert(defined(invoker.src_js), "src_js is required!") 513af6ab5fSopenharmony_ci assert(defined(invoker.dst_file), "dst_file is required!") 523af6ab5fSopenharmony_ci assert(defined(invoker.out_puts), "out_puts is required!") 533af6ab5fSopenharmony_ci 543af6ab5fSopenharmony_ci extra_dependencies = [] 553af6ab5fSopenharmony_ci if (defined(invoker.extra_dependencies)) { 563af6ab5fSopenharmony_ci extra_dependencies += invoker.extra_dependencies 573af6ab5fSopenharmony_ci } 583af6ab5fSopenharmony_ci 593af6ab5fSopenharmony_ci action("$target_name") { 603af6ab5fSopenharmony_ci if (defined(invoker.extra_visibility)) { 613af6ab5fSopenharmony_ci visibility = invoker.extra_visibility 623af6ab5fSopenharmony_ci } 633af6ab5fSopenharmony_ci 643af6ab5fSopenharmony_ci script = "${es2abc_root}/scripts/generate_js_bytecode.py" 653af6ab5fSopenharmony_ci 663af6ab5fSopenharmony_ci deps = extra_dependencies 673af6ab5fSopenharmony_ci deps += es2abc_build_deps 683af6ab5fSopenharmony_ci 693af6ab5fSopenharmony_ci args = [ 703af6ab5fSopenharmony_ci "--src-js", 713af6ab5fSopenharmony_ci invoker.src_js, 723af6ab5fSopenharmony_ci "--dst-file", 733af6ab5fSopenharmony_ci invoker.dst_file, 743af6ab5fSopenharmony_ci "--frontend-tool-path", 753af6ab5fSopenharmony_ci rebase_path("${es2abc_build_path}"), 763af6ab5fSopenharmony_ci ] 773af6ab5fSopenharmony_ci 783af6ab5fSopenharmony_ci if (defined(invoker.extension)) { 793af6ab5fSopenharmony_ci args += [ 803af6ab5fSopenharmony_ci "--extension", 813af6ab5fSopenharmony_ci invoker.extension, 823af6ab5fSopenharmony_ci ] 833af6ab5fSopenharmony_ci } 843af6ab5fSopenharmony_ci 853af6ab5fSopenharmony_ci if (defined(invoker.dump_symbol_table)) { 863af6ab5fSopenharmony_ci args += [ 873af6ab5fSopenharmony_ci "--dump-symbol-table", 883af6ab5fSopenharmony_ci invoker.dump_symbol_table, 893af6ab5fSopenharmony_ci ] 903af6ab5fSopenharmony_ci } 913af6ab5fSopenharmony_ci if (defined(invoker.input_symbol_table)) { 923af6ab5fSopenharmony_ci args += [ 933af6ab5fSopenharmony_ci "--input-symbol-table", 943af6ab5fSopenharmony_ci invoker.input_symbol_table, 953af6ab5fSopenharmony_ci ] 963af6ab5fSopenharmony_ci } 973af6ab5fSopenharmony_ci 983af6ab5fSopenharmony_ci if (defined(invoker.extra_args)) { 993af6ab5fSopenharmony_ci args += invoker.extra_args 1003af6ab5fSopenharmony_ci } 1013af6ab5fSopenharmony_ci 1023af6ab5fSopenharmony_ci if (defined(invoker.in_puts)) { 1033af6ab5fSopenharmony_ci inputs = invoker.in_puts 1043af6ab5fSopenharmony_ci } 1053af6ab5fSopenharmony_ci 1063af6ab5fSopenharmony_ci outputs = invoker.out_puts 1073af6ab5fSopenharmony_ci } 1083af6ab5fSopenharmony_ci} 1093af6ab5fSopenharmony_ci 1103af6ab5fSopenharmony_citemplate("es2abc_gen_newest_abc") { 1113af6ab5fSopenharmony_ci assert(defined(invoker.src_js), "src_js is required!") 1123af6ab5fSopenharmony_ci assert(defined(invoker.dst_file), "dst_file is required!") 1133af6ab5fSopenharmony_ci assert(defined(invoker.out_puts), "out_puts is required!") 1143af6ab5fSopenharmony_ci 1153af6ab5fSopenharmony_ci extra_dependencies = [] 1163af6ab5fSopenharmony_ci if (defined(invoker.extra_dependencies)) { 1173af6ab5fSopenharmony_ci extra_dependencies += invoker.extra_dependencies 1183af6ab5fSopenharmony_ci } 1193af6ab5fSopenharmony_ci 1203af6ab5fSopenharmony_ci action("$target_name") { 1213af6ab5fSopenharmony_ci if (defined(invoker.extra_visibility)) { 1223af6ab5fSopenharmony_ci visibility = invoker.extra_visibility 1233af6ab5fSopenharmony_ci } 1243af6ab5fSopenharmony_ci 1253af6ab5fSopenharmony_ci script = "${es2abc_root}/scripts/generate_js_bytecode.py" 1263af6ab5fSopenharmony_ci 1273af6ab5fSopenharmony_ci deps = extra_dependencies 1283af6ab5fSopenharmony_ci deps += es2abc_build_deps 1293af6ab5fSopenharmony_ci 1303af6ab5fSopenharmony_ci args = [ 1313af6ab5fSopenharmony_ci "--src-js", 1323af6ab5fSopenharmony_ci invoker.src_js, 1333af6ab5fSopenharmony_ci "--dst-file", 1343af6ab5fSopenharmony_ci invoker.dst_file, 1353af6ab5fSopenharmony_ci "--frontend-tool-path", 1363af6ab5fSopenharmony_ci rebase_path("${es2abc_build_path}"), 1373af6ab5fSopenharmony_ci ] 1383af6ab5fSopenharmony_ci 1393af6ab5fSopenharmony_ci if (defined(invoker.extension)) { 1403af6ab5fSopenharmony_ci args += [ 1413af6ab5fSopenharmony_ci "--extension", 1423af6ab5fSopenharmony_ci invoker.extension, 1433af6ab5fSopenharmony_ci ] 1443af6ab5fSopenharmony_ci } 1453af6ab5fSopenharmony_ci 1463af6ab5fSopenharmony_ci if (defined(invoker.dump_symbol_table)) { 1473af6ab5fSopenharmony_ci args += [ 1483af6ab5fSopenharmony_ci "--dump-symbol-table", 1493af6ab5fSopenharmony_ci invoker.dump_symbol_table, 1503af6ab5fSopenharmony_ci ] 1513af6ab5fSopenharmony_ci } 1523af6ab5fSopenharmony_ci if (defined(invoker.input_symbol_table)) { 1533af6ab5fSopenharmony_ci args += [ 1543af6ab5fSopenharmony_ci "--input-symbol-table", 1553af6ab5fSopenharmony_ci invoker.input_symbol_table, 1563af6ab5fSopenharmony_ci ] 1573af6ab5fSopenharmony_ci } 1583af6ab5fSopenharmony_ci 1593af6ab5fSopenharmony_ci if (defined(invoker.extra_args)) { 1603af6ab5fSopenharmony_ci args += invoker.extra_args 1613af6ab5fSopenharmony_ci } 1623af6ab5fSopenharmony_ci 1633af6ab5fSopenharmony_ci if (defined(invoker.in_puts)) { 1643af6ab5fSopenharmony_ci inputs = invoker.in_puts 1653af6ab5fSopenharmony_ci } 1663af6ab5fSopenharmony_ci 1673af6ab5fSopenharmony_ci args += [ "--target-api-sub-version=beta3" ] 1683af6ab5fSopenharmony_ci 1693af6ab5fSopenharmony_ci outputs = invoker.out_puts 1703af6ab5fSopenharmony_ci } 1713af6ab5fSopenharmony_ci} 172