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