Skip to content

Commit 659124f

Browse files
committed
install deps
1 parent 0408b9d commit 659124f

File tree

14 files changed

+177
-57
lines changed

14 files changed

+177
-57
lines changed

cmds/core/build.lisp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,5 @@
4141
:usage "-n <name> -o <path>"
4242
:options (options)
4343
:handler #'handler))
44+
45+
;;; End of cmds/core/build.lisp

cmds/core/dists.lisp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,5 @@
2828
:description "List out all installed dists"
2929
:options (options)
3030
:handler #'handler))
31+
32+
;;; End of cmds/core/dist.lisp

cmds/core/install-deps.lisp

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
;;;; cmds/core/install-deps.lisp --- Build executable
2+
3+
;;; Commentary
4+
;;
5+
;; The `install-deps' command definition.
6+
;;
7+
8+
;;; Code
9+
10+
(defpackage qob-cli/install-deps
11+
(:use cl)
12+
(:export command))
13+
14+
(in-package :qob-cli/install-deps)
15+
16+
(defun options ()
17+
"Options for `install-deps' command."
18+
(list
19+
(clingon:make-option
20+
:flag
21+
:description "install include development dependencies"
22+
:long-name "dev"
23+
:key :dev)))
24+
25+
(defun handler (cmd)
26+
"Handler for `install-deps' command."
27+
(qob-cli:call-script "core/install-deps" cmd))
28+
29+
(defun command ()
30+
"The `install-deps' command."
31+
(clingon:make-command
32+
:name "install-deps"
33+
:description "Automatically install system dependencies"
34+
:options (options)
35+
:handler #'handler))
36+
37+
;;; End of cmds/core/install-deps.lisp

cmds/core/install.lisp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,5 @@
2929
:usage "[names..]"
3030
:options (options)
3131
:handler #'handler))
32+
33+
;;; End of cmds/core/install.lisp

cmds/core/list.lisp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,5 @@
2828
:description "List the registered system"
2929
:options (options)
3030
:handler #'handler))
31+
32+
;;; End of cmds/core/list.lisp

cmds/qob.lisp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,7 @@
5858
:sub-commands `(,(qob-cli/build:command)
5959
,(qob-cli/dists:command)
6060
,(qob-cli/install:command)
61+
,(qob-cli/install-deps:command)
6162
,(qob-cli/list:command))))
63+
64+
;;; End of cmds/qob.lisp

lisp/_color.lisp

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -26,20 +26,13 @@
2626
#\Esc (qob-color-code color) str #\Esc)
2727
str))
2828

29-
(defun qob-ansi-red (str)
30-
"Color STR in red."
31-
(qob-color-it :red str))
32-
33-
(defun qob-ansi-green (str)
34-
"Color STR in green."
35-
(qob-color-it :green str))
36-
37-
(defun qob-ansi-yellow (str)
38-
"Color STR in yellow."
39-
(qob-color-it :yellow str))
40-
41-
(defun qob-ansi-cyan (str)
42-
"Color STR in cyan."
43-
(qob-color-it :cyan str))
29+
(defun qob-ansi-black (str) (qob-color-it :black str))
30+
(defun qob-ansi-red (str) (qob-color-it :red str))
31+
(defun qob-ansi-green (str) (qob-color-it :green str))
32+
(defun qob-ansi-yellow (str) (qob-color-it :yellow str))
33+
(defun qob-ansi-blue (str) (qob-color-it :blue str))
34+
(defun qob-ansi-magenta (str) (qob-color-it :magenta str))
35+
(defun qob-ansi-cyan (str) (qob-color-it :cyan str))
36+
(defun qob-ansi-white (str) (qob-color-it :white str))
4437

4538
;;; End of lisp/_color.lisp

lisp/_prepare.lisp

Lines changed: 64 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -37,23 +37,28 @@ The arguments FMT and ARGS are used to form the output message."
3737

3838
(defun qob-trace (msg &rest args)
3939
"Send trace message; see function `qob--msg' for arguments MSG and ARGS."
40-
(apply #'qob-msg msg args))
40+
(let ((msg (apply #'format nil msg args)))
41+
(qob-msg (qob-ansi-white msg))))
4142

4243
(defun qob-debug (msg &rest args)
4344
"Send debug message; see function `qob--msg' for arguments MSG and ARGS."
44-
(apply #'qob-msg msg args))
45+
(let ((msg (apply #'format nil msg args)))
46+
(qob-msg (qob-ansi-blue msg))))
4547

4648
(defun qob-info (msg &rest args)
4749
"Send info message; see function `qob--msg' for arguments MSG and ARGS."
48-
(qob-msg (qob-ansi-cyan (format nil msg args))))
50+
(let ((msg (apply #'format nil msg args)))
51+
(qob-msg (qob-ansi-cyan msg))))
4952

5053
(defun qob-warn (msg &rest args)
5154
"Send warning message; see function `qob--msg' for arguments MSG and ARGS."
52-
(qob-msg (qob-ansi-yellow (format nil msg args))))
55+
(let ((msg (apply #'format nil msg args)))
56+
(qob-msg (qob-ansi-yellow msg))))
5357

5458
(defun qob-error (msg &rest args)
5559
"Send error message; see function `qob--msg' for arguments MSG and ARGS."
56-
(qob-msg (qob-ansi-red (format nil msg args))))
60+
(let ((msg (apply #'format nil msg args)))
61+
(qob-msg (qob-ansi-red msg))))
5762

5863
;;
5964
;;; Environment
@@ -170,27 +175,33 @@ the `qob-start' execution.")
170175
;;; Package
171176

172177
(defconstant qob-source-mapping
173-
`((quicklisp . "https://www.quicklisp.org/")
178+
`((quicklisp . "http://beta.quicklisp.org/")
174179
(ultralisp . "http://dist.ultralisp.org/"))
175180
"Mapping of source name and url.")
176181

182+
(defvar qob-ql-init-p nil
183+
"Set to t when QuickLisp is initialized.")
184+
177185
(defun qob-ql-installed-dir ()
178186
"Return the QuickLisp installed directory base on scope."
179187
(uiop:merge-pathnames* "quicklisp/" (if (qob-global-p)
180188
(user-homedir-pathname)
181189
(qob-dot-home))))
182190

183-
(defun qob-init-ql ()
191+
(defun qob-init-ql (&optional force)
184192
"Initialize QuickLisp."
185-
(let* ((ql-dir (qob-ql-installed-dir))
186-
(ql-init (uiop:merge-pathnames* "setup.lisp" ql-dir)))
187-
(unless qob-quicklisp-installed-p
188-
(qob-quicklisp-install ql-dir))
189-
(when (probe-file ql-init)
190-
(load ql-init))))
193+
(when (or (not qob-ql-init-p)
194+
force)
195+
(let* ((ql-dir (qob-ql-installed-dir))
196+
(ql-init (uiop:merge-pathnames* "setup.lisp" ql-dir)))
197+
(unless qob-quicklisp-installed-p
198+
(qob-quicklisp-install ql-dir))
199+
(when (probe-file ql-init)
200+
(load ql-init)))
201+
(setq qob-ql-init-p t)))
191202

192203
;;
193-
;;; Core
204+
;;; ASDF file
194205

195206
(defun qob-asd-test-files ()
196207
"Return a list of ASD test files."
@@ -206,6 +217,30 @@ If optional argument WITH-TEST is non-nil; include test ASD files as well."
206217
(remove-if (lambda (filename) (qob-el-memq filename tests)) files)
207218
files))
208219

220+
(defvar qob-asds-init-p nil
221+
"Set to t when ASDF files are initialized.")
222+
223+
(defvar qob-loaded-asds nil
224+
"Loaded ASD files.")
225+
226+
(defun qob-init-asds (&optional force)
227+
"Initialize the ASD files."
228+
(when (and (qob-local-p)
229+
(or (not qob-asds-init-p)
230+
force))
231+
(setq qob-loaded-asds nil) ; reset
232+
(let ((files (qob-asd-files t)))
233+
(mapc (lambda (file)
234+
(push (asdf:load-asd file) qob-loaded-asds)
235+
(qob-info "Loaded ASD file ~A" file))
236+
files))))
237+
238+
;;
239+
;;; ASDF system
240+
241+
(defvar qob-systems-init-p nil
242+
"Set to t when system is initialized.")
243+
209244
(defun qob-load-system (filename)
210245
"Load the system from ASD's FILENAME; and return the registered name."
211246
(let ((dir (qob-el-file-name-directory filename))
@@ -218,14 +253,21 @@ If optional argument WITH-TEST is non-nil; include test ASD files as well."
218253
"Return a system of given NAME."
219254
(asdf/system-registry:registered-system name))
220255

221-
(defun qob-init-system ()
222-
"Setup the system."
223-
(qob-init-ql)
224-
(let ((files (qob-asd-files t)))
225-
(mapc (lambda (file)
226-
(qob-load-system file)
227-
(qob-info "Load ASD file ~A" file))
228-
files)))
256+
(defvar qob-loaded-systems nil
257+
"List of loaded systems.")
258+
259+
(defun qob-init-systems(&optional force)
260+
"Initialize the ASD systems."
261+
(when (and (qob-local-p)
262+
(or (not qob-systems-init-p)
263+
force))
264+
(setq qob-loaded-systems nil) ; reset
265+
(let ((files (qob-asd-files t)))
266+
(mapc (lambda (file)
267+
(push (qob-load-system file) qob-loaded-systems)
268+
(qob-info "Loaded system file ~A" file))
269+
files))
270+
(setq qob-systems-init-p t)))
229271

230272
;;
231273
;;; Externals

lisp/core/build.lisp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,11 @@
1010
;; Optional arguments:
1111
;;
1212
;; --name, -n path to the ASD file
13-
;; --output, -o output directory
1413
;;
1514

1615
;;; Code
1716

18-
(qob-init-system)
17+
(qob-init-systems)
1918

2019
(let ((names qob-args))
2120
;; Delete if exists to prevent errors.

lisp/core/dists.lisp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@
1414
(defun qob-dists--print (dists)
1515
"Print list of dists."
1616
(dolist (dist dists)
17-
;; TODO: Print useful information.
18-
(qob-println "~A" (ql-dist:archive-url dist))))
17+
(let ((name (slot-value dist 'ql-dist:name))
18+
(version (slot-value dist 'ql-dist:version))
19+
(url (slot-value dist 'ql-dist::distinfo-subscription-url)))
20+
(qob-println " ~A ~A ~A" name version url))))
1921

2022
(let ((dists (ql-dist:all-dists)))
2123
(qob-info "Available dists:")

lisp/core/install-deps.lisp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@
1010
;;; Code
1111

1212
(qob-init-ql)
13+
(qob-init-asds)
1314

14-
15+
(dolist (asd qob-loaded-asds)
16+
(qob-println "ASD: ~A" (asdf:component-depends-on asd nil))
17+
)
1518

1619
;;; End of lisp/core/install-deps.lisp

lisp/core/install.lisp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,12 @@
1616

1717
(qob-init-ql)
1818

19-
(dolist (name qob-args)
20-
(qob-info "Installing package ~A..." name)
21-
(ql:quickload name))
19+
(let ((names qob-args))
20+
(cond ((zerop (length names))
21+
(qob-help "core/install"))
22+
(t
23+
(dolist (name names)
24+
(qob-info "Installing package ~A..." name)
25+
(ql:quickload name)))))
2226

2327
;;; End of lisp/core/install.lisp

lisp/core/list.lisp

Lines changed: 40 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,33 @@
1111

1212
(qob-init-ql)
1313

14-
(defun qob-list--print-system (name)
14+
(defun qob-list--print-system (name system)
15+
"Print the SYSTEM."
16+
(let ((version (or (asdf:component-version system)
17+
"0"))
18+
(desc (or (asdf:system-description system)
19+
"")))
20+
(qob-println " [+] ~A ~A ~A"
21+
name version desc)))
22+
23+
(defun qob-list--print-system-by-name (name)
1524
"Print the system info by NAME."
16-
(let* ((system (asdf:find-system name))
17-
(version (or (asdf:component-version system)
18-
"0")))
19-
(qob-println " ~A (~A)"
20-
(qob-ansi-green name)
21-
(qob-ansi-yellow version))))
22-
23-
(let* ((pre-systems (asdf/system-registry:registered-systems))
25+
(let ((system (asdf:find-system name)))
26+
(qob-list--print-system name system)))
27+
28+
(defun qob-list--print-dist (dist)
29+
""
30+
(let ((systems (ql-dist:provided-systems dist)))
31+
(dolist (system systems)
32+
(let ((name (ql-dist:name system))
33+
(version (or (ql-dist:version system)
34+
"0"))
35+
)
36+
(qob-println " [+] ~A (~A)"
37+
name version)
38+
))))
39+
40+
(let* ((pre-systems (asdf:registered-systems))
2441
(pre-systems (reverse pre-systems))
2542
(post-systems)
2643
(local-p (qob-local-p)))
@@ -29,15 +46,26 @@
2946

3047
(setq post-systems (remove-if (lambda (system)
3148
(qob-el-memq system pre-systems))
32-
(asdf/system-registry:registered-systems))
49+
(asdf:registered-systems))
3350
post-systems (reverse post-systems))
3451

3552
(qob-println "Pre-built systems:")
36-
(mapc #'qob-list--print-system pre-systems)
53+
(qob-msg "")
54+
(mapc #'qob-list--print-system-by-name pre-systems)
55+
(qob-msg "")
56+
(qob-info "(Total of ~A system registered)" (length pre-systems)
57+
(qob--sinr pre-systems "" "s"))
3758

3859
(when local-p
3960
(qob-msg "")
4061
(qob-println "User systems:")
41-
(mapc #'qob-list--print-system post-systems)))
62+
(qob-msg "")
63+
(mapc #'qob-list--print-system-by-name post-systems)
64+
(qob-msg "")
65+
(qob-info "(Total of ~A system~A registered)" (length post-systems)
66+
(qob--sinr post-systems "" "s")))
67+
68+
(when (qob-all-p)
69+
(mapc #'qob-list--print-dist (ql-dist:all-dists))))
4270

4371
;;; End of lisp/core/list.lisp

qob-cli.asd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
(:file "cmds/core/build")
1414
(:file "cmds/core/dists")
1515
(:file "cmds/core/install")
16+
(:file "cmds/core/install-deps")
1617
(:file "cmds/core/list")
1718
(:file "cmds/qob")
1819
;; Program

0 commit comments

Comments
 (0)