Skip to content

Commit

Permalink
Better invocation
Browse files Browse the repository at this point in the history
  • Loading branch information
Shinmera committed Dec 30, 2023
1 parent 7f1f0c3 commit b1fe9e7
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 24 deletions.
5 changes: 1 addition & 4 deletions .github/workflows/rebuild-index.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,7 @@ jobs:
- uses: actions/checkout@v1
- name: Rebuild
run: |
./compile.lisp fonts
./compile.lisp txt
./compile.lisp css
./compile.lisp web
./compile.lisp all fonts txt css web
- name: GH Pages deploy
if: github.head_ref == null
run: |
Expand Down
46 changes: 26 additions & 20 deletions compile.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,21 @@ exec sbcl \
(make-pathname :name name :type type :defaults *here*))

(defun run (program &rest args)
(flet ((normalize (arg)
(etypecase arg
(string arg)
(pathname (uiop:native-namestring arg))
(real (princ-to-string arg)))))
(uiop:run-program (list* program (loop for arg in args
append (if (listp arg)
(mapcar #'normalize arg)
(list (normalize arg))))))))
(let ((program-args (loop for arg = (car args)
until (or (null args) (keywordp arg))
collect arg
do (pop args))))
(flet ((normalize (arg)
(etypecase arg
(string arg)
(pathname (uiop:native-namestring arg))
(real (princ-to-string arg)))))
(apply #'uiop:run-program
(list* program (loop for arg in program-args
append (if (listp arg)
(mapcar #'normalize arg)
(list (normalize arg)))))
args))))

(defun outdated-p (out in)
(or (not (probe-file out))
Expand Down Expand Up @@ -132,7 +138,7 @@ for file in argv[2:]:
(atlas (pathname-utils:directory-name dir))))))

(defun release (&optional (file (file "promptfont" "zip")))
(run "zip" "-j" file
(run "zip" "-j" "-X" file
(file "LICENSE" "txt")
(file "README" "md")
(file "index" "html")
Expand All @@ -143,25 +149,25 @@ for file in argv[2:]:
(file "promptfont" "css")
(directory (file :wild "png"))))

(defun all ()
(fixup)
(fonts)
(txt)
(css)
(web)
(atlas)
(release))
(defun run-command (command &rest args)
(apply (intern (format NIL "~:@(~a~)" command) #.*package*) args))

(defun all (&rest commands)
(dolist (command (or commands '(fixup fonts txt css web atlas release)))
(run-command command)))

(defun help ()
(format T "PromptFont data management utilities
Commands:
help --- Show this help screen
all --- Performs all below commands. This is run by default
all [command...]
--- Performs all below commands. This is run by default
fixup --- Fixes up the glyphs.json file
fonts --- Generates the promptfont.ttf and .otf files
atlas [bank] [size]
--- Generates the glyph texture atlas files
Defaults to all banks and size of 64
txt --- Generates the chars.txt file
css --- Generates the promptfont.css file
web --- Generates the index.html file
Expand All @@ -176,4 +182,4 @@ https://shinmera.com/promptfont
(defun main ()
(destructuring-bind (argv0 &optional (command "all") &rest args) (uiop:raw-command-line-arguments)
(declare (ignore argv0))
(apply (intern (format NIL "~:@(~a~)" command) #.*package*) args)))
(apply #'run-command command args)))

0 comments on commit b1fe9e7

Please sign in to comment.