-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathlistings.scm
197 lines (178 loc) · 6.12 KB
/
listings.scm
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
(import (scheme base)
(scheme char)
(scheme file)
(scheme write)
(srfi 28)
(srfi 193))
(define (disp . xs)
(for-each display xs)
(newline))
(define-record-type scheme
(make-scheme name host
user repo
git-ref/head
git-ref/release
filename
contents
extras)
scheme?
(name scheme-name)
(host scheme-host)
(user scheme-user)
;; TODO: Add Bitbucket and Savannah support
(repo scheme-repo)
(git-ref/head scheme-git-ref/head)
(git-ref/release scheme-git-ref/release)
(filename scheme-filename)
(contents scheme-contents)
(extras scheme-extras))
(define schemes
(list
(make-scheme "bigloo" "github"
"manuel-serrano" "bigloo"
"master" "4.5b"
"manuals/srfi.texi"
"^@item @code{srfi-[0-9]+} "
'())
(make-scheme "chibi" "github"
"ashinn" "chibi-scheme"
"master" "0.11"
"lib/srfi/[0-9]+.sld"
#f
'(0))
(make-scheme "gambit" "github"
"gambit" "gambit"
"master" "v4.9.5"
"lib/srfi/[0-9]+"
#f
'())
(make-scheme "gauche" "github"
"shirok" "Gauche"
"master" "release0_9_15"
"src/srfis.scm"
"^srfi-[0-9]+"
'())
(make-scheme "gerbil" "github"
"mighty-gerbils" "gerbil"
"master" "v0.18.1"
"doc/reference/srfi/README.md"
"\\[SRFI +[0-9]+\\]"
'())
(make-scheme "kawa" "gitlab"
"kashell" "Kawa"
"master" "3.1.1"
"doc/kawa.texi"
"^@uref{http://srfi.schemers.org/srfi-[0-9]+.*, ?SRFI[ -][0-9]+}:"
'())
(make-scheme "loko" "gitlab"
"weinholt" "loko"
"master" "v0.12.1"
"Documentation/manual/lib-std.texi"
"^@code{\\(srfi :[0-9]+ "
'())
(make-scheme "sagittarius" "github"
"ktakashi" "sagittarius-scheme"
"master" "version_0.9.11"
"doc/srfi.md"
"SRFI-[0-9]+]"
'())
(make-scheme "racket" "github"
"racket" "srfi"
"master" "v8.12"
"srfi-lib/srfi/[%a0-9]*"
#f
'())
(make-scheme "stklos" "github"
"egallesio" "STklos"
"master" "stklos-2.10"
"SUPPORTED-SRFIS"
"SRFI-[0-9]+:"
'(15))
(make-scheme "tr7" "gitlab"
"jobol" "tr7"
"v1" "v1.0.10"
"tr7libs/srfi/[0-9]+.sld"
#f
'(0))
(make-scheme "unsyntax" "gitlab"
"nieper" "unsyntax"
"master" "v0.0.3"
"src/srfi/[0-9]+.s.?.?"
#f
'(0 7 46))
;; "On hiatus" since 2019.
#|
(make-scheme "vicare" "github"
"marcomaggi" "vicare"
"master" "v0.4d1.2"
"doc/srfi.texi"
"@ansrfi{[0-9]+}"
'())
|#
))
(define (scheme-archive-url scm git-ref)
(apply format "https://~a.com/~a/~a/~a/~a.tar.gz"
(scheme-host scm)
(scheme-user scm)
(scheme-repo scm)
(cond
((or (string=? (scheme-host scm) "github"))
(list "archive"
git-ref))
((string=? (scheme-host scm) "gitlab")
(list "-/archive"
(if (string=? git-ref (scheme-git-ref/head scm))
git-ref
(string-append git-ref
"/" (scheme-name scm)
"-" git-ref)))))))
(define (scheme-archive-filename scm git-ref)
(define archive-filename
;; HACK: GitHub archives strip the #\v in the dirname in archive
(if (and (>= (string-length git-ref) 2)
(string=? (scheme-host scm) "github")
(char=? #\v (string-ref git-ref 0))
(char-numeric? (string-ref git-ref 1)))
(substring git-ref 1 (string-length git-ref))
git-ref))
(format "~a-~a/~a"
(scheme-repo scm)
;; HACK: Workaround for GitLab's wonky "add hash to dirname" quirk
(if (string=? (scheme-host scm) "gitlab")
(string-append archive-filename
(if (scheme-contents scm) "*" ".*"))
archive-filename)
(scheme-filename scm)))
(define (write-listing scm git-ref suffix)
(define name (string-append (scheme-name scm) suffix))
(with-output-to-file
(string-append (script-directory) "listings/" name ".sh")
(lambda ()
(define tab " ")
(disp "#!/usr/bin/env bash")
(disp "# Auto-generated by listings.scm")
(disp "set -eu -o pipefail")
(disp "cd \"$(dirname \"$0\")\"")
(disp "{")
(for-each (lambda (extra) (disp tab "echo " extra))
(scheme-extras scm))
(when git-ref
(disp tab "curl --location --fail --silent --show-error \\")
(disp tab tab (scheme-archive-url scm git-ref) " |")
(disp tab tab "gunzip |")
(cond ((not (scheme-contents scm))
(disp tab tab "${TAR:-tar} -tf - |")
(disp tab tab "sed 's@[^/]*/@@' |")
(disp tab tab "grep -oE '" (scheme-filename scm) "' |")
(disp tab tab "sed 's@%3a@@' |")
(disp tab tab "sed 's/.*\\///'"))
(else
(disp tab tab "${TAR:-tar} -xf - --to-stdout --wildcards '"
(scheme-archive-filename scm git-ref) "' |")
(disp tab tab "grep -oE '" (scheme-contents scm) "'"))))
(disp "} | grep -oE '[0-9]+' | sort -g | uniq"
" >../data/" name ".pose"))))
(for-each (lambda (scm)
(write-listing scm (scheme-git-ref/head scm) "-head")
(write-listing scm (scheme-git-ref/release scm) ""))
schemes)