• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef DEVELOPTOOLS_PACKING_TOOL_APT_FRAMEWORKS_INCLUDE_CONSTANTS_H
17 #define DEVELOPTOOLS_PACKING_TOOL_APT_FRAMEWORKS_INCLUDE_CONSTANTS_H
18 
19 #include <getopt.h>
20 #include <string>
21 
22 namespace OHOS {
23 namespace AppPackingTool {
24 namespace Constants {
25 const std::string CMD_HELP = "help";
26 const std::string CMD_PACK = "pack";
27 const std::string CMD_UNPACK = "unpack";
28 
29 const std::string MODE_HAP = "hap";
30 const std::string MODE_HSP = "hsp";
31 const std::string MODE_APP = "app";
32 const std::string MODE_HQF = "hqf";
33 const std::string MODE_APPQF = "appqf";
34 const std::string MODE_MULTIAPP = "multiApp";
35 const std::string MODE_VERSION_NORMALIZE = "versionNormalize";
36 const std::string MODE_PACKAGE_NORMALIZE = "packageNormalize";
37 const std::string MODE_FAST_APP = "fastApp";
38 const std::string MODE_RES = "res";
39 const std::string COMPRESSOR_TEMP_DIR = "temp";
40 const std::string COMPRESSOR_APP_TEMP_DIR = "app_";
41 const std::string COMPRESSOR_FAST_APP_TEMP_DIR = "fastApp_";
42 const std::string COMPRESSOR_MULTIAPP_TEMP_DIR = "multiApp_";
43 const std::string COMPRESSOR_PACKAGENORMALIZE_TEMP_DIR = "packageNormalize_";
44 const std::string COMPRESSOR_VERSIONNORMALIZE_TEMP_DIR = "versionNormalize_";
45 const std::string PARAM_PREFIX = "--";
46 const std::string PARAM_MODE = "mode";
47 const std::string PARAM_JSON_PATH = "json-path";
48 const std::string PARAM_LIB_PATH = "lib-path";
49 const std::string PARAM_RES_PATH = "res-path";
50 const std::string PARAM_HNP_PATH = "hnp-path";
51 const std::string PARAM_FILE_PATH = "file-path";
52 const std::string PARAM_BIN_PATH = "bin-path";
53 const std::string PARAM_ASSETS_PATH = "assets-path";
54 const std::string PARAM_SHAREDLIBS_PATH = "shared-libs-path";
55 const std::string PARAM_ABC_PATH = "abc-path";
56 const std::string PARAM_ABILITY_SO_PATH = "ability-so-path";
57 const std::string PARAM_JAR_PATH = "jar-path";
58 const std::string PARAM_TXT_PATH = "txt-path";
59 const std::string PARAM_PACK_RES_PATH = "pack-res-path";
60 const std::string PARAM_ENTRYCARD_PATH = "entrycard-path";
61 const std::string PARAM_RESOURCES_PATH = "resources-path";
62 const std::string PARAM_INDEX_PATH = "index-path";
63 const std::string PARAM_PACK_INFO_PATH = "pack-info-path";
64 const std::string PARAM_PROFILE_PATH = "profile-path";
65 const std::string PARAM_ETS_PATH = "ets-path";
66 const std::string PARAM_OUT_PATH = "out-path";
67 const std::string PARAM_MAPLE_SO_PATH = "maple-so-path";
68 const std::string PARAM_MAPLE_SO_DIR = "maple-so-dir";
69 const std::string PARAM_RPCID_PATH = "rpcid-path";
70 const std::string PARAM_JS_PATH = "js-path";
71 const std::string PARAM_FORCE = "force";
72 const std::string PARAM_AN_PATH = "an-path";
73 const std::string PARAM_AP_PATH = "ap-path";
74 const std::string PARAM_DIR_LIST = "dir-list";
75 const std::string PARAM_COMPRESS_LEVEL = "compress-level";
76 const std::string PARAM_PKG_CONTEXT_PATH = "pkg-context-path";
77 const std::string PARAM_HAP_PATH = "hap-path";
78 const std::string PARAM_HSP_PATH = "hsp-path";
79 const std::string PARAM_SIGNATURE_PATH = "signature-path";
80 const std::string PARAM_CERTIFICATE_PATH = "certificate-path";
81 const std::string PARAM_HAP_LIST = "hap-list";
82 const std::string PARAM_HSP_LIST = "hsp-list";
83 const std::string PARAM_APP_LIST = "app-list";
84 const std::string PARAM_HQF_LIST = "hqf-list";
85 const std::string PARAM_INPUT_LIST = "input-list";
86 const std::string PARAM_VERSION_CODE = "version-code";
87 const std::string PARAM_VERSION_NAME = "version-name";
88 const std::string PARAM_APP_PATH = "app-path";
89 const std::string PARAM_RPCID = "rpcid";
90 const std::string PARAM_APPQF_PATH = "appqf-path";
91 const std::string PARAM_MAIN_MODULE_LIMIT = "main-module-limit";
92 const std::string PARAM_NORMAL_MODULE_LIMIT = "normal-module-limit";
93 const std::string PARAM_TOTAL_LIMIT = "total-limit";
94 const std::string PARAM_BUNDLE_NAME = "bundle-name";
95 
96 const std::string MODULE_JSON = "module.json";
97 const std::string CONFIG_JSON = "config.json";
98 const std::string PATCH_JSON = "patch.json";
99 const std::string LIB_PATH = "libs";
100 const std::string AN_PATH = "an";
101 const std::string AP_PATH = "ap";
102 const std::string JS_PATH = "js";
103 const std::string HNP_PATH = "hnp";
104 const std::string ASSETS_PATH = "assets";
105 const std::string RES_PATH = "res";
106 const std::string SO_DIR = "maple";
107 const std::string SO_ARM64_DIR = "maple/arm64/";
108 const std::string SHARED_LIBS_DIR = "shared_libs";
109 const std::string LINUX_FILE_SEPARATOR = "/";
110 const std::string ENTRYCARD_NAME = "EntryCard";
111 const std::string ENTRYCARD_BASE_NAME = "base";
112 const std::string ENTRYCARD_SNAPSHOT_NAME = "snapshot";
113 const std::string RESOURCES_PATH = "resources";
114 const std::string RESOURCES_INDEX = "resources.index";
115 const std::string PACK_INFO = "pack.info";
116 const std::string ETS_PATH = "ets";
117 const std::string RPCID_SC = "rpcid.sc";
118 const std::string PKG_CONTEXT_JSON = "pkgContextInfo.json";
119 const std::string PROFILE_NAME = "CAPABILITY.profile";
120 const std::string FILE_PACK_RES = "pack.res";
121 const std::string INVALID_PATH = "invalid";
122 const std::string TYPE_SHARED = "shared";
123 const std::string BUNDLE_TYPE_APP_SERVICE = "appService";
124 const std::string TEMP_HAP_DIR = "tempHapDir";
125 const std::string TEMP_HSP_DIR = "tempHspDir";
126 const std::string TEMP_SELECTED_HAP_DIR = "tempSelectedHapDir";
127 const std::string ATOMIC_SERVICE = "atomicService";
128 const std::string NULL_DIR_NAME = "";
129 const std::string DEVICE_TYPE_FITNESSWATCH = "fitnessWatch";
130 const std::string DEVICE_TYPE_FITNESSWATCH_NEW = "liteWearable";
131 const std::string VERSION_RECORD = "version_record.json";
132 const std::string VERSION_NAME_PATTERN = "^[0-9.]+|(?=.*[{])(?=.*[}])[0-9a-zA-Z_.{}]+$";
133 const std::string BUNDLE_NAME_PATTERN =
134     "([a-zA-Z]|[a-zA-Z]+(_*[0-9a-zA-Z])+)(\\.[0-9a-zA-Z]|\\.[0-9a-zA-Z]+(_*[0-9a-zA-Z])+){2,}";
135 
136 const std::string JSON_SUFFIX = ".json";
137 const std::string HAP_SUFFIX = ".hap";
138 const std::string HAR_SUFFIX = ".har";
139 const std::string HSP_SUFFIX = ".hsp";
140 const std::string APP_SUFFIX = ".app";
141 const std::string SO_SUFFIX = ".so";
142 const std::string RES_SUFFIX = ".res";
143 const std::string ABC_SUFFIX = ".abc";
144 const std::string JAR_SUFFIX = ".jar";
145 const std::string TXT_SUFFIX = ".txt";
146 const std::string PNG_SUFFIX = ".png";
147 const std::string HQF_SUFFIX = ".hqf";
148 const std::string APPQF_SUFFIX = ".appqf";
149 
150 const int32_t BUFFER_SIZE = 1024;
151 const int32_t BUNDLE_NAME_LEN_MIN = 7;
152 const int32_t BUNDLE_NAME_LEN_MAX = 128;
153 const int32_t APP_SUFFIX_LENGTH = 4;
154 const char COMMA_SPLIT = ',';
155 
156 constexpr const char* SHORT_OPTIONS = "";
157 const struct option LONG_OPTIONS[] = {
158     {PARAM_MODE.c_str(), required_argument, nullptr, 1},
159     {PARAM_JSON_PATH.c_str(), required_argument, nullptr, 2},
160     {PARAM_LIB_PATH.c_str(), required_argument, nullptr, 3},
161     {PARAM_RESOURCES_PATH.c_str(), required_argument, nullptr, 4},
162     {PARAM_INDEX_PATH.c_str(), required_argument, nullptr, 5},
163     {PARAM_PACK_INFO_PATH.c_str(), required_argument, nullptr, 6},
164     {PARAM_PROFILE_PATH.c_str(), required_argument, nullptr, 7},
165     {PARAM_ETS_PATH.c_str(), required_argument, nullptr, 8},
166     {PARAM_OUT_PATH.c_str(), required_argument, nullptr, 9},
167     {PARAM_MAPLE_SO_PATH.c_str(), required_argument, nullptr, 10},
168     {PARAM_MAPLE_SO_DIR.c_str(), required_argument, nullptr, 11},
169     {PARAM_RPCID_PATH.c_str(), required_argument, nullptr, 13},
170     {PARAM_JS_PATH.c_str(), required_argument, nullptr, 14},
171     {PARAM_FORCE.c_str(), required_argument, nullptr, 15},
172     {PARAM_AN_PATH.c_str(), required_argument, nullptr, 16},
173     {PARAM_AP_PATH.c_str(), required_argument, nullptr, 17},
174     {PARAM_DIR_LIST.c_str(), required_argument, nullptr, 18},
175     {PARAM_COMPRESS_LEVEL.c_str(), required_argument, nullptr, 19},
176     {PARAM_PKG_CONTEXT_PATH.c_str(), required_argument, nullptr, 20},
177     {PARAM_HAP_PATH.c_str(), required_argument, nullptr, 21},
178     {PARAM_HSP_PATH.c_str(), required_argument, nullptr, 22},
179     {PARAM_SIGNATURE_PATH.c_str(), required_argument, nullptr, 23},
180     {PARAM_CERTIFICATE_PATH.c_str(), required_argument, nullptr, 24},
181     {PARAM_HAP_LIST.c_str(), required_argument, nullptr, 25},
182     {PARAM_HSP_LIST.c_str(), required_argument, nullptr, 26},
183     {PARAM_APP_LIST.c_str(), required_argument, nullptr, 27},
184     {PARAM_HQF_LIST.c_str(), required_argument, nullptr, 28},
185     {PARAM_INPUT_LIST.c_str(), required_argument, nullptr, 29},
186     {PARAM_VERSION_CODE.c_str(), required_argument, nullptr, 30},
187     {PARAM_VERSION_NAME.c_str(), required_argument, nullptr, 31},
188     {PARAM_APP_PATH.c_str(), required_argument, nullptr, 32},
189     {PARAM_RPCID.c_str(), required_argument, nullptr, 33},
190     {PARAM_APPQF_PATH.c_str(), required_argument, nullptr, 34},
191     {PARAM_MAIN_MODULE_LIMIT.c_str(), required_argument, nullptr, 35},
192     {PARAM_NORMAL_MODULE_LIMIT.c_str(), required_argument, nullptr, 36},
193     {PARAM_FILE_PATH.c_str(), required_argument, nullptr, 37},
194     {PARAM_HNP_PATH.c_str(), required_argument, nullptr, 38},
195     {PARAM_JAR_PATH.c_str(), required_argument, nullptr, 39},
196     {PARAM_ASSETS_PATH.c_str(), required_argument, nullptr, 40},
197     {PARAM_RES_PATH.c_str(), required_argument, nullptr, 41},
198     {PARAM_PACK_RES_PATH.c_str(), required_argument, nullptr, 42},
199     {PARAM_ENTRYCARD_PATH.c_str(), required_argument, nullptr, 43},
200     {PARAM_BUNDLE_NAME.c_str(), required_argument, nullptr, 44},
201     {PARAM_TOTAL_LIMIT.c_str(), required_argument, nullptr, 45},
202     {nullptr, 0, nullptr, 0},
203 };
204 constexpr const int32_t OPTIONS_SIZE = sizeof(LONG_OPTIONS) / sizeof(LONG_OPTIONS[0]);
205 
206 enum PARAM_TYPE {
207     DEFAULT,
208     REGULAR_FILE,
209     REGULAR_FILE_ARRAY,
210     DIRECTORY,
211     DIRECTORY_ARRAY,
212     FILE_OR_DIRECTORY,
213     FILE_OR_DIRECTORY_ARRAY,
214 };
215 
216 constexpr const int32_t BUF_SIZE = 1024 * 4;
217 }
218 }  // namespace AppExecFwk
219 }  // namespace OHOS
220 #endif  // DEVELOPTOOLS_PACKING_TOOL_APT_FRAMEWORKS_INCLUDE_CONSTANTS_H