1 /* 2 * Copyright (c) 2024-2025 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_GENERAL_NORMALIZE = "generalNormalize"; 38 const std::string MODE_FAST_APP = "fastApp"; 39 const std::string MODE_RES = "res"; 40 const std::string COMPRESSOR_TEMP_DIR = "temp"; 41 const std::string COMPRESSOR_APP_TEMP_DIR = "app_"; 42 const std::string COMPRESSOR_FAST_APP_TEMP_DIR = "fastApp_"; 43 const std::string COMPRESSOR_MULTIAPP_TEMP_DIR = "multiApp_"; 44 const std::string COMPRESSOR_PACKAGENORMALIZE_TEMP_DIR = "packageNormalize_"; 45 const std::string COMPRESSOR_VERSIONNORMALIZE_TEMP_DIR = "versionNormalize_"; 46 const std::string COMPRESSOR_GENERALNORMALIZE_TEMP_DIR = "generalNormalize_"; 47 const std::string PARAM_PREFIX = "--"; 48 const std::string PARAM_MODE = "mode"; 49 const std::string PARAM_JSON_PATH = "json-path"; 50 const std::string PARAM_LIB_PATH = "lib-path"; 51 const std::string PARAM_RES_PATH = "res-path"; 52 const std::string PARAM_HNP_PATH = "hnp-path"; 53 const std::string PARAM_FILE_PATH = "file-path"; 54 const std::string PARAM_BIN_PATH = "bin-path"; 55 const std::string PARAM_ASSETS_PATH = "assets-path"; 56 const std::string PARAM_SHAREDLIBS_PATH = "shared-libs-path"; 57 const std::string PARAM_ABC_PATH = "abc-path"; 58 const std::string PARAM_ABILITY_SO_PATH = "ability-so-path"; 59 const std::string PARAM_JAR_PATH = "jar-path"; 60 const std::string PARAM_TXT_PATH = "txt-path"; 61 const std::string PARAM_PACK_RES_PATH = "pack-res-path"; 62 const std::string PARAM_ENTRYCARD_PATH = "entrycard-path"; 63 const std::string PARAM_RESOURCES_PATH = "resources-path"; 64 const std::string PARAM_INDEX_PATH = "index-path"; 65 const std::string PARAM_PACK_INFO_PATH = "pack-info-path"; 66 const std::string PARAM_PROFILE_PATH = "profile-path"; 67 const std::string PARAM_ETS_PATH = "ets-path"; 68 const std::string PARAM_OUT_PATH = "out-path"; 69 const std::string PARAM_MAPLE_SO_PATH = "maple-so-path"; 70 const std::string PARAM_MAPLE_SO_DIR = "maple-so-dir"; 71 const std::string PARAM_RPCID_PATH = "rpcid-path"; 72 const std::string PARAM_JS_PATH = "js-path"; 73 const std::string PARAM_FORCE = "force"; 74 const std::string PARAM_AN_PATH = "an-path"; 75 const std::string PARAM_AP_PATH = "ap-path"; 76 const std::string PARAM_DIR_LIST = "dir-list"; 77 const std::string PARAM_COMPRESS_LEVEL = "compress-level"; 78 const std::string PARAM_PKG_CONTEXT_PATH = "pkg-context-path"; 79 const std::string PARAM_HAP_PATH = "hap-path"; 80 const std::string PARAM_HSP_PATH = "hsp-path"; 81 const std::string PARAM_SIGNATURE_PATH = "signature-path"; 82 const std::string PARAM_CERTIFICATE_PATH = "certificate-path"; 83 const std::string PARAM_HAP_LIST = "hap-list"; 84 const std::string PARAM_HSP_LIST = "hsp-list"; 85 const std::string PARAM_APP_LIST = "app-list"; 86 const std::string PARAM_HQF_LIST = "hqf-list"; 87 const std::string PARAM_INPUT_LIST = "input-list"; 88 const std::string PARAM_VERSION_CODE = "version-code"; 89 const std::string PARAM_VERSION_NAME = "version-name"; 90 const std::string PARAM_DEVICE_TYPES = "device-types"; 91 const std::string PARAM_MIN_COMPATIBLE_VERSION_CODE = "min-compatible-version-code"; 92 const std::string PARAM_MIN_API_VERSION = "min-api-version"; 93 const std::string PARAM_COMPILE_SDK_TYPE = "compile-sdk-type"; 94 const std::string PARAM_TARGET_API_VERSION = "target-api-version"; 95 const std::string PARAM_API_RELEASE_TYPE = "api-release-type"; 96 const std::string PARAM_BUNDLE_TYPE = "bundle-type"; 97 const std::string PARAM_INSTALLATION_FREE = "installation-free"; 98 const std::string PARAM_DELIVERY_WITH_INSTALL = "delivery-with-install"; 99 const std::string PARAM_APP_PATH = "app-path"; 100 const std::string PARAM_RPCID = "rpcid"; 101 const std::string PARAM_APPQF_PATH = "appqf-path"; 102 const std::string PARAM_MAIN_MODULE_LIMIT = "main-module-limit"; 103 const std::string PARAM_NORMAL_MODULE_LIMIT = "normal-module-limit"; 104 const std::string PARAM_ATOMIC_SERVICE_ENTRY_SIZE_LIMIT = "atomic-service-entry-size-limit"; 105 const std::string PARAM_ATOMIC_SERVICE_NON_ENTRY_SIZE_LIMIT = "atomic-service-non-entry-size-limit"; 106 const std::string PARAM_TOTAL_LIMIT = "total-limit"; 107 const std::string PARAM_BUNDLE_NAME = "bundle-name"; 108 const std::string PARAM_PAC_JSON_PATH = "pac-json-path"; 109 110 const std::string MODULE_JSON = "module.json"; 111 const std::string CONFIG_JSON = "config.json"; 112 const std::string PATCH_JSON = "patch.json"; 113 const std::string PAC_JSON = "pac.json"; 114 const std::string LIB_PATH = "libs"; 115 const std::string AN_PATH = "an"; 116 const std::string AP_PATH = "ap"; 117 const std::string JS_PATH = "js"; 118 const std::string HNP_PATH = "hnp"; 119 const std::string ASSETS_PATH = "assets"; 120 const std::string RES_PATH = "res"; 121 const std::string SO_DIR = "maple"; 122 const std::string SO_ARM64_DIR = "maple/arm64/"; 123 const std::string SHARED_LIBS_DIR = "shared_libs"; 124 const std::string LINUX_FILE_SEPARATOR = "/"; 125 const std::string ENTRYCARD_NAME = "EntryCard"; 126 const std::string ENTRYCARD_BASE_NAME = "base"; 127 const std::string ENTRYCARD_SNAPSHOT_NAME = "snapshot"; 128 const std::string RESOURCES_PATH = "resources"; 129 const std::string RESOURCES_INDEX = "resources.index"; 130 const std::string PACK_INFO = "pack.info"; 131 const std::string ETS_PATH = "ets"; 132 const std::string RPCID_SC = "rpcid.sc"; 133 const std::string PKG_CONTEXT_JSON = "pkgContextInfo.json"; 134 const std::string PROFILE_NAME = "CAPABILITY.profile"; 135 const std::string FILE_PACK_RES = "pack.res"; 136 const std::string INVALID_PATH = "invalid"; 137 const std::string TYPE_SHARED = "shared"; 138 const std::string BUNDLE_TYPE_APP_SERVICE = "appService"; 139 const std::string TYPE_APP_PLUGIN = "appPlugin"; 140 const std::string TEMP_HAP_DIR = "tempHapDir"; 141 const std::string TEMP_HSP_DIR = "tempHspDir"; 142 const std::string TEMP_SELECTED_HAP_DIR = "tempSelectedHapDir"; 143 const std::string ATOMIC_SERVICE = "atomicService"; 144 const std::string NULL_DIR_NAME = ""; 145 const std::string DEVICE_TYPE_FITNESSWATCH = "fitnessWatch"; 146 const std::string DEVICE_TYPE_FITNESSWATCH_NEW = "liteWearable"; 147 const std::string VERSION_RECORD = "version_record.json"; 148 const std::string GENERAL_RECORD = "general_record.json"; 149 const std::string VERSION_NAME_PATTERN = "^[0-9.]+|(?=.*[{])(?=.*[}])[0-9a-zA-Z_.{}]+$"; 150 const std::string BUNDLE_NAME_PATTERN = 151 "([a-zA-Z]|[a-zA-Z]+(_*[0-9a-zA-Z])+)(\\.[0-9a-zA-Z]|\\.[0-9a-zA-Z]+(_*[0-9a-zA-Z])+){2,}"; 152 const std::string API_RELEASE_TYPE_PATTERN = "^(Canary[1-9]\\d*)|(Beta[1-9]\\d*)|(Release[1-9]\\d*)$"; 153 const std::vector<std::string> BUNDLE_TYPE_LIST = {"app", "appService", "atomicService", "shared", "appPlugin"}; 154 155 const std::string JSON_SUFFIX = ".json"; 156 const std::string HAP_SUFFIX = ".hap"; 157 const std::string HAR_SUFFIX = ".har"; 158 const std::string HSP_SUFFIX = ".hsp"; 159 const std::string APP_SUFFIX = ".app"; 160 const std::string SO_SUFFIX = ".so"; 161 const std::string RES_SUFFIX = ".res"; 162 const std::string ABC_SUFFIX = ".abc"; 163 const std::string JAR_SUFFIX = ".jar"; 164 const std::string TXT_SUFFIX = ".txt"; 165 const std::string PNG_SUFFIX = ".png"; 166 const std::string HQF_SUFFIX = ".hqf"; 167 const std::string APPQF_SUFFIX = ".appqf"; 168 169 const int32_t BUFFER_SIZE = 1024; 170 const int32_t BUNDLE_NAME_LEN_MIN = 7; 171 const int32_t BUNDLE_NAME_LEN_MAX = 128; 172 const int32_t APP_SUFFIX_LENGTH = 4; 173 const char COMMA_SPLIT = ','; 174 const int32_t MAX_VERSION_NAME_LENGTH = 127; 175 const int32_t MAX_VERSION_CODE = 2147483647; 176 const int32_t ATOMIC_SERVICE_ENTRY_SIZE_LIMIT_DEFAULT = 2048; 177 const int32_t ATOMIC_SERVICE_NON_ENTRY_SIZE_LIMIT_DEFAULT = 2048; 178 const int32_t ATOMIC_SERVICE_TOTAL_SIZE_LIMIT_MAX = 4194304; 179 180 constexpr const char* SHORT_OPTIONS = ""; 181 const struct option LONG_OPTIONS[] = { 182 {PARAM_MODE.c_str(), required_argument, nullptr, 1}, 183 {PARAM_JSON_PATH.c_str(), required_argument, nullptr, 2}, 184 {PARAM_LIB_PATH.c_str(), required_argument, nullptr, 3}, 185 {PARAM_RESOURCES_PATH.c_str(), required_argument, nullptr, 4}, 186 {PARAM_INDEX_PATH.c_str(), required_argument, nullptr, 5}, 187 {PARAM_PACK_INFO_PATH.c_str(), required_argument, nullptr, 6}, 188 {PARAM_PROFILE_PATH.c_str(), required_argument, nullptr, 7}, 189 {PARAM_ETS_PATH.c_str(), required_argument, nullptr, 8}, 190 {PARAM_OUT_PATH.c_str(), required_argument, nullptr, 9}, 191 {PARAM_MAPLE_SO_PATH.c_str(), required_argument, nullptr, 10}, 192 {PARAM_MAPLE_SO_DIR.c_str(), required_argument, nullptr, 11}, 193 {PARAM_RPCID_PATH.c_str(), required_argument, nullptr, 13}, 194 {PARAM_JS_PATH.c_str(), required_argument, nullptr, 14}, 195 {PARAM_FORCE.c_str(), required_argument, nullptr, 15}, 196 {PARAM_AN_PATH.c_str(), required_argument, nullptr, 16}, 197 {PARAM_AP_PATH.c_str(), required_argument, nullptr, 17}, 198 {PARAM_DIR_LIST.c_str(), required_argument, nullptr, 18}, 199 {PARAM_COMPRESS_LEVEL.c_str(), required_argument, nullptr, 19}, 200 {PARAM_PKG_CONTEXT_PATH.c_str(), required_argument, nullptr, 20}, 201 {PARAM_HAP_PATH.c_str(), required_argument, nullptr, 21}, 202 {PARAM_HSP_PATH.c_str(), required_argument, nullptr, 22}, 203 {PARAM_SIGNATURE_PATH.c_str(), required_argument, nullptr, 23}, 204 {PARAM_CERTIFICATE_PATH.c_str(), required_argument, nullptr, 24}, 205 {PARAM_HAP_LIST.c_str(), required_argument, nullptr, 25}, 206 {PARAM_HSP_LIST.c_str(), required_argument, nullptr, 26}, 207 {PARAM_APP_LIST.c_str(), required_argument, nullptr, 27}, 208 {PARAM_HQF_LIST.c_str(), required_argument, nullptr, 28}, 209 {PARAM_INPUT_LIST.c_str(), required_argument, nullptr, 29}, 210 {PARAM_VERSION_CODE.c_str(), required_argument, nullptr, 30}, 211 {PARAM_VERSION_NAME.c_str(), required_argument, nullptr, 31}, 212 {PARAM_APP_PATH.c_str(), required_argument, nullptr, 32}, 213 {PARAM_RPCID.c_str(), required_argument, nullptr, 33}, 214 {PARAM_APPQF_PATH.c_str(), required_argument, nullptr, 34}, 215 {PARAM_MAIN_MODULE_LIMIT.c_str(), required_argument, nullptr, 35}, 216 {PARAM_NORMAL_MODULE_LIMIT.c_str(), required_argument, nullptr, 36}, 217 {PARAM_FILE_PATH.c_str(), required_argument, nullptr, 37}, 218 {PARAM_HNP_PATH.c_str(), required_argument, nullptr, 38}, 219 {PARAM_JAR_PATH.c_str(), required_argument, nullptr, 39}, 220 {PARAM_ASSETS_PATH.c_str(), required_argument, nullptr, 40}, 221 {PARAM_RES_PATH.c_str(), required_argument, nullptr, 41}, 222 {PARAM_PACK_RES_PATH.c_str(), required_argument, nullptr, 42}, 223 {PARAM_ENTRYCARD_PATH.c_str(), required_argument, nullptr, 43}, 224 {PARAM_BUNDLE_NAME.c_str(), required_argument, nullptr, 44}, 225 {PARAM_TOTAL_LIMIT.c_str(), required_argument, nullptr, 45}, 226 {PARAM_DEVICE_TYPES.c_str(), required_argument, nullptr, 46}, 227 {PARAM_MIN_COMPATIBLE_VERSION_CODE.c_str(), required_argument, nullptr, 47}, 228 {PARAM_MIN_API_VERSION.c_str(), required_argument, nullptr, 48}, 229 {PARAM_COMPILE_SDK_TYPE.c_str(), required_argument, nullptr, 49}, 230 {PARAM_TARGET_API_VERSION.c_str(), required_argument, nullptr, 50}, 231 {PARAM_API_RELEASE_TYPE.c_str(), required_argument, nullptr, 51}, 232 {PARAM_BUNDLE_TYPE.c_str(), required_argument, nullptr, 52}, 233 {PARAM_INSTALLATION_FREE.c_str(), required_argument, nullptr, 53}, 234 {PARAM_DELIVERY_WITH_INSTALL.c_str(), required_argument, nullptr, 54}, 235 {PARAM_PAC_JSON_PATH.c_str(), required_argument, nullptr, 55}, 236 {PARAM_ATOMIC_SERVICE_ENTRY_SIZE_LIMIT.c_str(), required_argument, nullptr, 56}, 237 {PARAM_ATOMIC_SERVICE_NON_ENTRY_SIZE_LIMIT.c_str(), required_argument, nullptr, 57}, 238 {nullptr, 0, nullptr, 0}, 239 }; 240 constexpr const int32_t OPTIONS_SIZE = sizeof(LONG_OPTIONS) / sizeof(LONG_OPTIONS[0]); 241 242 enum PARAM_TYPE { 243 DEFAULT, 244 REGULAR_FILE, 245 REGULAR_FILE_ARRAY, 246 DIRECTORY, 247 DIRECTORY_ARRAY, 248 FILE_OR_DIRECTORY, 249 FILE_OR_DIRECTORY_ARRAY, 250 }; 251 252 constexpr const int32_t BUF_SIZE = 1024 * 4; 253 } 254 } // namespace AppExecFwk 255 } // namespace OHOS 256 #endif // DEVELOPTOOLS_PACKING_TOOL_APT_FRAMEWORKS_INCLUDE_CONSTANTS_H