lyp 1.3.8 → 1.3.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +10 -5
- data/bin/install_release.sh +4 -4
- data/bin/lilypond +1 -0
- data/bin/lyp-resolve +13 -0
- data/lib/lyp/cli.rb +12 -3
- data/lib/lyp/etc/lyp.ly +246 -69
- data/lib/lyp/etc/support.scm +54 -0
- data/lib/lyp/lilypond.rb +45 -2
- data/lib/lyp/resolver.rb +7 -3
- data/lib/lyp/templates/deps_wrapper.rb +4 -0
- data/lib/lyp/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 99d6a748bd82c29990f8e0bda5139028d2e14718
|
4
|
+
data.tar.gz: ea3b89d3f3f4079b6583bf67b2a2888a0ed192b1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 75e161b7d05a45e7caa4064e838a1e711743a7188e7681e34be43d328fe15af0a333d936e76372fdaa7a3f03b3715a383881dd41f94fc0e3cddae606b34146a1
|
7
|
+
data.tar.gz: cf2b052d9554a3a05534e54ca65d956dc28718dbe960ad7347dc406b4da6416ca411dfe867743c681ac6b3f626e1f60b8b9e81be750fee7536b7e2524f7dfcf9
|
data/README.md
CHANGED
@@ -2,20 +2,25 @@
|
|
2
2
|
<a href="https://travis-ci.org/noteflakes/lyp"><img src="https://travis-ci.org/noteflakes/lyp.svg?branch=master"></a>
|
3
3
|
</p>
|
4
4
|
<p align="center">
|
5
|
-
<a href="
|
5
|
+
<a href="http://lyp.noteflakes.com/#/packages">The lyp package index</a>
|
6
6
|
</p>
|
7
7
|
|
8
8
|
# lyp - The Lilypond Swiss Army Knife
|
9
9
|
|
10
10
|
lyp is an open-source tool that takes the pain out of working with [Lilypond](http://lilypond.org/).
|
11
11
|
|
12
|
-
__Use packages__: Install [packages](http://lyp.noteflakes.com
|
12
|
+
__Use packages__: Install [packages](http://lyp.noteflakes.com/#/user-guide?id=working-with-packages) to enhance your Lilypond files with additional functionality. Add [specialized tweaks](http://lyp.noteflakes.com/#/packages?id=tweaking) or even [change the music font](http://lyp.noteflakes.com/#/packages?id=fonts).
|
13
13
|
|
14
|
-
__No hassle Lilypond installation__: with lyp you can [install Lilypond](http://lyp.noteflakes.com
|
14
|
+
__No hassle Lilypond installation__: with lyp you can [install Lilypond](http://lyp.noteflakes.com/#/user-guide?id=installing-and-using-lilypond) with a single easy command, no need to click links, or unzip and copy files around.
|
15
15
|
|
16
|
-
__Even more tools for power users__: watch and automatically [recompile](http://lyp.noteflakes.com
|
16
|
+
__Even more tools for power users__: watch and automatically [recompile](http://lyp.noteflakes.com/#/user-guide?id=lyp-watch) changed source files, [flatten](http://lyp.noteflakes.com/#/user-guide?id=lyp-flatten) include files, and [automatically install](http://lyp.noteflakes.com/#/user-guide?id=lyp-compile) package dependencies or any required version of Lilypond.
|
17
17
|
|
18
|
-
|
18
|
+
## Documentation
|
19
|
+
|
20
|
+
- [User guide](http://lyp.noteflakes.com/#/user-guide)
|
21
|
+
- [Available packages](http://lyp.noteflakes.com/#/packages)
|
22
|
+
- [Developer guide](http://lyp.noteflakes.com/#/developer-guide)
|
23
|
+
- [FAQ](http://lyp.noteflakes.com/#/faq)
|
19
24
|
|
20
25
|
## Contributing
|
21
26
|
|
data/bin/install_release.sh
CHANGED
@@ -18,14 +18,14 @@ download() {
|
|
18
18
|
|
19
19
|
echo "Detecting latest lyp version..."
|
20
20
|
if has "curl"; then
|
21
|
-
LATEST_RELEASE=`curl -
|
21
|
+
LATEST_RELEASE=`curl -Ls https://github.com/noteflakes/lyp/releases/latest`
|
22
22
|
elif has "wget"; then
|
23
23
|
LATEST_RELEASE=`wget -qO- https://github.com/noteflakes/lyp/releases/latest`
|
24
24
|
else
|
25
25
|
fail "Could not find curl or wget"
|
26
26
|
fi
|
27
27
|
|
28
|
-
VERSION_REGEX="
|
28
|
+
VERSION_REGEX="Version ([0-9\.]+)"
|
29
29
|
if [[ $LATEST_RELEASE =~ $VERSION_REGEX ]]
|
30
30
|
then
|
31
31
|
LYP_VERSION="${BASH_REMATCH[1]}"
|
@@ -34,7 +34,7 @@ else
|
|
34
34
|
fi
|
35
35
|
|
36
36
|
WORKDIR="/tmp/lyp-release-installer"
|
37
|
-
URL_BASE="https://github.com/noteflakes/lyp/releases/download
|
37
|
+
URL_BASE="https://github.com/noteflakes/lyp/releases/download/$LYP_VERSION"
|
38
38
|
PLATFORM=`uname -sp`
|
39
39
|
case $PLATFORM in
|
40
40
|
"Linux x86_64")
|
@@ -62,4 +62,4 @@ tar -xzf "$WORKDIR/release.tar.gz" -C $WORKDIR
|
|
62
62
|
|
63
63
|
$RELEASE_PATH/bin/lyp install self
|
64
64
|
|
65
|
-
rm -rf $WORKDIR
|
65
|
+
rm -rf $WORKDIR
|
data/bin/lilypond
CHANGED
data/bin/lyp-resolve
ADDED
data/lib/lyp/cli.rb
CHANGED
@@ -54,7 +54,7 @@ class Lyp::CLI < Thor
|
|
54
54
|
"w" => :watch,
|
55
55
|
"x" => :exec
|
56
56
|
|
57
|
-
check_unknown_options! :except => [:compile, :watch, :benchmark]
|
57
|
+
check_unknown_options! :except => [:compile, :exec, :watch, :benchmark]
|
58
58
|
class_option :verbose, aliases: '-V', :type => :boolean, desc: 'show verbose output'
|
59
59
|
|
60
60
|
no_commands do
|
@@ -129,9 +129,10 @@ class Lyp::CLI < Thor
|
|
129
129
|
def compile(*argv)
|
130
130
|
opts, argv = Lyp::Lilypond.preprocess_argv(argv)
|
131
131
|
opts[:verbose] ||= options[:verbose]
|
132
|
+
argv.unshift('-V') if options[:verbose]
|
132
133
|
$cmd_options = opts
|
133
134
|
|
134
|
-
|
135
|
+
Lyp::Lilypond.select_lilypond_version(opts, argv.last)
|
135
136
|
|
136
137
|
$stderr.puts "Lyp #{Lyp::VERSION}" unless opts[:mode] == :quiet
|
137
138
|
Lyp::System.test_installed_status!
|
@@ -156,7 +157,15 @@ class Lyp::CLI < Thor
|
|
156
157
|
|
157
158
|
desc "exec <CMD> [<options>...]", "Execute a lilypond script"
|
158
159
|
def exec(*argv)
|
159
|
-
|
160
|
+
opts, argv = Lyp::Lilypond.preprocess_bin_script_argv(argv)
|
161
|
+
opts[:verbose] ||= options[:verbose]
|
162
|
+
$cmd_options = opts
|
163
|
+
|
164
|
+
$cmd_options = opts
|
165
|
+
|
166
|
+
Lyp::Lilypond.select_lilypond_version(opts, argv.last)
|
167
|
+
|
168
|
+
$stderr.puts "Lyp #{Lyp::VERSION}" unless opts[:mode] == :quiet
|
160
169
|
Lyp::System.test_installed_status!
|
161
170
|
Lyp::Lilypond.invoke_script(argv, {})
|
162
171
|
end
|
data/lib/lyp/etc/lyp.ly
CHANGED
@@ -4,15 +4,25 @@
|
|
4
4
|
|
5
5
|
(use-modules
|
6
6
|
(lily)
|
7
|
-
(ice-9 regex)
|
7
|
+
(ice-9 regex)
|
8
|
+
(ice-9 ftw))
|
9
|
+
|
10
|
+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
11
|
+
;; General utilities ;;
|
12
|
+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
13
|
+
|
14
|
+
(define (lyp:coerce-string x)
|
15
|
+
(if (symbol? x) (symbol->string x) x))
|
16
|
+
|
17
|
+
(define (lyp:list-string-or-symbol? x)
|
18
|
+
(or (list? x) (string? x) (symbol? x)))
|
8
19
|
|
9
20
|
(define lyp:path-separator "/")
|
10
21
|
(define (lyp:join-path . ls) (string-join ls lyp:path-separator))
|
11
22
|
|
12
23
|
; convert back-slashes to forward slashes (for use in lyp:split-path)
|
13
24
|
(define (lyp:normalize-path path)
|
14
|
-
(regexp-substitute/global #f "[\\]+" path 'pre "/" 'post)
|
15
|
-
)
|
25
|
+
(regexp-substitute/global #f "[\\]+" path 'pre "/" 'post))
|
16
26
|
|
17
27
|
(define (lyp:split-path path)
|
18
28
|
(string-split (lyp:normalize-path path) #\/))
|
@@ -24,15 +34,14 @@
|
|
24
34
|
(string-match lyp:absolute-path-pattern path))
|
25
35
|
|
26
36
|
; return an absolute path, resolving any . or .. parts
|
27
|
-
(define (lyp:expand-path path)
|
37
|
+
(define (lyp:expand-path path)
|
38
|
+
(let* (
|
28
39
|
; create a path list by joining the current directory
|
29
40
|
(tmp-path (if (lyp:absolute-path? path)
|
30
41
|
path (lyp:join-path (ly-getcwd) path)))
|
31
42
|
(src-list (lyp:split-path tmp-path))
|
32
43
|
(dst-list '())
|
33
|
-
|
34
|
-
(for-each
|
35
|
-
(lambda (p)
|
44
|
+
(resolve (lambda (p)
|
36
45
|
(cond
|
37
46
|
((eq? (length dst-list) 0) ; start of path
|
38
47
|
(set! dst-list (list p)))
|
@@ -41,12 +50,54 @@
|
|
41
50
|
((string=? p "..") ; go up a level (remove last part from list)
|
42
51
|
(set! dst-list (reverse (cdr (reverse dst-list)))))
|
43
52
|
(else
|
44
|
-
(set! dst-list (append dst-list (list p))))))
|
45
|
-
|
46
|
-
(
|
47
|
-
|
53
|
+
(set! dst-list (append dst-list (list p)))))))
|
54
|
+
)
|
55
|
+
(for-each resolve src-list)
|
56
|
+
(apply lyp:join-path dst-list)))
|
57
|
+
|
58
|
+
(define (lyp:for-each-matching-file pat proc)
|
59
|
+
(let* (
|
60
|
+
(startdir (lyp:find-pattern-start-dir pat))
|
61
|
+
(pat-regexp (lyp:pattern->regexp pat))
|
62
|
+
(proc (lambda (fn st flag)
|
63
|
+
(begin
|
64
|
+
(if (and (eq? flag 'regular) (string-match pat-regexp fn))
|
65
|
+
(proc fn))
|
66
|
+
#t
|
67
|
+
)))
|
68
|
+
)
|
69
|
+
(ftw startdir proc)))
|
70
|
+
|
71
|
+
; convert a filename wildcard pattern to a regexp
|
72
|
+
(define (lyp:pattern->regexp pat)
|
73
|
+
(let* (
|
74
|
+
(sub regexp-substitute/global)
|
75
|
+
(pat (sub #f "\\." pat 'pre "\\." 'post))
|
76
|
+
(pat (sub #f "\\*\\*/" pat 'pre "([^/]+/)@" 'post))
|
77
|
+
(pat (sub #f "\\*" pat 'pre "[^/]+" 'post))
|
78
|
+
(pat (sub #f "@" pat 'pre "*" 'post))
|
79
|
+
)
|
80
|
+
pat))
|
81
|
+
|
82
|
+
; find the start directory for a given filename pattern
|
83
|
+
; e.g. "abc/def/**/*.ly" => "abc/def"
|
84
|
+
; "/repo/docs/*" => "/repo/docs"
|
85
|
+
; "*.ly" => "."
|
86
|
+
; "../src/*.ly" => "../src"
|
87
|
+
; if no start directory is found for the given pattern, returns "."
|
88
|
+
(define (lyp:find-pattern-start-dir pat)
|
89
|
+
(let* (
|
90
|
+
(match (string-match "^(([^\\*]+)(/))" pat))
|
91
|
+
)
|
92
|
+
(if match (match:substring match 2) ".")))
|
93
|
+
|
94
|
+
(define (lyp:directory? fn)
|
95
|
+
(and (file-exists? fn)
|
96
|
+
(eq? (stat:type (stat fn)) 'directory)))
|
48
97
|
|
49
|
-
|
98
|
+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
99
|
+
;; package and include handling utilities ;;
|
100
|
+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
50
101
|
|
51
102
|
; hash table mapping package refs to package names
|
52
103
|
(define lyp:package-refs (make-hash-table))
|
@@ -85,27 +136,20 @@
|
|
85
136
|
(define (lyp:this-file) (or lyp:last-this-file lyp:input-filename))
|
86
137
|
(define (lyp:this-dir) (dirname (lyp:this-file)))
|
87
138
|
|
88
|
-
|
89
|
-
|
90
|
-
(current-dir (dirname current-file))
|
91
|
-
(abs-path (if (lyp:absolute-path? path)
|
92
|
-
path
|
93
|
-
(lyp:expand-path (lyp:join-path current-dir path))))
|
94
|
-
)
|
95
|
-
(if (not (file-exists? abs-path))
|
96
|
-
(throw 'lyp:failure "lyp:load"
|
97
|
-
(format "File not found ~a" abs-path) #f)
|
98
|
-
)
|
99
|
-
(ly:debug (format "lyp:load ~a\n" abs-path))
|
100
|
-
(set! lyp:last-this-file abs-path)
|
101
|
-
(load abs-path)
|
102
|
-
(set! lyp:last-this-file current-file)
|
103
|
-
))
|
139
|
+
; point to the entry point for the package being loaded
|
140
|
+
(define lyp:this-package-entry-point #f)
|
104
141
|
|
142
|
+
; format include command for included file
|
143
|
+
; the template also sets the lyp:last-this-file to the
|
144
|
+
; included file, in order to keep track of file location
|
105
145
|
(define (lyp:fmt-include path)
|
106
146
|
(format "#(set! lyp:last-this-file \"~A\")\n\\include \"~A\"\n#(set! lyp:last-this-file \"~A\")\n"
|
107
147
|
path path (lyp:this-file)))
|
108
148
|
|
149
|
+
; format include command for a package
|
150
|
+
; this template also sets the lyp:current-package-dir to the
|
151
|
+
; package entry point path, and resets it to its previous
|
152
|
+
; value after including the package files
|
109
153
|
(define (lyp:fmt-require entry-point-path package-dir)
|
110
154
|
(format "#(set! lyp:current-package-dir \"~A\")\n~A#(set! lyp:current-package-dir \"~A\")\n"
|
111
155
|
package-dir (lyp:fmt-include entry-point-path) lyp:current-package-dir))
|
@@ -116,60 +160,193 @@
|
|
116
160
|
(ly:parser-include-string str)
|
117
161
|
(ly:parser-include-string parser str)))
|
118
162
|
|
119
|
-
|
120
|
-
|
121
|
-
|
163
|
+
; convert a path to an absolute path using the
|
164
|
+
; directory for the currently processed file
|
165
|
+
(define (lyp:absolute-path-from-this-dir fn)
|
166
|
+
(if (lyp:absolute-path? fn)
|
167
|
+
fn
|
168
|
+
(lyp:expand-path (lyp:join-path (lyp:this-dir) fn))))
|
169
|
+
|
170
|
+
; define list of finalizer lambdas to be called after the user's file has been
|
171
|
+
; processed. packages invoke (lyp:finalize proc) to add their own code.
|
172
|
+
; Finalizers are called in the order they were added.
|
173
|
+
(define lyp:final-procs '())
|
174
|
+
|
175
|
+
; called after processing user's file, this procedure calls all registered
|
176
|
+
; finalizers.
|
177
|
+
(define (lyp:call-finalizers)
|
178
|
+
(for-each (lambda (p) (p)) lyp:final-procs))
|
179
|
+
|
180
|
+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
181
|
+
;; lyp API ;;
|
182
|
+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
183
|
+
|
184
|
+
(define (lyp:load:ref ref once)
|
185
|
+
(let* (
|
186
|
+
(ref (lyp:coerce-string ref))
|
187
|
+
)
|
188
|
+
(cond
|
189
|
+
((string-match "\\*" ref) (lyp:load:pattern pat once))
|
190
|
+
((lyp:directory? ref) (lyp:load:pattern (string-append ref "/*") once))
|
191
|
+
(else (lyp:load:file ref once)))
|
192
|
+
))
|
193
|
+
|
194
|
+
(define (lyp:load:pattern pat once)
|
195
|
+
(lyp:for-each-matching-file pat (lambda (fn) (lyp:load:file fn once))))
|
196
|
+
|
197
|
+
(define (lyp:load:file fn once)
|
198
|
+
(let* (
|
199
|
+
(abs-fn (lyp:absolute-path-from-this-dir fn))
|
200
|
+
(abs-fn-ly (string-append abs-fn ".ly"))
|
201
|
+
(abs-fn-ily (string-append abs-fn ".ily"))
|
202
|
+
)
|
203
|
+
(cond
|
204
|
+
((file-exists? abs-fn) (lyp:load:include abs-fn once))
|
205
|
+
((and (file-exists? abs-fn-ly) (file-exists? abs-fn-ily))
|
206
|
+
(throw 'lyp-failure "lyp:load:file"
|
207
|
+
(format "Ambiguous filename ~a" fn) #f))
|
208
|
+
((file-exists? abs-fn-ly) (lyp:load:include abs-fn-ly once))
|
209
|
+
((file-exists? abs-fn-ily) (lyp:load:include abs-fn-ily once))
|
210
|
+
(else (throw 'lyp-failure "lyp:load:file"
|
211
|
+
(format "File not found: ~a" fn) #f)))))
|
212
|
+
|
213
|
+
; performs the include
|
214
|
+
; this procedure expects the path to be absolute
|
215
|
+
; and the file to exist
|
216
|
+
(define (lyp:load:include path once)
|
217
|
+
(if (not (and once (hash-ref lyp:file-included? path)))
|
218
|
+
(begin
|
219
|
+
(ly:debug "include ~a\n" path)
|
220
|
+
(hash-set! lyp:file-included? path #t)
|
221
|
+
(lyp:include-string (lyp:fmt-include path)))
|
222
|
+
#f))
|
223
|
+
|
224
|
+
; load scheme file with correct relative path handling
|
225
|
+
; (deprecated?)
|
226
|
+
(define (lyp:load path) (let* (
|
227
|
+
(current-file (lyp:this-file))
|
228
|
+
(current-dir (dirname current-file))
|
122
229
|
(abs-path (if (lyp:absolute-path? path)
|
123
230
|
path
|
124
231
|
(lyp:expand-path (lyp:join-path current-dir path))))
|
125
|
-
(included? (and once (hash-ref lyp:file-included? abs-path)))
|
126
232
|
)
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
(lyp:include-string (lyp:fmt-include abs-path))
|
136
|
-
))
|
233
|
+
(if (not (file-exists? abs-path))
|
234
|
+
(throw 'lyp:failure "lyp:load"
|
235
|
+
(format "File not found ~a" abs-path) #f)
|
236
|
+
)
|
237
|
+
(ly:debug (format "lyp:load ~a\n" abs-path))
|
238
|
+
(set! lyp:last-this-file abs-path)
|
239
|
+
(load abs-path)
|
240
|
+
(set! lyp:last-this-file current-file)
|
137
241
|
))
|
138
242
|
|
139
|
-
;
|
140
|
-
; processed. packages invoke (lyp:finalize proc) to add their own code.
|
141
|
-
; Finalizers are called in the order they were added.
|
142
|
-
(define lyp:final-procs '())
|
243
|
+
; add a finalizer to be called after user's file is processed
|
143
244
|
(define (lyp:finalize proc)
|
144
245
|
(set! lyp:final-procs (append lyp:final-procs (list proc))))
|
145
|
-
|
146
|
-
|
246
|
+
|
247
|
+
(define (lyp:require ref)
|
248
|
+
(let* (
|
249
|
+
(ref (lyp:coerce-string ref))
|
250
|
+
(name (lyp:ref->name ref))
|
251
|
+
(package-dir (lyp:name->dir name))
|
252
|
+
(entry-point-path (lyp:join-path package-dir "package.ly"))
|
253
|
+
(loaded? (hash-ref lyp:package-loaded? name))
|
254
|
+
(last-package-entry-point lyp:this-package-entry-point)
|
255
|
+
)
|
256
|
+
(if (not loaded?) (begin
|
257
|
+
(ly:debug "Loading package ~a at ~a" name package-dir)
|
258
|
+
(hash-set! lyp:package-loaded? name #t)
|
259
|
+
(set! lyp:this-package-entry-point entry-point-path)
|
260
|
+
(lyp:include-string (lyp:fmt-require entry-point-path package-dir))
|
261
|
+
(set! lyp:this-package-entry-point last-package-entry-point)))))
|
262
|
+
|
147
263
|
)
|
148
264
|
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
(name (lyp:ref->name ref))
|
153
|
-
(package-dir (lyp:name->dir name))
|
154
|
-
(entry-point-path (lyp:join-path package-dir "package.ly"))
|
155
|
-
(loaded? (hash-ref lyp:package-loaded? name))
|
156
|
-
)
|
157
|
-
(if (not loaded?) (begin
|
158
|
-
(ly:debug "Loading package ~a at ~a" name package-dir)
|
159
|
-
(hash-set! lyp:package-loaded? name #t)
|
160
|
-
|
161
|
-
(lyp:include-string (lyp:fmt-require entry-point-path package-dir))
|
162
|
-
))
|
163
|
-
))
|
265
|
+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
266
|
+
%% Lilypond commands %%
|
267
|
+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
164
268
|
|
165
|
-
|
166
|
-
(
|
269
|
+
lyp-load = #(define-void-function (parser location ref)(lyp:list-string-or-symbol?)
|
270
|
+
(if (list? ref)
|
271
|
+
(for-each (lambda (r) (lyp:load:ref r #f)) ref)
|
272
|
+
(lyp:load:ref ref #f)))
|
167
273
|
|
168
|
-
|
169
|
-
(if
|
274
|
+
lyp-include = #(define-void-function (parser location ref)(lyp:list-string-or-symbol?)
|
275
|
+
(if (list? ref)
|
276
|
+
(for-each (lambda (r) (lyp:load:ref r #t)) ref)
|
277
|
+
(lyp:load:ref ref #t)))
|
278
|
+
|
279
|
+
lyp-require = #(define-void-function (parser location ref)(lyp:list-string-or-symbol?)
|
280
|
+
(if (list? ref)
|
281
|
+
(for-each (lambda (r) (lyp:require r) ref))
|
282
|
+
(lyp:require ref)))
|
283
|
+
|
284
|
+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
285
|
+
%% Deprecated Lilypond commands %%
|
286
|
+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
287
|
+
|
288
|
+
#(begin
|
289
|
+
(define (lyp:show-deprecated-msg location msg)
|
290
|
+
(if (not lyp:this-package-entry-point)
|
291
|
+
(begin
|
292
|
+
(if lyp:verbose
|
293
|
+
(ly:input-warning location msg)
|
294
|
+
(ly:debug msg)
|
295
|
+
)
|
296
|
+
; (ly:input-message location msg)
|
297
|
+
;(lyp:show-deprecated-docs-msg)
|
298
|
+
)))
|
299
|
+
|
300
|
+
(define lyp:deprecated-docs-msg-shown #f)
|
301
|
+
|
302
|
+
(define (lyp:show-deprecated--docs-msg)
|
303
|
+
(if (not lyp:deprecated-docs-msg-shown)
|
304
|
+
(begin
|
305
|
+
(set! lyp:deprecated-docs-msg-shown #t)
|
306
|
+
(lyp:finalize (lambda ()
|
307
|
+
(ly:debug lyp:msg:deprecated:docs))))))
|
308
|
+
|
309
|
+
(define lyp:msg:deprecated:pinclude
|
310
|
+
"\\pinclude is deprecated. Please use \\lyp-load instead.")
|
311
|
+
|
312
|
+
(define lyp:msg:deprecated:pincludeOnce
|
313
|
+
"\\pincludeOnce is deprecated. Please use \\lyp-include instead.")
|
314
|
+
|
315
|
+
(define lyp:msg:deprecated:pcondInclude
|
316
|
+
"\\pcondInclude is deprecated. Please wrap your \\lyp-load call with a scheme expression.")
|
317
|
+
|
318
|
+
(define lyp:msg:deprecated:pcondIncludeOnce
|
319
|
+
"\\pcondIncludeOnce is deprecated. Please wrap your \\lyp-include call with a scheme expression.")
|
320
|
+
|
321
|
+
(define lyp:msg:deprecated:require
|
322
|
+
"\\require is deprecated. Please use \\lyp-require instead.")
|
323
|
+
|
324
|
+
(define lyp:msg:deprecated:docs
|
325
|
+
"\n****************************************\nThe code in your file and/or packages you use include deprecated commands that will be removed in a future version of lyp. For more information on deprecated commands see the lyp user guide:\n http://lyp.noteflakes.com/\n****************************************\n")
|
326
|
+
)
|
327
|
+
|
328
|
+
pinclude = #(define-void-function (parser location ref)(string-or-symbol?)
|
329
|
+
(begin
|
330
|
+
(lyp:show-deprecated-msg location lyp:msg:deprecated:pinclude)
|
331
|
+
(lyp:load:ref ref #f)))
|
170
332
|
|
171
333
|
pincludeOnce = #(define-void-function (parser location path)(string-or-symbol?)
|
172
|
-
(
|
334
|
+
(begin
|
335
|
+
(lyp:show-deprecated-msg location lyp:msg:deprecated:pincludeOnce)
|
336
|
+
(lyp:load:ref path #t)))
|
337
|
+
|
338
|
+
pcondInclude = #(define-void-function (parser location expr path)(scheme? string-or-symbol?)
|
339
|
+
(begin
|
340
|
+
(lyp:show-deprecated-msg location lyp:msg:deprecated:pcondInclude)
|
341
|
+
(if expr (lyp:load:ref path #f))
|
342
|
+
))
|
173
343
|
|
174
344
|
pcondIncludeOnce = #(define-void-function (parser location expr path)(scheme? string-or-symbol?)
|
175
|
-
(
|
345
|
+
(begin
|
346
|
+
(lyp:show-deprecated-msg location lyp:msg:deprecated:pcondIncludeOnce)
|
347
|
+
(if expr (lyp:load:ref path #t))))
|
348
|
+
|
349
|
+
require = #(define-void-function (parser location ref)(string-or-symbol?)
|
350
|
+
(begin
|
351
|
+
(lyp:show-deprecated-msg location lyp:msg:deprecated:require)
|
352
|
+
(lyp:require ref)))
|
@@ -0,0 +1,54 @@
|
|
1
|
+
;
|
2
|
+
(use-modules
|
3
|
+
(ice-9 popen)
|
4
|
+
(ice-9 rdelim))
|
5
|
+
|
6
|
+
(define (lyp:pread cmd)
|
7
|
+
(let* (
|
8
|
+
(port (open-input-pipe cmd))
|
9
|
+
(output (read-delimited "" port))
|
10
|
+
)
|
11
|
+
(close-pipe port)
|
12
|
+
(if (string? output)
|
13
|
+
output
|
14
|
+
(throw 'lyp:failure "lyp:pread"
|
15
|
+
(format "Command failed: ~a" cmd) #f))))
|
16
|
+
|
17
|
+
; a hash mapping package refs to entry points
|
18
|
+
(define lyp:package-entry-points (make-hash-table))
|
19
|
+
|
20
|
+
; resolve a package reference
|
21
|
+
;
|
22
|
+
; The reference is first looked up in the package ref hash table.
|
23
|
+
; if not found, the resolver is invoked, and the information
|
24
|
+
; returned
|
25
|
+
(define (lyp:package-entry-point ref)
|
26
|
+
(catch #t
|
27
|
+
(lambda ()
|
28
|
+
(or
|
29
|
+
(hash-ref lyp:package-entry-points ref)
|
30
|
+
(lyp:find-package ref)))
|
31
|
+
(lambda (key . parameters)
|
32
|
+
; (set! error-thrown #t)
|
33
|
+
(throw 'lyp:failure "lyp:package-entry-point"
|
34
|
+
(format "Failed to resolve dependency ~a" ref) #f)
|
35
|
+
))
|
36
|
+
)
|
37
|
+
|
38
|
+
(define (lyp:find-package ref)
|
39
|
+
(let* (
|
40
|
+
(cmd (string-append "bin/lyp-resolve " ref))
|
41
|
+
(path (lyp:pread cmd))
|
42
|
+
)
|
43
|
+
(hash-set! lyp:package-entry-points ref path)
|
44
|
+
path
|
45
|
+
)
|
46
|
+
)
|
47
|
+
|
48
|
+
(define (lyp:load-package ref)
|
49
|
+
(let* (
|
50
|
+
(path (lyp:package-entry-point ref))
|
51
|
+
)
|
52
|
+
(lyp:load:ref path #t)
|
53
|
+
)
|
54
|
+
)
|
data/lib/lyp/lilypond.rb
CHANGED
@@ -66,6 +66,8 @@ module Lyp::Lilypond
|
|
66
66
|
when '-S', '--snippet'
|
67
67
|
argv_clean.concat ['-dbackend=eps', '-daux-files=#f', '--png', '-dresolution=600']
|
68
68
|
options[:snippet_paper_preamble] = true
|
69
|
+
when '--svg'
|
70
|
+
argv_clean.concat ['-dbackend=svg']
|
69
71
|
when '-u', '--use'
|
70
72
|
options[:use_version] = argv.shift
|
71
73
|
when '-V', '--verbose'
|
@@ -75,13 +77,50 @@ module Lyp::Lilypond
|
|
75
77
|
options[:mode] = :system
|
76
78
|
when '--invoke-quiet'
|
77
79
|
options[:mode] = :quiet
|
78
|
-
when '--svg'
|
79
|
-
argv_clean.concat ['-dbackend=svg']
|
80
80
|
else
|
81
81
|
argv_clean << arg
|
82
82
|
end
|
83
83
|
end
|
84
84
|
|
85
|
+
def preprocess_bin_script_argv(argv)
|
86
|
+
options = {}
|
87
|
+
argv = argv.dup # copy for iterating
|
88
|
+
argv_clean = []
|
89
|
+
while arg = argv.shift
|
90
|
+
parse_lilypond_bin_script_arg(arg, argv, argv_clean, options)
|
91
|
+
end
|
92
|
+
|
93
|
+
[options, argv_clean]
|
94
|
+
end
|
95
|
+
|
96
|
+
def parse_lilypond_bin_script_arg(arg, argv, argv_clean, options)
|
97
|
+
case arg
|
98
|
+
when ARGUMENT_EQUAL_REGEXP
|
99
|
+
argv.insert(0, "--#{$1}", $2)
|
100
|
+
when ARGUMENT_SHORTHAND_REGEXP
|
101
|
+
argv.insert(0, "-#{$1}", $2)
|
102
|
+
when NO_ARGUMENT_SHORTHAND_REGEXP
|
103
|
+
tmp_args = []
|
104
|
+
$1.each_char {|c| tmp_args << "-#{c}"}
|
105
|
+
tmp_args << "-#{$2}"
|
106
|
+
argv.insert(0, *tmp_args)
|
107
|
+
when '-E', '--env'
|
108
|
+
unless ENV['LILYPOND_VERSION']
|
109
|
+
raise "$LILYPOND_VERSION not set"
|
110
|
+
end
|
111
|
+
options[:use_version] = ENV['LILYPOND_VERSION']
|
112
|
+
when '-n', '--install'
|
113
|
+
options[:install] = true
|
114
|
+
when '-u', '--use'
|
115
|
+
options[:use_version] = argv.shift
|
116
|
+
when '--invoke-system'
|
117
|
+
options[:mode] = :system
|
118
|
+
else
|
119
|
+
argv_clean << arg
|
120
|
+
argv_clean += argv
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
85
124
|
def prepare_inline_music_file(music, opts = {})
|
86
125
|
filename = Lyp.tmp_filename('.ly')
|
87
126
|
File.open(filename, 'w+') do |f|
|
@@ -149,6 +188,10 @@ module Lyp::Lilypond
|
|
149
188
|
def invoke(argv, opts = {})
|
150
189
|
lilypond = current_lilypond
|
151
190
|
|
191
|
+
if opts[:verbose]
|
192
|
+
puts "#{lilypond} #{argv.join(" ")}"
|
193
|
+
end
|
194
|
+
|
152
195
|
case opts[:mode]
|
153
196
|
when :system
|
154
197
|
system("#{lilypond} #{argv.join(" ")}")
|
data/lib/lyp/resolver.rb
CHANGED
@@ -120,7 +120,11 @@ module Lyp
|
|
120
120
|
end
|
121
121
|
end
|
122
122
|
|
123
|
-
DEP_RE = /\\(require|include|pinclude|pincludeOnce)\s+(?:"|#')?([^\s"]+)"?/.freeze
|
123
|
+
# DEP_RE = /\\((?:lyp[\-\:]require)|lyp-load|lyp-include|require|include|pinclude|pincludeOnce)\s+(?:"|#')?([^\s"\)]+)"?/.freeze
|
124
|
+
DEP_RE = /\\(lyp-require|lyp-load|lyp-include|require|include|pinclude|pincludeOnce)\s+(?:"|#')?([^\s"]+)"?/.freeze
|
125
|
+
LYP_REQUIRE = "lyp-require".freeze
|
126
|
+
LYP_INCLUDE = "lyp-include".freeze
|
127
|
+
LYP_LOAD = "lyp-load".freeze
|
124
128
|
INCLUDE = "include".freeze
|
125
129
|
PINCLUDE = "pinclude".freeze
|
126
130
|
PINCLUDE_ONCE = "pincludeOnce".freeze
|
@@ -183,9 +187,9 @@ module Lyp
|
|
183
187
|
location[:line] += 1
|
184
188
|
line.scan(DEP_RE) do |type, ref|
|
185
189
|
case type
|
186
|
-
when INCLUDE, PINCLUDE, PINCLUDE_ONCE
|
190
|
+
when LYP_INCLUDE, LYP_LOAD, INCLUDE, PINCLUDE, PINCLUDE_ONCE
|
187
191
|
process_include_command(ref, dir, leaf, opts, location)
|
188
|
-
when REQUIRE
|
192
|
+
when LYP_REQUIRE, REQUIRE
|
189
193
|
process_require_command(ref, dir, leaf, opts, location)
|
190
194
|
end
|
191
195
|
end
|
@@ -4,6 +4,9 @@
|
|
4
4
|
# package_paths: {
|
5
5
|
# <specifier> => <package path>
|
6
6
|
# ...
|
7
|
+
# },
|
8
|
+
# opts: {
|
9
|
+
# ...
|
7
10
|
# }
|
8
11
|
# }
|
9
12
|
|
@@ -54,6 +57,7 @@ end
|
|
54
57
|
(define lyp:input-filename {{quote_path[user_filename]}})
|
55
58
|
(define lyp:input-dirname {{quote_path[user_dirname]}})
|
56
59
|
(define lyp:current-package-dir {{quote_path[current_package_dir]}})
|
60
|
+
(define lyp:verbose {{_[:opts][:verbose] ? '#t' : '#f'}})
|
57
61
|
`
|
58
62
|
|
59
63
|
_[:package_refs].each do |spec, name|
|
data/lib/lyp/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lyp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sharon Rosner
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-03-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httpclient
|
@@ -111,12 +111,14 @@ files:
|
|
111
111
|
- bin/install_release.sh
|
112
112
|
- bin/lilypond
|
113
113
|
- bin/lyp
|
114
|
+
- bin/lyp-resolve
|
114
115
|
- lib/lyp.rb
|
115
116
|
- lib/lyp/base.rb
|
116
117
|
- lib/lyp/cli.rb
|
117
118
|
- lib/lyp/etc/detect_system_lilypond.ly
|
118
119
|
- lib/lyp/etc/font.scm
|
119
120
|
- lib/lyp/etc/lyp.ly
|
121
|
+
- lib/lyp/etc/support.scm
|
120
122
|
- lib/lyp/git_based_rugged.rb
|
121
123
|
- lib/lyp/lilypond.rb
|
122
124
|
- lib/lyp/package.rb
|