restool命令选项优化

Signed-off-by: fangyunzhong <fangyunzhong2@huawei.com>
This commit is contained in:
fangyunzhong
2023-03-24 03:02:53 +00:00
parent fd1303da85
commit 6a28defe99
5 changed files with 172 additions and 109 deletions
+20 -14
View File
@@ -81,6 +81,7 @@ private:
uint32_t SetIdDefinedOutput(const std::string& argValue);
uint32_t SetIdDefinedInputPath(const std::string& argValue);
bool IsAscii(const std::string& argValue) const;
bool IsLongOpt(char *argv[]) const;
static const struct option CMD_OPTS[];
static const std::string CMD_PARAMS;
@@ -124,20 +125,25 @@ void CmdParser<T>::ShowUseage()
std::cout << "Usage:\n";
std::cout << TOOL_NAME << " [arguments] Package the OHOS resources.\n";
std::cout << "[arguments]:\n";
std::cout << " -i input resource path, can add more.\n";
std::cout << " -p package name.\n";
std::cout << " -o output path.\n";
std::cout << " -r resource header file path(like ./ResourceTable.js, ./ResrouceTable.h).\n";
std::cout << " -f if output path exists,force delete it.\n";
std::cout << " -v print tool version.\n";
std::cout << " -m module name, can add more, split by ','(like entry1,entry2,...).\n";
std::cout << " -j config.json path.\n";
std::cout << " -e start id mask, e.g 0x01000000, in [0x01000000, 0x06FFFFFF),[0x08000000, 0x41FFFFFF)\n";
std::cout << " -x resources folder path\n";
std::cout << " -z flag for incremental compilation\n";
std::cout << " -h Displays this help menu\n";
std::cout << " --ids save id_defined.json direcory\n";
std::cout << " --defined-ids input id_defined.json path\n";
std::cout << " -i/--inputPath input resource path, can add more.\n";
std::cout << " -p/--packageName package name.\n";
std::cout << " -o/--outputPath output path.\n";
std::cout << " -r/--resHeader resource header file path(like ./ResourceTable.js, ./ResrouceTable.h).\n";
std::cout << " -f/--forceWrite if output path exists,force delete it.\n";
std::cout << " -v/--version print tool version.\n";
std::cout << " -m/--modules module name, can add more, split by ','(like entry1,entry2,...).\n";
std::cout << " -j/--json config.json path.\n";
std::cout << " -e/--startId start id mask, e.g 0x01000000,";
std::cout << " in [0x01000000, 0x06FFFFFF),[0x08000000, 0x41FFFFFF)\n";
std::cout << " -x/--append resources folder path\n";
std::cout << " -z/--combine flag for incremental compilation\n";
std::cout << " -h/--help Displays this help menu\n";
std::cout << " -l/--fileList input json file of the option set, e.g resConfig.json.";
std::cout << " For details, see the developer documentation.\n";
std::cout << " --ids save id_defined.json direcory\n";
std::cout << " --defined-ids input id_defined.json path\n";
std::cout << " --dependEntry Build result directory of the specified entry module when the feature";
std::cout << " module resources are independently built in the FA model.\n";
}
template<class T>
+46 -24
View File
@@ -38,7 +38,7 @@ const static std::string LONG_PATH_HEAD = "\\\\?\\";
const static std::string ID_DEFINED_INDENTATION = " ";
const static int32_t VERSION_MAX_LEN = 128;
const static int32_t INT_TO_BYTES = sizeof(uint32_t);
static const int8_t RESTOOL_VERSION[VERSION_MAX_LEN] = { "Restool 4.001" };
static const int8_t RESTOOL_VERSION[VERSION_MAX_LEN] = { "Restool 4.002" };
const static int32_t TAG_LEN = 4;
enum class KeyType {
@@ -83,11 +83,6 @@ enum class OrientationType {
HORIZONTAL = 1,
};
const std::map<std::string, OrientationType> g_orientaionMap = {
{ "vertical", OrientationType::VERTICAL },
{ "horizontal", OrientationType::HORIZONTAL },
};
enum class DeviceType {
PHONE = 0,
TABLET = 1,
@@ -97,14 +92,6 @@ enum class DeviceType {
WEARABLE = 6,
};
const std::map<std::string, DeviceType> g_deviceMap = {
{ "phone", DeviceType::PHONE },
{ "tablet", DeviceType::TABLET },
{ "car", DeviceType::CAR },
{ "tv", DeviceType::TV },
{ "wearable", DeviceType::WEARABLE },
};
enum class ResolutionType {
SDPI = 120,
MDPI = 160,
@@ -114,6 +101,51 @@ enum class ResolutionType {
XXXLDPI = 640,
};
enum class NightMode {
DARK = 0,
LIGHT = 1,
};
enum class InputDevice {
INPUTDEVICE_NOT_SET = -1,
INPUTDEVICE_POINTINGDEVICE = 0,
};
enum Option {
END = -1,
IDS = 1,
DEFINED_IDS = 2,
DEPENDENTRY = 3,
STARTID = 'e',
FORCEWRITE = 'f',
HELP = 'h',
INPUTPATH = 'i',
JSON = 'j',
FILELIST = 'l',
MODULES = 'm',
OUTPUTPATH = 'o',
PACKAGENAME = 'p',
RESHEADER = 'r',
VERSION = 'v',
APPEND = 'x',
COMBINE = 'z',
UNKNOWN = '?',
NO_ARGUMENT = ':',
};
const std::map<std::string, OrientationType> g_orientaionMap = {
{ "vertical", OrientationType::VERTICAL },
{ "horizontal", OrientationType::HORIZONTAL },
};
const std::map<std::string, DeviceType> g_deviceMap = {
{ "phone", DeviceType::PHONE },
{ "tablet", DeviceType::TABLET },
{ "car", DeviceType::CAR },
{ "tv", DeviceType::TV },
{ "wearable", DeviceType::WEARABLE },
};
const std::map<std::string, ResolutionType> g_resolutionMap = {
{ "sdpi", ResolutionType::SDPI },
{ "mdpi", ResolutionType::MDPI },
@@ -123,21 +155,11 @@ const std::map<std::string, ResolutionType> g_resolutionMap = {
{ "xxxldpi", ResolutionType::XXXLDPI },
};
enum class NightMode {
DARK = 0,
LIGHT = 1,
};
const std::map<std::string, NightMode> g_nightModeMap = {
{ "dark", NightMode::DARK },
{ "light", NightMode::LIGHT },
};
enum class InputDevice {
INPUTDEVICE_NOT_SET = -1,
INPUTDEVICE_POINTINGDEVICE = 0,
};
const std::map<std::string, InputDevice> g_inputDeviceMap = {
{ "pointingdevice", InputDevice::INPUTDEVICE_POINTINGDEVICE },
};