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 
24 namespace OHOS {
25 namespace AppPackingTool {
26 namespace Constants {
27 const std::string CMD_HELP = "help";
28 const std::string CMD_PACK = "pack";
29 const std::string CMD_UNPACK = "unpack";
30 
31 const std::string MODE_HAP = "hap";
32 const std::string MODE_HSP = "hsp";
33 const std::string MODE_APP = "app";
34 const std::string MODE_HQF = "hqf";
35 const std::string MODE_APPQF = "appqf";
36 const std::string MODE_MULTIAPP = "multiApp";
37 const std::string MODE_VERSION_NORMALIZE = "versionNormalize";
38 const std::string MODE_PACKAGE_NORMALIZE = "packageNormalize";
39 
40 const std::string PARAM_PREFIX = "--";
41 const std::string PARAM_MODE = "mode";
42 const std::string PARAM_JSON_PATH = "json-path";
43 const std::string PARAM_LIB_PATH = "lib-path";
44 const std::string PARAM_RESOURCES_PATH = "resources-path";
45 const std::string PARAM_INDEX_PATH = "index-path";
46 const std::string PARAM_PACK_INFO_PATH = "pack-info-path";
47 const std::string PARAM_PROFILE_PATH = "profile-path";
48 const std::string PARAM_ETS_PATH = "ets-path";
49 const std::string PARAM_OUT_PATH = "out-path";
50 const std::string PARAM_MAPLE_SO_PATH = "maple-so-path";
51 const std::string PARAM_MAPLE_SO_DIR = "maple-so-dir";
52 const std::string PARAM_RPCID_PATH = "rpcid-path";
53 const std::string PARAM_JS_PATH = "js-path";
54 const std::string PARAM_FORCE = "force";
55 const std::string PARAM_AN_PATH = "an-path";
56 const std::string PARAM_AP_PATH = "ap-path";
57 const std::string PARAM_DIR_LIST = "dir-list";
58 const std::string PARAM_COMPRESS_LEVEL = "compress-level";
59 const std::string PARAM_PKG_CONTEXT_PATH = "pkg-context-path";
60 const std::string PARAM_HAP_PATH = "hap-path";
61 const std::string PARAM_HSP_PATH = "hsp-path";
62 const std::string PARAM_SIGNATURE_PATH = "signature-path";
63 const std::string PARAM_CERTIFICATE_PATH = "certificate-path";
64 const std::string PARAM_HAP_LIST = "hap-list";
65 const std::string PARAM_HSP_LIST = "hsp-list";
66 const std::string PARAM_APP_LIST = "app-list";
67 const std::string PARAM_HQF_LIST = "hqf-list";
68 const std::string PARAM_INPUT_LIST = "input-list";
69 const std::string PARAM_VERSION_CODE = "version-code";
70 const std::string PARAM_VERSION_NAME = "version-name";
71 const std::string PARAM_APP_PATH = "app-path";
72 const std::string PARAM_RPCID = "rpcid";
73 const std::string PARAM_APPQF_PATH = "appqf-path";
74 const std::string PARAM_MAIN_MODULE_LIMIT = "main-module-limit";
75 const std::string PARAM_NORMAL_MODULE_LIMIT = "normal-module-limit";
76 
77 const std::string MODULE_JSON = "module.json";
78 const std::string CONFIG_JSON = "config.json";
79 const std::string LIB_PATH = "libs";
80 const std::string RESOURCES_PATH = "resources";
81 const std::string RESOURCES_INDEX = "resources.index";
82 const std::string PACK_INFO = "pack.info";
83 const std::string ETS_PATH = "ets";
84 const std::string RPCID_SC = "rpcid.sc";
85 const std::string PKG_CONTEXT_JSON = "pkgContextInfo.json";
86 
87 const std::string JSON_SUFFIX = ".json";
88 const std::string HAP_SUFFIX = ".hap";
89 const std::string HSP_SUFFIX = ".hsp";
90 const std::string APP_SUFFIX = ".app";
91 
92 constexpr const char* SHORT_OPTIONS = "";
93 const 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 };
131 constexpr const int OPTIONS_SIZE = sizeof(LONG_OPTIONS) / sizeof(LONG_OPTIONS[0]);
132 
133 enum 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 
143 constexpr const int BUF_SIZE = 1024 * 4;
144 }
145 }  // namespace AppExecFwk
146 }  // namespace OHOS
147 
148 #endif  // DEVELOPTOOLS_PACKING_TOOL_APT_FRAMEWORKS_INCLUDE_CONSTANTS_H