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/config/clang/clang.gni") 15import("//build/config/python.gni") 16import("//build/ohos.gni") 17import("//build/ohos_var.gni") 18import("//build/templates/cxx/cxx.gni") 19 20if (!is_arkui_x) { 21 import("//build/rust/rustc_toolchain.gni") 22} 23 24template("_testcase_resources") { 25 assert(defined(invoker.testcase_target_name)) 26 assert(defined(invoker.test_output_dir)) 27 assert(defined(invoker.module_out_path)) 28 29 _deps = [] 30 if (defined(invoker.deps)) { 31 _deps += invoker.deps 32 } 33 action_with_pydeps(target_name) { 34 if (defined(invoker.testonly)) { 35 testonly = invoker.testonly 36 } 37 deps = _deps 38 inputs = [] 39 script = "//build/ohos/testfwk/testcase_resource_copy.py" 40 output_file = "$target_out_dir/$target_name.json" 41 outputs = [ output_file ] 42 depfile = "$target_gen_dir/$target_name.d" 43 args = [] 44 if (defined(invoker.resource_config_file)) { 45 args += [ 46 "--resource-config-file", 47 rebase_path(invoker.resource_config_file, root_build_dir), 48 ] 49 inputs += [ invoker.resource_config_file ] 50 } 51 args += [ 52 "--depfile", 53 rebase_path(depfile, root_build_dir), 54 "--testcase-target-name", 55 invoker.testcase_target_name, 56 "--part-build-out-path", 57 rebase_path(root_out_dir, root_build_dir), 58 "--resource-output-path", 59 rebase_path(invoker.test_output_dir + "/resource", root_build_dir), 60 "--module-out-path", 61 invoker.module_out_path, 62 "--output-file", 63 rebase_path(output_file, root_build_dir), 64 ] 65 } 66} 67 68# ohos test template 69template("_ohos_test") { 70 assert(defined(invoker.test_type), "test_type is required.") 71 assert(defined(invoker.module_out_path)) 72 73 _deps = [] 74 if (defined(invoker.deps)) { 75 _deps += invoker.deps 76 } 77 78 if (defined(invoker.crate_type)) { 79 _deps += [ 80 "//build/rust:libstd.dylib.so", 81 "//build/rust:libtest.dylib.so", 82 ] 83 } 84 85 test_output_dir = 86 "$root_out_dir/tests/${invoker.test_type}/${invoker.module_out_path}" 87 88 # generate module list file in gn stage 89 if (!skip_generate_module_list_file) { 90 _gen_module_list_script = "//build/ohos/testfwk/gen_module_list_files.py" 91 _arguments = [ 92 "--target", 93 target_name, 94 "--target_label", 95 get_label_info(":$target_name", "label_with_toolchain"), 96 "--source_dir", 97 rebase_path(get_label_info(":$target_name", "dir"), root_build_dir), 98 "--test_type", 99 invoker.test_type, 100 ] 101 102 _module_list_file = "$root_out_dir/module_list_files/${invoker.module_out_path}/$target_name.mlf" 103 104 _arguments += [ 105 "--output_dir", 106 rebase_path(test_output_dir, root_build_dir), 107 "--module_list_file", 108 rebase_path(_module_list_file, root_build_dir), 109 ] 110 exec_script(_gen_module_list_script, _arguments) 111 } 112 113 # copy testcase resource 114 testcase_target_name = target_name 115 _testcase_resources("${testcase_target_name}_resource_copy") { 116 if (defined(invoker.resource_config_file)) { 117 resource_config_file = invoker.resource_config_file 118 } 119 module_out_path = invoker.module_out_path 120 deps = _deps 121 testonly = true 122 } 123 124 # copy fuzz config file 125 if (defined(invoker.fuzz_config_file)) { 126 fuzz_config_file = invoker.fuzz_config_file 127 action("${target_name}_copy_fuzz_config_file") { 128 script = "//build/ohos/testfwk/fuzz_config_file_copy.py" 129 inputs = [ fuzz_config_file ] 130 args = [] 131 args += [ 132 "--fuzz-config-file-path", 133 rebase_path(fuzz_config_file, root_build_dir), 134 "--fuzz-config-file-output-path", 135 rebase_path(root_out_dir + "/tests/res", root_build_dir), 136 ] 137 outputs = [ "$target_out_dir/${target_name}_result.txt" ] 138 } 139 } 140 141 _has_sources = defined(invoker.sources) && invoker.sources != [] 142 if (_has_sources) { 143 _c_sources_file = "$target_gen_dir/$target_name.sources" 144 write_file(_c_sources_file, rebase_path(invoker.sources, root_build_dir)) 145 } 146 write_file("$test_output_dir/${target_name}_path.txt", 147 get_label_info(":$target_name", "dir"), 148 "string") 149 150 ohos_executable(target_name) { 151 forward_variables_from(invoker, 152 "*", 153 [ 154 "test_type", 155 "module_out_path", 156 "visibility", 157 ]) 158 forward_variables_from(invoker, [ "visibility" ]) 159 if (!defined(deps)) { 160 deps = [] 161 } 162 deps += [ ":${testcase_target_name}_resource_copy" ] 163 if (defined(invoker.fuzz_config_file)) { 164 deps += [ ":${target_name}_copy_fuzz_config_file" ] 165 } 166 167 subsystem_name = "tests" 168 part_name = invoker.test_type 169 ohos_test = true 170 testonly = true 171 output_name = "$target_name" 172 } 173} 174 175template("ohos_unittest") { 176 _ohos_test(target_name) { 177 forward_variables_from(invoker, "*") 178 test_type = "unittest" 179 deps = [] 180 if (defined(invoker.deps)) { 181 deps += invoker.deps 182 } 183 deps += [ "//third_party/googletest:gtest_main" ] 184 } 185} 186 187template("ohos_moduletest") { 188 _ohos_test(target_name) { 189 forward_variables_from(invoker, "*") 190 test_type = "moduletest" 191 deps = [] 192 if (defined(invoker.deps)) { 193 deps += invoker.deps 194 } 195 deps += [ "//third_party/googletest:gtest_main" ] 196 } 197} 198 199template("ohos_systemtest") { 200 _ohos_test(target_name) { 201 forward_variables_from(invoker, "*") 202 test_type = "systemtest" 203 } 204} 205 206template("ohos_performancetest") { 207 _ohos_test(target_name) { 208 forward_variables_from(invoker, "*") 209 test_type = "performance" 210 deps = [] 211 if (defined(invoker.deps)) { 212 deps += invoker.deps 213 } 214 deps += [ 215 "//test/testfwk/developer_test/aw/cxx/hwext:performance_test_static", 216 "//third_party/googletest:gtest_main", 217 ] 218 } 219} 220 221template("ohos_securitytest") { 222 _ohos_test(target_name) { 223 forward_variables_from(invoker, "*") 224 test_type = "security" 225 } 226} 227 228template("ohos_reliabilitytest") { 229 _ohos_test(target_name) { 230 forward_variables_from(invoker, "*") 231 test_type = "reliability" 232 } 233} 234 235template("ohos_distributedtest") { 236 _ohos_test(target_name) { 237 forward_variables_from(invoker, "*") 238 test_type = "distributedtest" 239 deps = [] 240 if (defined(invoker.deps)) { 241 deps += invoker.deps 242 } 243 deps += [ 244 "//test/testfwk/developer_test/aw/cxx/distributed:distributedtest_lib", 245 ] 246 } 247} 248 249template("ohos_fuzztest") { 250 # Judge the compliation library. 251 # Do the FUZZ compliation if the compliation library is the musl. 252 if (use_musl) { 253 _ohos_test(target_name) { 254 forward_variables_from(invoker, 255 "*", 256 [ 257 "deps", 258 "cflags", 259 ]) 260 test_type = "fuzztest" 261 deps = [] 262 if (defined(invoker.deps)) { 263 deps += invoker.deps 264 } 265 cflags = [] 266 if (defined(invoker.cflags)) { 267 cflags += invoker.cflags 268 } 269 cflags += [ 270 "-fno-sanitize-coverage=trace-pc-guard,edge,trace-cmp,indirect-calls,8bit-counters", 271 "-fsanitize=fuzzer", 272 ] 273 if (target_cpu == "arm64") { 274 libs = 275 [ "$clang_lib_base_path/aarch64-linux-ohos/libclang_rt.fuzzer.a" ] 276 } else if (target_cpu == "x86_64") { 277 libs = [ "$clang_lib_base_path/x86_64-linux-ohos/libclang_rt.fuzzer.a" ] 278 } else { 279 libs = [ "$clang_lib_base_path/arm-linux-ohos/libclang_rt.fuzzer.a" ] 280 } 281 } 282 } else { 283 group(target_name) { 284 not_needed(invoker, "*") 285 } 286 } 287} 288 289template("ohos_benchmarktest") { 290 _ohos_test(target_name) { 291 forward_variables_from(invoker, "*", [ "deps" ]) 292 test_type = "benchmark" 293 294 deps = [] 295 if (defined(invoker.deps)) { 296 deps += invoker.deps 297 } 298 deps += [ "//third_party/benchmark:benchmark" ] 299 } 300} 301 302template("_test_py_file_copy") { 303 assert(defined(invoker.sources), "sources is required.") 304 assert(defined(invoker.target_base_dir)) 305 assert(defined(invoker.copy_output_dir)) 306 307 action_with_pydeps(target_name) { 308 forward_variables_from(invoker, 309 [ 310 "sources", 311 "testonly", 312 "visibility", 313 ]) 314 script = "//build/ohos/testfwk/test_py_file_copy.py" 315 deps = [] 316 if (defined(invoker.deps)) { 317 deps += invoker.deps 318 } 319 320 depfile = "$target_gen_dir/$target_name.d" 321 outfile = "$target_out_dir/$target_name.out" 322 outputs = [ outfile ] 323 args = [ 324 "--target-base-dir", 325 rebase_path(invoker.target_base_dir, root_build_dir), 326 "--copy-output-dir", 327 rebase_path(invoker.copy_output_dir, root_build_dir), 328 "--outfile", 329 rebase_path(outfile, root_build_dir), 330 "--depfile", 331 rebase_path(depfile, root_build_dir), 332 "--source-files", 333 ] 334 args += rebase_path(sources, root_build_dir) 335 } 336} 337 338# python test template 339template("_ohos_test_py") { 340 assert(defined(invoker.test_type), "test_type is required.") 341 assert(defined(invoker.sources), "sources is required.") 342 343 _gen_module_list_script = "//build/ohos/testfwk/gen_module_list_files.py" 344 _arguments = [ 345 "--target", 346 target_name, 347 "--target_label", 348 get_label_info(":$target_name", "label_with_toolchain"), 349 "--source_dir", 350 rebase_path(get_label_info(":$target_name", "dir"), root_build_dir), 351 "--test_type", 352 invoker.test_type, 353 ] 354 355 if (defined(invoker.module_out_path)) { 356 test_output_dir = 357 "$root_out_dir/tests/${invoker.test_type}/${invoker.module_out_path}" 358 _module_list_file = "$root_out_dir/module_list_files/${invoker.module_out_path}/$target_name.mlf" 359 } else { 360 test_output_dir = "$root_out_dir/tests/${invoker.test_type}" 361 _module_list_file = "$root_out_dir/module_list_files/$target_name.mlf" 362 } 363 364 _arguments += [ 365 "--output_dir", 366 rebase_path(test_output_dir, root_build_dir), 367 "--module_list_file", 368 rebase_path(_module_list_file, root_build_dir), 369 ] 370 exec_script(_gen_module_list_script, _arguments) 371 372 _test_py_file_copy(target_name) { 373 testonly = true 374 target_base_dir = get_label_info(":$target_name", "dir") 375 copy_output_dir = test_output_dir 376 sources = get_path_info(invoker.sources, "abspath") 377 } 378} 379 380template("ohos_unittest_py") { 381 _ohos_test_py(target_name) { 382 forward_variables_from(invoker, "*") 383 test_type = "unittest" 384 } 385} 386 387template("ohos_moduletest_py") { 388 _ohos_test_py(target_name) { 389 forward_variables_from(invoker, "*") 390 test_type = "moduletest" 391 } 392} 393 394template("ohos_systemtest_py") { 395 _ohos_test_py(target_name) { 396 forward_variables_from(invoker, "*") 397 test_type = "systemtest" 398 } 399} 400 401template("ohos_performancetest_py") { 402 _ohos_test_py(target_name) { 403 forward_variables_from(invoker, "*") 404 test_type = "performance" 405 } 406} 407 408template("ohos_securitytest_py") { 409 _ohos_test_py(target_name) { 410 forward_variables_from(invoker, "*") 411 test_type = "security" 412 } 413} 414 415template("ohos_reliabilitytest_py") { 416 _ohos_test_py(target_name) { 417 forward_variables_from(invoker, "*") 418 test_type = "reliability" 419 } 420} 421 422template("ohos_distributedtest_py") { 423 _ohos_test_py(target_name) { 424 forward_variables_from(invoker, "*") 425 test_type = "distributedtest" 426 } 427} 428 429template("ohos_fuzztest_py") { 430 _ohos_test_py(target_name) { 431 forward_variables_from(invoker, "*") 432 test_type = "fuzztest" 433 } 434} 435 436#js api test template 437template("ohos_js_test") { 438 assert(defined(invoker.test_type), "test_type must be defined.") 439 assert(defined(invoker.hap_profile), "hap_profile must be defined.") 440 assert(defined(invoker.module_out_path), "module_out_path must be defined.") 441 442 # generate module list file in gn stage 443 _gen_module_list_script = "//build/ohos/testfwk/gen_module_list_files.py" 444 _arguments = [ 445 "--target", 446 target_name, 447 "--target_label", 448 get_label_info(":$target_name", "label_with_toolchain"), 449 "--source_dir", 450 rebase_path(get_label_info(":$target_name", "dir"), root_build_dir), 451 "--test_type", 452 invoker.test_type, 453 ] 454 455 _test_output_dir = 456 "$root_out_dir/tests/${invoker.test_type}/${invoker.module_out_path}" 457 _module_list_file = "$root_out_dir/module_list_files/${invoker.module_out_path}/$target_name.mlf" 458 459 _arguments += [ 460 "--output_dir", 461 rebase_path(_test_output_dir, root_build_dir), 462 "--module_list_file", 463 rebase_path(_module_list_file, root_build_dir), 464 ] 465 exec_script(_gen_module_list_script, _arguments) 466 467 # copy testcase resource 468 testcase_target_name = target_name 469 _testcase_resources("${testcase_target_name}_resource_copy") { 470 if (defined(invoker.resource_config_file)) { 471 resource_config_file = invoker.resource_config_file 472 } 473 module_out_path = invoker.module_out_path 474 test_output_dir = _test_output_dir 475 } 476 477 _suite_path = get_label_info(":$target_name", "dir") 478 _template_path = "//test/testfwk/developer_test/libs/js_template" 479 _target_path = "${_template_path}/$target_name" 480 _target_js_copy = "${target_name}__js_copy" 481 action_with_pydeps(_target_js_copy) { 482 script = "//build/ohos/testfwk/test_js_file_copy.py" 483 outputs = [ "$target_out_dir/$target_name.out" ] 484 args = [ 485 "--suite_path", 486 rebase_path(_suite_path, root_build_dir), 487 "--template_path", 488 rebase_path(_template_path, root_build_dir), 489 "--target_path", 490 rebase_path(_target_path, root_build_dir), 491 "--test_output_dir", 492 rebase_path(_test_output_dir, root_build_dir), 493 "--target_name", 494 testcase_target_name, 495 ] 496 deps = [ ":${testcase_target_name}_resource_copy" ] 497 } 498 499 _target_js_assets = "${target_name}__intl_js_assets" 500 ohos_js_assets(_target_js_assets) { 501 source_dir = "${_target_path}/src/main/js/default" 502 deps = [ ":$_target_js_copy" ] 503 } 504 _target_resources = "${target_name}__resources" 505 ohos_resources(_target_resources) { 506 sources = [ "${_target_path}/src/main/resources" ] 507 deps = [ ":$_target_js_assets" ] 508 hap_profile = invoker.hap_profile 509 } 510 511 ohos_hap(target_name) { 512 forward_variables_from(invoker, 513 "*", 514 [ 515 "test_type", 516 "module_out_path", 517 "visibility", 518 ]) 519 forward_variables_from(invoker, [ "visibility" ]) 520 521 deps = [ 522 ":$_target_js_assets", 523 ":$_target_resources", 524 ] 525 final_hap_path = "$_test_output_dir/$target_name.hap" 526 js_build_mode = "debug" 527 testonly = true 528 } 529} 530 531template("ohos_js_unittest") { 532 ohos_js_test(target_name) { 533 forward_variables_from(invoker, "*") 534 test_type = "unittest" 535 } 536} 537 538template("ohos_js_stage_test") { 539 if (defined(invoker.part_name)) { 540 _part_name = invoker.part_name 541 } 542 if (defined(invoker.subsystem_name)) { 543 _subsystem_name = invoker.subsystem_name 544 } 545 if (defined(invoker.test_type)) { 546 _test_type = invoker.test_type 547 } 548 _build_part_boolean = true 549 550 # generate module list file in gn stage 551 if (!skip_generate_module_list_file) { 552 _gen_module_list_script = "//build/ohos/testfwk/gen_module_list_files.py" 553 _arguments = [ 554 "--target", 555 target_name, 556 "--target_label", 557 get_label_info(":$target_name", "label_with_toolchain"), 558 "--source_dir", 559 rebase_path(get_label_info(":$target_name", "dir"), root_build_dir), 560 "--test_type", 561 _test_type, 562 ] 563 564 _test_output_dir = 565 "$root_out_dir/tests/${invoker.test_type}/${invoker.module_out_path}" 566 _module_list_file = "$root_out_dir/module_list_files/${invoker.module_out_path}/$target_name.mlf" 567 568 _arguments += [ 569 "--output_dir", 570 rebase_path(_test_output_dir, root_build_dir), 571 "--module_list_file", 572 rebase_path(_module_list_file, root_build_dir), 573 ] 574 exec_script(_gen_module_list_script, _arguments) 575 } 576 577 assert(defined(invoker.hap_name), 578 "hap_name is required in target ${target_name}") 579 assert(!defined(invoker.final_hap_path), 580 "please use hap_name instead of final_hap_path") 581 _hap_name = invoker.hap_name 582 _final_hap_path = "" 583 _target_name = "" 584 _final_hap_path = 585 "$root_out_dir/tests/haps/${invoker.module_out_path}/${_hap_name}.hap" 586 _target_name = "module_${target_name}" 587 588 _archive_filename = "${_hap_name}.hap" 589 590 if (_build_part_boolean == true) { 591 target("ohos_hap", _target_name) { 592 forward_variables_from(invoker, "*") 593 final_hap_path = _final_hap_path 594 testonly = true 595 } 596 } else { 597 print(tmp_subsystem_part + " is not build") 598 print(_target_name) 599 if (defined(invoker.certificate_profile)) { 600 print(invoker.certificate_profile) 601 } 602 if (defined(invoker.ets2abc)) { 603 print(invoker.ets2abc) 604 } 605 if (defined(invoker.deps)) { 606 print(invoker.deps) 607 } 608 if (defined(invoker.hap_profile)) { 609 print(invoker.hap_profile) 610 } 611 if (defined(invoker.testonly)) { 612 print(invoker.testonly) 613 } 614 } 615 616 _deps = [ ":module_${target_name}" ] 617 618 _archive_testfile = "$root_out_dir/tests/$_test_type/${invoker.module_out_path}/${_archive_filename}" 619 _arguments = [] 620 _arguments = [ 621 "--build_target_name", 622 target_name, 623 "--project_path", 624 rebase_path("."), 625 "--archive_testfile", 626 rebase_path("${_archive_testfile}"), 627 "--final_hap_path", 628 rebase_path("${_final_hap_path}"), 629 "--test_type", 630 _test_type, 631 "--module_out_path", 632 invoker.module_out_path, 633 ] 634 if (_subsystem_name != "") { 635 _arguments += [ 636 "--subsystem_name", 637 _subsystem_name, 638 ] 639 } 640 if (_part_name != "") { 641 _arguments += [ 642 "--part_name", 643 _part_name, 644 ] 645 } 646 647 action(target_name) { 648 deps = _deps 649 script = rebase_path("//build/ohos/testfwk/test_js_stage_file_copy.py") 650 args = _arguments 651 outputs = [ _archive_testfile ] 652 testonly = true 653 } 654} 655 656template("ohos_js_stage_unittest") { 657 ohos_js_stage_test(target_name) { 658 forward_variables_from(invoker, "*") 659 test_type = "unittest" 660 } 661} 662 663template("ohos_rust_unittest") { 664 _target_name = target_name 665 _rustflags = [] 666 _public_deps = [ "//build/rust/tests:original_libstd.so" ] 667 ohos_unittest("$_target_name") { 668 forward_variables_from(invoker, "*") 669 public_deps = _public_deps 670 if (!defined(invoker.crate_name)) { 671 crate_name = _target_name 672 } 673 crate_type = "bin" 674 if (defined(invoker.crate_type)) { 675 assert(invoker.crate_type == crate_type, 676 "crate_type should be $crate_type or use default value.") 677 } 678 679 if (defined(invoker.rustc_lints)) { 680 rustc_lints = invoker.rustc_lints 681 } 682 if (defined(invoker.clippy_lints)) { 683 clippy_lints = invoker.clippy_lints 684 } 685 686 if (!defined(rustc_lints) && !defined(clippy_lints)) { 687 file_path = 688 get_path_info(get_path_info(invoker.sources, "dir"), "abspath") 689 file_path_split = string_split(file_path[0], "/") 690 source_dir_begin = file_path_split[2] 691 692 if (source_dir_begin == "openharmony") { 693 _rustflags += allowAllLints 694 } else if (source_dir_begin == "prebuilts") { 695 _rustflags += allowAllLints 696 } else if (source_dir_begin == "vendor") { 697 _rustflags += rustcVendorLints 698 _rustflags += clippyVendorLints 699 } else if (source_dir_begin == "device") { 700 _rustflags += rustcVendorLints 701 _rustflags += clippyVendorLints 702 } else { 703 _rustflags += rustcOhosLints 704 _rustflags += clippyOhosLints 705 } 706 } 707 708 if (defined(rustc_lints)) { 709 if (invoker.rustc_lints == "openharmony") { 710 _rustflags += rustcOhosLints 711 } else if (rustc_lints == "vendor") { 712 _rustflags += rustcVendorLints 713 } else if (rustc_lints == "none") { 714 _rustflags += allowAllLints 715 } 716 } 717 if (defined(clippy_lints)) { 718 if (invoker.clippy_lints == "openharmony") { 719 _rustflags += clippyOhosLints 720 } else if (clippy_lints == "vendor") { 721 _rustflags += clippyVendorLints 722 } else if (clippy_lints == "none") { 723 _rustflags += allowAllLints 724 } 725 } 726 if (!defined(rustflags)) { 727 rustflags = _rustflags 728 } else { 729 rustflags += _rustflags 730 } 731 edition = rust_default_edition 732 if (defined(invoker.edition)) { 733 edition = invoker.edition 734 } 735 rustflags += [ 736 "--cfg", 737 "feature=\"test\"", 738 "--test", 739 "-Csymbol-mangling-version=v0", 740 "--edition=${edition}", 741 ] 742 } 743} 744 745template("ohos_rust_systemtest") { 746 _target_name = target_name 747 _rustflags = [] 748 _public_deps = [ "//build/rust/tests:original_libstd.so" ] 749 ohos_systemtest("$_target_name") { 750 forward_variables_from(invoker, "*") 751 public_deps = _public_deps 752 if (!defined(invoker.crate_name)) { 753 crate_name = _target_name 754 } 755 crate_type = "bin" 756 if (defined(invoker.crate_type)) { 757 assert(invoker.crate_type == crate_type, 758 "crate_type should be $crate_type or use default value.") 759 } 760 761 if (defined(invoker.rustc_lints)) { 762 rustc_lints = invoker.rustc_lints 763 } 764 if (defined(invoker.clippy_lints)) { 765 clippy_lints = invoker.clippy_lints 766 } 767 768 if (!defined(rustc_lints) && !defined(clippy_lints)) { 769 file_path = 770 get_path_info(get_path_info(invoker.sources, "dir"), "abspath") 771 file_path_split = string_split(file_path[0], "/") 772 source_dir_begin = file_path_split[2] 773 774 if (source_dir_begin == "openharmony") { 775 _rustflags += allowAllLints 776 } else if (source_dir_begin == "prebuilts") { 777 _rustflags += allowAllLints 778 } else if (source_dir_begin == "vendor") { 779 _rustflags += rustcVendorLints 780 _rustflags += clippyVendorLints 781 } else if (source_dir_begin == "device") { 782 _rustflags += rustcVendorLints 783 _rustflags += clippyVendorLints 784 } else { 785 _rustflags += rustcOhosLints 786 _rustflags += clippyOhosLints 787 } 788 } 789 790 if (defined(rustc_lints)) { 791 if (invoker.rustc_lints == "openharmony") { 792 _rustflags += rustcOhosLints 793 } else if (rustc_lints == "vendor") { 794 _rustflags += rustcVendorLints 795 } else if (rustc_lints == "none") { 796 _rustflags += allowAllLints 797 } 798 } 799 if (defined(clippy_lints)) { 800 if (invoker.clippy_lints == "openharmony") { 801 _rustflags += clippyOhosLints 802 } else if (clippy_lints == "vendor") { 803 _rustflags += clippyVendorLints 804 } else if (clippy_lints == "none") { 805 _rustflags += allowAllLints 806 } 807 } 808 if (!defined(rustflags)) { 809 rustflags = _rustflags 810 } else { 811 rustflags += _rustflags 812 } 813 edition = rust_default_edition 814 if (defined(invoker.edition)) { 815 edition = invoker.edition 816 } 817 rustflags += [ 818 "--cfg", 819 "feature=\"test\"", 820 "--test", 821 "-Csymbol-mangling-version=v0", 822 "--edition=${edition}", 823 ] 824 } 825} 826