Skip to content

Commit

Permalink
feat: Add clean dist
Browse files Browse the repository at this point in the history
  • Loading branch information
jcs090218 committed Nov 22, 2024
1 parent 0532217 commit 05fe1f8
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 5 deletions.
13 changes: 12 additions & 1 deletion lisp/_prepare.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ to actually set up the systems."
;; NOTE: Use this as project root?
(defun qob-primary-root ()
"Return the primary system path."
(let ((path (car (cdr (qob-primary-system-entry)))))
(let ((path (cdr (qob-primary-system-entry))))
(qob-file-name-directory path)))

(defun qob-find-asd-file (name)
Expand Down Expand Up @@ -608,6 +608,11 @@ Set up the systems; on contrary, you should use the function
(defvar qob-dist-path "dist/"
"Default path where to place the package artifact.")

(defun qob-dist-path ()
"Path to dist path."
(let ((path (or (qob-args 0) qob-dist-path)))
(qob-expand-fn path)))

;;
;;; Entry

Expand Down Expand Up @@ -693,4 +698,10 @@ Set up the systems; on contrary, you should use the function
(qob-msg "✓ Loading Qob file in ~A... done!" qob-file)
(qob-msg "✗ Loading Qob file... missing!")))))

;;
;;; Commad variables

(defvar qob-no-cleaning-operation-p nil
"Set to non-nil if there is no cleaning operation done.")

;;; End of lisp/_prepare.lisp
26 changes: 24 additions & 2 deletions lisp/clean/dist.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,30 @@

;;; Code

(defun qob-clean-dist ()
"Clean up the dist files."
(let* ((name (qob-primary-system-name))
(system (qob-primary-system))
(version (asdf:component-version system))
(f-name (qob-format "~A-~A" name version))
(f-tar (qob-expand-fn (qob-format "~A.tar" f-name) qob-dist-path))
(deleted 0)
(delete-dir nil))
(when (probe-file f-tar)
(ignore-errors (delete-file f-tar))
(incf deleted))
(setq delete-dir (ignore-errors (uiop:delete-empty-directory qob-dist-path)))
(qob-msg "")
(qob-info "(Total of ~A file~A and ~A directory deleted)" deleted
(qob--sinr deleted "" "s")
(if delete-dir "1" "0"))))

(qob-start
;; TODO: ..
)
(let ((qob-dist-path (qob-dist-path)))
(if (probe-file qob-dist-path)
(qob-clean-dist)
(progn
(qob-info "(No dist folder needs to be cleaned)" qob-dist-path)
(setq qob-no-cleaning-operation-p t)))))

;;; End of lisp/clean/dist.lisp
7 changes: 5 additions & 2 deletions lisp/core/package.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
(ignore-errors (delete-directory f-dir :recursive t))
(ensure-directories-exist f-dir)

;; Copy files over
(dolist (path (qob-system-files))
(let* ((path (qob-2str path))
(rel-path (qob-s-replace root "" path))
Expand All @@ -41,12 +42,14 @@
(qob-s-remove-prefix
(qob-2str qob-dist-path)
tar))))
;; Delete cache folder
(ignore-errors (delete-directory f-dir :recursive t))

(qob-msg "")
(qob-info "(Built in ~A.tar)" tar)))

(qob-start
(let* ((qob-dist-path (or (qob-args 0) qob-dist-path))
(qob-dist-path (qob-expand-fn qob-dist-path)))
(let ((qob-dist-path (qob-dist-path)))
(ensure-directories-exist qob-dist-path)

(let ((name (qob-primary-system-name))
Expand Down

0 comments on commit 05fe1f8

Please sign in to comment.