forked from quil-lang/quilc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild-app.lisp
61 lines (57 loc) · 2.63 KB
/
build-app.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
;;;; build-app.lisp
;;;;
;;;; This file is loaded by the Makefile to produce a quilc[.exe] binary.
;;;;
(unless *load-truename*
(error "This file is meant to be loaded."))
(pushnew :hunchentoot-no-ssl *features*)
(pushnew :drakma-no-ssl *features*)
(require 'asdf)
(let ((*default-pathname-defaults* (make-pathname :type nil
:name nil
:defaults *load-truename*))
(output-file (make-pathname :name "quilc"
:type #+win32 "exe" #-win32 nil))
(system-table (make-hash-table :test 'equal))
(entry-point "quilc::entry-point"))
(flet ((option-present-p (name)
(find name sb-ext:*posix-argv* :test 'string=))
(make-toplevel-function (entry)
(lambda ()
(with-simple-restart (abort "Abort")
(funcall (read-from-string entry)
sb-ext:*posix-argv*))))
(load-systems-table ()
(unless (probe-file "system-index.txt")
(error "Generate system-index.txt with 'make system-index.txt' first."))
(setf (gethash "quilc" system-table) (merge-pathnames "quilc.asd"))
(with-open-file (stream "system-index.txt")
(loop
:for system-file := (read-line stream nil)
:while system-file
:do (setf (gethash (pathname-name system-file) system-table)
(merge-pathnames system-file)))))
(local-system-search (name)
(values (gethash name system-table))))
(load-systems-table)
(push #'local-system-search asdf:*system-definition-search-functions*)
(asdf:load-system "quilc")
#-win32
(asdf:load-system "cl-quil/tweedledum")
;; TODO Something is broken here. If zap-info is left to do it's thing on
;; Windows, there is a weird error. This is a short-term fix.
#-win32
(funcall (read-from-string "quilc::zap-info"))
(funcall (read-from-string "quilc::setup-debugger"))
(when (option-present-p "--quilc-sdk")
(load "app/src/mangle-shared-objects.lisp"))
(when (option-present-p "--unsafe")
(format t "~&Using unsafe entry point~%")
(setf entry-point "quilc::%entry-point"))
(force-output)
(sb-ext:save-lisp-and-die output-file
:compression #+sb-core-compression t
#-sb-core-compression nil
:save-runtime-options t
:executable t
:toplevel (make-toplevel-function entry-point))))