1# Copyright (c) 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/ark_config.gni") 15import("$ark_root/tests/test_helper.gni") 16import("$build_root/config/components/ets_frontend/es2abc_config.gni") 17 18abc2prog_test_configs = [ 19 "$ark_root:ark_config", 20 "$ark_root/assembler:arkassembler_public_config", 21 "$ark_root/libpandabase:arkbase_public_config", 22 "$ark_root/libpandafile:arkfile_public_config", 23] 24 25abc2prog_test_deps = [ 26 "$ark_root/abc2program:abc2program", 27 "$ark_root/assembler:libarkassembler_static", 28 "$ark_root/libpandabase:libarkbase_static", 29 "$ark_root/libpandafile:libarkfile_static", 30] 31 32test_ts_dir = "//arkcompiler/runtime_core/abc2program/tests/ts/" 33test_line_number_dir = 34 "//arkcompiler/runtime_core/abc2program/tests/ts/release-line-number/" 35test_json_dir = "//arkcompiler/runtime_core/abc2program/tests/json/" 36 37abc2prog_test_release_line_number_files = [ 38 "InvalidOpcode", 39 "CommonSyntax", 40 "TsNewFeatrueSyntax", 41] 42 43foreach(file, abc2prog_test_release_line_number_files) { 44 es2abc_gen_abc("gen_${file}_abc") { 45 test_ts = "${test_line_number_dir}${file}.ts" 46 test_abc = "$target_out_dir/${file}.abc" 47 48 src_js = rebase_path(test_ts) 49 dst_file = rebase_path(test_abc) 50 extra_args = [ "--module" ] 51 in_puts = [ test_ts ] 52 out_puts = [ test_abc ] 53 } 54} 55 56abc2prog_test_ts_files = [ 57 "HelloWorld", 58 "Annotations", 59] 60 61foreach(file, abc2prog_test_ts_files) { 62 es2abc_gen_abc("gen_${file}_abc") { 63 test_ts = "${test_ts_dir}${file}.ts" 64 test_abc = "$target_out_dir/${file}.abc" 65 66 src_js = rebase_path(test_ts) 67 dst_file = rebase_path(test_abc) 68 extra_args = [ "--module" ] 69 if (file == "Annotations") { 70 extra_args += [ "--enable-annotations" ] 71 } 72 in_puts = [ test_ts ] 73 out_puts = [ test_abc ] 74 } 75} 76 77abc2prog_debug_test_ts_files = [ "HelloWorld" ] 78 79foreach(file, abc2prog_debug_test_ts_files) { 80 es2abc_gen_abc("gen_${file}_debug_abc") { 81 test_ts = "${test_ts_dir}${file}.ts" 82 test_abc = "$target_out_dir/${file}Debug.abc" 83 84 src_js = rebase_path(test_ts) 85 dst_file = rebase_path(test_abc) 86 extra_args = [ 87 "--debug", 88 "--module", 89 ] 90 in_puts = [ test_ts ] 91 out_puts = [ test_abc ] 92 } 93} 94 95abc2prog_test_json_files = [ "JsonTest" ] 96 97foreach(file, abc2prog_test_json_files) { 98 es2abc_gen_abc("gen_${file}_abc") { 99 test_json = "${test_json_dir}${file}.json" 100 test_abc = "$target_out_dir/${file}.abc" 101 102 src_js = rebase_path(test_json) 103 dst_file = rebase_path(test_abc) 104 extra_args = [ 105 "--module", 106 "--merge-abc", 107 ] 108 in_puts = [ test_json ] 109 out_puts = [ test_abc ] 110 } 111} 112 113abc2prog_include_dirs = [ 114 "$ark_root/abc2program", 115 "$ark_root/assembler", 116 "$target_gen_dir", 117 "$target_gen_dir/../", 118 "$target_gen_dir/../../assembler", 119] 120 121script_sources = [ 122 "cpp_sources/abc2program_test_utils.cpp", 123 "cpp_sources/hello_world_test.cpp", 124 "cpp_sources/release_line_number.cpp", 125] 126 127host_unittest_action("Abc2ProgScriptTest") { 128 module_out_path = module_output_path 129 sources = script_sources 130 include_dirs = abc2prog_include_dirs 131 configs = abc2prog_test_configs 132 external_deps = [ sdk_libc_secshared_dep ] 133 deps = abc2prog_test_deps 134 test_abc_dir = rebase_path(target_out_dir) 135 test_abc_dump_dir = rebase_path(test_ts_dir) 136 defines = [ 137 "GRAPH_TEST_ABC_DIR=\"${test_abc_dir}/\"", 138 "GRAPH_TEST_ABC_DUMP_DIR=\"${test_abc_dump_dir}/\"", 139 ] 140 141 foreach(file, abc2prog_test_ts_files) { 142 deps += [ ":gen_${file}_abc" ] 143 } 144 foreach(file, abc2prog_debug_test_ts_files) { 145 deps += [ ":gen_${file}_debug_abc" ] 146 } 147 foreach(file, abc2prog_test_json_files) { 148 deps += [ ":gen_${file}_abc" ] 149 } 150 foreach(file, abc2prog_test_release_line_number_files) { 151 deps += [ ":gen_${file}_abc" ] 152 } 153} 154 155action("gen_filesinfo_action") { 156 script = "handle_fileinfo.py" 157 158 inputs = [ "sourceLang/filesInfo.txt" ] 159 outputs = [ "${target_out_dir}/sourceLang/filesInfo.txt" ] 160 args = [ 161 rebase_path("sourceLang/filesInfo.txt"), 162 rebase_path("${target_out_dir}/sourceLang/filesInfo.txt"), 163 rebase_path("./"), 164 ] 165} 166 167es2abc_gen_abc("gen_sourceLang_abc") { 168 test_abc = "$target_out_dir/sourceLang.abc" 169 fileinfo_path = rebase_path("${target_out_dir}/sourceLang/filesInfo.txt") 170 src_js = "@${fileinfo_path}" 171 dst_file = rebase_path(test_abc) 172 extra_args = [ 173 "--module", 174 "--merge-abc", 175 "--enable-annotations", 176 ] 177 out_puts = [ test_abc ] 178} 179 180host_unittest_action("Abc2ProgSourceLangTest") { 181 module_out_path = module_output_path 182 sources = [ "cpp_sources/sourceLang_test.cpp" ] 183 include_dirs = abc2prog_include_dirs 184 configs = abc2prog_test_configs 185 external_deps = [ sdk_libc_secshared_dep ] 186 deps = abc2prog_test_deps 187 test_abc_dir = rebase_path(target_out_dir) 188 test_abc_dump_dir = rebase_path(test_ts_dir) 189 defines = [ 190 "GRAPH_TEST_ABC_DIR=\"${test_abc_dir}/\"", 191 "GRAPH_TEST_ABC_DUMP_DIR=\"${test_abc_dump_dir}/\"", 192 ] 193 194 deps += [ 195 ":gen_filesinfo_action", 196 ":gen_sourceLang_abc", 197 ] 198} 199 200group("host_unittest") { 201 testonly = true 202 deps = [ 203 ":Abc2ProgScriptTestAction", 204 ":Abc2ProgSourceLangTestAction", 205 ] 206} 207