File tree Expand file tree Collapse file tree 8 files changed +101
-26
lines changed Expand file tree Collapse file tree 8 files changed +101
-26
lines changed Original file line number Diff line number Diff line change 1
1
# qob
2
2
/.qob
3
3
4
+ # executables
5
+ qob
6
+ * .exe
7
+
4
8
# lisp
5
9
* .FASL
6
10
* .fasl
Original file line number Diff line number Diff line change 1
- # others
1
+ / lisp
2
2
qob. *
Original file line number Diff line number Diff line change 36
36
:description " output directory"
37
37
:short-name #\o
38
38
:long-name " output"
39
- :required t
40
39
:key :output )))
41
40
42
41
(defun handler (cmd)
43
42
" Handler for `build' command."
44
43
(let* ((name (clingon :getopt cmd :name ))
45
44
(output (clingon :getopt cmd :output )))
45
+ ; ; Delete if exists to prevent errors.
46
+ (when (uiop :file-exists-p output)
47
+ (delete-file output))
46
48
; ; TODO: Change build path.
47
- (format t " ~A " output)
48
-
49
-
50
49
(qob :setup)
51
50
(asdf :operate :build-op name)))
52
51
Original file line number Diff line number Diff line change 22
22
(defun handler (cmd)
23
23
" Handler for `list' command."
24
24
(declare (ignore cmd))
25
- (qob :setup)
26
- (format t " ~A " (asdf/system-registry :registered-systems)))
25
+ ; ;(qob:setup)
26
+ ; ;(format t "~A" (asdf/system-registry:registered-systems))
27
+ (qob :call-lisp " core/list" ))
27
28
28
29
(defun command ()
29
30
" List command."
Original file line number Diff line number Diff line change 7
7
8
8
; ;; Code
9
9
10
+ (require ' asdf)
11
+
10
12
(push ' *default-pathname-defaults* asdf :*central-registry* )
11
13
(asdf :load-system " qob" )
12
14
20
22
21
23
; ;(uiop:dump-image "./bin/qob.exe" :executable t)
22
24
25
+ (defun copy-directory (src-dir dst-dir)
26
+ " Recursively copy the contents of SRC-DIR to DST-DIR."
27
+ (let ((src (uiop :parse-native-namestring src-dir))
28
+ (dst (uiop :parse-native-namestring dst-dir)))
29
+ ; ; Ensure the source directory exists
30
+ (unless (probe-file src)
31
+ (error " Source directory ~a does not exist!" src))
32
+
33
+ ; ; Create destination directory if it doesn't exist
34
+ (unless (probe-file dst)
35
+ (ensure-directories-exist dst))
36
+
37
+ ; ; Recursively copy files and directories
38
+ (dolist (entry (directory (merge-pathnames " *" src)))
39
+ (let ((entry-name (uiop :parse-native-namestring entry)))
40
+ (if (uiop :file-exists-p entry-name)
41
+ ; ; Copy file
42
+ (uiop :copy-file entry-name (merge-pathnames (uiop :pathname-name entry) dst))
43
+ ; ; Recursively copy subdirectory
44
+ (copy-directory entry-name (merge-pathnames (uiop :pathname-name entry) dst)))))))
45
+
46
+ (copy-directory " lisp" " bin/lisp" )
47
+
23
48
(let ((exec (el-lib :el-expand-fn (if (uiop :os-windows-p)
24
- " ./ bin/qob.exe"
25
- " ./ bin/qob" ))))
49
+ " bin/qob.exe"
50
+ " bin/qob" ))))
26
51
(when (uiop :file-exists-p exec)
27
52
(delete-file exec)))
28
53
Original file line number Diff line number Diff line change 10
10
(defpackage el-lib
11
11
(:use cl)
12
12
(:export el-memq
13
+ el-member
13
14
el-expand-fn
14
- el-member))
15
+ el-executable-find
16
+ el-move-path))
15
17
16
18
(in-package :el-lib )
17
19
20
+ (defvar el-executables nil
21
+ " Executable cache." )
22
+
23
+ (defun el-executables ()
24
+ " Return list of executables."
25
+ (loop with path = (uiop :getenv " PATH" )
26
+ for p in (uiop :split-string path :separator
27
+ (if (uiop :os-windows-p) " ;" " :" ))
28
+ for dir = (probe-file p)
29
+ when (uiop :directory-exists-p dir)
30
+ append (uiop :directory-files dir)))
31
+
32
+ (defun el-executable-find (name)
33
+ " Mimic `executable-find' function."
34
+ (unless el-executables
35
+ (setq el-executables (el-executables)))
36
+ (find name el-executables
37
+ :test #' equalp
38
+ :key #' pathname-name ))
39
+
18
40
(defun el-memq (elt list )
19
41
" Mimic `memq' function."
20
42
(member elt list :test #' eq ))
21
43
22
44
(defun el-member (elt list )
23
45
(member elt list :test #' string= ))
24
46
25
- (defun el-expand-fn (path-string &optional (dir-name (uiop :getcwd)))
47
+ (defun el-expand-fn (path &optional (dir-name (uiop :getcwd)))
26
48
" Like `expand-file-name' function."
27
- (uiop :unix-namestring
28
- (uiop :ensure-absolute-pathname
29
- (uiop :merge-pathnames*
30
- (uiop :parse-unix-namestring path-string))
31
- dir-name)))
49
+ (uiop :ensure-absolute-pathname (uiop :merge-pathnames* path dir-name)))
Original file line number Diff line number Diff line change 11
11
(:use cl)
12
12
(:export
13
13
; ; src/utils.lsip
14
- setup
15
- load-system
16
- asd-files
17
- asd-test-files
14
+ call-lisp
15
+ setup ; TODO: move to prepare.lisp
16
+ load-system ; TODO: move to prepare.lisp
17
+ asd-files ; TODO: move to prepare.lisp
18
+ asd-test-files ; TODO: move to prepare.lisp
18
19
; ; src/logger.lsip
19
- print
20
- trace
21
- debug
22
- info
23
- warning
24
- error
20
+ print ; TODO: move to prepare.lisp
21
+ trace ; TODO: move to prepare.lisp
22
+ debug ; TODO: move to prepare.lisp
23
+ info ; TODO: move to prepare.lisp
24
+ warning ; TODO: move to prepare.lisp
25
+ error ; TODO: move to prepare.lisp
25
26
; ; cmds/qob.lisp
26
27
command
27
28
; ; src/main.lsip
Original file line number Diff line number Diff line change 9
9
10
10
(in-package :qob )
11
11
12
+ (defvar *lisp-root* " lisp/"
13
+ " Directory path points to the lisp folder." )
14
+
15
+ (defun program-name ()
16
+ " Lisp program we target to run."
17
+ (or (uiop :getenv " QOB_LISP" )
18
+ " sbcl" ))
19
+
20
+ (defun lisp-script (name)
21
+ " Form lisp script path."
22
+ (concatenate ' string name " .lisp" ))
23
+
24
+ (defun call-lisp (script &rest args)
25
+ " Run the lisp implementation."
26
+ (let ((lisp-impls (program-name)))
27
+ (unless (el-lib :el-executable-find lisp-impls)
28
+ (error " Defined Lisp implementation is not installed: ~A " lisp-impls))
29
+ (let* ((lisp-dir (el-lib :el-expand-fn *lisp-root* sb-ext :*runtime-pathname* ))
30
+ (script (lisp-script script)))
31
+ (format t " ~A " (el-lib :el-expand-fn script lisp-dir))
32
+ ; ; (uiop:run-program (list lisp-impls
33
+ ; ; "--load" (el-lib:el-expand-fn script *lisp-root*)
34
+ ; ; )
35
+ ; ; :output t
36
+ ; ; :force-shell t)
37
+ )))
38
+
12
39
(defun setup ()
13
40
" Setup the system."
14
41
(let ((files (asd-files t )))
You can’t perform that action at this time.
0 commit comments