-
Notifications
You must be signed in to change notification settings - Fork 265
/
Copy pathmake-image.lisp.in
82 lines (75 loc) · 4.38 KB
/
make-image.lisp.in
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
(require :uiop)
(in-package #:cl-user)
(let* ((expected-warnings
'((sb-kernel:redefinition-with-defgeneric . 1)
(sb-kernel:redefinition-with-defun . 13)
(sb-kernel:redefinition-with-defmethod . 1)
(uiop/lisp-build:compile-warned-warning . 1)
(sb-int:type-style-warning . 1)
(sb-kernel:redefinition-with-defmacro . 34)
(sb-c::unknown-typep-note . 8)))
(actual-warnings
(mapcar (lambda (x) (cons (car x) 0)) expected-warnings))
(in-ci (< 0 (length (sb-ext:posix-getenv "STUMPWM_CI"))))
;; Synchronize with variable sbcl_version in
;; tests/integration-tests/container-scripts/install-deps
(expected-sbcl-version-in-ci "2.2.10")
(on-ci-version
(equal expected-sbcl-version-in-ci (lisp-implementation-version)))
(handler (lambda (condition)
(let ((condition-type (type-of condition)))
(or (assoc condition-type actual-warnings)
(push (cons condition-type 0) actual-warnings))
(incf (cdr (assoc condition-type actual-warnings)))
(format t "~A: ~A~%" condition-type condition)))))
(handler-bind
((warning handler)
(sb-ext:code-deletion-note handler)
(sb-ext:compiler-note handler))
(load "load-stumpwm.lisp"))
(when in-ci
(when (not on-ci-version)
(error "Unexpected SBCL version when running in CI"))
(let ((warning-types (mapcar #'car actual-warnings)))
(dolist (warning-type warning-types)
(let ((expected (or (cdr (assoc warning-type expected-warnings)) 0))
(actual (cdr (assoc warning-type actual-warnings))))
(when (/= expected actual)
(error "Expected ~S warnings of type ~S but actual number was ~S."
expected warning-type actual)))))))
(stumpwm:set-module-dir "@MODULE_DIR@")
;; To support reproducible (compiled) builds we modify the version string
;; to exclude the timestamp. This could be done in version.lisp as well but
;; it hinders StumpWM users who do not compile the manager.
(when @REPRODUCIBLE@
(let* ((ver stumpwm:*version*)
(idx (search "compiled on" ver :test #'char-equal)))
(setf stumpwm:*version* (concatenate
'string
(subseq ver 0 idx)
"Reproducible Build"))))
(when (uiop:version<= "3.1.5" (asdf:asdf-version))
;; We register StumpWM and its dependencies as immutable, to stop ASDF from
;; looking for their source code when loading modules.
(uiop:symbol-call '#:asdf '#:register-immutable-system :stumpwm)
(dolist (system-name (uiop:symbol-call '#:asdf '#:system-depends-on (asdf:find-system :stumpwm)))
(uiop:symbol-call '#:asdf '#:register-immutable-system system-name)))
(sb-ext:save-lisp-and-die "stumpwm" :toplevel (lambda ()
;; stumpwm might be built in a fake enviroment, so use uiop:restore-image
;; to compute the real uiop:*user-cache* for that user
(uiop:restore-image)
;; and clean the asdf configuration to avoid some cached paths as well
(asdf:clear-configuration)
(asdf:clear-output-translations)
(asdf:initialize-output-translations
'(:output-translations
:enable-user-cache
:ignore-inherited-configuration))
;; asdf requires SBCL_HOME to be set, so set it to the value when the image was built
(alexandria:when-let ((home #.(sb-ext:posix-getenv "SBCL_HOME")))
(sb-posix:putenv (format nil "SBCL_HOME=~A" home)))
(stumpwm:stumpwm)
0)
:executable t
:purify t
:compression (if (member :sb-core-compression *features*) @COMPRESSION@ nil))