| Name | Date | Size | #Lines | LOC | ||
|---|---|---|---|---|---|---|
| .. | - | - | ||||
| include/ | 22-Oct-2025 | - | 3,183 | 2,117 | ||
| src/ | 22-Oct-2025 | - | 10,703 | 9,190 | ||
| test/ | 22-Oct-2025 | - | 92 | 75 | ||
| BUILD.gn | D | 22-Oct-2025 | 3.2 KiB | 119 | 110 | |
| CMakeLists.txt | D | 22-Oct-2025 | 1.7 KiB | 43 | 35 | |
| LICENSE | D | 22-Oct-2025 | 9.9 KiB | 177 | 150 | |
| OAT.xml | D | 22-Oct-2025 | 1.8 KiB | 40 | 21 | |
| README.md | D | 22-Oct-2025 | 1.6 KiB | 59 | 41 | |
| README_zh.md | D | 22-Oct-2025 | 7 KiB | 165 | 119 | |
| bundle.json | D | 22-Oct-2025 | 882 | 37 | 36 | |
| restool.gni | D | 22-Oct-2025 | 769 | 16 | 14 | |
| restool_faq.json | D | 22-Oct-2025 | 508 | 14 | 13 | |
| win32.cmake | D | 22-Oct-2025 | 409 | 11 | 9 |
README.md
1# OpenHarmony resource compile tool 2 3## Description 4resource tool is used in computer.In OpenHarmony SDK toolchain.Provide to IDE.Support Windows, Linux, MacOS platform. 5 6## Directory Structure 7 8``` 9/developtools 10|----global_resource_tool 11| |----include #Header file 12| |----src #source code file 13| |----test #Test case 14| |----build #Depending on the third-party library compilation script 15| |----BUILD.gn #Compile script 16| |----CMakeLists.txt #CMake file 17| |----win32.cmake #Windows cross compilation script 18``` 19 20## Instructions 21 22### Test 23 24In PC, run `python test.py ./restool ./out` 25 26### Help 27 28resource tool usually integrate to IDE, OpenHarmony compile system. 29 30resource tool command e.g: 31 32-v version 33-i input resource path 34-o output resource path 35-r resource ID header file path 36-p package name 37-f if output path exists,force override it 38-m module name, can add more, split by ','(like entry1,entry2,...) 39-j config.json path 40-e start id mask, e.g 0x01000000, in [0x01000000, 0x06FFFFFF),[0x08000000, 0x41FFFFFF) 41 42``` 43entry Directory Structure 44| |----resource 45| |----config.json or module.json 46``` 47`./restool -i entry1 -i entry2 -j xxx/module.json -p ohos.demo.xxx -o out -r out/ResourceTable.h ` 48 49## Related to the storehouse 50 51**global_resource_tool** 52 53[third_party_cJSON](https://gitee.com/openharmony/third_party_cJSON/blob/master/README.md) 54 55[third_party_libpng](https://gitee.com/openharmony/third_party_libpng/blob/master/README.md) 56 57[third_party_bounds_checking_function](https://gitee.com/openharmony/third_party_bounds_checking_function/blob/master/README.en.md) 58 59
README_zh.md
1# OpenHarmony资源编译工具 2 3## 简介 4restool(资源编译工具)是一种资源构建工具。通过编译资源文件创建资源索引、解析资源。restool保存在sdk安装目录下的toolchains子目录。 5 6## 代码目录 7 8``` 9/developtools 10|----global_resource_tool 11| |----include #头文件 12| |----src #源代码文件 13| |----test #测试用例 14| |----build #依赖三方库编译脚本 15| |----BUILD.gn #编译脚本 16| |----CMakeLists.txt #CMake文件 17| |----win32.cmake #Windows交叉编译脚本 18``` 19 20## 使用说明 21 22### SDK编译命令 23 24[SDK编译命令参考](https://gitee.com/openharmony/build/blob/master/README_zh.md) 25 26### 参数说明 27 28#### restool支持的命令选项 29 30| 选项 | 是否可缺省 | 是否存在入参 | 描述 | 31| -------- | -------- | -------- | -------- | 32| -i/--inputPath | 不可缺省 | 带参数 | 指定需要构建的资源目录或者资源中间件。<br>在资源目录中支持指定一个编译好的Hap资源目录(解压态),在此Hap的基础上完成叠加编译。| 33| -j/--json | 不可缺省 | 带参数 | 指定config.json或者module.json文件路径。 | 34| -o/--outputPath | 不可缺省 | 带参数 | 指定已编译资源的输出路径。 | 35| -p/--packageName | 不可缺省 | 带参数 | 指定编译资源的bundle名称。 | 36| -r/--resHeader | 不可缺省 | 带参数 | 指定资源的头文件路径,有三种格式:“.txt”、“.js”、“.h”。 | 37| -e/--startId | 可缺省 | 带参数 | 指定生成资源的起始ID值,例如:0x01000000,范围[0x01000000, 0x06FFFFFF),[0x08000000, 0x41FFFFFF) | 38| -f/--forceWrite | 可缺省 | 不带参数 | 如果输出路径已经存在。强制删除,重新生成。 | 39| -h/--help | 可缺省 | 不带参数 | 查看工具帮助信息。 | 40| -m/--modules | 可缺省 | 带参数 | 多模块联合编译时,指定多个模块名。用“,”连接。 | 41| -x/--append | 可缺省 | 带参数 | 指定生成中间文件的资源目录或单个资源路径。同一个命令可以多次指定。 | 42| -z/--combine | 可缺省 | 不带参数 | 针对资源中间文件目录,生成编译结果。 | 43| -v/--version | 可缺省 | 不带参数 | 查看工具版本号。 | 44| -l/--fileList | 可缺省 | 带参数 | 指定命令选项的集合json文件,例如:resConfig.json。详细格式查看开发文档。 | 45| --ids | 可缺省 | 带参数 | 指定生成id_defined.json的输出目录。 | 46| --defined-ids | 可缺省 | 带参数 | 指定id_defined.json文件路径,一般都是通过--ids生成。<br>id_defined.json包含资源类型、名称及其ID的列表。<br>开发者可以自定义id_defined.json中的资源ID。 | 47| --dependEntry | 可缺省 | 带参数 | FA模型下单独编译feature时,指定entry模块的编译结果目录。 | 48| --icon-check | 可缺省 | 不带参数 | 开启icon和startWindowIcon的PNG图片校验功能。 | 49| --target-config | 可缺省 | 带参数 | 与“-i”命令同时使用,支持选择编译。<br>具体可参考如下**target-config参数说明**。| 50| --thread | 可缺省 | 带参数 | 指定资源编译时开启的子线程数量。| 51| --ignored-file | 可缺省 | 带参数 | 指定资源编译时文件和文件夹的忽略规则,格式为正则表达式,多个规则之间以“:”分隔。例如:“\\.git:\\.svn”表示忽略名称为“.git”、“.svn”的文件和文件夹。| 52 53**target-config参数说明** 54 55支持参数配置类型:MccMnc、Locale、Orientation、Device、ColorMode、Density 56 57参数格式说明:配置之间用“;”分割,配置中的值用“[]”封装,并使用“,”分割。 58 59MccMnc匹配规则:Mcc(国家码)必须相同;Mnc(网络码)不存在时默认匹配,否则Mnc须相同才匹配。 60 61Locale匹配规则:Locale匹配需满足以下三条规则。 62 631、语言须相同。 64 652、脚本(文字)不存在时默认匹配,否则必须相同。 66 673、国家或地区不存在时默认匹配,否则必须相同。 68 69参数举例说明:Locale[zh_CN,en_US];Device[phone],该参数过滤其他语言,保留能匹配上zh_CN和en_US的语言;过滤其他设备,保留phone;其他参数(如MccMnc、Orientation等)配置不过滤均保留。 70 71 72#### restool支持的子命令 73 74| 命令 | 描述 | 75| --- | ---- | 76| dump | 以json的格式输出hap包中resource的内容。 | 77 78**dump命令** 79 80``` 81restool dump [-h] [config] filePath 82``` 83dump命令参数列表 84 85| 参数 | 是否可缺省 | 是否存在入参 | 描述 | 86| --- | --------- | ---------- |------- | 87| -h | 可缺省 | 不带参数 | 帮助信息。 | 88| config | 可缺省 | 不带参数 | 只打印hap包中资源的限定词信息。 | 89 90示例: 91 92```sh 93# 打印hap包中所有的资源信息 94restool dump entry.hap 95# 打印hap包中资源的限定词信息 96restool dump config entry.hap 97``` 98 99### 使用实例 100 101例如:entry目录结构如下 102``` 103entry/src/main 104| |----resource 105| | |----base 106| | | |----element 107| | | |----media 108| | | |----profile 109| | |----rawfile 110| |----config.json/module.json 111``` 112 113构建资源全量命令: 114 115``` 116restool -i entry/src/main -j entry/src/main/module.json -p com.ohos.demo -o out -r out/ResourceTable.txt -f 117``` 118 119构建资源增量命令(仅预览模式可用),具体步骤如下: 120 1211.生成资源中间件: 122``` 123restool -x entry/src/main/resource -o out 124``` 1252.编译中间件: 126``` 127restool -i out1 -i out2 -o out -p com.ohos.demo -r out/ResourceTable.txt -j entry/src/main/module.json -f -z 128``` 129 130叠加资源编译命令: 131 132``` 133# hapResource为解压后的Hap包路径 134restool -i entry/src/main -i hapResource -j entry/src/main/module.json -p com.ohos.demo -o out -r out/ResourceTable.txt -f 135``` 136 137固定资源ID的方式有两种,如下: 138 139方式一:在resource/base/element/目录下存放自定义id_defined.json文件。构建成功后,生成的ID值将会和id_defined.json文件中自定义的ID值保持一致。 140 141方式二:通过--ids 命令生成id_defined.json文件。--defined-ids命令指定id_defined.json文件。构建成功后,生成的ID值将会和id_defined.json文件中自定义的ID值保持一致。 142 143生成id_defined.json文件: 144``` 145restool -i entry/src/main -j entry/src/main/module.json -p com.ohos.demo -o out -r out/ResourceTable.txt --ids out -f 146``` 147 148指定资源ID固定的id_defined.json文件: 149``` 150restool -i entry/src/main -j entry/src/main/module.json -p com.ohos.demo -o out1 -r out1/ResourceTable.txt --defined-ids out/id_defined.json -f 151``` 152 153### 资源类型介绍 154[资源类型介绍](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/quick-start/resource-categories-and-access.md) 155 156## 相关仓 157 158**global_resource_tool** 159 160[third_party_cJSON](https://gitee.com/openharmony/third_party_cJSON/blob/master/README.md) 161 162[third_party_libpng](https://gitee.com/openharmony/third_party_libpng/blob/master/README.md) 163 164[third_party_bounds_checking_function](https://gitee.com/openharmony/third_party_bounds_checking_function/blob/master/README.md ) 165