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/python.gni") 15import("//build/ohos/app/app_internal.gni") 16import("//build/ohos/notice/notice.gni") 17import("//build/ohos_var.gni") 18import("//build/templates/common/collect_target.gni") 19import("//build/templates/metadata/module_info.gni") 20 21declare_args() { 22 app_need_publicity = false 23} 24 25# Declare an OHOS AppScope target 26# 27# Variables: 28# app_profile: common config of hap. 29# sources: list of asset files to be included in hap. 30# 31template("ohos_app_scope") { 32 forward_variables_from(invoker, [ "testonly" ]) 33 assert(defined(invoker.app_profile), 34 "app_profile must be defined for ohos_app_scope") 35 assert(defined(invoker.sources), "sources must be defined for ohos_app_scope") 36 37 _metadata = "$target_gen_dir/$target_name.metadata" 38 _metadata_target = "${target_name}__metadata" 39 write_meta_data(_metadata_target) { 40 forward_variables_from(invoker, [ "app_profile" ]) 41 type = "app_profile" 42 meta_data = _metadata 43 resources = invoker.sources 44 app_profile = invoker.app_profile 45 } 46 group(target_name) { 47 public_deps = [ ":$_metadata_target" ] 48 } 49} 50 51# Declare an OHOS assets target 52# 53# Variables: 54# deps: dependencies of this target. 55# sources: list of asset files to be included in hap. 56# 57template("ohos_assets") { 58 forward_variables_from(invoker, [ "testonly" ]) 59 assert(defined(invoker.sources), "sources must be defined for ohos_assets") 60 _metadata = "$target_gen_dir/$target_name.metadata" 61 62 _metadata_target = "${target_name}__metadata" 63 write_meta_data(_metadata_target) { 64 forward_variables_from(invoker, [ "deps" ]) 65 type = "assets" 66 meta_data = _metadata 67 raw_assets = invoker.sources 68 } 69 group(target_name) { 70 public_deps = [ ":$_metadata_target" ] 71 } 72} 73 74# Declare a js assets target 75# 76# Variables: 77# source_dir: js assets directory, only one directory supported, string not list. 78# js2abc: whether to transform js bundle to ark bytecode, default value 79# follows build_ark. 80# ets2abc: whether to transform ets bundle to ark bytecode, default value false 81# deps: dependencies of this target. 82# 83template("ohos_js_assets") { 84 forward_variables_from(invoker, [ "testonly" ]) 85 assert(defined(invoker.source_dir), 86 "source_dir must be defined for ohos_js_assets") 87 88 _metadata = "$target_gen_dir/$target_name.metadata" 89 _metadata_target = "${target_name}__metadata" 90 write_meta_data(_metadata_target) { 91 forward_variables_from(invoker, 92 [ 93 "source_dir", 94 "deps", 95 ]) 96 meta_data = _metadata 97 if (defined(invoker.ets2abc) && invoker.ets2abc) { 98 type = "ets_assets" 99 ets_assets = [ source_dir ] 100 } else if (defined(invoker.js2abc) && invoker.js2abc) { 101 type = "js_assets" 102 js_assets = [ source_dir ] 103 } else { 104 type = "unresolved_assets" 105 unresolved_assets = [ source_dir ] 106 } 107 if (defined(invoker.hap_profile)) { 108 hap_profile = invoker.hap_profile 109 } 110 } 111 group(target_name) { 112 public_deps = [ ":$_metadata_target" ] 113 } 114} 115 116# Declare an OHOS resource target 117# 118# Variables: 119# deps: dependencies of this target. 120# sources: list of resource files to be compiled. 121# hap_profile: hap_profile is used when building resources. 122# 123template("ohos_resources") { 124 forward_variables_from(invoker, [ "testonly" ]) 125 assert(defined(invoker.sources), "sources must be defined for ohos_resources") 126 _metadata = "$target_gen_dir/$target_name.metadata" 127 128 _deps = [] 129 if (defined(invoker.deps)) { 130 _deps += invoker.deps 131 } 132 133 module_config = "" 134 module_configs = string_split(invoker.hap_profile, "/") 135 foreach(_module_config, module_configs) { 136 module_config = _module_config 137 } 138 _generated_profile = "$target_gen_dir/${target_name}/${module_config}" 139 _metadata_target = "${target_name}__metadata" 140 write_meta_data(_metadata_target) { 141 forward_variables_from(invoker, [ "package_name" ]) 142 type = "resources" 143 meta_data = _metadata 144 resources = invoker.sources 145 hap_profile = _generated_profile 146 deps = _deps 147 possible_deps = _deps 148 } 149 150 _deps += [ ":$_metadata_target" ] 151 152 # compile_resources target here only used for concat app.json to module.json 153 _compile_profile_target = "${target_name}__compile_profile" 154 merge_profile(_compile_profile_target) { 155 forward_variables_from(invoker, 156 [ 157 "deps", 158 "hap_profile", 159 ]) 160 meta_data = _metadata 161 generated_profile = _generated_profile 162 if (defined(deps)) { 163 deps += _deps 164 } else { 165 deps = _deps 166 } 167 } 168 169 _deps += [ ":$_compile_profile_target" ] 170 171 # compile_resources target here only used for resources.h generation 172 _compile_resources_target = "${target_name}__compile_resources" 173 _generated_header_dir = "$target_gen_dir/$target_name" 174 compile_resources(_compile_resources_target) { 175 forward_variables_from(invoker, 176 [ 177 "deps", 178 "package_name", 179 ]) 180 hap_profile = _generated_profile 181 meta_data = _metadata 182 generated_header_dir = _generated_header_dir 183 if (defined(deps)) { 184 deps += _deps 185 } else { 186 deps = _deps 187 } 188 } 189 190 _resources_config = "${target_name}__resources_headers" 191 config(_resources_config) { 192 include_dirs = [ _generated_header_dir ] 193 } 194 195 group(target_name) { 196 public_deps = [ ":$_metadata_target" ] 197 deps = [ 198 ":$_compile_profile_target", 199 ":$_compile_resources_target", 200 ] 201 public_configs = [ ":$_resources_config" ] 202 } 203} 204 205if (app_need_publicity) { 206 template("_ohos_publicity") { 207 forward_variables_from(invoker, 208 [ 209 "_hap_name", 210 "module_install_dir", 211 "relative_install_dir", 212 ]) 213 214 action(target_name) { 215 script = "//build/scripts/collect_publicity.py" 216 module_type = "app" 217 if (defined(module_install_dir)) { 218 not_needed([ "relative_install_dir" ]) 219 install_dir = string_replace(module_install_dir, "${module_type}/", "") 220 } else if (defined(relative_install_dir)) { 221 install_dir = relative_install_dir 222 } else { 223 install_dir = "" 224 } 225 226 if (install_dir == "") { 227 print( 228 "${invoker.module_label} not set install dir, empty install dir is invalid.") 229 } 230 args = [] 231 if (defined(invoker.publicity_file)) { 232 inputs = [ invoker.publicity_file ] 233 source = inputs[0] 234 args += [ 235 "--source", 236 rebase_path(source, root_build_dir), 237 ] 238 } else { 239 print("${invoker.module_label} need to set publicity_file.") 240 } 241 outputs = [ "${root_build_dir}/app_publicity/${install_dir}/${_hap_name}_publicity.xml" ] 242 args += [ 243 "--output", 244 rebase_path(outputs[0], root_build_dir), 245 ] 246 } 247 } 248} 249 250template("ohos_app") { 251 forward_variables_from(invoker, 252 [ 253 "testonly", 254 "install_enable", 255 "install_images", 256 "module_install_dir", 257 "relative_install_dir", 258 "nodejs_path", 259 ]) 260 if (defined(invoker.hvigor_home) || defined(invoker.sdk_home)) { 261 _check_target = "${target_name}__hap_check" 262 target_path = get_label_info(":${target_name}", "label_no_toolchain") 263 action(_check_target) { 264 forward_variables_from(invoker, 265 [ 266 "sdk_home", 267 "hvigor_home", 268 ]) 269 script = "//build/scripts/check_hvigor_hap.py" 270 outputs = [ "${target_out_dir}/${target_name}.txt" ] 271 inputs = [ "${preloader_output_dir}/hvigor_compile_hap_whitelist.json" ] 272 273 args = [ 274 "--target-path", 275 target_path, 276 "--output", 277 rebase_path(outputs[0], root_build_dir), 278 "--hvigor-compile-hap-allow-file", 279 rebase_path(inputs[0], root_build_dir), 280 ] 281 if (defined(sdk_home) && sdk_home != "") { 282 args += [ 283 "--sdk-home", 284 rebase_path(sdk_home, "//"), 285 ] 286 } 287 if (defined(hvigor_home) && hvigor_home != "") { 288 args += [ 289 "--hvigor-home", 290 rebase_path(hvigor_home, "//"), 291 ] 292 } 293 } 294 } 295 _test_target = defined(testonly) && testonly 296 _unsigned_hap_path_list = 297 "${target_out_dir}/${target_name}/unsigned_hap_path_list.json" 298 299 _abs_path = get_path_info("./", "abspath") 300 _hap_out_dir = "${target_out_dir}/${target_name}" 301 if (defined(invoker.nodejs_path)) { 302 _nodejs_path = invoker.nodejs_path 303 } 304 if (defined(invoker.hap_out_dir)) { 305 _hap_out_dir = invoker.hap_out_dir 306 } 307 308 _hap_name = target_name 309 if (defined(invoker.hap_name)) { 310 _hap_name = invoker.hap_name 311 } 312 313 if (defined(invoker.build_profile)) { 314 build_profile = invoker.build_profile 315 } else { 316 build_profile = "./build-profile.json5" 317 } 318 319 _js_build_mode = "release" 320 if (defined(invoker.js_build_mode)) { 321 _js_build_mode = invoker.js_build_mode 322 } 323 324 if (defined(invoker.system_lib_deps)) { 325 _system_lib_deps = invoker.system_lib_deps 326 } 327 328 _main_target_name = target_name 329 330 if (defined(invoker.subsystem_name) && defined(invoker.part_name)) { 331 _subsystem_name = invoker.subsystem_name 332 _part_name = invoker.part_name 333 } else if (defined(invoker.part_name)) { 334 _part_name = invoker.part_name 335 _part_subsystem_info_file = 336 "$root_build_dir/build_configs/parts_info/part_subsystem.json" 337 _arguments = [ 338 "--part-name", 339 _part_name, 340 "--part-subsystem-info-file", 341 rebase_path(_part_subsystem_info_file, root_build_dir), 342 ] 343 _get_subsystem_script = "//build/templates/common/get_subsystem_name.py" 344 _subsystem_name = 345 exec_script(_get_subsystem_script, _arguments, "trim string") 346 } else if (defined(invoker.subsystem_name)) { 347 _subsystem_name = invoker.subsystem_name 348 _part_name = _subsystem_name 349 } else { 350 _subsystem_name = "build" 351 _part_name = "build_framework" 352 } 353 354 assert(_subsystem_name != "") # Mark as used 355 assert(_part_name != "") # Mark as used 356 357 module_label = get_label_info(":${target_name}", "label_with_toolchain") 358 _collect_target = "${target_name}__collect" 359 collect_module_target(_collect_target) {} 360 361 if (!defined(install_enable)) { 362 install_enable = true 363 } 364 365 if (!_test_target) { 366 if (defined(install_images)) { 367 app_allow_images = [ "system", "cloud_rom" ] 368 allow_image = filter_exclude(install_images, app_allow_images) 369 assert( 370 allow_image == [], 371 "${module_label} has invaild install_images: ${invoker.install_images}, allowed values: ${app_allow_images}") 372 } 373 if (defined(module_install_dir)) { 374 app_allow_path = [ "app/*" ] 375 if (filter_exclude([ module_install_dir ], app_allow_path) != [] || 376 module_install_dir == "app/") { 377 assert( 378 false, 379 "${module_label} has invaild module_install_dir: ${invoker.module_install_dir}, allowed values: app/{{app_name}}") 380 } 381 } 382 383 if (!defined(module_install_dir) && !defined(relative_install_dir)) { 384 print( 385 "Set module_install_dir or relative_install_dir field in the ${module_label}. Do not install the module to app.") 386 } 387 388 if (app_need_publicity) { 389 if (install_enable) { 390 _publicity_target = "${_main_target_name}_publicity" 391 _ohos_publicity(_publicity_target) { 392 forward_variables_from(invoker, [ "publicity_file" ]) 393 } 394 } 395 } 396 } 397 398 _module_info_target = "${_main_target_name}_info" 399 generate_module_info(_module_info_target) { 400 module_name = _main_target_name 401 module_type = "app" 402 module_source_dir = get_path_info(_hap_out_dir, "dir") 403 404 if (defined(invoker.install_images)) { 405 module_install_images = [] 406 module_install_images += invoker.install_images 407 } else { 408 module_install_images = [ "system" ] 409 } 410 411 if (defined(invoker.symlink_target_name)) { 412 symlink_target_name = invoker.symlink_target_name 413 } 414 415 notice = "$target_out_dir/$_main_target_name.notice.txt" 416 } 417 418 _notice_target = "${target_name}_notice" 419 collect_notice(_notice_target) { 420 forward_variables_from(invoker, 421 [ 422 "license_as_sources", 423 "license_file", 424 ]) 425 module_name = _main_target_name 426 module_type = "app" 427 module_source_dir = get_label_info(":${_main_target_name}", "dir") 428 } 429 430 _compile_app_target = "${target_name}_compile_app" 431 compile_app(_compile_app_target) { 432 if (defined(_nodejs_path)) { 433 nodejs_path = _nodejs_path 434 } 435 build_mode = _js_build_mode 436 cwd = _abs_path 437 unsigned_hap_path_list = _unsigned_hap_path_list 438 deps = [ 439 ":${_collect_target}", 440 ":${_notice_target}", 441 ] 442 443 if (defined(invoker.hvigor_home) || defined(invoker.sdk_home)) { 444 deps += [ ":${_check_target}" ] 445 } 446 447 if (!_test_target && app_need_publicity) { 448 if (install_enable) { 449 deps += [ ":${_publicity_target}" ] 450 } else { 451 if (defined(invoker.publicity_file)) { 452 print( 453 "${module_label} is not install, please delete set publicity_file: ${invoker.publicity_file}.") 454 } 455 } 456 } else { 457 if (defined(invoker.publicity_file)) { 458 not_needed(invoker, [ "publicity_file" ]) 459 } 460 } 461 462 product = "default" 463 if (defined(invoker.product) && invoker.product != "") { 464 product = invoker.product 465 } 466 467 module_target = "default" 468 if (defined(invoker.module_target)) { 469 module_target = invoker.module_target 470 } 471 472 modules_filter = false 473 if (defined(invoker.modules_filter) && invoker.modules_filter) { 474 module_filter = true 475 } 476 477 ohos_test_coverage = false 478 if (defined(invoker.ohos_test_coverage) && invoker.ohos_test_coverage) { 479 ohos_test_coverage = invoker.ohos_test_coverage 480 } 481 482 if (defined(invoker.deps)) { 483 deps += invoker.deps 484 } 485 if (defined(invoker.system_lib_deps)) { 486 system_lib_deps = _system_lib_deps 487 deps += _system_lib_deps 488 } 489 if (defined(invoker.test_hap)) { 490 test_hap = invoker.test_hap 491 } 492 if (defined(invoker.test_module)) { 493 test_module = invoker.test_module 494 } 495 if (defined(invoker.module_libs_dir)) { 496 module_libs_dir = invoker.module_libs_dir 497 } 498 if (defined(invoker.sdk_home)) { 499 sdk_home = invoker.sdk_home 500 } else { 501 sdk_home = "//prebuilts/ohos-sdk/linux" 502 } 503 if (defined(invoker.sdk_type_name)) { 504 sdk_type_name = invoker.sdk_type_name 505 } 506 if (defined(invoker.hvigor_home)) { 507 hvigor_home = invoker.hvigor_home 508 } 509 if (defined(invoker.build_modules)) { 510 build_modules = invoker.build_modules 511 } 512 if (defined(invoker.assemble_type)) { 513 assemble_type = invoker.assemble_type 514 } 515 if (defined(invoker.build_level)) { 516 build_level = invoker.build_level 517 } 518 } 519 _hap_list = "${target_out_dir}/${target_name}/hap_list.json" 520 if (defined(invoker.hap_list)) { 521 _hap_list_json = { 522 do_filter = true 523 hap_list = invoker.hap_list 524 } 525 write_file(_hap_list, _hap_list_json, "json") 526 } 527 app_sign(target_name) { 528 forward_variables_from(invoker, 529 [ 530 "private_key_path", 531 "signature_algorithm", 532 "certificate_profile", 533 "keystore_path", 534 "keystore_password", 535 "key_alias", 536 "certificate_file", 537 "compatible_version", 538 ]) 539 unsigned_hap_path_list = _unsigned_hap_path_list 540 deps = [ 541 ":$_compile_app_target", 542 ":$_module_info_target", 543 ] 544 hap_out_dir = _hap_out_dir 545 hap_name = _hap_name 546 hap_list = _hap_list 547 install_module_info = { 548 module_def = get_label_info(":$target_name", "label_with_toolchain") 549 module_info_file = 550 rebase_path(get_label_info(module_def, "target_out_dir"), 551 root_build_dir) + "/${target_name}_module_info.json" 552 toolchain = current_toolchain 553 toolchain_out_dir = rebase_path(root_out_dir, root_build_dir) 554 part_name = _part_name 555 subsystem_name = _subsystem_name 556 } 557 } 558} 559 560# Declare an OHOS hap target 561# 562# Variables: 563# deps: dependencies of this target. 564# hap_name: name of output hap file. 565# final_hap_path: full path of output hap file, final_hap_path overwrites hap_name. 566# js2abc: whether to transform js bundle to ark bytecode, default value 567# follows build_ark. 568# ets2abc: whether to transform js bundle to ark bytecode, default value false 569# 570# 571template("ohos_hap") { 572 forward_variables_from(invoker, 573 [ 574 "testonly", 575 "install_enable", 576 "install_images", 577 "module_install_dir", 578 "relative_install_dir", 579 ]) 580 assert(defined(invoker.hap_profile), 581 "hap_profile must be defined for ohos_hap") 582 583 _test_target = defined(testonly) && testonly 584 _deps = [] 585 if (defined(invoker.deps)) { 586 _deps = invoker.deps 587 } 588 589 _hap_profile = invoker.hap_profile 590 _hap_name = target_name 591 if (defined(invoker.hap_name)) { 592 _hap_name = invoker.hap_name 593 } 594 595 _hap_path = "$target_out_dir/$_hap_name.hap" 596 if (defined(invoker.final_hap_path)) { 597 _hap_path = invoker.final_hap_path 598 } 599 600 _js2abc = build_ark 601 if (defined(invoker.js2abc)) { 602 _js2abc = invoker.js2abc 603 } 604 605 _ets2abc = false 606 if (defined(invoker.ets2abc)) { 607 _ets2abc = invoker.ets2abc 608 } 609 610 if (_ets2abc) { 611 _js2abc = false 612 } 613 614 _js_build_mode = "release" 615 if (defined(invoker.js_build_mode)) { 616 _js_build_mode = invoker.js_build_mode 617 } 618 619 _main_target_name = target_name 620 621 if (defined(invoker.subsystem_name) && defined(invoker.part_name)) { 622 _subsystem_name = invoker.subsystem_name 623 _part_name = invoker.part_name 624 } else if (defined(invoker.part_name)) { 625 _part_name = invoker.part_name 626 _part_subsystem_info_file = 627 "$root_build_dir/build_configs/parts_info/part_subsystem.json" 628 _arguments = [ 629 "--part-name", 630 _part_name, 631 "--part-subsystem-info-file", 632 rebase_path(_part_subsystem_info_file, root_build_dir), 633 ] 634 _get_subsystem_script = "//build/templates/common/get_subsystem_name.py" 635 _subsystem_name = 636 exec_script(_get_subsystem_script, _arguments, "trim string") 637 } else if (defined(invoker.subsystem_name)) { 638 _subsystem_name = invoker.subsystem_name 639 _part_name = _subsystem_name 640 } else { 641 _subsystem_name = "build" 642 _part_name = "build_framework" 643 } 644 645 assert(_subsystem_name != "") # Mark as used 646 assert(_part_name != "") # Mark as used 647 648 # metadata is used to record all necessary data for hap. 649 _metadata_target = "${target_name}__metadata" 650 _meta_data = "$target_gen_dir/$target_name.metadata" 651 write_meta_data(_metadata_target) { 652 forward_variables_from(invoker, 653 [ 654 "raw_assets", 655 "resources", 656 "js_assets", 657 "ets_assets", 658 ]) 659 hap_profile = invoker.hap_profile 660 meta_data = _meta_data 661 possible_deps = _deps 662 type = "hap" 663 js2abc = _js2abc 664 hap_path = _hap_path 665 } 666 667 _js_assets_target = "${target_name}__js_assets" 668 _packaged_js_assets = "$target_out_dir/$target_name/js_assets.zip" 669 compile_js_assets(_js_assets_target) { 670 hap_profile = _hap_profile 671 packaged_js_assets = _packaged_js_assets 672 meta_data = _meta_data 673 deps = [ ":$_metadata_target" ] + _deps 674 build_mode = _js_build_mode 675 js2abc = _js2abc 676 ets2abc = _ets2abc 677 if (defined(testonly) && testonly == true) { 678 main_target_name = _main_target_name 679 } 680 } 681 682 _resources_target = "${target_name}__compile_resources" 683 _packaged_resources = "$target_out_dir/$target_name/resources.zip" 684 _generated_header_dir = "$target_out_dir/$target_name" 685 compile_resources(_resources_target) { 686 hap_profile = _hap_profile 687 packaged_resources = _packaged_resources 688 generated_header_dir = _generated_header_dir 689 meta_data = _meta_data 690 deps = [ ":$_metadata_target" ] + _deps 691 } 692 693 module_label = get_label_info(":${target_name}", "label_with_toolchain") 694 _collect_target = "${target_name}__collect" 695 collect_module_target(_collect_target) { 696 forward_variables_from(invoker, [ "install_images" ]) 697 } 698 699 _notice_target = "${target_name}__notice" 700 collect_notice(_notice_target) { 701 forward_variables_from(invoker, 702 [ 703 "license_as_sources", 704 "license_file", 705 ]) 706 module_type = "app" 707 module_name = _main_target_name 708 module_source_dir = get_label_info(":${_main_target_name}", "dir") 709 } 710 711 if (!defined(install_enable)) { 712 install_enable = true 713 } 714 715 if (!_test_target) { 716 if (defined(install_images)) { 717 app_allow_images = [ "system" ] 718 allow_image = filter_exclude(install_images, app_allow_images) 719 assert( 720 allow_image == [], 721 "${module_label} has invaild install_images: ${invoker.install_images}, allowed values: ${app_allow_images}") 722 } 723 724 if (defined(module_install_dir)) { 725 app_allow_path = [ "app/*" ] 726 if (filter_exclude([ module_install_dir ], app_allow_path) != [] || 727 module_install_dir == "app/") { 728 assert( 729 false, 730 "${module_label} has invaild module_install_dir: ${invoker.module_install_dir}, allowed values: app/{{app_name}}") 731 } 732 } 733 734 if (!defined(module_install_dir) && !defined(relative_install_dir)) { 735 print( 736 "Set module_install_dir or relative_install_dir field in the ${module_label}. Do not install the module to app.") 737 } 738 739 if (app_need_publicity) { 740 if (install_enable) { 741 _publicity_target = "${_main_target_name}_publicity" 742 _ohos_publicity(_publicity_target) { 743 forward_variables_from(invoker, [ "publicity_file" ]) 744 } 745 } 746 } 747 } 748 749 _module_info_target = "${_main_target_name}_info" 750 generate_module_info(_module_info_target) { 751 module_name = _main_target_name 752 module_type = "app" 753 754 module_source_dir = get_path_info(_hap_path, "dir") 755 module_install_name = get_path_info(_hap_path, "name") 756 if (defined(invoker.module_install_name)) { 757 module_install_name = invoker.module_install_name 758 } 759 760 module_install_images = [ "system" ] 761 if (defined(invoker.install_images)) { 762 module_install_images = [] 763 module_install_images += invoker.install_images 764 } 765 766 module_output_extension = ".hap" 767 768 if (defined(invoker.symlink_target_name)) { 769 symlink_target_name = invoker.symlink_target_name 770 } 771 notice = "$target_out_dir/$_main_target_name.notice.txt" 772 } 773 774 package_app(target_name) { 775 forward_variables_from(invoker, 776 [ 777 "shared_libraries", 778 "external_deps", 779 "private_key_path", 780 "signature_algorithm", 781 "certificate_profile", 782 "keystore_path", 783 "keystore_password", 784 "key_alias", 785 "certificate_file", 786 "compatible_version", 787 ]) 788 deps = [ 789 ":$_js_assets_target", 790 ":$_metadata_target", 791 ":$_notice_target", 792 ":$_resources_target", 793 ":${_collect_target}", 794 ] 795 796 if (!ohos_indep_compiler_enable) { 797 deps += [ "//developtools/packing_tool:packing_tool" ] 798 } 799 if (!_test_target && app_need_publicity) { 800 if (install_enable) { 801 deps += [ ":${_publicity_target}" ] 802 } else { 803 if (defined(invoker.publicity_file)) { 804 print( 805 "${module_label} is not install, please delete set publicity_file: ${invoker.publicity_file}.") 806 } 807 } 808 } else { 809 if (defined(invoker.publicity_file)) { 810 not_needed(invoker, [ "publicity_file" ]) 811 } 812 } 813 if (!skip_gen_module_info) { 814 deps += [ ":$_module_info_target" ] 815 } 816 enable_ark = build_ark 817 if (defined(shared_libraries)) { 818 deps += shared_libraries 819 } 820 packaged_js_assets = _packaged_js_assets 821 packaged_resources = _packaged_resources 822 hap_profile = _hap_profile 823 meta_data = _meta_data 824 hap_path = _hap_path 825 build_mode = _js_build_mode 826 827 install_module_info = { 828 module_def = get_label_info(":$target_name", "label_with_toolchain") 829 module_info_file = 830 rebase_path(get_label_info(module_def, "target_out_dir"), 831 root_build_dir) + "/${target_name}_module_info.json" 832 subsystem_name = _subsystem_name 833 part_name = _part_name 834 toolchain = current_toolchain 835 toolchain_out_dir = rebase_path(root_out_dir, root_build_dir) 836 } 837 } 838} 839