| Name | Date | Size | #Lines | LOC | ||
|---|---|---|---|---|---|---|
| .. | - | - | ||||
| include/ | 06-May-2025 | - | 3,049 | 2,008 | ||
| src/ | 06-May-2025 | - | 9,901 | 8,449 | ||
| test/ | 06-May-2025 | - | 92 | 75 | ||
| BUILD.gn | D | 06-May-2025 | 2.9 KiB | 107 | 97 | |
| CMakeLists.txt | D | 06-May-2025 | 1.7 KiB | 43 | 35 | |
| LICENSE | D | 06-May-2025 | 9.9 KiB | 177 | 150 | |
| OAT.xml | D | 06-May-2025 | 1.8 KiB | 40 | 21 | |
| README.md | D | 06-May-2025 | 1.6 KiB | 59 | 41 | |
| README_zh.md | D | 06-May-2025 | 6.6 KiB | 163 | 117 | |
| bundle.json | D | 06-May-2025 | 882 | 37 | 36 | |
| restool.gni | D | 06-May-2025 | 695 | 15 | 13 | |
| win32.cmake | D | 06-May-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 51**target-config参数说明** 52 53支持参数配置类型:MccMnc、Locale、Orientation、Device、ColorMode、Density 54 55参数格式说明:配置之间用“;”分割,配置中的值用“[]”封装,并使用“,”分割。 56 57MccMnc匹配规则:Mcc(国家码)必须相同;Mnc(网络码)不存在时默认匹配,否则Mnc须相同才匹配。 58 59Locale匹配规则:Locale匹配需满足以下三条规则。 60 611、语言须相同。 62 632、脚本(文字)不存在时默认匹配,否则必须相同。 64 653、国家或地区不存在时默认匹配,否则必须相同。 66 67参数举例说明:Locale[zh_CN,en_US];Device[phone],该参数过滤其他语言,保留能匹配上zh_CN和en_US的语言;过滤其他设备,保留phone;其他参数(如MccMnc、Orientation等)配置不过滤均保留。 68 69 70#### restool支持的子命令 71 72| 命令 | 描述 | 73| --- | ---- | 74| dump | 以json的格式输出hap包中resource的内容。 | 75 76**dump命令** 77 78``` 79restool dump [-h] [config] filePath 80``` 81dump命令参数列表 82 83| 参数 | 是否可缺省 | 是否存在入参 | 描述 | 84| --- | --------- | ---------- |------- | 85| -h | 可缺省 | 不带参数 | 帮助信息。 | 86| config | 可缺省 | 不带参数 | 只打印hap包中资源的限定词信息。 | 87 88示例: 89 90```sh 91# 打印hap包中所有的资源信息 92restool dump entry.hap 93# 打印hap包中资源的限定词信息 94restool dump config entry.hap 95``` 96 97### 使用实例 98 99例如:entry目录结构如下 100``` 101entry/src/main 102| |----resource 103| | |----base 104| | | |----element 105| | | |----media 106| | | |----profile 107| | |----rawfile 108| |----config.json/module.json 109``` 110 111构建资源全量命令: 112 113``` 114restool -i entry/src/main -j entry/src/main/module.json -p com.ohos.demo -o out -r out/ResourceTable.txt -f 115``` 116 117构建资源增量命令(仅预览模式可用),具体步骤如下: 118 1191.生成资源中间件: 120``` 121restool -x entry/src/main/resource -o out 122``` 1232.编译中间件: 124``` 125restool -i out1 -i out2 -o out -p com.ohos.demo -r out/ResourceTable.txt -j entry/src/main/module.json -f -z 126``` 127 128叠加资源编译命令: 129 130``` 131# hapResource为解压后的Hap包路径 132restool -i entry/src/main -i hapResource -j entry/src/main/module.json -p com.ohos.demo -o out -r out/ResourceTable.txt -f 133``` 134 135固定资源ID的方式有两种,如下: 136 137方式一:在resource/base/element/目录下存放自定义id_defined.json文件。构建成功后,生成的ID值将会和id_defined.json文件中自定义的ID值保持一致。 138 139方式二:通过--ids 命令生成id_defined.json文件。--defined-ids命令指定id_defined.json文件。构建成功后,生成的ID值将会和id_defined.json文件中自定义的ID值保持一致。 140 141生成id_defined.json文件: 142``` 143restool -i entry/src/main -j entry/src/main/module.json -p com.ohos.demo -o out -r out/ResourceTable.txt --ids out -f 144``` 145 146指定资源ID固定的id_defined.json文件: 147``` 148restool -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 149``` 150 151### 资源类型介绍 152[资源类型介绍](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/quick-start/resource-categories-and-access.md) 153 154## 相关仓 155 156**global_resource_tool** 157 158[third_party_cJSON](https://gitee.com/openharmony/third_party_cJSON/blob/master/README.md) 159 160[third_party_libpng](https://gitee.com/openharmony/third_party_libpng/blob/master/README.md) 161 162[third_party_bounds_checking_function](https://gitee.com/openharmony/third_party_bounds_checking_function/blob/master/README.md ) 163