mirror of
https://github.com/openharmony/developtools_global_resource_tool.git
synced 2026-07-18 17:24:42 -04:00
资源编译时id固定异常bug处理
Signed-off-by: fangyunzhong <fangyunzhong2@huawei.com>
This commit is contained in:
@@ -134,7 +134,7 @@ void CmdParser<T>::ShowUseage()
|
||||
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 << " in [0x01000000, 0x06FFFFFF),[0x08000000, 0xFFFFFFFF)\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";
|
||||
|
||||
@@ -27,7 +27,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
|
||||
const std::map<int64_t, std::vector<ResourceItem>> &GetResources() const
|
||||
{
|
||||
return items_;
|
||||
};
|
||||
@@ -35,7 +35,7 @@ public:
|
||||
{
|
||||
moduleName_ = moduleName;
|
||||
};
|
||||
uint32_t MergeResourceItem(const std::map<int32_t, std::vector<ResourceItem>> &resourceInfos);
|
||||
uint32_t MergeResourceItem(const std::map<int64_t, std::vector<ResourceItem>> &resourceInfos);
|
||||
|
||||
private:
|
||||
uint32_t ScanModule(const std::string &input, const std::string &output);
|
||||
@@ -43,7 +43,7 @@ private:
|
||||
void CheckAllItems(std::vector<std::pair<ResType, std::string>> &noBaseResource);
|
||||
|
||||
// id, resource items
|
||||
std::map<int32_t, std::vector<ResourceItem>> items_;
|
||||
std::map<int64_t, std::vector<ResourceItem>> items_;
|
||||
std::string moduleName_;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ public:
|
||||
IResourceCompiler(ResType type, const std::string &output);
|
||||
virtual ~IResourceCompiler();
|
||||
uint32_t Compile(const std::vector<DirectoryInfo> &directoryInfos);
|
||||
const std::map<int32_t, std::vector<ResourceItem>> &GetResult() const;
|
||||
const std::map<int64_t, std::vector<ResourceItem>> &GetResult() const;
|
||||
uint32_t Compile(const FileInfo &fileInfo);
|
||||
void SetModuleName(const std::string &moduleName);
|
||||
uint32_t CompileForAppend(const FileInfo &fileInfo);
|
||||
@@ -43,7 +43,7 @@ protected:
|
||||
std::string moduleName_;
|
||||
|
||||
// id, resource items
|
||||
std::map<int32_t, std::vector<ResourceItem>> resourceInfos_;
|
||||
std::map<int64_t, std::vector<ResourceItem>> resourceInfos_;
|
||||
// ResType, name, resourceItems
|
||||
std::map<std::pair<ResType, std::string>, std::vector<ResourceItem>> nameInfos_;
|
||||
|
||||
|
||||
@@ -40,19 +40,19 @@ private:
|
||||
uint32_t Init(const std::string &filePath, bool isSystem);
|
||||
using ParseFunction = std::function<bool(const cJSON *, ResourceId&)>;
|
||||
void InitParser();
|
||||
uint32_t IdDefinedToResourceIds(const cJSON *record, bool isSystem, const int32_t strtSysId = 0);
|
||||
uint32_t IdDefinedToResourceIds(const cJSON *record, bool isSystem, const int64_t strtSysId = 0);
|
||||
bool ParseType(const cJSON *type, ResourceId &resourceId);
|
||||
bool ParseName(const cJSON *name, ResourceId &resourceId);
|
||||
bool ParseOrder(const cJSON *order, ResourceId &resourceId);
|
||||
bool ParseId(const cJSON *id, ResourceId &resourceId);
|
||||
bool PushResourceId(const ResourceId &resourceId, bool isSystem);
|
||||
int32_t GetStartId() const;
|
||||
int64_t GetStartId() const;
|
||||
std::map<std::pair<ResType, std::string>, ResourceId> sysDefinedIds_;
|
||||
std::map<std::pair<ResType, std::string>, ResourceId> appDefinedIds_;
|
||||
std::map<int32_t, ResourceId> idDefineds_;
|
||||
std::map<int64_t, ResourceId> idDefineds_;
|
||||
std::map<std::string, ParseFunction> handles_;
|
||||
const PackageParser packageParser_;
|
||||
static const int32_t START_SYS_ID;
|
||||
static const int64_t START_SYS_ID;
|
||||
ResourceIdCluster type_;
|
||||
cJSON *root_;
|
||||
};
|
||||
|
||||
+15
-15
@@ -27,27 +27,27 @@ namespace Global {
|
||||
namespace Restool {
|
||||
class IdWorker : public Singleton<IdWorker> {
|
||||
public:
|
||||
uint32_t Init(ResourceIdCluster &type, int32_t start = 0x01000000);
|
||||
int32_t GenerateId(ResType resType, const std::string &name);
|
||||
uint32_t Init(ResourceIdCluster &type, int64_t start = 0x01000000);
|
||||
int64_t GenerateId(ResType resType, const std::string &name);
|
||||
std::vector<ResourceId> GetHeaderId() const;
|
||||
int32_t GetId(ResType resType, const std::string &name) const;
|
||||
int32_t GetSystemId(ResType resType, const std::string &name) const;
|
||||
bool PushCache(ResType resType, const std::string &name, int32_t id);
|
||||
void PushDelId(int32_t id);
|
||||
int64_t GetId(ResType resType, const std::string &name) const;
|
||||
int64_t GetSystemId(ResType resType, const std::string &name) const;
|
||||
bool PushCache(ResType resType, const std::string &name, int64_t id);
|
||||
void PushDelId(int64_t id);
|
||||
|
||||
private:
|
||||
int32_t GenerateAppId(ResType resType, const std::string &name);
|
||||
int32_t GenerateSysId(ResType resType, const std::string &name);
|
||||
int32_t GetMaxId(int32_t startId) const;
|
||||
int32_t GetCurId();
|
||||
int32_t appId_;
|
||||
int32_t maxId_;
|
||||
int64_t GenerateAppId(ResType resType, const std::string &name);
|
||||
int64_t GenerateSysId(ResType resType, const std::string &name);
|
||||
int64_t GetMaxId(int64_t startId) const;
|
||||
int64_t GetCurId();
|
||||
int64_t appId_;
|
||||
int64_t maxId_;
|
||||
ResourceIdCluster type_;
|
||||
std::map<std::pair<ResType, std::string>, int32_t> ids_;
|
||||
std::map<std::pair<ResType, std::string>, int64_t> ids_;
|
||||
std::map<std::pair<ResType, std::string>, ResourceId> sysDefinedIds_;
|
||||
std::map<std::pair<ResType, std::string>, ResourceId> appDefinedIds_;
|
||||
std::vector<int32_t> delIds_;
|
||||
std::map<std::pair<ResType, std::string>, int32_t> cacheIds_;
|
||||
std::vector<int64_t> delIds_;
|
||||
std::map<std::pair<ResType, std::string>, int64_t> cacheIds_;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ class ReferenceParser {
|
||||
public:
|
||||
ReferenceParser();
|
||||
virtual ~ReferenceParser();
|
||||
uint32_t ParseRefInResources(std::map<int32_t, std::vector<ResourceItem>> &items, const std::string &output);
|
||||
uint32_t ParseRefInResources(std::map<int64_t, std::vector<ResourceItem>> &items, const std::string &output);
|
||||
uint32_t ParseRefInResourceItem(ResourceItem &resourceItem) const;
|
||||
uint32_t ParseRefInJsonFile(ResourceItem &resourceItem, const std::string &output, const bool isIncrement = false);
|
||||
uint32_t ParseRefInString(std::string &value, bool &update) const;
|
||||
|
||||
@@ -30,7 +30,7 @@ public:
|
||||
virtual ~ResourceAppend() {};
|
||||
uint32_t Append();
|
||||
uint32_t Combine();
|
||||
const std::map<int32_t, std::vector<std::shared_ptr<ResourceItem>>> GetItems() const
|
||||
const std::map<int64_t, std::vector<std::shared_ptr<ResourceItem>>> GetItems() const
|
||||
{
|
||||
return items_;
|
||||
}
|
||||
@@ -60,15 +60,15 @@ private:
|
||||
std::string ParseString(const char buffer[], int32_t length, int32_t &offset) const;
|
||||
int32_t ParseInt32(const char buffer[], int32_t length, int32_t &offset) const;
|
||||
bool ParseRef();
|
||||
bool CheckModuleResourceItem(const std::shared_ptr<ResourceItem> &resourceItem, int32_t id);
|
||||
bool CheckModuleResourceItem(const std::shared_ptr<ResourceItem> &resourceItem, int64_t id);
|
||||
bool IsBaseIdDefined(const FileInfo &fileInfo);
|
||||
#ifdef __WIN32
|
||||
bool LoadResourceItemWin(const std::string &filePath);
|
||||
#endif
|
||||
void CheckAllItems(std::vector<std::pair<ResType, std::string>> &noBaseResource);
|
||||
const PackageParser &packageParser_;
|
||||
std::map<int32_t, std::vector<std::shared_ptr<ResourceItem>>> items_;
|
||||
std::map<int32_t, std::vector<std::shared_ptr<ResourceItem>>> itemsForModule_;
|
||||
std::map<int64_t, std::vector<std::shared_ptr<ResourceItem>>> items_;
|
||||
std::map<int64_t, std::vector<std::shared_ptr<ResourceItem>>> itemsForModule_;
|
||||
std::vector<std::shared_ptr<ResourceItem>> refs_;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ const static std::string NEW_LINE_PATH = "\nat ";
|
||||
const static std::string LONG_PATH_HEAD = "\\\\?\\";
|
||||
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 5.003" };
|
||||
static const int8_t RESTOOL_VERSION[VERSION_MAX_LEN] = { "Restool 5.004" };
|
||||
const static int32_t TAG_LEN = 4;
|
||||
|
||||
enum class KeyType {
|
||||
@@ -190,8 +190,8 @@ struct IdData {
|
||||
};
|
||||
|
||||
struct ResourceId {
|
||||
int32_t id;
|
||||
int32_t seq;
|
||||
int64_t id;
|
||||
int64_t seq;
|
||||
std::string type;
|
||||
std::string name;
|
||||
};
|
||||
|
||||
@@ -28,19 +28,19 @@ public:
|
||||
ResourceModule(const std::string &modulePath, const std::string &moduleOutput, const std::string &moduleName);
|
||||
virtual ~ResourceModule() {};
|
||||
uint32_t ScanResource();
|
||||
const std::map<int32_t, std::vector<ResourceItem>> &GetOwner() const;
|
||||
const std::map<int64_t, std::vector<ResourceItem>> &GetOwner() const;
|
||||
const std::map<ResType, std::vector<DirectoryInfo>> &GetScanDirectorys() const;
|
||||
static uint32_t MergeResourceItem(std::map<int32_t, std::vector<ResourceItem>> &alls,
|
||||
const std::map<int32_t, std::vector<ResourceItem>> &other, bool tipError = false);
|
||||
static uint32_t MergeResourceItem(std::map<int64_t, std::vector<ResourceItem>> &alls,
|
||||
const std::map<int64_t, std::vector<ResourceItem>> &other, bool tipError = false);
|
||||
|
||||
protected:
|
||||
const std::string &modulePath_;
|
||||
const std::string &moduleOutput_;
|
||||
const std::string &moduleName_;
|
||||
std::map<int32_t, std::vector<ResourceItem>> owner_;
|
||||
std::map<int64_t, std::vector<ResourceItem>> owner_;
|
||||
std::map<ResType, std::vector<DirectoryInfo>> scanDirs_;
|
||||
private:
|
||||
void Push(const std::map<int32_t, std::vector<ResourceItem>> &other);
|
||||
void Push(const std::map<int64_t, std::vector<ResourceItem>> &other);
|
||||
static const std::vector<ResType> SCAN_SEQ;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -52,11 +52,11 @@ private:
|
||||
uint32_t PackAppend();
|
||||
uint32_t PackCombine();
|
||||
uint32_t HandleFeature();
|
||||
uint32_t FindResourceItems(const std::map<int32_t, std::vector<ResourceItem>> &resInfoLocal,
|
||||
std::vector<ResourceItem> &items, int32_t id) const;
|
||||
uint32_t FindResourceItems(const std::map<int64_t, std::vector<ResourceItem>> &resInfoLocal,
|
||||
std::vector<ResourceItem> &items, int64_t id) const;
|
||||
uint32_t HandleLabel(std::vector<ResourceItem> &items, ConfigParser &config) const;
|
||||
uint32_t HandleIcon(std::vector<ResourceItem> &items, ConfigParser &config) const;
|
||||
void SaveResourceItem(const ResourceItem &resourceItem, int32_t nextId) const;
|
||||
void SaveResourceItem(const ResourceItem &resourceItem, int64_t nextId) const;
|
||||
void CheckConfigJson();
|
||||
void CheckConfigJsonForCombine(ResourceAppend &resourceAppend);
|
||||
bool CopyIcon(std::string &dataPath, const std::string &idName, std::string &fileName) const;
|
||||
|
||||
+12
-12
@@ -30,8 +30,8 @@ public:
|
||||
ResourceTable();
|
||||
virtual ~ResourceTable();
|
||||
uint32_t CreateResourceTable();
|
||||
uint32_t CreateResourceTable(const std::map<int32_t, std::vector<std::shared_ptr<ResourceItem>>> &items);
|
||||
uint32_t LoadResTable(const std::string path, std::map<int32_t, std::vector<ResourceItem>> &resInfos);
|
||||
uint32_t CreateResourceTable(const std::map<int64_t, std::vector<std::shared_ptr<ResourceItem>>> &items);
|
||||
uint32_t LoadResTable(const std::string path, std::map<int64_t, std::vector<ResourceItem>> &resInfos);
|
||||
private:
|
||||
struct TableData {
|
||||
int32_t id;
|
||||
@@ -63,7 +63,7 @@ private:
|
||||
int32_t id;
|
||||
};
|
||||
uint32_t SaveToResouorceIndex(const std::map<std::string, std::vector<TableData>> &configs) const;
|
||||
uint32_t CreateIdDefined(const std::map<int32_t, std::vector<ResourceItem>> &allResource) const;
|
||||
uint32_t CreateIdDefined(const std::map<int64_t, std::vector<ResourceItem>> &allResource) const;
|
||||
bool InitIndexHeader(IndexHeader &indexHeader, uint32_t count) const;
|
||||
bool Prepare(const std::map<std::string, std::vector<TableData>> &configs,
|
||||
std::map<std::string, LimitKeyConfig> &limitKeyConfigs,
|
||||
@@ -74,16 +74,16 @@ private:
|
||||
void SaveLimitKeyConfigs(const std::map<std::string, LimitKeyConfig> &limitKeyConfigs,
|
||||
std::ostringstream &out) const;
|
||||
void SaveIdSets(const std::map<std::string, IdSet> &idSets, std::ostringstream &out) const;
|
||||
bool ReadFileHeader(std::ifstream &in, IndexHeader &indexHeader, int32_t &pos, int32_t length) const;
|
||||
bool ReadLimitKeys(std::ifstream &in, std::map<int32_t, std::vector<KeyParam>> &limitKeys,
|
||||
uint32_t count, int32_t &pos, int32_t length) const;
|
||||
bool ReadIdTables(std::ifstream &in, std::map<int32_t, std::pair<int32_t, int32_t>> &datas,
|
||||
uint32_t count, int32_t &pos, int32_t length) const;
|
||||
bool ReadDataRecordPrepare(std::ifstream &in, RecordItem &record, int32_t &pos, int32_t length) const;
|
||||
bool ReadFileHeader(std::ifstream &in, IndexHeader &indexHeader, int64_t &pos, int64_t length) const;
|
||||
bool ReadLimitKeys(std::ifstream &in, std::map<int64_t, std::vector<KeyParam>> &limitKeys,
|
||||
uint32_t count, int64_t &pos, int64_t length) const;
|
||||
bool ReadIdTables(std::ifstream &in, std::map<int64_t, std::pair<int64_t, int64_t>> &datas,
|
||||
uint32_t count, int64_t &pos, int64_t length) const;
|
||||
bool ReadDataRecordPrepare(std::ifstream &in, RecordItem &record, int64_t &pos, int64_t length) const;
|
||||
bool ReadDataRecordStart(std::ifstream &in, RecordItem &record,
|
||||
const std::map<int32_t, std::vector<KeyParam>> &limitKeys,
|
||||
const std::map<int32_t, std::pair<int32_t, int32_t>> &datas,
|
||||
std::map<int32_t, std::vector<ResourceItem>> &resInfos) const;
|
||||
const std::map<int64_t, std::vector<KeyParam>> &limitKeys,
|
||||
const std::map<int64_t, std::pair<int64_t, int64_t>> &datas,
|
||||
std::map<int64_t, std::vector<ResourceItem>> &resInfos) const;
|
||||
std::string indexFilePath_;
|
||||
std::string idDefinedPath_;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user