新增开启png图标尺寸校验选项

Signed-off-by: fangyunzhong <fangyunzhong2@huawei.com>
This commit is contained in:
fangyunzhong
2023-08-14 03:21:34 +00:00
parent 181fc08dc4
commit 41d1b4a327
7 changed files with 40 additions and 4 deletions
+1
View File
@@ -36,6 +36,7 @@ private:
uint32_t GetString(const Json::Value &node, int c, HandleBack callback);
uint32_t GetArray(const Json::Value &node, int c, HandleBack callback);
uint32_t GetModuleNames(const Json::Value &node, int c, HandleBack callback);
uint32_t GetBool(const Json::Value &node, int c, HandleBack callback);
};
}
}
+4
View File
@@ -52,6 +52,7 @@ public:
const std::string &GetDependEntry() const;
const std::string &GetIdDefinedOutput() const;
const std::string &GetIdDefinedInputPath() const;
bool GetIconCheck() const;
private:
void InitCommand();
@@ -77,6 +78,7 @@ private:
uint32_t SetIdDefinedInputPath(const std::string& argValue);
bool IsAscii(const std::string& argValue) const;
bool IsLongOpt(char *argv[]) const;
uint32_t IconCheck();
static const struct option CMD_OPTS[];
static const std::string CMD_PARAMS;
@@ -97,6 +99,7 @@ private:
std::string dependEntry_;
std::string idDefinedOutput_;
std::string idDefinedInputPath_;
bool isIconCheck_ = false;
};
template<class T>
@@ -136,6 +139,7 @@ void CmdParser<T>::ShowUseage()
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";
std::cout << " --icon-check Enable the PNG image verification function for icons and startwindows.\n";
}
template<class T>
+1
View File
@@ -114,6 +114,7 @@ enum Option {
IDS = 1,
DEFINED_IDS = 2,
DEPENDENTRY = 3,
ICON_CHECK = 4,
STARTID = 'e',
FORCEWRITE = 'f',
HELP = 'h',
+13
View File
@@ -61,6 +61,7 @@ void CmdList::InitFileListCommand(Json::Value &root, HandleBack callback)
fileListHandles_.push_back(bind(&CmdList::GetArray, this, root["moduleResources"], Option::INPUTPATH, callback));
fileListHandles_.push_back(bind(&CmdList::GetArray, this, root["dependencies"], Option::INPUTPATH, callback));
fileListHandles_.push_back(bind(&CmdList::GetModuleNames, this, root["moduleNames"], Option::MODULES, callback));
fileListHandles_.push_back(bind(&CmdList::GetBool, this, root["iconCheck"], Option::ICON_CHECK, callback));
}
uint32_t CmdList::GetString(const Json::Value &node, int c, HandleBack callback)
@@ -113,6 +114,18 @@ uint32_t CmdList::GetModuleNames(const Json::Value &node, int c, HandleBack call
}
return RESTOOL_SUCCESS;
}
uint32_t CmdList::GetBool(const Json::Value &node, int c, HandleBack callback)
{
if (node.type() != Json::booleanValue) {
return RESTOOL_SUCCESS;
}
if (node.asBool() && callback(c, "") != RESTOOL_SUCCESS) {
return RESTOOL_ERROR;
}
return RESTOOL_SUCCESS;
}
}
}
}
+13
View File
@@ -39,6 +39,7 @@ const struct option PackageParser::CMD_OPTS[] = {
{ "help", no_argument, nullptr, Option::HELP},
{ "ids", required_argument, nullptr, Option::IDS},
{ "defined-ids", required_argument, nullptr, Option::DEFINED_IDS},
{ "icon-check", no_argument, nullptr, Option::ICON_CHECK},
{ 0, 0, 0, 0},
};
@@ -338,6 +339,17 @@ const string &PackageParser::GetIdDefinedInputPath() const
return idDefinedInputPath_;
}
uint32_t PackageParser::IconCheck()
{
isIconCheck_ = true;
return RESTOOL_SUCCESS;
}
bool PackageParser::GetIconCheck() const
{
return isIconCheck_;
}
bool PackageParser::IsAscii(const string& argValue) const
{
#ifdef __WIN32
@@ -373,6 +385,7 @@ void PackageParser::InitCommand()
handles_.emplace(Option::HELP, [this](const string &) -> uint32_t { return ShowHelp(); });
handles_.emplace(Option::IDS, bind(&PackageParser::SetIdDefinedOutput, this, _1));
handles_.emplace(Option::DEFINED_IDS, bind(&PackageParser::SetIdDefinedInputPath, this, _1));
handles_.emplace(Option::ICON_CHECK, [this](const string &) -> uint32_t { return IconCheck(); });
}
uint32_t PackageParser::HandleProcess(int c, const string& argValue)
+2 -2
View File
@@ -74,7 +74,7 @@ void ResourceCheck::CheckNodeInResourceItem(const string &key, const ResourceIte
return;
}
if (width != height) {
cout << "Warning: the png width and height not equal" << NEW_LINE_PATH << filePath << endl;
cerr << "Warning: the png width and height not equal" << NEW_LINE_PATH << filePath << endl;
return;
}
auto result = g_keyNodeIndexs.find(key);
@@ -85,7 +85,7 @@ void ResourceCheck::CheckNodeInResourceItem(const string &key, const ResourceIte
if (normalSize != 0 && width > normalSize) {
string warningMsg = "Warning: The width or height of the png file referenced by the " + key + \
" exceeds the limit (" + to_string(normalSize) + " pixels)" + NEW_LINE_PATH + filePath;
cout << warningMsg << endl;
cerr << warningMsg << endl;
}
}
+6 -2
View File
@@ -346,7 +346,9 @@ uint32_t ResourcePack::PackNormal()
return RESTOOL_ERROR;
}
CheckConfigJson();
if (packageParser_.GetIconCheck()) {
CheckConfigJson();
}
ResourceTable resourceTable;
if (!packageParser_.GetDependEntry().empty()) {
@@ -565,7 +567,9 @@ uint32_t ResourcePack::PackCombine()
return RESTOOL_ERROR;
}
CheckConfigJsonForCombine(resourceAppend);
if (packageParser_.GetIconCheck()) {
CheckConfigJsonForCombine(resourceAppend);
}
if (GenerateHeader() != RESTOOL_SUCCESS) {
return RESTOOL_ERROR;