-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.ros
160 lines (143 loc) · 4.9 KB
/
build.ros
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
#!/bin/sh
#|-*- mode:lisp -*-|#
#|
exec ros -Q -- $0 "$@"
|#
(progn ;;init forms
(ros:ensure-asdf)
;;#+quicklisp(ql:quickload '() :silent t)
)
(defpackage :ros.script.build.3787867962
(:use :cl))
(in-package :ros.script.build.3787867962)
(defvar *var* nil)
(defvar *sh* nil)
(defgeneric sh (command &key echo)
(:documentation
"Takes a string or list of strings and runs it from a shell."))
(defmethod sh ((command string) &key (echo t))
(declare (ignorable echo))
;;(push command *sh*)
(when echo
(format *error-output* "sh:~A~%" command)
(force-output t))
(multiple-value-bind (output error-output return-status)
(uiop:run-program command :input :interactive
:output :interactive
:error-output :interactive
:ignore-error-status t)
(declare (ignore output error-output))
(unless (zerop return-status)
(error "Command ~S exited with error code ~A." command return-status))))
(defmethod sh ((command list) &key echo)
(let ((command1 (format nil "~{~A~^ ~}" command)))
(sh command1 :echo echo)))
(defun env (name)
(let ((val (ros:getenv name)))
(unless (zerop (length val))
val)))
(defun version-target (&key (target :compiler))
(values (or (env "TRAVIS_TAG")
(env "APPVEYOR_REPO_TAG_NAME")
(env "VERSION")
(let ((branch (env "TRAVIS_BRANCH")))
(unless (equal "master" branch)
branch))
"99.99.99")
(let ((m (or (env "ARCH")
(roswell.util:uname-m))))
(cond ((and (equal m "armhf")
(eql target :compiler))
"arm")
((and (not (eql target :compiler))
(equal m "arm"))
"armhf")
(t m)))
(or (env "SUFFIX")
"")))
(defun archive-sbcl-bin (version uname uname-m suffix)
(declare (ignorable version uname uname-m suffix))
(let ((release-dir (namestring (uiop:getcwd)))
(base (format nil "sbcl-~A-~A-~A~A"
version
uname-m
uname
suffix)))
(declare (ignorable release-dir))
(progn ;; bzip2
(sh (format nil
#-win32 "ln -s sbcl ~A~A"
#+win32 "cp -r sbcl ~A~A"
release-dir
base))
(sh (format nil "bash sbcl/binary-distribution.sh ~A" base))
(let ((path (format nil "~A-binary.tar" base)))
(when (probe-file (format nil "~A/src/runtime/libsbcl.so" base))
;; adding shared
(sh (format nil "tar -rf ~A ~A/src/runtime/libsbcl.so" path base)))
(sh (format nil "rm -f ~A.bz2" path))
(sh (format nil "bzip2 ~A" path))))
#+win32
(progn ;; msi
(uiop:chdir (format nil "~A/sbcl/" release-dir))
(sh "bash make-windows-installer.sh")
(sh (format nil "cp output/*.msi ../~A-binary.msi" base)))))
(export
(defun default (&rest argv)
(declare (ignore argv))))
(export
(defun uname (&rest argv)
(declare (ignore argv))
(format t "~A~%"
(or (env "ARCH")
(nth-value 1 (version-target))))
(force-output)))
(export
(defun branch (&rest argv)
(declare (ignore argv))
(let* ((version (version-target))
(release (and version (< (length version) 20)
(not (equal version "99.99.99")))))
(format t "~:[master~;sbcl-~:*~A~]~%"
(and release version))
(force-output))))
(export
(defun version (&rest argv)
(declare (ignore argv))
(format t "~A~%" (version-target))
(force-output)))
(export
(defun archive (&rest argv)
(declare(ignore argv))
(multiple-value-bind (ver target suffix) (version-target :target :archive)
(loop for m in (uiop:split-string target :separator '(#\, #\Space))
with os = (or (env "OS") (roswell.util:uname))
do (format t "~S ~S ~S~%" ver m suffix)
(force-output)
(archive-sbcl-bin ver os m suffix)))
(force-output)))
(export
(defun nop (&rest argv)
(declare (ignore argv))
(print "nop!!")))
(defun optp (arg)
(when (and arg
(loop for i across arg
repeat 2
always (eql i #\-)))
(subseq arg 2)))
(defun main (&rest argv)
(loop
for opt = (optp (first argv))
while opt
when opt
do (setf *var* (acons opt (second argv) *var*)
argv (cdr argv))
do (setf argv (cdr argv))
finally (let ((symbol (read-from-string (if argv
(first argv)
"default"))))
(when (eql (nth-value 1 (find-symbol (string symbol))) :external)
(funcall symbol (rest argv)))))
(format t "~{~A~%~}" (reverse *sh*)))
;;; vim: set ft=lisp lisp: