1# Copyright (c) 2020 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/lite/config/subsystem/aafwk/path.gni") 15 16declare_args() { 17 ohos_sign_haps_by_server = false 18 hapsigner = "//developtools/hapsigner/dist/hap-sign-tool.jar" 19 packtool = "//developtools/packing_tool/jar/app_packing_tool.jar" 20 jks_file = "//developtools/hapsigner/dist/OpenHarmony.p12" 21 cert_file = "//developtools/hapsigner/dist/OpenHarmonyApplication.pem" 22 default_hap_signature_algorithm = "SHA256withECDSA" 23 sign_server = "rnd-signserver.huawei.com" 24 privatekey = "OpenHarmony Application Release" 25 keystorepasswd = "123456" 26} 27 28template("hap_pack") { 29 assert(defined(invoker.cert_profile), "cert_profile in required.") 30 assert(defined(invoker.hap_name), "hap_name in required.") 31 assert(defined(invoker.privatekey), "privatekey in required.") 32 33 if (ohos_sign_haps_by_server == false) { 34 invoker.privatekey = "OpenHarmony Application Release" 35 } 36 37 unsignhap_path = 38 "$root_out_dir/system/internal/unsigned_${invoker.hap_name}.hap" 39 signhap_path = "$root_out_dir/system/internal/${invoker.hap_name}.hap" 40 41 action(target_name) { 42 if (defined(invoker.deps)) { 43 deps = [] 44 deps += invoker.deps 45 } 46 script = "//build/lite/hap_pack.py" 47 args = [ 48 "--packing-tool-path", 49 rebase_path(packtool), 50 ] 51 if (defined(invoker.mode)) { 52 args += [ 53 "--mode", 54 invoker.mode, 55 ] 56 } 57 if (defined(invoker.json_path)) { 58 args += [ 59 "--json-path", 60 rebase_path(invoker.json_path), 61 ] 62 } 63 if (defined(invoker.resources_path)) { 64 args += [ 65 "--resources-path", 66 rebase_path(invoker.resources_path), 67 ] 68 } 69 if (defined(invoker.assets_path)) { 70 args += [ 71 "--assets-path", 72 rebase_path(invoker.assets_path), 73 ] 74 } 75 if (defined(invoker.lib_path)) { 76 args += [ 77 "--lib-path", 78 rebase_path(invoker.lib_path), 79 ] 80 } 81 if (defined(invoker.shared_libs_path)) { 82 args += [ 83 "--shared-libs-path", 84 rebase_path(invoker.shared_libs_path), 85 ] 86 } 87 if (defined(invoker.ability_so_path)) { 88 args += [ 89 "--ability-so-path", 90 rebase_path(invoker.ability_so_path), 91 ] 92 } 93 if (defined(invoker.index_path)) { 94 args += [ 95 "--index-path", 96 rebase_path(invoker.index_path), 97 ] 98 } 99 if (defined(invoker.force)) { 100 args += [ 101 "--force", 102 invoker.force, 103 ] 104 } 105 args += [ 106 "--signtool-path", 107 rebase_path(hapsigner), 108 "--privatekey", 109 invoker.privatekey, 110 "--sign-algo", 111 default_hap_signature_algorithm, 112 "--unsignhap-path", 113 rebase_path(unsignhap_path), 114 "--signhap-path", 115 rebase_path(signhap_path), 116 "--sign-server", 117 sign_server, 118 "--jks-path", 119 rebase_path(jks_file), 120 "--cert-path", 121 rebase_path(cert_file), 122 ] 123 if (ohos_sign_haps_by_server) { 124 args += [ 125 "--sign-by-server", 126 "True", 127 ] 128 } else { 129 args += [ 130 "--sign-by-server", 131 "False", 132 ] 133 } 134 if (defined(invoker.cert_profile)) { 135 args += [ 136 "--cert-profile", 137 rebase_path(invoker.cert_profile), 138 ] 139 } 140 outputs = [ "$target_out_dir/${target_name}_build_log.txt" ] 141 } 142} 143