66 lines
2.0 KiB
Scheme
66 lines
2.0 KiB
Scheme
|
#!/usr/bin/guile -s
|
||
|
!#
|
||
|
(use-modules
|
||
|
(ice-9 match)
|
||
|
(srfi srfi-1)
|
||
|
(ice-9 format)
|
||
|
(ice-9 regex))
|
||
|
|
||
|
;; (format #t "~2%")
|
||
|
|
||
|
(define *options*
|
||
|
'("pac" "size"))
|
||
|
|
||
|
(define *project-name*
|
||
|
(regexp-substitute #f (string-match ".*/" (getcwd)) 'post))
|
||
|
|
||
|
(define get-valid-args
|
||
|
(lambda (cli-args)
|
||
|
;; (format (current-error-port) "~s~s~%" "cli-args - " cli-args)
|
||
|
(map (lambda (opt)
|
||
|
(find (lambda (cli-word)
|
||
|
(string-match
|
||
|
(string-append opt "*")
|
||
|
cli-word))
|
||
|
cli-args))
|
||
|
*options*)))
|
||
|
|
||
|
(define valid-args->alist
|
||
|
(lambda (valid-args)
|
||
|
;; (format (current-error-port) "~s~s~%" "valid-args - " valid-args)
|
||
|
(map (lambda (arg)
|
||
|
(and arg
|
||
|
(string-contains arg "=")
|
||
|
(cons
|
||
|
(regexp-substitute #f (string-match "=" arg) 'pre)
|
||
|
(regexp-substitute #f (string-match "=" arg) 'post))))
|
||
|
valid-args)))
|
||
|
|
||
|
(if (< (length (command-line)) 2)
|
||
|
(format #t "~a~%" "Usage: build.scm TARGET [ARG=VALUE]*")
|
||
|
(let* ((cli-args (command-line))
|
||
|
(target (cadr cli-args))
|
||
|
(valid-args (get-valid-args cli-args))
|
||
|
(alist (valid-args->alist valid-args))
|
||
|
(size (match (assoc-ref alist "size")
|
||
|
("a4" "-a4")
|
||
|
(_ "")))
|
||
|
(ly-command (string-append
|
||
|
"lilypond "
|
||
|
|
||
|
(match (assoc-ref alist "pac")
|
||
|
("off" "-dno-point-and-click ")
|
||
|
(_ ""))
|
||
|
|
||
|
"-o output/"
|
||
|
*project-name* (match target
|
||
|
("main" "")
|
||
|
(_ (string-append "-" target)))
|
||
|
size
|
||
|
" "
|
||
|
|
||
|
target size ".ly")))
|
||
|
;; (format (current-error-port) "~s~s~%" "alist - " alist)
|
||
|
(format #t "~2%~a~2%" ly-command)
|
||
|
(system ly-command)))
|