Skip to content

Commit

Permalink
Add task arguments to FILE macro.
Browse files Browse the repository at this point in the history
  • Loading branch information
takagi committed Sep 30, 2016
1 parent 4b3b481 commit 3aa5b15
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
18 changes: 11 additions & 7 deletions src/lake.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -316,13 +316,17 @@
,@forms))
*tasks*)))))

(defmacro file (name dependency &body body)
(check-type name string)
(multiple-value-bind (forms desc) (parse-body body)
`(register-task (make-file-task ,name *namespace* ',dependency ,desc
#'(lambda ()
,@forms))
*tasks*)))
(defmacro file (name-and-args dependency &body body)
(check-type name-and-args (or string name-and-args))
(destructuring-bind (name . args) (ensure-list name-and-args)
(let ((args1 (mapcar #'car
(mapcar #'ensure-pair args))))
(multiple-value-bind (forms desc) (parse-body body)
`(register-task
(make-file-task ,name *namespace* ',args ',dependency ,desc
#'(lambda ,args1
,@forms))
*tasks*)))))

(defmacro directory (name &optional desc)
(check-type name string)
Expand Down
7 changes: 4 additions & 3 deletions t/lake.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -671,14 +671,15 @@

(let ((lake::*tasks* nil))

(file "hello.o" ("hello.c")
(file ("hello.o" foo) ("hello.c")
"desc"
(echo foo)
(echo "gcc -c hello.c"))

(with-test-directory
(sh "touch hello.c")
(is-print (lake::run-task "hello.o" lake::*tasks*)
(format nil "gcc -c hello.c~%")
(is-print (lake::run-task "hello.o[123]" lake::*tasks*)
(format nil "123~%gcc -c hello.c~%")
"base case 1."))

(is-error (macroexpand '(file (format nil "hello.o") ("hello.c")
Expand Down

0 comments on commit 3aa5b15

Please sign in to comment.