49 lines
1.4 KiB
Common Lisp
49 lines
1.4 KiB
Common Lisp
(defpackage :timecalc-build
|
|
(:use :cl)
|
|
(:import-from :timecalc-logic
|
|
:load-models))
|
|
|
|
(in-package :timecalc-build)
|
|
|
|
(defclass timecalc-op (asdf:program-op)
|
|
())
|
|
|
|
(defvar *build-rules* nil
|
|
"rules to be ran when we execute a build operation")
|
|
|
|
(defmacro define-build-rule (&body body)
|
|
"macro to add a new build-rule"
|
|
(let ((name (gensym)))
|
|
`(flet ((,name ()
|
|
,@body))
|
|
(push #',name *build-rules*))))
|
|
|
|
(defmethod asdf:output-files ((o timecalc-op) (c asdf:system))
|
|
(values (list (asdf/system:component-build-pathname c))
|
|
t))
|
|
|
|
(defmethod asdf:perform ((o timecalc-op) (c asdf:system))
|
|
(mapcar #'funcall *build-rules*) ;; runs our build rules
|
|
(apply #'uiop:dump-image
|
|
(car (asdf:output-files o c))
|
|
(append '(:executable t)
|
|
#+(and Win32 sbcl)
|
|
'(:application-type :console)
|
|
#+sb-core-compression
|
|
'(:compression t))))
|
|
|
|
;; BUILD RULES
|
|
(define-build-rule
|
|
;; load up all json files in {source-dir}/systems
|
|
(let ((dir (merge-pathnames "systems/" (asdf:system-source-directory :timecalc))))
|
|
(load-models (uiop:directory-files dir "*.system"))))
|
|
|
|
|
|
;; feel like this needs to be here so asdf recognizes
|
|
;; our custom program op for the build process
|
|
(flet ((export! (symbol package)
|
|
(import symbol package)
|
|
(export symbol package)))
|
|
(export! 'timecalc-op :asdf/bundle)
|
|
(export! 'timecalc-op :asdf))
|