mirror of
https://github.com/openharmony/developtools_global_resource_tool.git
synced 2026-07-18 00:54:31 -04:00
@@ -35,7 +35,7 @@ public:
|
||||
class PackageParser : public ICmdParser {
|
||||
public:
|
||||
PackageParser() {};
|
||||
~PackageParser() = default;
|
||||
virtual ~PackageParser() = default;
|
||||
uint32_t Parse(int argc, char *argv[]) override;
|
||||
const std::vector<std::string> &GetInputs() const;
|
||||
const std::string &GetPackageName() const;
|
||||
@@ -104,7 +104,7 @@ template<class T>
|
||||
void CmdParser<T>::ShowUseage()
|
||||
{
|
||||
std::cout << "This is an OHOS Packaging Tool.\n";
|
||||
std::cout << "Useage:\n";
|
||||
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";
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace Restool {
|
||||
class FileManager : public Singleton<FileManager> {
|
||||
public:
|
||||
uint32_t ScanModules(const std::vector<std::string> &inputs, const std::string &output);
|
||||
const std::map<int32_t, std::vector<ResourceItem>> &GetResources() const { return alls_; };
|
||||
const std::map<int32_t, std::vector<ResourceItem>> &GetResources() const { return items_; };
|
||||
void SetModuleName(const std::string &moduleName) { moduleName_ = moduleName; };
|
||||
uint32_t ScanIncrement(const std::string &output);
|
||||
|
||||
@@ -42,7 +42,7 @@ private:
|
||||
const std::map<ResType, std::vector<DirectoryInfo>> &resTypeOfDirs) const;
|
||||
|
||||
// id, resource items
|
||||
std::map<int32_t, std::vector<ResourceItem>> alls_;
|
||||
std::map<int32_t, std::vector<ResourceItem>> items_;
|
||||
std::string moduleName_;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ public:
|
||||
ReferenceParser();
|
||||
virtual ~ReferenceParser();
|
||||
uint32_t ParseRefInSolidXml(const std::vector<std::string> &solidXmlFolders) const;
|
||||
uint32_t ParseRefInElement(std::map<int32_t, std::vector<ResourceItem>> &alls) const;
|
||||
uint32_t ParseRefInElement(std::map<int32_t, std::vector<ResourceItem>> &items) const;
|
||||
uint32_t ParseRefInString(std::string &value, bool &update) const;
|
||||
uint32_t ParseRefInProfile(const std::string &output) const;
|
||||
uint32_t ParseRefInJson(const std::string &filePath) const;
|
||||
|
||||
@@ -116,7 +116,7 @@ public:
|
||||
static bool CopyFleInner(const std::string &src, const std::string &dst);
|
||||
|
||||
/**
|
||||
* @brief create directorys
|
||||
* @brief create directories
|
||||
* @param filePath: directory path
|
||||
* @return true if success, other false
|
||||
*/
|
||||
|
||||
@@ -46,7 +46,7 @@ uint32_t FileManager::ScanModules(const vector<string> &inputs, const string &ou
|
||||
uint32_t FileManager::ScanIncrement(const string &output)
|
||||
{
|
||||
auto &incrementManager = IncrementManager::GetInstance();
|
||||
alls_ = incrementManager.GetResourceItems();
|
||||
items_ = incrementManager.GetResourceItems();
|
||||
vector<string> sxmlFolders;
|
||||
FilterRefSolidXml(output, sxmlFolders, incrementManager.GetScanDirs());
|
||||
return ParseReference(output, sxmlFolders);
|
||||
@@ -67,14 +67,14 @@ uint32_t FileManager::ScanModule(const string &input, const string &output,
|
||||
|
||||
uint32_t FileManager::MergeResourceItem(const map<int32_t, vector<ResourceItem>> &resourceInfos)
|
||||
{
|
||||
return ResourceModule::MergeResourceItem(alls_, resourceInfos);
|
||||
return ResourceModule::MergeResourceItem(items_, resourceInfos);
|
||||
}
|
||||
|
||||
uint32_t FileManager::ParseReference(const string &output, const vector<string> &sxmlFolders)
|
||||
{
|
||||
ReferenceParser referenceParser;
|
||||
if (referenceParser.ParseRefInSolidXml(sxmlFolders) != RESTOOL_SUCCESS ||
|
||||
referenceParser.ParseRefInElement(alls_) != RESTOOL_SUCCESS ||
|
||||
referenceParser.ParseRefInElement(items_) != RESTOOL_SUCCESS ||
|
||||
referenceParser.ParseRefInProfile(output) != RESTOOL_SUCCESS) {
|
||||
return RESTOOL_ERROR;
|
||||
}
|
||||
|
||||
@@ -87,9 +87,9 @@ uint32_t ReferenceParser::ParseRefInSolidXml(const vector<string> &solidXmlFolde
|
||||
return RESTOOL_SUCCESS;
|
||||
}
|
||||
|
||||
uint32_t ReferenceParser::ParseRefInElement(map<int32_t, vector<ResourceItem>> &alls) const
|
||||
uint32_t ReferenceParser::ParseRefInElement(map<int32_t, vector<ResourceItem>> &items) const
|
||||
{
|
||||
for (auto &iter : alls) {
|
||||
for (auto &iter : items) {
|
||||
for (auto &resourceItem : iter.second) {
|
||||
if (IsNotElement(resourceItem.GetResType())) {
|
||||
break;
|
||||
|
||||
@@ -75,7 +75,7 @@ bool ResourceUtil::OpenJsonFile(const string &path, Json::Value &root)
|
||||
{
|
||||
ifstream ifs(path, ios::binary);
|
||||
if (!ifs) {
|
||||
cerr << "Error: open json faild '" << path << "'" << endl;
|
||||
cerr << "Error: open json failed '" << path << "'" << endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -33,6 +33,10 @@ uint32_t PackCmdHandle(PackageParser &packageParser)
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
if (argv == nullptr) {
|
||||
cerr << "Error: argv null" << endl;
|
||||
return RESTOOL_ERROR;
|
||||
}
|
||||
auto &parser = CmdParser<PackageParser>::GetInstance();
|
||||
if (parser.Parse(argc, argv) != RESTOOL_SUCCESS) {
|
||||
parser.ShowUseage();
|
||||
|
||||
@@ -43,9 +43,14 @@ bool SolidXml::GenerateSolidXml(const string &filePath)
|
||||
return false;
|
||||
}
|
||||
|
||||
xmlNodePtr rootNode = xmlDocGetRootElement(doc);
|
||||
if (rootNode == nullptr) {
|
||||
xmlFreeDoc(doc);
|
||||
return false;
|
||||
}
|
||||
auto root = make_shared<XmlNode>();
|
||||
nodes_.push_back(root);
|
||||
Compile(xmlDocGetRootElement(doc), root);
|
||||
Compile(rootNode, root);
|
||||
xmlFreeDoc(doc);
|
||||
return SaveToFile(filePath);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user