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 <iostream>
20#include <map>
21#include <string>
22#include <getopt.h>
23
24namespace OHOS {
25namespace AppPackingTool {
26namespace Constants {
27const std::string CMD_HELP = "help";
28const std::string CMD_PACK = "pack";
29const std::string CMD_UNPACK = "unpack";
30
31const std::string MODE_HAP = "hap";
32const std::string MODE_HSP = "hsp";
33const std::string MODE_APP = "app";
34const std::string MODE_HQF = "hqf";
35const std::string MODE_APPQF = "appqf";
36const std::string MODE_MULTIAPP = "multiApp";
37const std::string MODE_VERSION_NORMALIZE = "versionNormalize";
38const std::string MODE_PACKAGE_NORMALIZE = "packageNormalize";
39
40const std::string PARAM_PREFIX = "--";
41const std::string PARAM_MODE = "mode";
42const std::string PARAM_JSON_PATH = "json-path";
43const std::string PARAM_LIB_PATH = "lib-path";
44const std::string PARAM_RESOURCES_PATH = "resources-path";
45const std::string PARAM_INDEX_PATH = "index-path";
46const std::string PARAM_PACK_INFO_PATH = "pack-info-path";
47const std::string PARAM_PROFILE_PATH = "profile-path";
48const std::string PARAM_ETS_PATH = "ets-path";
49const std::string PARAM_OUT_PATH = "out-path";
50const std::string PARAM_MAPLE_SO_PATH = "maple-so-path";
51const std::string PARAM_MAPLE_SO_DIR = "maple-so-dir";
52const std::string PARAM_RPCID_PATH = "rpcid-path";
53const std::string PARAM_JS_PATH = "js-path";
54const std::string PARAM_FORCE = "force";
55const std::string PARAM_AN_PATH = "an-path";
56const std::string PARAM_AP_PATH = "ap-path";
57const std::string PARAM_DIR_LIST = "dir-list";
58const std::string PARAM_COMPRESS_LEVEL = "compress-level";
59const std::string PARAM_PKG_CONTEXT_PATH = "pkg-context-path";
60const std::string PARAM_HAP_PATH = "hap-path";
61const std::string PARAM_HSP_PATH = "hsp-path";
62const std::string PARAM_SIGNATURE_PATH = "signature-path";
63const std::string PARAM_CERTIFICATE_PATH = "certificate-path";
64const std::string PARAM_HAP_LIST = "hap-list";
65const std::string PARAM_HSP_LIST = "hsp-list";
66const std::string PARAM_APP_LIST = "app-list";
67const std::string PARAM_HQF_LIST = "hqf-list";
68const std::string PARAM_INPUT_LIST = "input-list";
69const std::string PARAM_VERSION_CODE = "version-code";
70const std::string PARAM_VERSION_NAME = "version-name";
71const std::string PARAM_APP_PATH = "app-path";
72const std::string PARAM_RPCID = "rpcid";
73const std::string PARAM_APPQF_PATH = "appqf-path";
74const std::string PARAM_MAIN_MODULE_LIMIT = "main-module-limit";
75const std::string PARAM_NORMAL_MODULE_LIMIT = "normal-module-limit";
76
77const std::string MODULE_JSON = "module.json";
78const std::string CONFIG_JSON = "config.json";
79const std::string LIB_PATH = "libs";
80const std::string RESOURCES_PATH = "resources";
81const std::string RESOURCES_INDEX = "resources.index";
82const std::string PACK_INFO = "pack.info";
83const std::string ETS_PATH = "ets";
84const std::string RPCID_SC = "rpcid.sc";
85const std::string PKG_CONTEXT_JSON = "pkgContextInfo.json";
86
87const std::string JSON_SUFFIX = ".json";
88const std::string HAP_SUFFIX = ".hap";
89const std::string HSP_SUFFIX = ".hsp";
90const std::string APP_SUFFIX = ".app";
91
92constexpr const char* SHORT_OPTIONS = "";
93const struct option LONG_OPTIONS[] = {
94    {PARAM_MODE.c_str(), required_argument, nullptr, 1},
95    {PARAM_JSON_PATH.c_str(), required_argument, nullptr, 2},
96    {PARAM_LIB_PATH.c_str(), required_argument, nullptr, 3},
97    {PARAM_RESOURCES_PATH.c_str(), required_argument, nullptr, 4},
98    {PARAM_INDEX_PATH.c_str(), required_argument, nullptr, 5},
99    {PARAM_PACK_INFO_PATH.c_str(), required_argument, nullptr, 6},
100    {PARAM_PROFILE_PATH.c_str(), required_argument, nullptr, 7},
101    {PARAM_ETS_PATH.c_str(), required_argument, nullptr, 8},
102    {PARAM_OUT_PATH.c_str(), required_argument, nullptr, 9},
103    {PARAM_MAPLE_SO_PATH.c_str(), required_argument, nullptr, 10},
104    {PARAM_MAPLE_SO_DIR.c_str(), required_argument, nullptr, 11},
105    {PARAM_RPCID_PATH.c_str(), required_argument, nullptr, 13},
106    {PARAM_JS_PATH.c_str(), required_argument, nullptr, 14},
107    {PARAM_FORCE.c_str(), required_argument, nullptr, 15},
108    {PARAM_AN_PATH.c_str(), required_argument, nullptr, 16},
109    {PARAM_AP_PATH.c_str(), required_argument, nullptr, 17},
110    {PARAM_DIR_LIST.c_str(), required_argument, nullptr, 18},
111    {PARAM_COMPRESS_LEVEL.c_str(), required_argument, nullptr, 19},
112    {PARAM_PKG_CONTEXT_PATH.c_str(), required_argument, nullptr, 20},
113    {PARAM_HAP_PATH.c_str(), required_argument, nullptr, 21},
114    {PARAM_HSP_PATH.c_str(), required_argument, nullptr, 22},
115    {PARAM_SIGNATURE_PATH.c_str(), required_argument, nullptr, 23},
116    {PARAM_CERTIFICATE_PATH.c_str(), required_argument, nullptr, 24},
117    {PARAM_HAP_LIST.c_str(), required_argument, nullptr, 25},
118    {PARAM_HSP_LIST.c_str(), required_argument, nullptr, 26},
119    {PARAM_APP_LIST.c_str(), required_argument, nullptr, 27},
120    {PARAM_HQF_LIST.c_str(), required_argument, nullptr, 28},
121    {PARAM_INPUT_LIST.c_str(), required_argument, nullptr, 29},
122    {PARAM_VERSION_CODE.c_str(), required_argument, nullptr, 30},
123    {PARAM_VERSION_NAME.c_str(), required_argument, nullptr, 31},
124    {PARAM_APP_PATH.c_str(), required_argument, nullptr, 32},
125    {PARAM_RPCID.c_str(), required_argument, nullptr, 33},
126    {PARAM_APPQF_PATH.c_str(), required_argument, nullptr, 34},
127    {PARAM_MAIN_MODULE_LIMIT.c_str(), required_argument, nullptr, 35},
128    {PARAM_NORMAL_MODULE_LIMIT.c_str(), required_argument, nullptr, 36},
129    {nullptr, 0, nullptr, 0},
130};
131constexpr const int OPTIONS_SIZE = sizeof(LONG_OPTIONS) / sizeof(LONG_OPTIONS[0]);
132
133enum PARAM_TYPE {
134    DEFAULT,
135    REGULAR_FILE,
136    REGULAR_FILE_ARRAY,
137    DIRECTORY,
138    DIRECTORY_ARRAY,
139    FILE_OR_DIRECTORY,
140    FILE_OR_DIRECTORY_ARRAY,
141};
142
143constexpr const int BUF_SIZE = 1024 * 4;
144}
145}  // namespace AppExecFwk
146}  // namespace OHOS
147
148#endif  // DEVELOPTOOLS_PACKING_TOOL_APT_FRAMEWORKS_INCLUDE_CONSTANTS_H