-
Notifications
You must be signed in to change notification settings - Fork 72
/
Makefile
223 lines (181 loc) · 7.27 KB
/
Makefile
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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
COMMIT_HASH=$(shell git rev-parse --short HEAD)
LISP_CACHE ?= $(HOME)/.cache/common-lisp
RIGETTI_LISP_LIBRARY_HOME=../
SBCL_BIN=sbcl
SBCL=$(SBCL_BIN) --dynamic-space-size 4096 --noinform --no-userinit --no-sysinit --non-interactive
QUICKLISP_HOME=$(HOME)/quicklisp
QUICKLISP_SETUP=$(QUICKLISP_HOME)/setup.lisp
QUICKLISP=$(SBCL) --load $(QUICKLISP_HOME)/setup.lisp \
--eval '(push (truename ".") asdf:*central-registry*)' \
--eval "(push (truename \"$(RIGETTI_LISP_LIBRARY_HOME)\") ql:*local-project-directories*)"
QUICKLISP_BOOTSTRAP_URL=https://beta.quicklisp.org/quicklisp.lisp
UNAME_S=$(shell uname -s)
PREFIX ?= /usr/local
all: quilc
###############################################################################
# SETUP
###############################################################################
$(QUICKLISP_SETUP):
mkdir -p $(QUICKLISP_HOME)
curl -o $(QUICKLISP_HOME)/quicklisp-bootstrap.lisp \
$(QUICKLISP_BOOTSTRAP_URL)
$(SBCL) --load $(QUICKLISP_HOME)/quicklisp-bootstrap \
--eval "(quicklisp-quickstart:install :path \"$(QUICKLISP_HOME)\")"
system-index.txt: $(QUICKLISP_SETUP)
$(QUICKLISP) \
$(FOREST_SDK_FEATURE) \
--eval "(ql:quickload '(quilc ${POST_LOAD_ASDF_SYSTEMS}))" \
--eval "(ql:write-asdf-manifest-file \"system-index.txt\")"
###############################################################################
# DEPENDENCIES
###############################################################################
dump-version-info:
$(QUICKLISP) \
--eval '(format t "~A ~A" (lisp-implementation-type) (lisp-implementation-version))' \
--eval '(print (ql-dist:find-system "alexa"))' \
--eval '(print (ql-dist:find-system "magicl"))' \
--eval '(print (ql-dist:find-system "qvm"))' \
--eval '(print (ql-dist:find-system "rpcq"))' \
--eval '(terpri)' --quit
install-test-deps:
ifeq ($(UNAME_S),Linux)
ifeq ($(shell sed -n "s/^ID=//p" /etc/os-release),debian)
apt-get update && apt-get install -y git libblas-dev libffi-dev liblapack-dev libzmq3-dev
else ifeq ($(shell sed -n "s/^ID=//p" /etc/os-release),ubuntu)
apt update && apt install -y git libblas-dev libffi-dev liblapack-dev libzmq3-dev
else
echo "Centos-based platforms unsupported"
endif
else
echo "Non-Linux-based platforms unsupported"
endif
###############################################################################
# BUILD
###############################################################################
.PHONY: quilc
quilc: system-index.txt
ASDF_SYSTEMS_TO_LOAD="quilc ${POST_LOAD_ASDF_SYSTEMS}" \
$(SBCL) $(FOREST_SDK_FEATURE) \
--eval "(setf sb-ext:\*on-package-variance\* '(:warn (:swank :swank-backend :swank-repl) :error t))" \
--load "build-app.lisp" \
$(FOREST_SDK_OPTION) \
$(QUILC_UNSAFE_OPTION)
quilc-sdk-base: FOREST_SDK_FEATURE=--eval '(pushnew :forest-sdk *features*)' --eval ' (push :drakma-no-ssl *features*)'
quilc-sdk-base: clean clean-cache quilc
# By default, relocate shared libraries on SDK builds
quilc-sdk: FOREST_SDK_OPTION=--quilc-sdk
quilc-sdk: quilc-sdk-base
# Don't relocate shared libraries on barebones SDK builds
quilc-sdk-barebones: quilc-sdk-base
quilc-unsafe: QUILC_UNSAFE_OPTION=--unsafe
quilc-unsafe: quilc
quilc-discrete: COALTON_ENV=release
quilc-discrete: POST_LOAD_ASDF_SYSTEMS="cl-quil/discrete"
quilc-discrete: quilc
DOCKER_BUILD_TARGET=all
DOCKER_TAG=rigetti/quilc:$(COMMIT_HASH)
.PHONY: docker
docker: Dockerfile
docker build --build-arg build_target=$(DOCKER_BUILD_TARGET) \
-t $(DOCKER_TAG) .
docker-sdk: DOCKER_BUILD_TARGET=quilc-sdk
docker-sdk: DOCKER_TAG=quilc-sdk
docker-sdk: docker
docker-sdk-barebones: DOCKER_BUILD_TARGET=quilc-sdk-barebones
docker-sdk-barebones: DOCKER_TAG=quilc-sdk-barebones
docker-sdk-barebones: docker
# Start a dockerized sbcl for development
docker-sbcl:
docker compose up
###############################################################################
# INSTALL/UNINSTALL
###############################################################################
.PHONY: install
install: quilc
install quilc $(DESTDIR)$(PREFIX)/bin
.PHONY: uninstall
uninstall:
rm -f $(DESTDIR)$(PREFIX)/bin/quilc
###############################################################################
# TEST
###############################################################################
.PHONY: test test-cl-quil test-quilc test-quilt test-quilec test-discrete test-libquilc
test: test-cl-quil test-quilt test-quilec test-quilc test-discrete test-libquilc
test-cl-quil:
$(QUICKLISP) \
--eval "(ql:quickload :cl-quil-tests)" \
--eval "(asdf:test-system :cl-quil)"
test-quilc:
$(QUICKLISP) \
--eval "(ql:quickload :quilc-tests)" \
--eval "(asdf:test-system :quilc)"
test-libquilc:
$(QUICKLISP) \
--eval "(ql:quickload :libquilc-tests)" \
--eval "(asdf:test-system :libquilc)"
test-chip-library:
$(QUICKLISP) \
--eval "(ql:quickload :cl-quil/chip-library-tests)" \
--eval "(asdf:test-system :cl-quil/chip-library)"
test-quilt:
$(QUICKLISP) \
--eval "(ql:quickload :cl-quil/quilt-tests)" \
--eval "(asdf:test-system :cl-quil/quilt)"
test-quilec:
$(QUICKLISP) \
--eval "(ql:quickload :cl-quil/quilec-tests)" \
--eval "(asdf:test-system :cl-quil/quilec)"
test-discrete:
$(QUICKLISP) \
--eval "(ql:quickload :cl-quil/discrete-tests)" \
--eval "(asdf:test-system :cl-quil/discrete)"
test-ccl:
ccl -n --batch --load $(QUICKLISP_HOME)/setup.lisp \
--eval '(push (truename ".") asdf:*central-registry*)' \
--eval "(push (truename \"$(RIGETTI_LISP_LIBRARY_HOME)\") ql:*local-project-directories*)" \
--eval "(ql:quickload :quilc)" \
--eval '(quit)'
###############################################################################
# BENCHMARKS
###############################################################################
.PHONY: benchmark-qasm benchmark-nq benchmark-nq-2x
benchmark-qasm:
$(QUICKLISP) \
--eval "(ql:quickload :cl-quil-benchmarking)" \
--eval "(cl-quil-benchmarking::benchmark-qasm-suite)"
benchmark-nq:
$(QUICKLISP) \
--eval "(ql:quickload :cl-quil-benchmarking)" \
--eval "(cl-quil-benchmarking::benchmark-nq)"
benchmark-nq-2x:
$(QUICKLISP) \
--eval "(ql:quickload :cl-quil-benchmarking)" \
--eval "(cl-quil-benchmarking::benchmark-nq)" \
--eval "(cl-quil-benchmarking::benchmark-nq)"
###############################################################################
# CLEAN
###############################################################################
.PHONY: clean clean-quicklisp clean-cache cleanall
clean:
rm -f quilc system-index.txt build-output.log
rm -f coverage-report/*.html
rm -f src/contrib/**/*.so src/contrib/**/*.dylib
clean-quicklisp:
@echo "Cleaning up old projects in Quicklisp"
$(QUICKLISP) \
--eval '(ql-dist:clean (ql-dist:dist "quicklisp"))'
clean-cache:
@echo "Deleting $(LISP_CACHE)"
rm -rf "$(LISP_CACHE)"
cleanall: clean clean-cache clean-quicklisp
@echo "All cleaned and reindexed."
# Download and install Quicklisp.
quicklisp:
curl -o /tmp/quicklisp.lisp "http://beta.quicklisp.org/quicklisp.lisp"
sbcl --noinform --non-interactive \
--load /tmp/quicklisp.lisp \
--eval '(quicklisp-quickstart:install)'
echo >> ~/.sbclrc
echo '#-quicklisp(let ((i(merge-pathnames "quicklisp/setup.lisp" (user-homedir-pathname))))(when(probe-file i)(load i)))' >> ~/.sbclrc
echo "#+quicklisp(push \"$(shell pwd | xargs dirname)/\" ql:*local-project-directories*)" >> ~/.sbclrc
rm -f /tmp/quicklisp.lisp