irpack 0.2.3 → 0.2.4
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/irpack.rb +22 -0
- data/lib/irpack/application.rb +4 -0
- data/lib/irpack/entrypoint.rb +2 -0
- data/lib/irpack/missing.rb +1 -1
- data/test/test_application.rb +7 -0
- data/test/test_irpack.rb +38 -0
- metadata +5 -3
data/lib/irpack.rb
CHANGED
@@ -57,10 +57,31 @@ module IRPack
|
|
57
57
|
}.collect {|asm| asm.location }
|
58
58
|
end
|
59
59
|
|
60
|
+
def ironruby_standard_library_version
|
61
|
+
ruby_context = binding.clr_member(:LocalScope).call.ruby_context
|
62
|
+
ruby_context.standard_library_version
|
63
|
+
end
|
64
|
+
|
65
|
+
def ironruby_library_path
|
66
|
+
ruby_context = binding.clr_member(:LocalScope).call.ruby_context
|
67
|
+
binpath = ENV[ruby_context.class.bin_dir_environment_variable] ||
|
68
|
+
File.dirname(System::Reflection::Assembly.get_entry_assembly.location)
|
69
|
+
File.expand_path(File.join(binpath, '..', 'Lib'))
|
70
|
+
end
|
71
|
+
|
72
|
+
def ironruby_libraries(dstpath='stdlib', srcpath=ironruby_library_path)
|
73
|
+
res = {}
|
74
|
+
Dir.glob(File.join(srcpath, "{ironruby,ruby/#{ironruby_standard_library_version}}", '**', '*')) do |fn|
|
75
|
+
res[fn] = fn.sub(/^#{srcpath}/, dstpath) if File.file?(fn)
|
76
|
+
end
|
77
|
+
res
|
78
|
+
end
|
79
|
+
|
60
80
|
def pack(output_file, files, entry_file, opts={})
|
61
81
|
opts = {
|
62
82
|
:target => :exe,
|
63
83
|
:compress => false,
|
84
|
+
:complete => false,
|
64
85
|
:embed_references => true,
|
65
86
|
:module_name => path_to_module_name(output_file)
|
66
87
|
}.update(opts)
|
@@ -71,6 +92,7 @@ module IRPack
|
|
71
92
|
references = opts[:references] || ironruby_assemblies
|
72
93
|
compress = opts[:compress]
|
73
94
|
pack_files = {}.merge(files)
|
95
|
+
pack_files = ironruby_libraries.merge(pack_files) if opts[:complete]
|
74
96
|
if opts[:embed_references] then
|
75
97
|
references.each do |asm|
|
76
98
|
pack_files[asm] = File.basename(asm)
|
data/lib/irpack/application.rb
CHANGED
@@ -31,6 +31,7 @@ module IRPack
|
|
31
31
|
:output_file,
|
32
32
|
:target,
|
33
33
|
:compress,
|
34
|
+
:complete,
|
34
35
|
:embed_references,
|
35
36
|
:entry_file,
|
36
37
|
:files) do
|
@@ -40,6 +41,7 @@ module IRPack
|
|
40
41
|
args.output_file = nil
|
41
42
|
args.target = :exe
|
42
43
|
args.compress = false
|
44
|
+
args.complete = false
|
43
45
|
args.embed_references = true
|
44
46
|
args.entry_file = nil
|
45
47
|
args.files = {}
|
@@ -49,6 +51,7 @@ module IRPack
|
|
49
51
|
opt.on('--window', 'Generate window app.') { args.target = :winexe }
|
50
52
|
opt.on('--console', 'Generate console app.[default]') { args.target = :exe }
|
51
53
|
opt.on('--compress', 'Compress package.') { args.compress = true }
|
54
|
+
opt.on('--complete', 'Embed all standard libraries.') { args.complete = true }
|
52
55
|
opt.on('--no-embed', 'Do not embed IronRuby assemblies.') {|v| args.embed_references = v }
|
53
56
|
opt.banner = "Usage: #{$0} [options] ENTRYFILE [EMBEDFILES...]"
|
54
57
|
opt.parse!(argv)
|
@@ -79,6 +82,7 @@ module IRPack
|
|
79
82
|
args.entry_file,
|
80
83
|
:target => args.target,
|
81
84
|
:compress => args.compress,
|
85
|
+
:complete => args.complete,
|
82
86
|
:embed_references => args.embed_references)
|
83
87
|
return 0
|
84
88
|
end
|
data/lib/irpack/entrypoint.rb
CHANGED
@@ -178,6 +178,8 @@ module IRPack
|
|
178
178
|
runtime_setup.LanguageSetups.Add(IronRuby.Ruby.CreateRubySetup());
|
179
179
|
runtime_setup.Options["MainFile"] = entry_file;
|
180
180
|
runtime_setup.Options["Arguments"] = args;
|
181
|
+
runtime_setup.Options["ApplicationBase"] = entry_path;
|
182
|
+
runtime_setup.Options["StandardLibrary"] = Path.Combine(entry_path, "stdlib");
|
181
183
|
runtime_setup.HostType = typeof(IRHost);
|
182
184
|
runtime_setup.HostArguments = new object[] { package };
|
183
185
|
var engine = IronRuby.Ruby.GetEngine(IronRuby.Ruby.CreateRuntime(runtime_setup));
|
data/lib/irpack/missing.rb
CHANGED
data/test/test_application.rb
CHANGED
@@ -39,6 +39,7 @@ class TC_ApplicationArguments < Test::Unit::TestCase
|
|
39
39
|
argv = ['entry.rb']
|
40
40
|
args = IRPack::Application::Arguments.parse!(argv)
|
41
41
|
assert(!args.compress)
|
42
|
+
assert(!args.complete)
|
42
43
|
assert(args.embed_references)
|
43
44
|
assert_equal(:exe, args.target)
|
44
45
|
assert_equal(File.expand_path('entry.exe'), File.expand_path(args.output_file))
|
@@ -77,6 +78,12 @@ class TC_ApplicationArguments < Test::Unit::TestCase
|
|
77
78
|
assert(args.compress)
|
78
79
|
end
|
79
80
|
|
81
|
+
def test_parse_complete
|
82
|
+
argv = ['--complete', 'entry.rb']
|
83
|
+
args = IRPack::Application::Arguments.parse!(argv)
|
84
|
+
assert(args.complete)
|
85
|
+
end
|
86
|
+
|
80
87
|
def test_parse_basedir
|
81
88
|
argv = [
|
82
89
|
'-b', 'foo/bar',
|
data/test/test_irpack.rb
CHANGED
@@ -46,6 +46,27 @@ class TC_IRPack < Test::Unit::TestCase
|
|
46
46
|
end
|
47
47
|
end
|
48
48
|
|
49
|
+
def test_ironruby_library_path_with_env
|
50
|
+
ENV['IRONRUBY_11'] = 'c:/foo/bar/bin'
|
51
|
+
assert_equal('c:/foo/bar/Lib', IRPack.ironruby_library_path)
|
52
|
+
end
|
53
|
+
|
54
|
+
def test_ironruby_library_path_without_env
|
55
|
+
ENV['IRONRUBY_11'] = nil
|
56
|
+
binpath = File.dirname(System::Reflection::Assembly.get_entry_assembly.location)
|
57
|
+
assert_equal(File.expand_path(File.join(binpath, '../Lib')), IRPack.ironruby_library_path)
|
58
|
+
end
|
59
|
+
|
60
|
+
def test_ironruby_libraries
|
61
|
+
libs = IRPack.ironruby_libraries
|
62
|
+
assert(libs.size>0)
|
63
|
+
libs.each do |src, dst|
|
64
|
+
assert_match(/^stdlib\/((ruby\/1\.9\.1|ironruby)\/.+)/, dst)
|
65
|
+
assert_match(/#{$1}$/, src)
|
66
|
+
assert(File.file?(src))
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
49
70
|
def test_pack
|
50
71
|
entry = Tempfile.open(File.basename(__FILE__)) do |f|
|
51
72
|
f.write <<-RB
|
@@ -71,5 +92,22 @@ class TC_IRPack < Test::Unit::TestCase
|
|
71
92
|
assert_equal(File.expand_path(outfile), IRPack.pack(outfile, files, 'entry.rb'))
|
72
93
|
assert_equal('Hello World!', `#{outfile}`.chomp)
|
73
94
|
end
|
95
|
+
|
96
|
+
def test_pack_with_complete
|
97
|
+
entry = Tempfile.open(File.basename(__FILE__)) do |f|
|
98
|
+
f.write <<-RB
|
99
|
+
require 'stringio'
|
100
|
+
io = StringIO.new('Hello')
|
101
|
+
puts io.read
|
102
|
+
RB
|
103
|
+
f.path
|
104
|
+
end
|
105
|
+
files = {
|
106
|
+
entry => 'entry.rb',
|
107
|
+
}
|
108
|
+
outfile = tempfilename('.exe')
|
109
|
+
assert_equal(File.expand_path(outfile), IRPack.pack(outfile, files, 'entry.rb', complete: true))
|
110
|
+
assert_equal('Hello', `#{outfile}`.chomp)
|
111
|
+
end
|
74
112
|
end
|
75
113
|
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: irpack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.2.
|
5
|
+
version: 0.2.4
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- kumaryu
|
@@ -10,7 +10,8 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-
|
13
|
+
date: 2011-10-22 00:00:00 +09:00
|
14
|
+
default_executable:
|
14
15
|
dependencies: []
|
15
16
|
|
16
17
|
description: |
|
@@ -41,6 +42,7 @@ files:
|
|
41
42
|
- test/test_missing.rb
|
42
43
|
- test/test_packager.rb
|
43
44
|
- test/utils.rb
|
45
|
+
has_rdoc: true
|
44
46
|
homepage: http://github.com/kumaryu/irpack
|
45
47
|
licenses: []
|
46
48
|
|
@@ -64,7 +66,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
64
66
|
requirements:
|
65
67
|
- none
|
66
68
|
rubyforge_project:
|
67
|
-
rubygems_version: 1.
|
69
|
+
rubygems_version: 1.6.2
|
68
70
|
signing_key:
|
69
71
|
specification_version: 3
|
70
72
|
summary: Generate a standalone executable file from IronRuby scripts.
|