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("//build/ohos.gni") 15import("//build/test.gni") 16if (precise_xts) { 17 import("//out/preloader/precise_run.gni") 18} 19 20declare_args() { 21 SUITES_OUTPUT_ROOT = "$root_out_dir/suites" 22 SUITE_ARCHIVE_DIR = "$root_out_dir/suites/archives" 23 TESTCONFIG_FILENAME = "Test.xml" 24 XTS_ROOT = "//test/xts" 25 ACTS_ROOT = "//test/xts/acts" 26 HATS_ROOT = "//test/xts/hats" 27 HITS_ROOT = "//test/xts/hits" 28 DCTS_ROOT = "//test/xts/dcts" 29 30 # create testsuite archive is time-consuming, do it only if necessary 31 make_archive = false 32 XTS_SUITENAME = getenv("XTS_SUITENAME") 33 if (getenv("XTS_SUITETYPE") != "") { 34 XTS_SUITETYPE = string_split(getenv("XTS_SUITETYPE"), ",") 35 } else { 36 XTS_SUITETYPE = ["bin", "hap_dynamic"] 37 } 38} 39 40template("ohos_testsuite_base") { 41 assert(defined(invoker.project_type), 42 "project_type is required in target ${target_name}") 43 44 _part_name = "common" 45 46 if (defined(invoker.part_name)) { 47 _part_name = invoker.part_name 48 } 49 50 precise_build_boolean = true 51 if (precise_xts && filter_include(precise_run, 52 [ 53 "all", 54 _part_name, 55 ]) == []) { 56 print("precise_xts is on ,${_part_name} is not on build") 57 precise_build_boolean = false 58 } 59 if (precise_build_boolean) { 60 _subsystem_name = "common" 61 if (defined(invoker.subsystem_name)) { 62 _subsystem_name = invoker.subsystem_name 63 } 64 _project_type = invoker.project_type 65 66 _build_part_boolean = false 67 tmp_subsystem_part = "${_subsystem_name}_${_part_name}" 68 _part_script_judge = "//test/xts/tools/build/judgePart.py" 69 _script_judge_args1 = [ 70 rebase_path("$preloader_output_dir") + "/parts_config.json", 71 tmp_subsystem_part, 72 "judgePart", 73 ] 74 _build_part_boolean_str = exec_script(rebase_path(_part_script_judge), 75 _script_judge_args1, 76 "trim string") 77 if (_build_part_boolean_str == "True") { 78 _build_part_boolean = true 79 } 80 81 if (_subsystem_name == "kernel" || _subsystem_name == "common") { 82 _build_part_boolean = true 83 } 84 85 _test_files = "" 86 if (defined(invoker.generated_testfiles)) { 87 foreach(file, invoker.generated_testfiles) { 88 _test_files = 89 _test_files + "," + rebase_path("$root_gen_dir") + "/" + file 90 } 91 } 92 93 _is_testbundle = defined(invoker.is_testbundle) && invoker.is_testbundle 94 95 if (defined(invoker.sub_output_dir)) { 96 _output_file_dir = rebase_path( 97 "$root_out_dir/tests/moduletest/${invoker.sub_output_dir}") 98 } else if (defined(invoker.module_out_path)) { 99 _output_file_dir = rebase_path( 100 "$root_out_dir/tests/moduletest/${invoker.module_out_path}") 101 } else { 102 _output_file_dir = rebase_path("$root_out_dir/tests/moduletest") 103 } 104 _output_file = "${_output_file_dir}/module_${target_name}" 105 106 if (_project_type == "gtest" || _project_type == "ctestbundle") { 107 _output_file = "${_output_file_dir}/${target_name}" 108 _archive_filename = "${target_name}" 109 if (_build_part_boolean == true) { 110 target("ohos_moduletest", "module_${target_name}") { 111 forward_variables_from(invoker, "*") 112 testonly = true 113 } 114 } else { 115 print(tmp_subsystem_part + " is not build") 116 if (defined(invoker.public_configs)) { 117 print(invoker.public_configs) 118 } 119 if (defined(invoker.external_deps)) { 120 print(invoker.external_deps) 121 } 122 if (defined(invoker.deps)) { 123 print(invoker.deps) 124 } 125 if (defined(invoker.configs)) { 126 print(invoker.configs) 127 } 128 if (defined(invoker.sources)) { 129 print(invoker.sources) 130 } 131 not_needed(invoker, "*") 132 } 133 } else if (_project_type == "zunit" || _project_type == "javatestbundle") { 134 _output_file = "${_output_file_dir}/module_${target_name}.dex" 135 _archive_filename = "${target_name}.dex" 136 if (_build_part_boolean == true) { 137 target("ohos_java_moduletest", "module_${target_name}") { 138 forward_variables_from(invoker, "*") 139 testonly = true 140 } 141 } 142 } else if (_project_type == "hostjunit") { 143 _output_file = "${_output_file_dir}/module_${target_name}.jar" 144 if (defined(invoker.final_jar_path)) { 145 _output_file = invoker.final_jar_path 146 } 147 _archive_filename = "${target_name}.jar" 148 if (_build_part_boolean == true) { 149 target("java_library", "module_${target_name}") { 150 forward_variables_from(invoker, "*") 151 is_host_library = true 152 } 153 } 154 } else if (_project_type == "testhap" || _project_type == "haptestbundle" || 155 _project_type == "testhapassist" || _project_type == "testapp" || 156 _project_type == "testappassist") { 157 assert(defined(invoker.hap_name), 158 "hap_name is required in target ${target_name}") 159 assert(!defined(invoker.final_hap_path), 160 "please use hap_name instead of final_hap_path") 161 162 _hap_name = invoker.hap_name 163 _final_hap_path = "" 164 _target_name = "" 165 _suite_out_dir = "${SUITES_OUTPUT_ROOT}/${XTS_SUITENAME}" 166 subsystem_name = XTS_SUITENAME 167 if (subsystem_name == "acts") { 168 _suite_out_dir = "${SUITES_OUTPUT_ROOT}/${XTS_SUITENAME}/acts" 169 } 170 if (_project_type == "testhapassist") { 171 _final_hap_path = "${_suite_out_dir}/testcases/${_hap_name}.hap" 172 _target_name = target_name 173 } else { 174 _final_hap_path = "${SUITES_OUTPUT_ROOT}/haps/${_hap_name}.hap" 175 _target_name = "module_${target_name}" 176 } 177 _output_file = _final_hap_path 178 _archive_filename = "${_hap_name}.hap" 179 if (_build_part_boolean == true) { 180 if (_project_type == "testapp") { 181 target("ohos_app", _target_name) { 182 forward_variables_from(invoker, "*") 183 subsystem_name = XTS_SUITENAME 184 hap_out_dir = "${SUITES_OUTPUT_ROOT}/haps" 185 testonly = true 186 } 187 } else if (_project_type == "testappassist") { 188 target("ohos_app", target_name) { 189 forward_variables_from(invoker, "*") 190 subsystem_name = XTS_SUITENAME 191 hap_out_dir = "${_suite_out_dir}/testcases" 192 testonly = true 193 } 194 } else { 195 target("ohos_hap", _target_name) { 196 forward_variables_from(invoker, "*") 197 subsystem_name = XTS_SUITENAME 198 final_hap_path = _final_hap_path 199 testonly = true 200 } 201 } 202 } else { 203 print(tmp_subsystem_part + " is not build") 204 not_needed(invoker, "*") 205 } 206 } else if (_project_type == "pythontest") { 207 if (defined(invoker.outputs_dir)) { 208 _out_put_dir = invoker.outputs_dir 209 _archive_filename = "${_subsystem_name}/${_out_put_dir}" 210 } else { 211 _archive_filename = "${_subsystem_name}" 212 } 213 _test_files = invoker.output_file 214 _deps = [] 215 if (defined(invoker.deps)) { 216 _deps = invoker.deps 217 } 218 } else if (_project_type == "js_test_hap") { 219 _hap_name = invoker.test_hap_name 220 _output_file = invoker.hap_source_path 221 _archive_filename = "${_hap_name}.hap" 222 } 223 224 _apilibrary_deps = "" 225 if (_is_testbundle && defined(invoker.deps)) { 226 foreach(dep, invoker.deps) { 227 _apilibrary_deps = _apilibrary_deps + "," + dep 228 } 229 } 230 231 if (_project_type != "pythontest" && _project_type != "js_test_hap" && 232 _project_type != "testhapassist" && _project_type != "testappassist") { 233 _deps = [ ":module_${target_name}" ] 234 } else if (_project_type == "pythontest") { 235 print("this is pythontest") 236 } else if (_project_type != "testhapassist" && 237 _project_type != "testappassist") { 238 _deps = [] 239 } 240 _suite_out_dir = "${SUITES_OUTPUT_ROOT}/${XTS_SUITENAME}" 241 242 _archive_testfile = "" 243 subsystem_name = XTS_SUITENAME 244 if (subsystem_name == "acts") { 245 _suite_out_dir = "${SUITES_OUTPUT_ROOT}/${XTS_SUITENAME}/acts" 246 } 247 if (_project_type == "testhapassist" || _project_type == "testappassist") { 248 _archive_testfile = 249 "${_suite_out_dir}/testcases/module_${_archive_filename}" 250 } else if (_project_type == "testapp") { 251 _hap_name = invoker.hap_name 252 if (_hap_name == "validator" && subsystem_name == "acts") { 253 _suite_out_dir = "${SUITES_OUTPUT_ROOT}/${XTS_SUITENAME}/acts-validator" 254 _archive_testfile = "${_suite_out_dir}/testcases/${_archive_filename}" 255 } else { 256 _archive_testfile = "${_suite_out_dir}/testcases/${_archive_filename}" 257 } 258 } else { 259 _archive_testfile = "${_suite_out_dir}/testcases/${_archive_filename}" 260 } 261 _arguments = [ 262 "build_module_with_testbundle", 263 "--build_gen_dir", 264 rebase_path("$root_gen_dir"), 265 "--build_target_name", 266 target_name, 267 "--buildgen_testfile", 268 rebase_path(_output_file), 269 "--project_path", 270 rebase_path("."), 271 "--test_xml", 272 rebase_path(TESTCONFIG_FILENAME), 273 "--project_type", 274 _project_type, 275 "--suite_out_dir", 276 rebase_path("${_suite_out_dir}"), 277 "--archive_testfile", 278 rebase_path("${_archive_testfile}"), 279 ] 280 281 if (_subsystem_name != "") { 282 _arguments += [ 283 "--subsystem_name", 284 _subsystem_name, 285 ] 286 } 287 if (_part_name != "") { 288 _arguments += [ 289 "--part_name", 290 _part_name, 291 ] 292 } 293 if (_apilibrary_deps != "") { 294 _arguments += [ 295 "--apilibrary_deps", 296 _apilibrary_deps, 297 ] 298 } 299 300 if (_test_files != "") { 301 _arguments += [ 302 "--test_files", 303 _test_files, 304 ] 305 } 306 if (_build_part_boolean == true && _project_type != "testhapassist" && 307 _project_type != "testappassist") { 308 action(target_name) { 309 deps = _deps 310 script = rebase_path("//test/xts/tools/build/suite.py") 311 args = _arguments 312 outputs = [ _archive_testfile ] 313 testonly = true 314 } 315 } else if (_build_part_boolean == false) { 316 action(target_name) { 317 script = rebase_path("//test/xts/tools/build/judgePart.py") 318 args = _arguments 319 outputs = [ _archive_testfile ] 320 testonly = true 321 } 322 if (defined(_deps)) { 323 print(_deps) 324 } 325 } 326 } else { 327 group(target_name) { 328 print(target_name + " is not build") 329 not_needed(invoker, "*") 330 } 331 } 332} 333 334# 过滤suite_type 335template("ohos_testsuite_base_with_filter") { 336 if (XTS_SUITETYPE == [] || 337 filter_include(XTS_SUITETYPE, [ invoker.suite_type ]) != []) { 338 # Begin:临时方案:复制hypium到工程路径,hvigor支持ohosTest后可删除 339 if (invoker.suite_type == "hap_static") { 340 _project_dir = rebase_path(".") 341 exec_script(rebase_path("//test/xts/tools/build/copy_hypium_static.sh"), 342 [ _project_dir ]) 343 } 344 345 # End :临时方案:复制hypium到工程路径,hvigor支持ohosTest后可删除 346 347 target("ohos_testsuite_base", "${target_name}") { 348 not_needed(invoker, [ invoker.suite_type ]) 349 forward_variables_from(invoker, "*") 350 } 351 } else { 352 group(target_name) { 353 print("[XTS] suite_type mismatch, no need build " + target_name) 354 not_needed(invoker, "*") 355 } 356 } 357} 358 359template("ohos_moduletest_suite") { 360 target("ohos_testsuite_base_with_filter", "${target_name}") { 361 forward_variables_from(invoker, "*") 362 if (!defined(module_out_path)) { 363 module_out_path = "xts/modules" 364 } 365 project_type = "gtest" 366 suite_type = "bin" 367 } 368} 369 370template("ohos_hap_suite") { 371 suite_type = "hap_dynamic" 372 target("ohos_testsuite_base_with_filter", "${target_name}") { 373 forward_variables_from(invoker, "*") 374 375 # auto add HJUnitRunner entry ability and test-framework 376 if (defined(hap_profile)) { 377 # NOTE:: the GN tool disallow source files located in the ${out_dir} 378 # so we put the generated files in the xts dir. remember to REMOVE these. 379 _profile_relative_path = rebase_path(hap_profile, rebase_path(XTS_ROOT)) 380 _fixed_profile_path = 381 "${XTS_ROOT}/autogen_apiobjs/${_profile_relative_path}" 382 _fixer_script = rebase_path( 383 "//test/xts/tools/build/adapter/haptest_manifest_fixer.py") 384 exec_script(_fixer_script, 385 [ 386 "add_entryability", 387 "--raw_file=" + rebase_path(hap_profile), 388 "--dest_file=" + rebase_path(_fixed_profile_path), 389 ]) 390 hap_profile = _fixed_profile_path 391 } 392 393 if (defined(deps)) { 394 deps += [ "//test/xts/tools/hjunit:testkit_harmonyjunitrunner_java" ] 395 } else { 396 deps = [ "//test/xts/tools/hjunit:testkit_harmonyjunitrunner_java" ] 397 } 398 399 project_type = "testhap" 400 arkts_type = "dynamic" 401 } 402} 403 404template("ohos_js_hap_suite") { 405 target("ohos_testsuite_base_with_filter", "${target_name}") { 406 forward_variables_from(invoker, "*") 407 project_type = "testhap" 408 suite_type = "hap_dynamic" 409 } 410} 411 412template("ohos_js_app_suite") { 413 target("ohos_testsuite_base_with_filter", "${target_name}") { 414 forward_variables_from(invoker, "*") 415 project_type = "testapp" 416 suite_type = "hap_dynamic" 417 } 418} 419 420# arkts 1.2 hap entrance 421template("ohos_js_app_assist_static_suite") { 422 target("ohos_testsuite_base_with_filter", target_name) { 423 forward_variables_from(invoker, "*") 424 project_type = "testappassist" 425 suite_type = "hap_static" 426 hvigor_home = "//prebuilts/command-line-tools/hvigor" 427 nodejs_path = 428 "//prebuilts/build-tools/common/nodejs/node-v18.20.1-linux-x64/bin/node" 429 } 430} 431 432template("ohos_js_app_static_suite") { 433 target("ohos_testsuite_base_with_filter", "${target_name}") { 434 forward_variables_from(invoker, "*") 435 project_type = "testapp" 436 suite_type = "hap_static" 437 hvigor_home = "//prebuilts/command-line-tools/hvigor" 438 nodejs_path = 439 "//prebuilts/build-tools/common/nodejs/node-v18.20.1-linux-x64/bin/node" 440 } 441} 442 443template("ohos_shell_app_suite") { 444 target("ohos_adapter_shell_app_suite", "${target_name}") { 445 forward_variables_from(invoker, "*") 446 } 447} 448 449template("ohos_prebuilt_suite") { 450 assert(!defined(invoker.source_files) || !defined(invoker.jar_path) || 451 !defined(invoker.source_dir), 452 "source_files, jar_path or source_dir must be specified one.") 453 assert(!defined(invoker.final_jar_path), 454 "final_jar_path is not allowed in target ${target_name}") 455 456 if (defined(invoker.jar_path)) { 457 _output_name = "${target_name}.jar" 458 if (defined(invoker.output_name)) { 459 _output_name = "${invoker.output_name}.jar" 460 } 461 462 _output_type = "tools" 463 if (defined(invoker.output_type)) { 464 _output_type = invoker.output_type 465 } 466 467 _final_jar_path = 468 "${SUITES_OUTPUT_ROOT}/${XTS_SUITENAME}/${_output_type}/${_output_name}" 469 470 target("java_prebuilt", "${target_name}") { 471 forward_variables_from(invoker, "*") 472 final_jar_path = _final_jar_path 473 is_host_library = true 474 } 475 } else { 476 assert(defined(invoker.output_dir), 477 "output_dir is require in target ${target_name}") 478 _outputs = [] 479 _copy_args = [ 480 "--method_name", 481 "copy_file", 482 ] 483 _deps = [] 484 _output_dir = "${SUITES_OUTPUT_ROOT}/${XTS_SUITENAME}/${invoker.output_dir}" 485 if (defined(invoker.source_dir)) { 486 _copy_args += [ 487 "--arguments", 488 "output=" + rebase_path(_output_dir) + "#source_dirs=" + 489 rebase_path(invoker.source_dir) + "#to_dir=True", 490 ] 491 _outputs = [ _output_dir ] 492 } else if (defined(invoker.source_files)) { 493 _sources = "" 494 foreach(src, invoker.source_files) { 495 _sources = _sources + rebase_path(src) + "," 496 } 497 _copy_args += [ 498 "--arguments", 499 "output=" + rebase_path(_output_dir) + "#sources=" + _sources + 500 "#to_dir=True", 501 ] 502 _outputs = [ _output_dir ] 503 } 504 if (defined(invoker.deps)) { 505 _deps = invoker.deps 506 } 507 action(target_name) { 508 script = rebase_path("//test/xts/tools/build/utils.py") 509 deps = _deps 510 args = _copy_args 511 outputs = _outputs 512 } 513 } 514} 515 516template("ohos_deploy_xdevice") { 517 _suite_out_dir = "${SUITES_OUTPUT_ROOT}/${XTS_SUITENAME}" 518 subsystem_name = XTS_SUITENAME 519 if (subsystem_name == "acts") { 520 _hap_name = target_name 521 if (_hap_name == "validator") { 522 _suite_out_dir = "${SUITES_OUTPUT_ROOT}/${XTS_SUITENAME}/acts-validator" 523 } else { 524 _suite_out_dir = "${SUITES_OUTPUT_ROOT}/${XTS_SUITENAME}/acts" 525 } 526 } 527 528 _args = [ 529 "build_xdevice", 530 "--source_dir", 531 rebase_path("//test/testfwk/xdevice"), 532 "--suite_out_dir", 533 rebase_path(_suite_out_dir), 534 ] 535 536 if (defined(invoker.configs_dir)) { 537 _args += [ 538 "--configs_dir", 539 rebase_path(rebase_path(invoker.configs_dir)), 540 ] 541 } 542 543 if (defined(invoker.resources_dir)) { 544 _args += [ 545 "--resources_dir", 546 rebase_path(rebase_path(invoker.resources_dir)), 547 ] 548 } 549 550 action(target_name) { 551 testonly = true 552 script = rebase_path("//test/xts/tools/build/suite.py") 553 args = _args 554 outputs = [ 555 "${_suite_out_dir}/tools/xdevice-ohos-0.0.0.tar.gz", 556 "${_suite_out_dir}/tools/xdevice-0.0.0.tar.gz", 557 "${_suite_out_dir}/tools/xdevice-devicetest-0.0.0.tar.gz", 558 "${_suite_out_dir}/tools/run.sh", 559 "${_suite_out_dir}/tools/run.bat", 560 ] 561 } 562} 563 564template("ohos_test_suite") { 565 _output = "${SUITES_OUTPUT_ROOT}/${target_name}.zip" 566 _suite_path = rebase_path("${SUITES_OUTPUT_ROOT}/${XTS_SUITENAME}") 567 _suite_archive_dir = rebase_path("${SUITE_ARCHIVE_DIR}") 568 _prebuilts_files = rebase_path("//xts/resource") 569 _gen_args = [ 570 "archive_suite", 571 "--suite_path", 572 _suite_path, 573 "--prebuilts_resource", 574 _prebuilts_files, 575 "--suite_archive_dir", 576 _suite_archive_dir, 577 "--make_archive", 578 "${make_archive}", 579 ] 580 581 _deps = [] 582 if (defined(invoker.deps)) { 583 _deps += invoker.deps 584 } 585 586 action(target_name) { 587 testonly = true 588 script = rebase_path("//test/xts/tools/build/suite.py") 589 deps = _deps 590 args = _gen_args 591 outputs = [ _output ] 592 } 593} 594 595template("pythontest_suite") { 596 assert(defined(invoker.script), "script is required in target ${target_name}") 597 598 _subsystem_name = "" 599 if (defined(invoker.subsystem_name)) { 600 _subsystem_name = invoker.subsystem_name 601 } else { 602 _local_path = rebase_path(".") 603 _args1 = [ 604 "--method_name", 605 "get_subsystem_name", 606 "--arguments", 607 "path=${_local_path}", 608 ] 609 _subsystem_name = 610 exec_script(rebase_path("//test/xts/tools/build/utils.py"), 611 _args1, 612 "trim string") 613 } 614 _deps = [] 615 if (defined(invoker.deps)) { 616 _deps = invoker.deps + _deps 617 } 618 _outputs_dir = "" 619 if (defined(invoker.outputs_dir)) { 620 _outputs_dir = invoker.outputs_dir 621 } 622 _output_file = rebase_path("${invoker.script}") 623 624 target("ohos_testsuite_base", "${target_name}") { 625 project_type = "pythontest" 626 subsystem_name = _subsystem_name 627 output_file = _output_file 628 deps = _deps 629 outputs_dir = _outputs_dir 630 } 631} 632 633template("executable_suite") { 634 assert(defined(invoker.suite_name), 635 "suite_name is required in target ${target_name}") 636 _suite_name = invoker.suite_name 637 _local_path = rebase_path(".") 638 _args1 = [ 639 "--method_name", 640 "get_subsystem_name", 641 "--arguments", 642 "path=${_local_path}", 643 ] 644 _subsystem_name = exec_script(rebase_path("//test/xts/tools/build/utils.py"), 645 _args1, 646 "trim string") 647 648 _outputs_dir = "" 649 if (defined(invoker.outputs_dir)) { 650 _outputs_dir = "${invoker.outputs_dir}" 651 } 652 ohos_executable(target_name) { 653 forward_variables_from(invoker, 654 "*", 655 [ 656 "test_type", 657 "module_out_path", 658 "visibility", 659 ]) 660 forward_variables_from(invoker, [ "visibility" ]) 661 if (!defined(deps)) { 662 deps = [] 663 } 664 665 subsystem_name = "tests" 666 part_name = "ssts" 667 ohos_test = true 668 testonly = true 669 output_name = "$target_name" 670 test_output_dir = "$SUITES_OUTPUT_ROOT/${_suite_name}/testcases/${_subsystem_name}/${_outputs_dir}" 671 if (defined(invoker.output_extension)) { 672 output_extension = invoker.output_extension 673 } 674 } 675} 676 677template("js_hap_suite") { 678 assert(defined(invoker.hap_source_path), 679 "hap_source_path is required in target ${target_name}") 680 assert(defined(invoker.test_hap_name), 681 "test_hap_name is required in target ${target_name}") 682 if (defined(invoker.deps)) { 683 _deps = invoker.deps 684 } 685 target("ohos_testsuite_base", "${target_name}") { 686 forward_variables_from(invoker, "*") 687 project_type = "js_test_hap" 688 suite_type = "hap_dynamic" 689 } 690} 691 692template("ohos_hap_assist_suite") { 693 target("ohos_testsuite_base_with_filter", target_name) { 694 forward_variables_from(invoker, "*") 695 project_type = "testhapassist" 696 suite_type = "hap_dynamic" 697 } 698} 699 700template("ohos_app_assist_suite") { 701 target("ohos_testsuite_base_with_filter", target_name) { 702 forward_variables_from(invoker, "*") 703 project_type = "testappassist" 704 suite_type = "hap_dynamic" 705 } 706} 707 708template("ohos_sh_assist_suite_base") { 709 _part_name = "common" 710 711 if (defined(invoker.part_name)) { 712 _part_name = invoker.part_name 713 } 714 715 precise_build_boolean = true 716 if (precise_xts && filter_include(precise_run, 717 [ 718 "all", 719 _part_name, 720 ]) == []) { 721 print("precise_xts is on ,${_part_name} is not on build") 722 precise_build_boolean = false 723 } 724 725 if (precise_build_boolean) { 726 action(target_name) { 727 forward_variables_from(invoker, "*") 728 } 729 } else { 730 group(target_name) { 731 print(target_name + " is not build") 732 not_needed(invoker, "*") 733 } 734 } 735} 736 737# 过滤suite_type 738template("ohos_sh_assist_suite") { 739 if (XTS_SUITETYPE == [] || 740 filter_include(XTS_SUITETYPE, [ invoker.suite_type ]) != []) { 741 target("ohos_sh_assist_suite_base", "${target_name}") { 742 not_needed(invoker, [ invoker.suite_type ]) 743 forward_variables_from(invoker, "*") 744 } 745 } else { 746 group(target_name) { 747 print("[XTS] suite_type mismatch, no need build " + target_name) 748 not_needed(invoker, "*") 749 } 750 } 751} 752 753template("merge_xts_notice") { 754 _deps = [] 755 if (defined(invoker.deps)) { 756 _deps += invoker.deps 757 } 758 target = invoker.target 759 action(target_name) { 760 _merged_notice_txt = "$root_out_dir/suites/${target}/NOTICE.txt" 761 _merged_notice_gz = "$root_out_dir/suites/${target}/NOTICE.xml.gz" 762 depfile = 763 "$root_out_dir/gen/build/ohos/packages/merge_system_notice_file_phone.d" 764 765 testonly = true 766 outputs = [ 767 _merged_notice_txt, 768 _merged_notice_gz, 769 ] 770 771 deps = _deps 772 773 script = "//build/ohos/notice/merge_notice_files.py" 774 _notice_root_dir = "NOTICE_FILES" 775 776 args = [ 777 "--image-name", 778 "system", 779 "--notice-root-dir", 780 rebase_path(_notice_root_dir, root_build_dir), 781 "--output-notice-txt", 782 rebase_path(_merged_notice_txt, root_out_dir), 783 "--output-notice-gz", 784 rebase_path(_merged_notice_gz, root_out_dir), 785 "--notice-title", 786 "Notices for files contained in the system filesystem image in this directory:", 787 "--static-library-notice-dir", 788 rebase_path(static_libraries_notice_dir, root_build_dir), 789 "--target-cpu", 790 target_cpu, 791 "--depfile", 792 rebase_path(depfile, root_build_dir), 793 ] 794 } 795} 796 797# 过滤suite_type 798template("ohos_xts_static_library") { 799 if (XTS_SUITETYPE == [] || filter_include(XTS_SUITETYPE, [ "bin" ]) != []) { 800 target("ohos_static_library", "${target_name}") { 801 forward_variables_from(invoker, "*") 802 } 803 } else { 804 group(target_name) { 805 print("[XTS] suite_type mismatch, no need build " + target_name) 806 not_needed(invoker, "*") 807 } 808 } 809} 810 811# 过滤suite_type 812template("ohos_xts_executable") { 813 if (XTS_SUITETYPE == [] || filter_include(XTS_SUITETYPE, [ "bin" ]) != []) { 814 target("ohos_executable", "${target_name}") { 815 forward_variables_from(invoker, "*") 816 } 817 } else { 818 group(target_name) { 819 print("[XTS] suite_type mismatch, no need build " + target_name) 820 not_needed(invoker, "*") 821 } 822 } 823} 824 825# 过滤suite_type 826template("ohos_xts_action") { 827 if (defined(invoker.suite_type)) { 828 _suite_type = invoker.suite_type 829 not_needed(invoker, [ invoker.suite_type ]) 830 } else { 831 _suite_type = "bin" 832 } 833 not_needed(invoker, [ _suite_type ]) 834 if (XTS_SUITETYPE == [] || 835 filter_include(XTS_SUITETYPE, [ _suite_type ]) != []) { 836 action("${target_name}") { 837 forward_variables_from(invoker, "*") 838 } 839 } else { 840 group(target_name) { 841 print("[XTS] suite_type mismatch, no need build " + target_name) 842 not_needed(invoker, "*") 843 } 844 } 845} 846 847# 过滤suite_type 848template("ohos_xts_group") { 849 if (defined(invoker.suite_type)) { 850 _suite_type = invoker.suite_type 851 not_needed(invoker, [ invoker.suite_type ]) 852 } else { 853 _suite_type = "bin" 854 } 855 not_needed([ _suite_type ]) 856 if (XTS_SUITETYPE == [] || 857 filter_include(XTS_SUITETYPE, [ _suite_type ]) != []) { 858 group("${target_name}") { 859 forward_variables_from(invoker, "*") 860 } 861 } else { 862 group(target_name) { 863 print("[XTS] suite_type mismatch, no need build " + target_name) 864 not_needed(invoker, "*") 865 } 866 } 867} 868