-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtasks#.scm
50 lines (48 loc) · 1.53 KB
/
tasks#.scm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
(##namespace ("ssrun#"
make-task
task?
task-name
task-parameters
task-description
task-depends
task-handler
task-executed?
task
task-run
define-task
current-task
main-task
))
;; (define-macro (task depends . body)
;; (let((name (gensym 'task))
;; (self '(gensym 'self)))
;; `(let((,self '()))
;; (set! ,self
;; (make-task
;; ,name
;; (list ,@depends)
;; ,(if (and (pair? body) (string? (car body))) (car body) (symbol->string name))
;; (lambda ()
;; (parameterize
;; ((current-task ,self))
;; ,@body))))
;; ,self)))
(define-macro (define-task name&args depends . body)
(let ((name (if (pair? name&args)
(car name&args)
name&args))
(params (if (pair? name&args)
(cdr name&args)
'())))
`(begin
(define ,name
(make-task (quote ,name)
',params
,(if (and (pair? body) (string? (car body)))
(car body)
(symbol->string name))
(list ,@depends)
(lambda ,params
(parameterize ((current-task ,name))
,@body))))
(main-task ,name))))