-
Notifications
You must be signed in to change notification settings - Fork 0
顶部定义
许兴逸 edited this page Feb 16, 2024
·
5 revisions
(define <variable> <value>)
(define (<function-name> <arg1> <arg2>...)
<op1>
<op2>
<op3>...)
定义变量和函数,例子:
(define x 10)
(define (print-hello) (display "Hello, world!"))
(define (add x y) (+ x y))
(defines
(<variable1> <value1>)
(<variable2 <value2>)
...)
(defines
((<function-name> <arg1> <arg2>...)
<op1>
<op2>
<op3>...)
((<function-name> <arg1> <arg2>...)
<op1>
<op2>
<op3>...))
定义一组变量和函数,例子:
(defines
(a 1)
(b 2)
(c 3)
((add a b) (+ a b))
((sub a b) (- a b)))
(import
<pie-file1>
<pie-file2>
<pie-file3>...)
导入模块,将会把模块中export的对象导入到本文件的作用域中。
当路径开头为https://
或http://
时,允许从http服务上导入pie文件。
例:
(import
"./a.pie"
"./b.pie")
(export
<export-object1>
<export-object2>
<export-object3>...)
导出模块,以允许导入此模块的模块或者命令行访问本模块中的对象,可以导出的对象有:
- 变量
- 函数
- task
- action
例:
(defines
(a 1)
((add a b) (+ a b)))
(action clear
(delete "./build"))
(export
a
add
clear)
(action <action-name>
<op1>
<op2>
<op3>...)
(action (<action-name> <arg1> <arg2>...)
<op1>
<op2>
<op3>...)
定义一个构建action,例子:
(action (compile-all-c-files build-dir)
;; 调用编译task
)
(action (link-o-files build-dir)
;; 调用链接task
)
(action build
(ensure-dir "./build")
(compile-all-c-files "./build")
(link-o-files "./build") ;; 这里将会等待上一个调用的action所有任务完成后才会继续
)
(task (<task-name> <arg1> <arg2>...)
<sub-definitions>...)
定义一个构建task,每个构建task都会包含多条子定义,支持的子定义如下:
- define
- defines
- in - 可以接受一个或多个文件路径或文件路径列表,表示task的输入文件
- out - 可以接受一个或多个文件路径或文件路径列表,表示task的输出文件
- do - 表示在调用task时要执行的操作,通常这里不执行什么操作,该块的返回值将会被用作调用task的返回值
- make - 表示在构建阶段要执行的操作,将会在action执行结束时并行执行
例:
(task (copy-file src-file dst-file) ;; 定义用于复制文件的构建task
(in src-file) ;; 将src-file定义为输入文件
(out dst-file) ;; 将dst-file定义为输出文件
(make ;; 在构建时执行
(copy src-file dst-file))) ;; 在构建时复制文件
弦语蝶梦独立游戏工作室