-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Pipe是一个主要用于构建游戏素材的增量式构建自动化系统。
Pipe在启动时将会在工作目录下查找build.pipe
,并载入此文件,默认无参数执行build
段落。
一个Pipe构建脚本文件以.pipe
文件结尾,由多个以下段落组成:
- include
- operation
- task
- action
其中include段落可以包含其它Pipe构建脚本文件,以加载其他内容:
- include "a.pipe"
- include "b.pipe"
- include "subDir/a.pipe"
- include "../parent.pipe"
Pipe将会自动剔除相同的多个文件,使得每个Pipe文件仅被加载一次。
除了include段落以外,其他段落均可以被拆分以分散写在多个位置,并声明此段落用于何种平台,及它用于向何种目标平台生成文件,如以下例子:
- operation an-operation for windows to linux
此段落为一个用于windows操作系统,以linux为生成目标的operation段落,其名称为an-operation
。
除此之外,也可以声明多个名称相同的目标,使用不同的平台声明:
- operation an-operation for windows to linux # 用于从Windows向linux生成
- operation an-operation for macos to linux # 用于从macos向linux生成
- operation an-operation for linux to linux # 用于从linux向linux生成
- operation an-operation for windows # 用于从windows向任意平台生成
- operation an-operation to linux # 用于从任意平台向linux生成
- operation an-operation # 用于从任意平台向任意平台生成
另外,可以同时声明多个生成平台或生成目标:
- operation an-operation for { windows, linux, macos } to { ps2, ps3, ps4, ps5 }
另外,在使用pipe时,可以通过--for
参数和--to
参数来手动指定要使用哪个平台和哪个目标,默认均为当前正在使用的平台。
Operation段落用于描述一组最小的操作,不同的操作之间可能会被并行执行。
Operation通常来源于:
- 系统命令
- 可执行文件
- 通过operation段落定义
Operation可以接受一组参数。
以下是一个示例:
- operation copy-file %src% %dst% for windows
copy %src% %dst%
- operation copy-file %src% %dst% for { linux, macos }
cp %src% %dst
task用于描述一个构建任务,task段落仅描述此构建任务的元数据,如输入文件、输出文件等,task段落必须跟一个同名的operation段落。其operation操作用于执行耗时的构建任务,而task段落用于执行构建任务之前没有依赖且不耗时的前置任务。
task段落可用于动态生成依赖列表。
task段落与其同名的operation段落应该具有相同的参数。
- task copy-file %src% %dst% # 生成一个构建任务
input %src% # 指定一个输入文件
output %dst% # 指定一个输出文件
- operation copy-file %src% %dst% for windows # 在构建阶段执行
copy %src% %dst%
- operation copy-file %src% %dst% for { linux, macos }
cp %src% %dst
action段落用于描述一个动作,该动作将会创建一系列任务,并在分析依赖后执行构建操作。
可以通过命令行来调用action并传入参数。
可以定义before action
和after action
段落用于描述在action执行前后的补充动作,before action
与after action
均为operation段落,应当与同名action传入相同参数。
如果没有特殊参数,Pipe将会自动从build
action开始执行。
在任何动作开始执行之前,将会执行before all
;在所有动作执行结束之后将会执行after all
。
- action build
copy-file "a.png" "b.png"
copy-file "b.png" "c.png"
- before all
# 在执行任何动作之前执行
- before action build
# 在执行build之前执行
- after action
# 在执行build之后执行
- after all
# 在所有动作执行结束后执行
None | To Action | To Task | To Operation |
---|---|---|---|
Call From Action | 执行并等待结束 | 生成构建任务 | 执行并等待结束 |
Call From Task | 不可调用 | 生成更多构建任务 | 执行并等待结束 |
Call From Operation | 不可调用 | 不可调用 | 执行并等待结束 |
flowchart LR
subgraph stagePre["预处理阶段"]
beforeAll["before all"] --> beforeAction["before action"]
end
subgraph stageAnal["分析阶段"]
action --> |call| op["operation x"]
action --> |call| op2["operation y"]
action --> |call| taskA["task a"]
action --> |call| taskB["task b"]
action --> |call| taskC["task c"]
end
subgraph stageBuild["构建阶段"]
taskA -..-> |generate task and pass variables|operationA["operation a"]
taskB -..-> |generate task and pass variables|operationB["operation b"]
taskC -..-> |generate task and pass variables|operationC["operation c"]
end
subgraph stageClean["清理阶段"]
afterAction["after action"] --> afterAll["after all"]
end
beforeAction ==> action
stageBuild ==> afterAction
- task Create-Font %ttfFile% for { Windows, Linux } to Nintendo-Switch
set %more% (tail %ttfFile%)
set %ttfFile% (head %ttfFile%)
set %outFile% (changeExtension %ttfFile% ".out")
input %ttfFile%
output %outFile%
- operation Create-Font %ttfFile%
sdftool %ttfFile% %temp%
spritepacker %temp% %outFile%
- action build for Windows to Nintendo-Switch
CreateFont "1.ttf"
CreateFont "2.ttf"
- before action build for Windows to Nintendo-Switch
set %out% "./output"
mkdir %out%
- after action build for Windows to Nintendo-Switch
- include "More.pipe"