rmk-ruby 0.2.0 → 0.3.0
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/exe/rmk +36 -6
- data/lib/rmk/vdir.rb +19 -8
- data/lib/rmk/version.rb +1 -1
- data/rmk.gemspec +0 -2
- metadata +3 -18
- data/Rakefile +0 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d0860631aa3de30455ccdba853f9903ceed06434c1f8d1821eacbf9c73d0ceb2
|
4
|
+
data.tar.gz: b3d0657268c1ee001489f6c9668b41b87b6e35cb787f5a4372b1606b4981f3e9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b92087e0b8fa7eb22dd7e8bfc3b214959f679add45004564faddc6ad9d78e1682939af46e56ee123447cca73487e8e5eff85bc9d5fd236424ed4f937e335e71d
|
7
|
+
data.tar.gz: 56c1fa207caec58c36d71b5e5c47047a4f23d98afa547525a90dffb6532d0c17afb889e76b94a6988ce2c6875b0a76c3d6b01b1cb49ac5343d12cfad6e215f15
|
data/exe/rmk
CHANGED
@@ -23,11 +23,10 @@ parser = OptionParser.new{ |opts|
|
|
23
23
|
opts.on '--link-outdir=dir', 'symbol link outdir to this dir, default <system temp dir>/<repository name>, set / to disable' do |dir|
|
24
24
|
cache_options[:link] = dir
|
25
25
|
end
|
26
|
-
opts.on '--name=name', "repository name, default repository root dir's name" do |name| cache_options[:name] = name end
|
27
26
|
|
28
27
|
opts.separator 'variant options:'
|
29
|
-
opts.on '-V', '--variant x,y,z', Array, 'variant list to build' do |list|
|
30
|
-
options[:variants] = list
|
28
|
+
opts.on '-V', '--variant [x,y,z]', Array, 'variant list to build, empty for build all variants' do |list|
|
29
|
+
options[:variants] = list || []
|
31
30
|
end
|
32
31
|
|
33
32
|
opts.separator 'info options:'
|
@@ -42,6 +41,7 @@ parser = OptionParser.new{ |opts|
|
|
42
41
|
}
|
43
42
|
targets = parser.parse(ARGV)
|
44
43
|
Dir.chdir options[:prjroot] if options[:prjroot]
|
44
|
+
clean = options.empty? && cache_options.empty? && targets[0] == 'clean'
|
45
45
|
options_file = '.rmk/options'
|
46
46
|
loaded_options = File.exist?(options_file) ? Marshal.load(IO.binread options_file) : {}
|
47
47
|
if cache_options.empty?
|
@@ -50,9 +50,37 @@ elsif cache_options.any?{|k, v| v != loaded_options[k]}
|
|
50
50
|
Dir.mkdir '.rmk' unless Dir.exist? '.rmk'
|
51
51
|
IO.binwrite options_file, Marshal.dump(cache_options)
|
52
52
|
end
|
53
|
-
|
54
|
-
|
55
|
-
|
53
|
+
def default_options
|
54
|
+
return @options if @options
|
55
|
+
file = 'root.rmk'
|
56
|
+
@options = {}
|
57
|
+
return @options unless File.exist? file
|
58
|
+
Rmk::VDir.parse_file file do |line|
|
59
|
+
match = line.match /^(\w+)\s*=\s*(.*)$/
|
60
|
+
raise "syntax error, 'root.rmk' only support raw var define" unless match
|
61
|
+
@options[match[1].to_sym] = match[2].sub(/(?<!\$)(?:\$\$)*\K\s+$/,'').gsub(/\$([$\s])/){$1}
|
62
|
+
end
|
63
|
+
@options
|
64
|
+
end
|
65
|
+
srcroot = cache_options[:srcroot] || default_options[:srcroot] || '..'
|
66
|
+
outroot = cache_options[:outroot] || default_options[:outroot] || '_Build'
|
67
|
+
link = cache_options[:link] || File.join(ENV['TMP'], default_options[:name] || File.basename(Dir.pwd))
|
68
|
+
if clean
|
69
|
+
raise 'outdir not exist for clean' unless Dir.exist? outroot
|
70
|
+
if Dir.exist? File.join outroot, '.rmk'
|
71
|
+
dir = File.symlink?(outroot) ? File.readlink(outroot) : outroot
|
72
|
+
FileUtils.rmtree dir
|
73
|
+
puts "dir '#{dir}' rmoved"
|
74
|
+
else
|
75
|
+
Dir[File.join outroot, '*/'].each do |dir|
|
76
|
+
next unless Dir.exist? File.join dir, '.rmk'
|
77
|
+
FileUtils.rmtree dir
|
78
|
+
puts "dir '#{dir}' rmoved"
|
79
|
+
end
|
80
|
+
end
|
81
|
+
puts 'clean done'
|
82
|
+
exit
|
83
|
+
end
|
56
84
|
if link && link != '/'
|
57
85
|
require 'fileutils'
|
58
86
|
link = link.gsub(/\$(?:(\$)|{(.*?)})/){$1 || ENV[$2]}.gsub! ?\\, ?\/
|
@@ -73,6 +101,8 @@ else
|
|
73
101
|
end
|
74
102
|
variants = options[:variants]
|
75
103
|
if variants
|
104
|
+
variants = default_options[:variants]&.split /\s*,\s*/ if variants.empty?
|
105
|
+
raise "can't find variants list for build all variants" unless variants && !variants.empty?
|
76
106
|
if variants.size == 1
|
77
107
|
variants = variants[0]
|
78
108
|
outroot = File.join outroot, variants
|
data/lib/rmk/vdir.rb
CHANGED
@@ -269,11 +269,9 @@ class Rmk::VDir
|
|
269
269
|
def parse
|
270
270
|
raise "dir '#{@abs_src_path}' has been parsed" if @state
|
271
271
|
@state = []
|
272
|
-
file = join_abs_src_path '
|
272
|
+
file = join_abs_src_path 'template.rmk'
|
273
273
|
@defaultfile = file if ::File.exist? file
|
274
|
-
file =
|
275
|
-
parse_file file if ::File.exist? file
|
276
|
-
file = join_abs_src_path 'dir.rmk'
|
274
|
+
file = join_abs_src_path 'rmk.rmk'
|
277
275
|
if ::File.exist? file
|
278
276
|
parse_file file
|
279
277
|
elsif @defaultfile
|
@@ -285,6 +283,14 @@ class Rmk::VDir
|
|
285
283
|
|
286
284
|
def parse_file(file)
|
287
285
|
last_state, @state = @state, [{indent:0, type:nil, condition:nil, vars:@vars}]
|
286
|
+
Rmk::VDir.parse_file file, &method(:parse_line)
|
287
|
+
@state = last_state
|
288
|
+
rescue
|
289
|
+
$!.backtrace[-1] << (@virtual_path ? " in vpath '#{@virtual_path}'" : "in vpath '<root>'")
|
290
|
+
raise
|
291
|
+
end
|
292
|
+
|
293
|
+
def self.parse_file(file, &parse_line)
|
288
294
|
lines = IO.readlines file
|
289
295
|
markid = lid = 0
|
290
296
|
while lid < lines.size
|
@@ -296,16 +302,21 @@ class Rmk::VDir
|
|
296
302
|
lid += 1
|
297
303
|
lines[lid]&.lstrip!
|
298
304
|
end
|
299
|
-
parse_line lid < lines.size ? line + lines[lid] : line
|
305
|
+
parse_line.call lid < lines.size ? line + lines[lid] : line
|
300
306
|
lid += 1
|
301
307
|
end
|
302
|
-
@state = last_state
|
303
308
|
rescue
|
304
|
-
|
309
|
+
markid = "#{file}:#{markid + 1}:"
|
310
|
+
if $!.respond_to? :rmk_mark
|
311
|
+
$!.set_backtrace $!.backtrace.push markid
|
312
|
+
else
|
313
|
+
$!.define_singleton_method(:rmk_mark){}
|
314
|
+
$!.set_backtrace [markid]
|
315
|
+
end
|
305
316
|
raise
|
306
317
|
end
|
307
318
|
|
308
|
-
def parse_line(line
|
319
|
+
def parse_line(line)
|
309
320
|
match = /^(?<indent> *|\t*)(?:(?<firstword>\w+)\s*(?<content>.+)?)?$/.match line
|
310
321
|
raise 'syntax error' unless match
|
311
322
|
indent, firstword, line = match[:indent].size, match[:firstword], match[:content]
|
data/lib/rmk/version.rb
CHANGED
data/rmk.gemspec
CHANGED
metadata
CHANGED
@@ -1,29 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rmk-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- pbl
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-01-
|
12
|
-
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: rake
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - ">="
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: 12.3.0
|
20
|
-
type: :development
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - ">="
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: 12.3.0
|
11
|
+
date: 2018-01-08 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
27
13
|
description: build tool like make, tup, ninja...
|
28
14
|
email:
|
29
15
|
- a@pbl.pw
|
@@ -37,7 +23,6 @@ files:
|
|
37
23
|
- Gemfile
|
38
24
|
- LICENSE
|
39
25
|
- README.md
|
40
|
-
- Rakefile
|
41
26
|
- bin/console
|
42
27
|
- bin/setup
|
43
28
|
- exe/rmk
|