lyp-win 0.3.5 → 0.3.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/install_release.sh +1 -1
- data/bin/lilypond +5 -49
- data/lib/lyp/cli.rb +5 -24
- data/lib/lyp/etc/lyp.ly +19 -24
- data/lib/lyp/lilypond.rb +53 -0
- data/lib/lyp/resolver.rb +47 -29
- data/lib/lyp/templates/deps_wrapper.rb +13 -2
- data/lib/lyp/version.rb +1 -1
- data/lib/lyp/wrapper.rb +2 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bcd584088a605705ca3dd2da68b7091971b4a54a
|
4
|
+
data.tar.gz: 9d979652b8d29b20200b554603cfe411a92592da
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3137343b1150ff6c1fbded1362aed582b78900e0720b63a31fc471908a0e3dfef2d1c12a4576a91beeeb299d1d2b4ee054da08ae8750d696523615e73eaa9d91
|
7
|
+
data.tar.gz: 07648102dac19de97b57fa77e902fd3b69c767f2fd018d40d5aac0357983210ac083988d1bbcd6783e3ce23710bebfe7d34b01ef5ef69af74ead678546bf07a8
|
data/bin/install_release.sh
CHANGED
data/bin/lilypond
CHANGED
@@ -5,54 +5,9 @@ $LOAD_PATH.unshift File.expand_path("../lib", File.dirname(__FILE__))
|
|
5
5
|
require 'lyp/version'
|
6
6
|
require 'lyp'
|
7
7
|
|
8
|
-
|
9
|
-
options = {}
|
10
|
-
argv = ARGV.dup # copy for iterating
|
11
|
-
argv_clean = []
|
12
|
-
while arg = argv.shift
|
13
|
-
case arg
|
14
|
-
when '-r', '--raw'
|
15
|
-
options[:raw] = true
|
16
|
-
when '-E', '--env'
|
17
|
-
unless ENV['LILYPOND_VERSION']
|
18
|
-
STDERR.puts "$LILYPOND_VERSION not set"
|
19
|
-
exit 1
|
20
|
-
end
|
21
|
-
options[:use_version] = ENV['LILYPOND_VERSION']
|
22
|
-
when '-u', '--use'
|
23
|
-
options[:use_version] = argv.shift
|
24
|
-
when /^(?:\-u|\-\-use\=)"?([^\s]+)"?/
|
25
|
-
options[:use_version] = $1
|
26
|
-
when '-n', '--install'
|
27
|
-
options[:install] = true
|
28
|
-
else
|
29
|
-
argv_clean << arg
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
[options, argv_clean]
|
34
|
-
end
|
35
|
-
$options, $argv = process_argv
|
8
|
+
$options, $argv = Lyp::Lilypond.preprocess_argv(ARGV)
|
36
9
|
|
37
|
-
|
38
|
-
if $options[:use_version]
|
39
|
-
if $options[:install]
|
40
|
-
Lyp::Lilypond.install_if_missing($options[:use_version])
|
41
|
-
end
|
42
|
-
Lyp::Lilypond.force_version!($options[:use_version])
|
43
|
-
end
|
44
|
-
Lyp::Lilypond.check_lilypond!
|
45
|
-
Lyp::Lilypond.current_lilypond.tap do |path|
|
46
|
-
unless path && File.file?(path)
|
47
|
-
STDERR.puts "No version of lilypond found. To install lilypond run 'lyp install lilypond'."
|
48
|
-
exit 1
|
49
|
-
end
|
50
|
-
end
|
51
|
-
rescue => e
|
52
|
-
STDERR.puts e.message
|
53
|
-
exit 1
|
54
|
-
end
|
55
|
-
$lilypond_path = get_lilypond_path
|
10
|
+
$lilypond_path = Lyp::Lilypond.select_lilypond_version($options)
|
56
11
|
|
57
12
|
if $options[:raw]
|
58
13
|
exec("#{$lilypond_path} #{$argv.join(' ')}")
|
@@ -68,10 +23,11 @@ LILYPOND_HELP_SWITCHES = %w{
|
|
68
23
|
}
|
69
24
|
LYP_LY_HELP = <<EOF
|
70
25
|
Lyp-provided options:
|
71
|
-
-r, --raw run raw lilypond (no pre-processing)
|
72
26
|
-E, --env use version specified in $LILYPOND_VERSION
|
27
|
+
-n, --install install the specified version if not found
|
28
|
+
-R, --raw run raw lilypond (no pre-processing)
|
29
|
+
-r, --require=PACKAGE preload the specified package
|
73
30
|
-u, --use=VERSION use the given version of lilypond
|
74
|
-
-n, --install install the given version if not found
|
75
31
|
EOF
|
76
32
|
|
77
33
|
case $argv.first
|
data/lib/lyp/cli.rb
CHANGED
@@ -45,7 +45,7 @@ class Lyp::CLI < Thor
|
|
45
45
|
package_name "lyp"
|
46
46
|
map "-v" => :version
|
47
47
|
check_unknown_options! :except => :compile
|
48
|
-
class_option :verbose, aliases: '-V', :type => :boolean
|
48
|
+
class_option :verbose, aliases: '-V', :type => :boolean, desc: 'show verbose output'
|
49
49
|
|
50
50
|
desc "version", "show Lyp version"
|
51
51
|
def version
|
@@ -100,33 +100,14 @@ class Lyp::CLI < Thor
|
|
100
100
|
end
|
101
101
|
|
102
102
|
desc "compile [<option>...] <FILE>", "Invokes lilypond with given file"
|
103
|
-
|
104
|
-
|
105
|
-
method_option :use, aliases: '-u', type: :string, desc: 'Use specified version'
|
106
|
-
def compile(*args)
|
107
|
-
$cmd_options = options
|
103
|
+
def compile(*argv)
|
104
|
+
opts, argv = Lyp::Lilypond.preprocess_argv(argv)
|
108
105
|
|
109
|
-
|
110
|
-
unless ENV['LILYPOND_VERSION']
|
111
|
-
STDERR.puts "$LILYPOND_VERSION not set"
|
112
|
-
exit 1
|
113
|
-
end
|
114
|
-
options[:use] = ENV['LILYPOND_VERSION']
|
115
|
-
end
|
116
|
-
|
117
|
-
if options[:use]
|
118
|
-
if options[:install]
|
119
|
-
Lyp::Lilypond.install_if_missing(options[:use], no_version_test: true)
|
120
|
-
end
|
121
|
-
Lyp::Lilypond.force_version!(options[:use])
|
122
|
-
end
|
106
|
+
lilypond_path = Lyp::Lilypond.select_lilypond_version(opts)
|
123
107
|
|
124
|
-
# check lilypond default / current settings
|
125
|
-
Lyp::Lilypond.check_lilypond!
|
126
|
-
|
127
108
|
$stderr.puts "Lyp #{Lyp::VERSION}"
|
128
109
|
Lyp::System.test_installed_status!
|
129
|
-
Lyp::Lilypond.compile(
|
110
|
+
Lyp::Lilypond.compile(argv, opts)
|
130
111
|
end
|
131
112
|
|
132
113
|
desc "test [<option>...] [.|PATTERN]", "Runs package tests on installed packages or local directory"
|
data/lib/lyp/etc/lyp.ly
CHANGED
@@ -96,62 +96,59 @@
|
|
96
96
|
(throw 'lyp:failure "lyp:load"
|
97
97
|
(format "File not found ~a" abs-path) #f)
|
98
98
|
)
|
99
|
+
(ly:debug (format "lyp:load ~a\n" abs-path))
|
99
100
|
(set! lyp:last-this-file abs-path)
|
100
101
|
(load abs-path)
|
101
102
|
(set! lyp:last-this-file current-file)
|
102
103
|
))
|
103
104
|
|
104
|
-
(define (lyp:
|
105
|
+
(define (lyp:fmt-include path)
|
106
|
+
(format "#(set! lyp:last-this-file \"~A\")\n\\include \"~A\"\n#(set! lyp:last-this-file \"~A\")\n"
|
107
|
+
path path (lyp:this-file)))
|
108
|
+
|
109
|
+
(define (lyp:fmt-require entry-point-path package-dir)
|
110
|
+
(format "#(set! lyp:current-package-dir \"~A\")\n~A#(set! lyp:current-package-dir \"~A\")\n"
|
111
|
+
package-dir (lyp:fmt-include entry-point-path) lyp:current-package-dir))
|
112
|
+
|
113
|
+
; helper function to cover API changes from 2.18 to 2.19
|
114
|
+
(define (lyp:include-string str)
|
105
115
|
(if (defined? '*parser*)
|
106
|
-
(ly:parser-
|
107
|
-
|
108
|
-
(ly:parser-parse-string (ly:parser-clone parser)
|
109
|
-
(format "\\include \"~a\"" path))))
|
116
|
+
(ly:parser-include-string str)
|
117
|
+
(ly:parser-include-string parser str)))
|
110
118
|
)
|
111
119
|
|
112
120
|
% command form
|
113
121
|
require = #(define-void-function (parser location ref)(string?) (let* (
|
114
|
-
(current-file (lyp:this-file))
|
115
122
|
(name (lyp:ref->name ref))
|
116
123
|
(package-dir (lyp:name->dir name))
|
117
124
|
(entry-point-path (lyp:join-path package-dir "package.ly"))
|
118
125
|
(loaded? (hash-ref lyp:package-loaded? name))
|
119
|
-
(prev-package-dir lyp:current-package-dir)
|
120
126
|
)
|
121
127
|
(if (not loaded?) (begin
|
122
128
|
(ly:debug "Loading package ~a at ~a" name package-dir)
|
123
|
-
(set! lyp:current-package-dir package-dir)
|
124
129
|
(hash-set! lyp:package-loaded? name #t)
|
125
130
|
|
126
|
-
(
|
127
|
-
(lyp:do-include parser entry-point-path)
|
128
|
-
(set! lyp:last-this-file current-file)
|
129
|
-
|
130
|
-
(set! lyp:current-package-dir prev-package-dir)
|
131
|
+
(lyp:include-string (lyp:fmt-require entry-point-path package-dir))
|
131
132
|
))
|
132
133
|
))
|
133
134
|
|
134
135
|
pinclude = #(define-void-function (parser location path)(string?) (let* (
|
135
|
-
(current-
|
136
|
-
(current-dir (dirname current-file))
|
136
|
+
(current-dir (lyp:this-dir))
|
137
137
|
(abs-path (if (lyp:absolute-path? path)
|
138
138
|
path
|
139
139
|
(lyp:expand-path (lyp:join-path current-dir path))))
|
140
140
|
)
|
141
|
-
(ly:debug
|
141
|
+
(ly:debug "\\pinclude ~a\n" abs-path)
|
142
142
|
(if (not (file-exists? abs-path))
|
143
143
|
(throw 'lyp:failure "\\pinclude"
|
144
144
|
(format "File not found ~a" abs-path) #f))
|
145
145
|
|
146
146
|
(hash-set! lyp:file-included? abs-path #t)
|
147
|
-
(
|
148
|
-
(lyp:do-include parser abs-path)
|
149
|
-
(set! lyp:last-this-file current-file)
|
147
|
+
(lyp:include-string (lyp:fmt-include abs-path))
|
150
148
|
))
|
151
149
|
|
152
150
|
pincludeOnce = #(define-void-function (parser location path)(string?) (let* (
|
153
|
-
(current-
|
154
|
-
(current-dir (dirname current-file))
|
151
|
+
(current-dir (lyp:this-dir))
|
155
152
|
(abs-path (if (lyp:absolute-path? path)
|
156
153
|
path
|
157
154
|
(lyp:expand-path (lyp:join-path current-dir path))))
|
@@ -164,8 +161,6 @@ pincludeOnce = #(define-void-function (parser location path)(string?) (let* (
|
|
164
161
|
(format "File not found ~a" abs-path) #f))
|
165
162
|
|
166
163
|
(hash-set! lyp:file-included? abs-path #t)
|
167
|
-
(
|
168
|
-
(lyp:do-include parser abs-path)
|
169
|
-
(set! lyp:last-this-file current-file)
|
164
|
+
(lyp:include-string (lyp:fmt-include abs-path))
|
170
165
|
)
|
171
166
|
)))
|
data/lib/lyp/lilypond.rb
CHANGED
@@ -4,6 +4,59 @@ require 'ruby-progressbar'
|
|
4
4
|
|
5
5
|
module Lyp::Lilypond
|
6
6
|
class << self
|
7
|
+
def preprocess_argv(argv)
|
8
|
+
options = {}
|
9
|
+
argv = argv.dup # copy for iterating
|
10
|
+
argv_clean = []
|
11
|
+
while arg = argv.shift
|
12
|
+
case arg
|
13
|
+
when '-R', '--raw'
|
14
|
+
options[:raw] = true
|
15
|
+
when '-r', '--require'
|
16
|
+
options[:ext_require] ||= []
|
17
|
+
options[:ext_require] << argv.shift
|
18
|
+
when /^(?:\-r|\-\-require\=)"?([^\s]+)"?/
|
19
|
+
options[:ext_require] ||= []
|
20
|
+
options[:ext_require] << $1
|
21
|
+
when '-E', '--env'
|
22
|
+
unless ENV['LILYPOND_VERSION']
|
23
|
+
STDERR.puts "$LILYPOND_VERSION not set"
|
24
|
+
exit 1
|
25
|
+
end
|
26
|
+
options[:use_version] = ENV['LILYPOND_VERSION']
|
27
|
+
when '-u', '--use'
|
28
|
+
options[:use_version] = argv.shift
|
29
|
+
when /^(?:\-u|\-\-use\=)"?([^\s]+)"?/
|
30
|
+
options[:use_version] = $1
|
31
|
+
when '-n', '--install'
|
32
|
+
options[:install] = true
|
33
|
+
else
|
34
|
+
argv_clean << arg
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
[options, argv_clean]
|
39
|
+
end
|
40
|
+
|
41
|
+
def select_lilypond_version(opts)
|
42
|
+
if opts[:use_version]
|
43
|
+
if opts[:install]
|
44
|
+
Lyp::Lilypond.install_if_missing(opts[:use_version])
|
45
|
+
end
|
46
|
+
Lyp::Lilypond.force_version!(opts[:use_version])
|
47
|
+
end
|
48
|
+
Lyp::Lilypond.check_lilypond!
|
49
|
+
Lyp::Lilypond.current_lilypond.tap do |path|
|
50
|
+
unless path && File.file?(path)
|
51
|
+
STDERR.puts "No version of lilypond found. To install lilypond run 'lyp install lilypond'."
|
52
|
+
exit 1
|
53
|
+
end
|
54
|
+
end
|
55
|
+
rescue => e
|
56
|
+
STDERR.puts e.message
|
57
|
+
exit 1
|
58
|
+
end
|
59
|
+
|
7
60
|
def compile(argv, opts = {})
|
8
61
|
unless argv.last == '-'
|
9
62
|
fn = Lyp.wrap(argv.pop, opts)
|
data/lib/lyp/resolver.rb
CHANGED
@@ -2,6 +2,7 @@ class Lyp::Resolver
|
|
2
2
|
def initialize(user_file, opts = {})
|
3
3
|
@user_file = user_file
|
4
4
|
@opts = opts
|
5
|
+
@ext_require = @opts[:ext_require]
|
5
6
|
end
|
6
7
|
|
7
8
|
# Resolving package dependencies involves two stages:
|
@@ -25,7 +26,8 @@ class Lyp::Resolver
|
|
25
26
|
user_file: @user_file,
|
26
27
|
definite_versions: definite_versions,
|
27
28
|
package_refs: refs,
|
28
|
-
package_dirs: dirs
|
29
|
+
package_dirs: dirs,
|
30
|
+
preload: @opts[:ext_require]
|
29
31
|
}
|
30
32
|
end
|
31
33
|
|
@@ -88,37 +90,18 @@ class Lyp::Resolver
|
|
88
90
|
ly_content.scan(DEP_RE) do |type, ref|
|
89
91
|
case type
|
90
92
|
when INCLUDE, PINCLUDE, PINCLUDE_ONCE
|
91
|
-
|
92
|
-
# command to include package files, e.g. \pinclude "inc/init.ly".
|
93
|
-
#
|
94
|
-
# But a package can also qualify the file reference with the package
|
95
|
-
# name, in order to be able to load files after the package has already
|
96
|
-
# been loaded, e.g. \pinclude "mypack:inc/init.ly"
|
97
|
-
if ref =~ /^([^\:]+)\:(.+)$/
|
98
|
-
# ignore null package (used for testing purposes only)
|
99
|
-
next if $1 == 'null'
|
100
|
-
ref = $2
|
101
|
-
end
|
102
|
-
qualified_path = File.expand_path(ref, dir)
|
103
|
-
queue_file_for_processing(qualified_path, tree, leaf)
|
93
|
+
process_include_command(ref, dir, tree, leaf, opts)
|
104
94
|
when REQUIRE
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
forced_path = File.expand_path($2, dir)
|
109
|
-
end
|
110
|
-
|
111
|
-
ref =~ Lyp::PACKAGE_RE
|
112
|
-
package, version = $1, $2
|
113
|
-
next if package == 'null'
|
114
|
-
|
115
|
-
# set forced path if applicable
|
116
|
-
if forced_path
|
117
|
-
set_forced_package_path(tree, package, forced_path)
|
118
|
-
end
|
95
|
+
process_require_command(ref, dir, tree, leaf, opts)
|
96
|
+
end
|
97
|
+
end
|
119
98
|
|
120
|
-
|
99
|
+
# process any external requires (supplied using the -r command line option)
|
100
|
+
if @ext_require
|
101
|
+
@ext_require.each do |p|
|
102
|
+
process_require_command(p, dir, tree, leaf, opts)
|
121
103
|
end
|
104
|
+
@ext_require = nil
|
122
105
|
end
|
123
106
|
|
124
107
|
tree[:processed_files][path] = true
|
@@ -126,6 +109,41 @@ class Lyp::Resolver
|
|
126
109
|
raise "Cannot find file #{path}"
|
127
110
|
end
|
128
111
|
|
112
|
+
def process_include_command(ref, dir, tree, leaf, opts)
|
113
|
+
# a package would normally use a plain \pinclude or \pincludeOnce
|
114
|
+
# command to include package files, e.g. \pinclude "inc/init.ly".
|
115
|
+
#
|
116
|
+
# But a package can also qualify the file reference with the package
|
117
|
+
# name, in order to be able to load files after the package has already
|
118
|
+
# been loaded, e.g. \pinclude "mypack:inc/init.ly"
|
119
|
+
if ref =~ /^([^\:]+)\:(.+)$/
|
120
|
+
# ignore null package (used for testing purposes only)
|
121
|
+
return if $1 == 'null'
|
122
|
+
ref = $2
|
123
|
+
end
|
124
|
+
qualified_path = File.expand_path(ref, dir)
|
125
|
+
queue_file_for_processing(qualified_path, tree, leaf)
|
126
|
+
end
|
127
|
+
|
128
|
+
def process_require_command(ref, dir, tree, leaf, opts)
|
129
|
+
forced_path = nil
|
130
|
+
if ref =~ /^([^\:]+)\:(.+)$/
|
131
|
+
ref = $1
|
132
|
+
forced_path = File.expand_path($2, dir)
|
133
|
+
end
|
134
|
+
|
135
|
+
ref =~ Lyp::PACKAGE_RE
|
136
|
+
package, version = $1, $2
|
137
|
+
return if package == 'null'
|
138
|
+
|
139
|
+
# set forced path if applicable
|
140
|
+
if forced_path
|
141
|
+
set_forced_package_path(tree, package, forced_path)
|
142
|
+
end
|
143
|
+
|
144
|
+
find_package_versions(ref, tree, leaf, opts)
|
145
|
+
end
|
146
|
+
|
129
147
|
def queue_file_for_processing(path, tree, leaf)
|
130
148
|
(tree[:queue] ||= []) << {path: path, leaf: leaf}
|
131
149
|
end
|
@@ -50,10 +50,21 @@ _[:package_dirs].each do |package, path|
|
|
50
50
|
(hash-set! lyp:package-dirs "{{package}}" {{quote_path[path]}})`
|
51
51
|
end
|
52
52
|
|
53
|
-
|
54
53
|
`
|
55
54
|
)
|
56
55
|
|
57
56
|
#(ly:debug "package loader is ready")
|
57
|
+
`
|
58
|
+
|
59
|
+
if _[:preload]
|
60
|
+
_[:preload].each do |package|
|
61
|
+
`
|
62
|
+
\require "{{package}}"
|
63
|
+
`
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
`
|
58
68
|
\include {{quote_path[user_filename]}}
|
59
|
-
`
|
69
|
+
`
|
70
|
+
|
data/lib/lyp/version.rb
CHANGED
data/lib/lyp/wrapper.rb
CHANGED
@@ -6,7 +6,7 @@ module Lyp
|
|
6
6
|
))
|
7
7
|
|
8
8
|
def self.wrap(fn, opts = {})
|
9
|
-
r = Lyp::Resolver.new(fn).resolve_package_dependencies
|
9
|
+
r = Lyp::Resolver.new(fn, opts).resolve_package_dependencies
|
10
10
|
|
11
11
|
# copy current_package_dir option
|
12
12
|
r[:current_package_dir] = opts[:current_package_dir]
|
@@ -15,6 +15,7 @@ module Lyp
|
|
15
15
|
fn = "#{Lyp::TMP_ROOT}/wrappers/#{File.basename(fn)}"
|
16
16
|
|
17
17
|
File.open(fn, 'w+') {|f| f << WRAPPER_TEMPLATE.render(r)}
|
18
|
+
|
18
19
|
fn
|
19
20
|
end
|
20
21
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lyp-win
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sharon Rosner
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-03-
|
11
|
+
date: 2016-03-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httpclient
|