Add mkly rules

This commit is contained in:
contrapunctus 2020-12-20 12:58:34 +05:30
parent 4976297453
commit 4d7226f9f8
1 changed files with 48 additions and 0 deletions

48
mkly-rules.scm Normal file
View File

@ -0,0 +1,48 @@
(define shell-path "/usr/bin/bash")
(define project-name (getcwd-base))
(define options)
;; Return a list of build rules.
;;
;; TARGET is a single target passed on the command line, or "" if none
;; was supplied. (If multiple targets are passed on the command line,
;; this function will be called once with each target.)
;;
;; Return value is a list of rules, where each rule is a list in
;; the form (PATTERN COMMAND [ARG ...])
;;
;; PATTERN can be
;; * a symbol - COMMAND will be run when the target passed on the
;; command line matches this symbol;
;; * a string - treated as a regular expression; COMMAND will be run
;; when it matches the target passed on the command line
;; * `else', as the last rule - COMMAND will be run when no other rule matches
;;
;; COMMAND and arguments can be any value - lists will be flattened,
;; all values will be converted to strings, and spaces will be added.
;; String values will be quoted, which is useful for escaping file
;; names in the final command to be run.
(define (rules target)
(let* ((subdir (parent target))
(branch (vcs-current-branch))
(dest (begin
(when subdir
(chdir subdir)
(set! project-name (getcwd-base)))
(use-dir! (format #f "~:[output-~a~;output/~]"
branch branch)))))
;; A main.ly could also exist both in the root and in the
;; sub-directories, but this will just compile the root main.ly regardless.
`((all main.ly part-*.ly)
(dev lilypond
-o ,(string-append dest project-name "-pacON")
main.ly)
(main.ly lilypond -dno-point-and-click
-o ,(string-append dest project-name)
,target)
("part-.*\\.ly" lilypond -dno-point-and-click
-o ,(string-append
dest project-name "-"
(file-name-no-extension target))
,target)
(else mkly all))))