-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathentry.lisp
150 lines (128 loc) · 4.88 KB
/
entry.lisp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
#-quicklisp
(let ((quicklisp-setup (probe-file "quicklisp/setup.lisp")))
(when quicklisp-setup
(load quicklisp-setup)))
;; https://groups.google.com/g/quicklisp/c/wrULkRePVE4
#+win32
(quicklisp-client::make-system-index "quicklisp/local-projects/")
;; Load CALM
#-calm
(load "calm.asd")
#-calm
(ql:quickload :calm)
(in-package #:calm)
(calm-config)
;; switch to the CALM_APP_DIR
(uiop:chdir *calm-env-app-dir*)
(defun copy-dist-files (pathname)
;; copy files
(let* ((ori-lib-dir (merge-pathnames "lib/" *calm-env-calm-home*))
(dist-dir (merge-pathnames pathname *calm-env-app-dir*))
(ori-assets-dir (merge-pathnames "assets/" *calm-env-app-dir*))
(dist-assets-dir (merge-pathnames "assets/" dist-dir))
(ori-fonts-dir (merge-pathnames "fonts/" *calm-env-app-dir*))
(dist-fonts-dir (merge-pathnames "fonts/" dist-dir))
(dist-lib-dir (merge-pathnames "lib/" dist-dir))
(dist-bin-dir (merge-pathnames "bin/" dist-dir))
(calm-bin #+win32 "calmNoConsole.exe" #-win32 "calm"))
;; clean old dist
(uiop:delete-directory-tree dist-dir :validate t :if-does-not-exist :ignore)
;; mkdir
(mapcar #'ensure-directories-exist (list dist-bin-dir))
;; copy dependencies
(u:copy-dir ori-lib-dir dist-lib-dir)
;; copy assets
(u:copy-dir ori-assets-dir dist-assets-dir)
;; copy fonts
(u:copy-dir ori-fonts-dir dist-fonts-dir)
;; copy calm launcher
(u:copy-file
(merge-pathnames calm-bin *calm-env-calm-home*)
(merge-pathnames (str:concat "calm" #+win32 ".exe") dist-dir))))
(defun dist (pathname)
(u:calm-log "binary pathname ~A~%" pathname)
(copy-dist-files pathname)
;; load `canvas.lisp'
(load (merge-pathnames "canvas.lisp" *calm-env-app-dir*))
;; dump binary
(sb-ext:save-lisp-and-die
(merge-pathnames (str:concat "bin/calm-app" #+win32 ".exe") pathname)
:compression 22
#+win32 :application-type
#+win32 :gui
:executable t
:toplevel
#'calm:calm-start))
(defun dist-by-new-process ()
(let ((calm-bin-abs (str:concat (namestring *calm-env-calm-home*) "calm" #+win32 ".exe")))
;; the following command will quit SBCL,
;; so exec it as external cmd instead of load lisp file
(u:calm-log-fancy "dumping binary, this may take a few minutes...")
(u:exec (str:concat calm-bin-abs " dist"))))
(defun publish-web ()
(u:load-from-calm "s/usr/web/wasm.lisp")
(u:load-from-calm "s/usr/web/load-and-compile.lisp")
(u:load-from-calm "s/usr/web/post-compile.lisp"))
(defun publish ()
(setf (uiop:getenv "DIST_DIR") (uiop:native-namestring (uiop:merge-pathnames* "dist/" *calm-env-app-dir*)))
#+darwin
(progn
(dist-by-new-process)
(u:calm-log "building macOS Application...")
(u:load-from-calm "s/usr/macos/bundle.lisp")
(u:calm-log "building macOS DMG, this may take a while...")
(u:load-from-calm "s/usr/macos/dmg.lisp"))
#+win32
(progn
(u:load-from-calm "s/usr/windows/icon.lisp")
(setf (uiop:getenv "CALM_WITH_ICON") "YES_MY_LORD")
(dist-by-new-process)
(u:calm-log "building Windows Installer...")
(u:load-from-calm "s/usr/windows/installer.lisp"))
#+linux
(progn
(dist-by-new-process)
(u:calm-log "building Linux AppImage...")
(u:load-from-calm "s/usr/linux/appimage.lisp")))
(alexandria:switch (*calm-env-calm-cmd* :test #'equal)
("test"
(u:calm-log-fancy "Nothing to test.")
(uiop:quit 0))
("alive"
(u:load-from-calm "s/dev/all/start-alive.lisp"))
("show"
(calm:calm-load-and-start))
("hello"
(u:copy-file (merge-pathnames "s/usr/all/panic.lisp" *calm-env-calm-home*)
(merge-pathnames "canvas.lisp" *calm-env-app-dir*))
(ensure-directories-exist (merge-pathnames "assets/" *calm-env-app-dir*))
(ensure-directories-exist (merge-pathnames "fonts/" *calm-env-app-dir*))
(u:copy-file (merge-pathnames "s/usr/all/fonts.conf" *calm-env-calm-home*)
(merge-pathnames "fonts/fonts.conf" *calm-env-app-dir*))
(u:calm-log-fancy "Hello, sample files and directories created, please enjoy"))
("publish" (publish))
("publish-web" (publish-web))
("publish-with-options"
(setf (uiop:getenv "CALM_ASK_ME") "yes-please")
(publish))
("publish-web-with-options"
(setf (uiop:getenv "CALM_ASK_ME") "yes-please")
(publish-web))
;; rebuild calm.core
;; this could speed up your CALM command
#+sbcl
("core" (sb-ext:save-lisp-and-die (merge-pathnames *calm-env-calm-home* "calm.core")))
#+darwin
("make-bundle" (u:load-from-calm "s/usr/macos/bundle.lisp"))
#+darwin
("make-dmg" (u:load-from-calm "s/usr/macos/dmg.lisp"))
#+win32
("make-installer" (u:load-from-calm "s/usr/windows/installer.lisp"))
#+win32
("set-icon" (u:load-from-calm "s/usr/windows/icon.lisp"))
#+linux
("make-appimage" (u:load-from-calm "s/usr/linux/appimage.lisp"))
#+sbcl
("dist" (dist #p"dist/"))
(t (format t "UNKOWN CALM_CMD: ~A~%" *calm-env-calm-cmd*)))
(uiop:quit)