irpack 0.2.4 → 0.2.5
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.
- data/README.rdoc +193 -0
- data/lib/irpack.rb +23 -7
- data/lib/irpack/application.rb +69 -6
- data/lib/irpack/entrypoint.rb +55 -11
- data/test/test_application.rb +95 -0
- data/test/test_entrypoint.rb +172 -4
- metadata +17 -8
data/README.rdoc
ADDED
@@ -0,0 +1,193 @@
|
|
1
|
+
=irpack
|
2
|
+
|
3
|
+
irpack converts your IronRuby scripts to a standalone .exe file.
|
4
|
+
Generated executable does not require IronRuby, but only .NET Framework or mono.
|
5
|
+
|
6
|
+
==Requirements
|
7
|
+
IronRuby 1.1.3 or later.
|
8
|
+
|
9
|
+
==Installation
|
10
|
+
|
11
|
+
$ igem install irpack
|
12
|
+
|
13
|
+
You need to use igem (gem command for IronRuby) instead of gem.
|
14
|
+
|
15
|
+
==Usage
|
16
|
+
$ irpack [options] ENTRYFILE [EMBEDFILES...]
|
17
|
+
-b BASEDIR Specify base directory. [base of ENTRYFILE]
|
18
|
+
-o OUTPUTFILE Specify output file name.
|
19
|
+
--window Generate window app.
|
20
|
+
--console Generate console app.[default]
|
21
|
+
--compress Compress package.
|
22
|
+
--complete Embed all standard libraries.
|
23
|
+
--no-embed Do not embed IronRuby assemblies.
|
24
|
+
Runtime options:
|
25
|
+
-Idirectory specify $LOAD_PATH directory (may be used more than once)
|
26
|
+
-rlibrary require the library, before executing your script
|
27
|
+
-d set debugging flags (set $DEBUG to true)
|
28
|
+
-D emit debugging information (PDBs) for Visual Studio debugger
|
29
|
+
-v print version number, then turn on verbose mode
|
30
|
+
-w turn warnings on for your script
|
31
|
+
-W[level] set warning level; 0=silence, 1=medium (default), 2=verbose
|
32
|
+
--trace enable support for set_trace_func
|
33
|
+
--profile enable support for 'pi = IronRuby::Clr.profile { block_to_profile }'
|
34
|
+
--exception-detail enable ExceptionDetail mode
|
35
|
+
--no-adaptive-compilation
|
36
|
+
disable adaptive compilation - all code will be compiled
|
37
|
+
--compilation-threshold THRESHOLD
|
38
|
+
the number of iterations before the interpreter starts compiling
|
39
|
+
--pass-exceptions do not catch exceptions that are unhandled by script code
|
40
|
+
--private-binding enable binding to private members
|
41
|
+
--show-clr-exceptions
|
42
|
+
display CLS Exception information
|
43
|
+
|
44
|
+
Specify rb file on ENTRYFILE to generate exe. Executables includes ENTRYFILE and
|
45
|
+
IronRuby dlls in their resource.
|
46
|
+
|
47
|
+
When runtime, script can open EMBEDFILES with relative path from BASEDIR.
|
48
|
+
|
49
|
+
for example:
|
50
|
+
$ irpack -o hoge/fuga.exe -d foo bar/entry.rb foo/hello.rb
|
51
|
+
|
52
|
+
hoge/fuga.exe runs embedded bar/entry.rb.
|
53
|
+
To load foo/hello.rb, require 'hello' (relative path from BASEDIR 'foo').
|
54
|
+
A real file is used if hello.rb exists in both embedded and real filesystem in
|
55
|
+
same directory as executable.
|
56
|
+
|
57
|
+
To specify exe icon, embed ico file.
|
58
|
+
|
59
|
+
To generate application which has no console window use '--window' option.
|
60
|
+
|
61
|
+
'--no-embed' option exclude IronRuby dlls from embedded files. A generated
|
62
|
+
executable requires IronRuby dlls.
|
63
|
+
|
64
|
+
If scripts use any standard libraries, embed them too. '--complete' embeds
|
65
|
+
all of standard libraries into exe.
|
66
|
+
|
67
|
+
Executable file is compacted by '--compress' option that compresses embedded
|
68
|
+
files. To load compressed file costs extra time.
|
69
|
+
|
70
|
+
Runtime options are passed to script engine when generated executable started
|
71
|
+
as well as ir.exe.
|
72
|
+
|
73
|
+
==Limitations
|
74
|
+
Embedded native dlls and mixed (C++/CLI) assemblies are not loadable.
|
75
|
+
|
76
|
+
=irpack
|
77
|
+
|
78
|
+
irpackはIronRubyのスクリプトを単体で動く.exeファイルに変換するアプリケーションで
|
79
|
+
す。生成した実行ファイルは.NET FrameworkやmonoさえあればIronRubyをインストールし
|
80
|
+
ていない環境でも動かすことができます。
|
81
|
+
|
82
|
+
==動作環境
|
83
|
+
IronRuby 1.1.3以降。
|
84
|
+
|
85
|
+
==インストール
|
86
|
+
|
87
|
+
$ igem install irpack
|
88
|
+
|
89
|
+
IronRubyでしか動かないのでigem (IronRubyのgemコマンド)を使ってインストールしてく
|
90
|
+
ださい。
|
91
|
+
|
92
|
+
==使い方
|
93
|
+
|
94
|
+
$ irpack [options] ENTRYFILE [EMBEDFILES...]
|
95
|
+
-b BASEDIR 埋め込み基準のディレクトリを指定します。[ENTRYFILEのあるディレクトリ]
|
96
|
+
-o OUTPUTFILE 出力ファイル名を指定します。[ENTRYFILEの拡張子を.exeにしたもの]
|
97
|
+
--window ウィンドウアプリを生成します。
|
98
|
+
--console コンソールアプリを生成します。[default]
|
99
|
+
--compress パッケージの圧縮をします。
|
100
|
+
--complete 全ての標準ライブラリを埋め込みます。
|
101
|
+
--no-embed IronRubyの埋め込みを行いません。
|
102
|
+
実行時オプション:
|
103
|
+
-Idirectory $LOAD_PATHディレクトリを指定します。(複数回指定できます。)
|
104
|
+
-rlibrary スクリプト実行前にlibraryを読み込みます。
|
105
|
+
-d デバッグフラグを設定します。($DEBUGをtrueに設定します。)
|
106
|
+
-D Visual Studioデバッガ用にデバッグ情報(PDB)を生成します。
|
107
|
+
-v バージョン番号を出力し、冗長モードを有効にします。
|
108
|
+
-w スクリプトの警告を有効します。
|
109
|
+
-W[level] 警告レベルを設定します: 0=無し, 1=普通(デフォルト), 2=冗長
|
110
|
+
--trace set_trace_funcサポートを有効にします。
|
111
|
+
--profile CLRプロファイラを有効にします。次のように使います
|
112
|
+
'pi = IronRuby::Clr.profile { block_to_profile }'
|
113
|
+
--exception-detail 例外詳細モードを有効にします。
|
114
|
+
--no-adaptive-compilation
|
115
|
+
適応型コンパイルを無効にします。全てのコードがコンパイルされます。
|
116
|
+
--compilation-threshold THRESHOLD
|
117
|
+
インタプリタがコンパイル開始するまでの繰り返し回数を指定します。
|
118
|
+
--pass-exceptions スクリプトで処理されなかった例外をcatchしないようにします。
|
119
|
+
--private-binding privateメンバへのバインディングを有効にします。
|
120
|
+
--show-clr-exceptions
|
121
|
+
CLS例外情報を表示します。
|
122
|
+
|
123
|
+
ENTRYFILEに起動するrbファイルを指定するとexeファイルが生成されます。exeファイル
|
124
|
+
にはENTRYFILEとIronRubyのdllが埋め込まれるので.NET Frameworkやmonoが入っている環
|
125
|
+
境でIronRubyのインストール無しに実行することができます。
|
126
|
+
|
127
|
+
ENTRYFILEに続けてファイルを指定することによって他のファイルもexeに埋め込むことが
|
128
|
+
できます。
|
129
|
+
|
130
|
+
埋め込まれたファイルはスクリプト中からは「実行ファイルのディレクトリ/基準ディレク
|
131
|
+
トリからの相対パス」に存在するように見えます。
|
132
|
+
たとえば、
|
133
|
+
|
134
|
+
$ irpack -o hoge/fuga.exe -d foo bar/entry.rb foo/hello.rb
|
135
|
+
|
136
|
+
としたときにfuga.exeの実行中(bar/entry.rb)からはfoo/hello.rbはhoge/hello.rb
|
137
|
+
(fuga.exeのあるディレクトリhoge)にあるように見えます。
|
138
|
+
もしhoge/hello.rbが本当にファイルとして存在した場合はそちらが優先して開かれます。
|
139
|
+
|
140
|
+
EMBEDFILESにアイコン(.ico)ファイルを指定するとexeのアイコンとして使用します。
|
141
|
+
|
142
|
+
'--console'や'--window'オプションでコンソールアプリを生成するかウィンドウアプリを
|
143
|
+
生成するか指定できます。省略時はコンソールアプリになります。ウィンドウアプリの場
|
144
|
+
合はコンソールウィンドウが開かなくなりますが、標準入出力は使用できません。また例
|
145
|
+
外が捕捉されずに落ちた場合のメッセージは標準エラー出力に出るようになっていますが、
|
146
|
+
ウィンドウアプリの場合はそれも表示されません。
|
147
|
+
|
148
|
+
'--no-embed'オプションを指定するとIronRuby.dllなどをexeに埋め込みません。配布する
|
149
|
+
場合は実行環境にIronRubyがインストールするかIronRuby.dllなどの必要なdllを同じディ
|
150
|
+
レクトリに置いて実行してください。
|
151
|
+
|
152
|
+
標準ライブラリを使用する場合は、使用するライブラリも埋め込まなければいけません。
|
153
|
+
'--complete'オプションを指定すると標準ライブラリを全て埋め込みます。実行ファイル
|
154
|
+
サイズはその分大きくなります。
|
155
|
+
|
156
|
+
'--compress'オプションは埋め込んだファイルを圧縮します。実行ファイルのサイズが小さ
|
157
|
+
くなりますが、読み込みに時間がかかるようになります。
|
158
|
+
|
159
|
+
実行時オプションは生成した実行ファイルの起動時にスクリプトエンジンに渡されます。
|
160
|
+
ir.exeに指定するのと同じものです。
|
161
|
+
|
162
|
+
==制限
|
163
|
+
C++/CLIの混合アセンブリやネイティブdllは埋め込めません。
|
164
|
+
|
165
|
+
生成したexeは生成に使用したIronRubyと同じバージョンの.NET Frameworkかそれに対応
|
166
|
+
するmonoが必要です。
|
167
|
+
.NET Framework 4のir.exeを使って生成したexeを実行するには.NET Framework4か
|
168
|
+
mono 2.8以降が必要ということです。
|
169
|
+
|
170
|
+
==License
|
171
|
+
zlib/libpng License.
|
172
|
+
|
173
|
+
Copyright (c) 2010-2011 Ryuichi Sakamoto.
|
174
|
+
|
175
|
+
This software is provided 'as-is', without any express or implied
|
176
|
+
warranty. In no event will the authors be held liable for any damages
|
177
|
+
arising from the use of this software.
|
178
|
+
|
179
|
+
Permission is granted to anyone to use this software for any purpose,
|
180
|
+
including commercial applications, and to alter it and redistribute it
|
181
|
+
freely, subject to the following restrictions:
|
182
|
+
|
183
|
+
1. The origin of this software must not be misrepresented; you must not
|
184
|
+
claim that you wrote the original software. If you use this software
|
185
|
+
in a product, an acknowledgment in the product documentation would be
|
186
|
+
appreciated but is not required.
|
187
|
+
|
188
|
+
2. Altered source versions must be plainly marked as such, and must not be
|
189
|
+
misrepresented as being the original software.
|
190
|
+
|
191
|
+
3. This notice may not be removed or altered from any source
|
192
|
+
distribution.
|
193
|
+
|
data/lib/irpack.rb
CHANGED
@@ -33,6 +33,7 @@ module IRPack
|
|
33
33
|
Microsoft.Dynamic
|
34
34
|
Microsoft.Scripting
|
35
35
|
Microsoft.Scripting.Core
|
36
|
+
Microsoft.Scripting.Metadata
|
36
37
|
IronRuby
|
37
38
|
IronRuby.Libraries
|
38
39
|
IronRuby.Libraries.Yaml
|
@@ -77,14 +78,29 @@ module IRPack
|
|
77
78
|
res
|
78
79
|
end
|
79
80
|
|
80
|
-
def pack(output_file, files, entry_file, opts={})
|
81
|
+
def pack(output_file, files, entry_file, opts={}, runtime_options={})
|
81
82
|
opts = {
|
82
|
-
:
|
83
|
-
:
|
84
|
-
:
|
85
|
-
:
|
86
|
-
:
|
83
|
+
target: :exe,
|
84
|
+
compress: false,
|
85
|
+
complete: false,
|
86
|
+
embed_references: true,
|
87
|
+
seach_paths: [],
|
88
|
+
module_name: path_to_module_name(output_file),
|
87
89
|
}.update(opts)
|
90
|
+
runtime_options = {
|
91
|
+
DebugMode: false,
|
92
|
+
PrivateBinding: false,
|
93
|
+
NoAdaptiveCompilation: false,
|
94
|
+
CompilationThreshold: -1,
|
95
|
+
ExceptionDetail: false,
|
96
|
+
ShowClrExceptions: false,
|
97
|
+
Profile: false,
|
98
|
+
Verbosity: 1,
|
99
|
+
DebugVariable: false,
|
100
|
+
EnableTracing: false,
|
101
|
+
RequiredPaths: [],
|
102
|
+
SearchPaths: [],
|
103
|
+
}.update(runtime_options)
|
88
104
|
output_file = File.expand_path(output_file)
|
89
105
|
basename = File.basename(output_file, '.*')
|
90
106
|
module_name = opts[:module_name]
|
@@ -101,7 +117,7 @@ module IRPack
|
|
101
117
|
|
102
118
|
Dir.mktmpdir(File.basename($0,'.*')) do |tmp_path|
|
103
119
|
entry_dll = File.join(tmp_path, module_name+'.EntryPoint.dll')
|
104
|
-
EntryPoint.compile(entry_dll, module_name, entry_file, references)
|
120
|
+
EntryPoint.compile(entry_dll, module_name, entry_file, references, runtime_options)
|
105
121
|
pack_files[entry_dll] = File.basename(entry_dll)
|
106
122
|
|
107
123
|
package_file = File.join(tmp_path, basename+'.pkg')
|
data/lib/irpack/application.rb
CHANGED
@@ -33,6 +33,7 @@ module IRPack
|
|
33
33
|
:compress,
|
34
34
|
:complete,
|
35
35
|
:embed_references,
|
36
|
+
:runtime_options,
|
36
37
|
:entry_file,
|
37
38
|
:files) do
|
38
39
|
def self.parse!(argv)
|
@@ -45,7 +46,21 @@ module IRPack
|
|
45
46
|
args.embed_references = true
|
46
47
|
args.entry_file = nil
|
47
48
|
args.files = {}
|
48
|
-
|
49
|
+
args.runtime_options = {
|
50
|
+
DebugMode: false,
|
51
|
+
PrivateBinding: false,
|
52
|
+
NoAdaptiveCompilation: false,
|
53
|
+
CompilationThreshold: -1,
|
54
|
+
ExceptionDetail: false,
|
55
|
+
ShowClrExceptions: false,
|
56
|
+
Profile: false,
|
57
|
+
Verbosity: 1,
|
58
|
+
DebugVariable: false,
|
59
|
+
EnableTracing: false,
|
60
|
+
RequiredPaths: [],
|
61
|
+
SearchPaths: [],
|
62
|
+
}
|
63
|
+
opt = OptionParser.new("Usage: #{$0} [options] ENTRYFILE [EMBEDFILES...]", 24, ' ')
|
49
64
|
opt.on('-b BASEDIR', 'Specify base directory. [base of ENTRYFILE]') {|v| basedir = v }
|
50
65
|
opt.on('-o OUTPUTFILE', 'Specify output file name.') {|v| args.output_file = v }
|
51
66
|
opt.on('--window', 'Generate window app.') { args.target = :winexe }
|
@@ -53,7 +68,52 @@ module IRPack
|
|
53
68
|
opt.on('--compress', 'Compress package.') { args.compress = true }
|
54
69
|
opt.on('--complete', 'Embed all standard libraries.') { args.complete = true }
|
55
70
|
opt.on('--no-embed', 'Do not embed IronRuby assemblies.') {|v| args.embed_references = v }
|
56
|
-
opt.
|
71
|
+
opt.separator('Runtime options:')
|
72
|
+
opt.on('-Idirectory', 'specify $LOAD_PATH directory (may be used more than once)') {|v|
|
73
|
+
args.runtime_options[:SearchPaths] << v
|
74
|
+
}
|
75
|
+
opt.on('-rlibrary', 'require the library, before executing your script') {|v|
|
76
|
+
args.runtime_options[:RequiredPaths] << v
|
77
|
+
}
|
78
|
+
opt.on('-d', 'set debugging flags (set $DEBUG to true)') {|v|
|
79
|
+
args.runtime_options[:DebugVariable] = v
|
80
|
+
}
|
81
|
+
opt.on('-D', 'emit debugging information (PDBs) for Visual Studio debugger') {|v|
|
82
|
+
args.runtime_options[:DebugMode] = v
|
83
|
+
}
|
84
|
+
opt.on('-v', 'print version number, then turn on verbose mode') {|v|
|
85
|
+
args.runtime_options[:Verbosity] = 2
|
86
|
+
}
|
87
|
+
opt.on('-w', 'turn warnings on for your script') {|v|
|
88
|
+
args.runtime_options[:Verbosity] = 2
|
89
|
+
}
|
90
|
+
opt.on('-W[level]', 'set warning level; 0=silence, 1=medium (default), 2=verbose', Integer) {|v|
|
91
|
+
args.runtime_options[:Verbosity] = (v || 2).to_i
|
92
|
+
}
|
93
|
+
opt.on('--trace', 'enable support for set_trace_func') {|v|
|
94
|
+
args.runtime_options[:EnableTracing] = v
|
95
|
+
}
|
96
|
+
opt.on('--profile', "enable support for 'pi = IronRuby::Clr.profile { block_to_profile }'") {|v|
|
97
|
+
args.runtime_options[:Profile] = v
|
98
|
+
}
|
99
|
+
opt.on('--exception-detail', 'enable ExceptionDetail mode') {|v|
|
100
|
+
args.runtime_options[:ExceptionDetail] = v
|
101
|
+
}
|
102
|
+
opt.on('--no-adaptive-compilation', 'disable adaptive compilation - all code will be compiled') {|v|
|
103
|
+
args.runtime_options[:NoAdaptiveCompilation] = true
|
104
|
+
}
|
105
|
+
opt.on('--compilation-threshold THRESHOLD', 'the number of iterations before the interpreter starts compiling', Integer) {|v|
|
106
|
+
args.runtime_options[:CompilationThreshold] = v.to_i
|
107
|
+
}
|
108
|
+
opt.on('--pass-exceptions', 'do not catch exceptions that are unhandled by script code') {|v|
|
109
|
+
args.runtime_options[:PassExceptions] = v
|
110
|
+
}
|
111
|
+
opt.on('--private-binding', 'enable binding to private members') {|v|
|
112
|
+
args.runtime_options[:PrivateBinding] = v
|
113
|
+
}
|
114
|
+
opt.on('--show-clr-exceptions', 'display CLS Exception information') {|v|
|
115
|
+
args.runtime_options[:ShowClrExceptions] = v
|
116
|
+
}
|
57
117
|
opt.parse!(argv)
|
58
118
|
|
59
119
|
if argv.size<1 then
|
@@ -80,10 +140,13 @@ module IRPack
|
|
80
140
|
args.output_file,
|
81
141
|
args.files,
|
82
142
|
args.entry_file,
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
143
|
+
{
|
144
|
+
target: args.target,
|
145
|
+
compress: args.compress,
|
146
|
+
complete: args.complete,
|
147
|
+
embed_references: args.embed_references,
|
148
|
+
},
|
149
|
+
args.runtime_options)
|
87
150
|
return 0
|
88
151
|
end
|
89
152
|
end
|
data/lib/irpack/entrypoint.rb
CHANGED
@@ -176,19 +176,46 @@ module IRPack
|
|
176
176
|
var entry_file = Path.Combine(entry_path, "<%= entry_file %>");
|
177
177
|
var runtime_setup = new ScriptRuntimeSetup();
|
178
178
|
runtime_setup.LanguageSetups.Add(IronRuby.Ruby.CreateRubySetup());
|
179
|
-
runtime_setup.
|
180
|
-
runtime_setup.
|
179
|
+
runtime_setup.DebugMode = <%= options[:DebugMode] %>;
|
180
|
+
runtime_setup.PrivateBinding = <%= options[:PrivateBinding] %>;
|
181
|
+
runtime_setup.Options["NoAdaptiveCompilation"] = <%= options[:NoAdaptiveCompilation] %>;
|
182
|
+
runtime_setup.Options["CompilationThreshold"] = <%= options[:CompilationThreshold] %>;
|
183
|
+
runtime_setup.Options["ExceptionDetail"] = <%= options[:ExceptionDetail] %>;
|
184
|
+
runtime_setup.Options["ShowClrExceptions"] = <%= options[:ShowClrExceptions] %>;
|
185
|
+
runtime_setup.Options["Profile"] = <%= options[:Profile] %>;
|
186
|
+
runtime_setup.Options["Verbosity"] = <%= options[:Verbosity] %>;
|
187
|
+
runtime_setup.Options["DebugVariable"] = <%= options[:DebugVariable] %>;
|
188
|
+
runtime_setup.Options["EnableTracing"] = <%= options[:EnableTracing] %>;
|
189
|
+
runtime_setup.Options["RequiredPaths"] = new string[] {
|
190
|
+
<%= options[:RequiredPaths].collect {|v| '@"' + v + '"'}.join(", ") %>
|
191
|
+
};
|
192
|
+
var search_paths = new string[] {
|
193
|
+
<%= options[:SearchPaths].collect {|v| '@"' + v + '"'}.join(", ") %>
|
194
|
+
};
|
195
|
+
for (int i=0; i<search_paths.Length; i++) {
|
196
|
+
if (!Path.IsPathRooted(search_paths[i])) {
|
197
|
+
search_paths[i] = Path.GetFullPath(Path.Combine(entry_path, search_paths[i]));
|
198
|
+
}
|
199
|
+
}
|
200
|
+
runtime_setup.Options["SearchPaths"] = search_paths;
|
201
|
+
runtime_setup.Options["MainFile"] = entry_file;
|
202
|
+
runtime_setup.Options["Arguments"] = args;
|
181
203
|
runtime_setup.Options["ApplicationBase"] = entry_path;
|
182
|
-
|
204
|
+
var stdlib = "<%= options[:StandardLibrary] %>";
|
205
|
+
if (Path.IsPathRooted(stdlib)) {
|
206
|
+
runtime_setup.Options["StandardLibrary"] = stdlib;
|
207
|
+
}
|
208
|
+
else {
|
209
|
+
runtime_setup.Options["StandardLibrary"] = Path.GetFullPath(Path.Combine(entry_path, stdlib));
|
210
|
+
}
|
183
211
|
runtime_setup.HostType = typeof(IRHost);
|
184
212
|
runtime_setup.HostArguments = new object[] { package };
|
185
213
|
var engine = IronRuby.Ruby.GetEngine(IronRuby.Ruby.CreateRuntime(runtime_setup));
|
214
|
+
<% if options[:PassExceptions] then %>
|
215
|
+
return engine.CreateScriptSourceFromFile(entry_file).ExecuteProgram();
|
216
|
+
<% else %>
|
186
217
|
try {
|
187
|
-
engine.
|
188
|
-
return 0;
|
189
|
-
}
|
190
|
-
catch (IronRuby.Builtins.SystemExit e) {
|
191
|
-
return e.Status;
|
218
|
+
return engine.CreateScriptSourceFromFile(entry_file).ExecuteProgram();
|
192
219
|
}
|
193
220
|
catch (Exception e) {
|
194
221
|
var thread_abort = e as System.Threading.ThreadAbortException;
|
@@ -197,17 +224,34 @@ module IRPack
|
|
197
224
|
}
|
198
225
|
return -1;
|
199
226
|
}
|
227
|
+
<% end %>
|
200
228
|
}
|
201
229
|
}
|
202
230
|
}
|
203
231
|
CS
|
204
232
|
module_function
|
205
|
-
|
233
|
+
DefaultOptions = {
|
234
|
+
DebugMode: false,
|
235
|
+
PrivateBinding: false,
|
236
|
+
NoAdaptiveCompilation: false,
|
237
|
+
CompilationThreshold: -1,
|
238
|
+
ExceptionDetail: false,
|
239
|
+
ShowClrExceptions: false,
|
240
|
+
Profile: false,
|
241
|
+
Verbosity: 1,
|
242
|
+
DebugVariable: false,
|
243
|
+
EnableTracing: false,
|
244
|
+
RequiredPaths: [],
|
245
|
+
SearchPaths: [],
|
246
|
+
StandardLibrary: 'stdlib',
|
247
|
+
}
|
248
|
+
def source(module_name, entry_file, options={})
|
249
|
+
options = DefaultOptions.merge(options)
|
206
250
|
ERB.new(Source).result(binding)
|
207
251
|
end
|
208
252
|
|
209
|
-
def compile(output_file, module_name, entry_file, references)
|
210
|
-
src = source(module_name, entry_file)
|
253
|
+
def compile(output_file, module_name, entry_file, references, options={})
|
254
|
+
src = source(module_name, entry_file, options)
|
211
255
|
sysasm = IRPack::CSCompiler.system_assemblies.collect {|asm|
|
212
256
|
IRPack::CSCompiler.assembly_location(asm)
|
213
257
|
}
|
data/test/test_application.rb
CHANGED
@@ -46,6 +46,17 @@ class TC_ApplicationArguments < Test::Unit::TestCase
|
|
46
46
|
assert_equal('entry.rb', args.entry_file)
|
47
47
|
assert_equal(1, args.files.size)
|
48
48
|
assert_equal('entry.rb', args.files[File.expand_path('entry.rb')])
|
49
|
+
assert(!args.runtime_options[:DebugVariable])
|
50
|
+
assert(!args.runtime_options[:DebugMode])
|
51
|
+
assert_equal(1, args.runtime_options[:Verbosity])
|
52
|
+
assert(!args.runtime_options[:EnableTracing])
|
53
|
+
assert(!args.runtime_options[:Profile])
|
54
|
+
assert(!args.runtime_options[:ExceptionDetail])
|
55
|
+
assert(!args.runtime_options[:NoAdaptiveCompilation])
|
56
|
+
assert_equal(-1, args.runtime_options[:CompilationThreshold])
|
57
|
+
assert(!args.runtime_options[:PassExceptions])
|
58
|
+
assert(!args.runtime_options[:PrivateBinding])
|
59
|
+
assert(!args.runtime_options[:ShowClrExceptions])
|
49
60
|
end
|
50
61
|
|
51
62
|
def test_parse_output_file
|
@@ -101,5 +112,89 @@ class TC_ApplicationArguments < Test::Unit::TestCase
|
|
101
112
|
assert_equal('hoge.rb', args.files[File.expand_path('foo/bar/hoge.rb')])
|
102
113
|
assert_equal('hoge/fuga.rb', args.files[File.expand_path('foo/bar/hoge/fuga.rb')])
|
103
114
|
end
|
115
|
+
|
116
|
+
def test_parse_debug_variable
|
117
|
+
argv = ['-d', 'entry.rb']
|
118
|
+
args = IRPack::Application::Arguments.parse!(argv)
|
119
|
+
assert(args.runtime_options[:DebugVariable])
|
120
|
+
end
|
121
|
+
|
122
|
+
def test_parse_debug_mode
|
123
|
+
argv = ['-D', 'entry.rb']
|
124
|
+
args = IRPack::Application::Arguments.parse!(argv)
|
125
|
+
assert(args.runtime_options[:DebugMode])
|
126
|
+
end
|
127
|
+
|
128
|
+
def test_parse_verbose
|
129
|
+
argv = ['-v', 'entry.rb']
|
130
|
+
args = IRPack::Application::Arguments.parse!(argv)
|
131
|
+
assert_equal(2, args.runtime_options[:Verbosity])
|
132
|
+
end
|
133
|
+
|
134
|
+
def test_parse_warn
|
135
|
+
argv = ['-w', 'entry.rb']
|
136
|
+
args = IRPack::Application::Arguments.parse!(argv)
|
137
|
+
assert_equal(2, args.runtime_options[:Verbosity])
|
138
|
+
end
|
139
|
+
|
140
|
+
def test_parse_warning
|
141
|
+
argv = ['-W', 'entry.rb']
|
142
|
+
args = IRPack::Application::Arguments.parse!(argv)
|
143
|
+
assert_equal(2, args.runtime_options[:Verbosity])
|
144
|
+
end
|
145
|
+
|
146
|
+
def test_parse_warning0
|
147
|
+
argv = ['-W0', 'entry.rb']
|
148
|
+
args = IRPack::Application::Arguments.parse!(argv)
|
149
|
+
assert_equal(0, args.runtime_options[:Verbosity])
|
150
|
+
end
|
151
|
+
|
152
|
+
def test_parse_trace
|
153
|
+
argv = ['--trace', 'entry.rb']
|
154
|
+
args = IRPack::Application::Arguments.parse!(argv)
|
155
|
+
assert(args.runtime_options[:EnableTracing])
|
156
|
+
end
|
157
|
+
|
158
|
+
def test_parse_profile
|
159
|
+
argv = ['--profile', 'entry.rb']
|
160
|
+
args = IRPack::Application::Arguments.parse!(argv)
|
161
|
+
assert(args.runtime_options[:Profile])
|
162
|
+
end
|
163
|
+
|
164
|
+
def test_parse_exception_detail
|
165
|
+
argv = ['--exception-detail', 'entry.rb']
|
166
|
+
args = IRPack::Application::Arguments.parse!(argv)
|
167
|
+
assert(args.runtime_options[:ExceptionDetail])
|
168
|
+
end
|
169
|
+
|
170
|
+
def test_parse_no_adaptive_compilation
|
171
|
+
argv = ['--no-adaptive-compilation', 'entry.rb']
|
172
|
+
args = IRPack::Application::Arguments.parse!(argv)
|
173
|
+
assert(args.runtime_options[:NoAdaptiveCompilation])
|
174
|
+
end
|
175
|
+
|
176
|
+
def test_parse_compilation_threshold
|
177
|
+
argv = ['--compilation-threshold', '8192', 'entry.rb']
|
178
|
+
args = IRPack::Application::Arguments.parse!(argv)
|
179
|
+
assert_equal(8192, args.runtime_options[:CompilationThreshold])
|
180
|
+
end
|
181
|
+
|
182
|
+
def test_parse_pass_exceptions
|
183
|
+
argv = ['--pass-exceptions', 'entry.rb']
|
184
|
+
args = IRPack::Application::Arguments.parse!(argv)
|
185
|
+
assert(args.runtime_options[:PassExceptions])
|
186
|
+
end
|
187
|
+
|
188
|
+
def test_parse_private_binding
|
189
|
+
argv = ['--private-binding', 'entry.rb']
|
190
|
+
args = IRPack::Application::Arguments.parse!(argv)
|
191
|
+
assert(args.runtime_options[:PrivateBinding])
|
192
|
+
end
|
193
|
+
|
194
|
+
def test_parse_show_clr_exceptions
|
195
|
+
argv = ['--show-clr-exceptions', 'entry.rb']
|
196
|
+
args = IRPack::Application::Arguments.parse!(argv)
|
197
|
+
assert(args.runtime_options[:ShowClrExceptions])
|
198
|
+
end
|
104
199
|
end
|
105
200
|
|
data/test/test_entrypoint.rb
CHANGED
@@ -33,8 +33,9 @@ class TC_IRPack_EntryPoint < Test::Unit::TestCase
|
|
33
33
|
module_name = 'TestModule'
|
34
34
|
entry_file = 'foo.rb'
|
35
35
|
references = ironruby_assemblies
|
36
|
+
runtime_options = {}
|
36
37
|
|
37
|
-
assert_equal(output_file, IRPack::EntryPoint.compile(output_file, module_name, entry_file, references))
|
38
|
+
assert_equal(output_file, IRPack::EntryPoint.compile(output_file, module_name, entry_file, references, runtime_options))
|
38
39
|
assert(File.exist?(output_file))
|
39
40
|
asm = nil
|
40
41
|
assert_nothing_raised do
|
@@ -55,8 +56,9 @@ class TC_IRPack_EntryPoint < Test::Unit::TestCase
|
|
55
56
|
module_name = 'TestModule'
|
56
57
|
entry_file = 'main.rb'
|
57
58
|
references = ironruby_assemblies
|
59
|
+
runtime_options = {}
|
58
60
|
|
59
|
-
IRPack::EntryPoint.compile(output_file, module_name, entry_file, references)
|
61
|
+
IRPack::EntryPoint.compile(output_file, module_name, entry_file, references, runtime_options)
|
60
62
|
asm = System::Reflection::Assembly.load_from(output_file)
|
61
63
|
main = asm.get_type("#{module_name}.EntryPoint").get_method('Main')
|
62
64
|
assert_not_nil(main)
|
@@ -74,8 +76,9 @@ class TC_IRPack_EntryPoint < Test::Unit::TestCase
|
|
74
76
|
module_name = 'TestModule'
|
75
77
|
entry_file = 'main.rb'
|
76
78
|
references = ironruby_assemblies
|
79
|
+
runtime_options = {}
|
77
80
|
|
78
|
-
IRPack::EntryPoint.compile(output_file, module_name, entry_file, references)
|
81
|
+
IRPack::EntryPoint.compile(output_file, module_name, entry_file, references, runtime_options)
|
79
82
|
asm = System::Reflection::Assembly.load_from(output_file)
|
80
83
|
main = asm.get_type("#{module_name}.EntryPoint").get_method('Main')
|
81
84
|
assert_not_nil(main)
|
@@ -101,8 +104,9 @@ class TC_IRPack_EntryPoint < Test::Unit::TestCase
|
|
101
104
|
module_name = 'TestModule'
|
102
105
|
entry_file = 'main.rb'
|
103
106
|
references = ironruby_assemblies
|
107
|
+
runtime_options = {}
|
104
108
|
|
105
|
-
IRPack::EntryPoint.compile(output_file, module_name, entry_file, references)
|
109
|
+
IRPack::EntryPoint.compile(output_file, module_name, entry_file, references, runtime_options)
|
106
110
|
asm = System::Reflection::Assembly.load_from(output_file)
|
107
111
|
main = asm.get_type("#{module_name}.EntryPoint").get_method('Main')
|
108
112
|
assert_not_nil(main)
|
@@ -115,5 +119,169 @@ class TC_IRPack_EntryPoint < Test::Unit::TestCase
|
|
115
119
|
end
|
116
120
|
end
|
117
121
|
end
|
122
|
+
|
123
|
+
def test_search_paths
|
124
|
+
output_file = tempfilename('.dll')
|
125
|
+
module_name = 'TestModule'
|
126
|
+
entry_file = 'main.rb'
|
127
|
+
references = ironruby_assemblies
|
128
|
+
runtime_options = {
|
129
|
+
SearchPaths: [
|
130
|
+
'foo',
|
131
|
+
'../bar',
|
132
|
+
],
|
133
|
+
}
|
134
|
+
|
135
|
+
IRPack::EntryPoint.compile(output_file, module_name, entry_file, references, runtime_options)
|
136
|
+
asm = System::Reflection::Assembly.load_from(output_file)
|
137
|
+
main = asm.get_type("#{module_name}.EntryPoint").get_method('Main')
|
138
|
+
assert_not_nil(main)
|
139
|
+
main_rb = <<-RB
|
140
|
+
if $:.any? {|path| /foo$/=~path } and
|
141
|
+
$:.any? {|path| /bar$/=~path } then
|
142
|
+
exit 0
|
143
|
+
else
|
144
|
+
exit 1
|
145
|
+
end
|
146
|
+
RB
|
147
|
+
create_package('main.rb' => main_rb) do |package|
|
148
|
+
res = main.invoke(nil, System::Array[System::Object].new([package, System::Array[System::String].new(0)]))
|
149
|
+
assert_equal(0, res)
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
def test_required_paths
|
154
|
+
output_file = tempfilename('.dll')
|
155
|
+
module_name = 'TestModule'
|
156
|
+
entry_file = 'main.rb'
|
157
|
+
references = ironruby_assemblies
|
158
|
+
runtime_options = {
|
159
|
+
RequiredPaths: [
|
160
|
+
'stringio',
|
161
|
+
'date',
|
162
|
+
],
|
163
|
+
StandardLibrary: '../Lib',
|
164
|
+
}
|
165
|
+
|
166
|
+
IRPack::EntryPoint.compile(output_file, module_name, entry_file, references, runtime_options)
|
167
|
+
asm = System::Reflection::Assembly.load_from(output_file)
|
168
|
+
main = asm.get_type("#{module_name}.EntryPoint").get_method('Main')
|
169
|
+
assert_not_nil(main)
|
170
|
+
main_rb = <<-RB
|
171
|
+
required_constants = [:StringIO, :DateTime]
|
172
|
+
if required_constants.all? {|const| Object.constants.include?(const) } then
|
173
|
+
exit 0
|
174
|
+
else
|
175
|
+
exit 1
|
176
|
+
end
|
177
|
+
RB
|
178
|
+
create_package('main.rb' => main_rb) do |package|
|
179
|
+
res = main.invoke(nil, System::Array[System::Object].new([package, System::Array[System::String].new(0)]))
|
180
|
+
assert_equal(0, res)
|
181
|
+
end
|
182
|
+
end
|
183
|
+
|
184
|
+
def test_debug_variable
|
185
|
+
output_file = tempfilename('.dll')
|
186
|
+
module_name = 'TestModule'
|
187
|
+
entry_file = 'main.rb'
|
188
|
+
references = ironruby_assemblies
|
189
|
+
runtime_options = {
|
190
|
+
DebugVariable: true,
|
191
|
+
}
|
192
|
+
|
193
|
+
IRPack::EntryPoint.compile(output_file, module_name, entry_file, references, runtime_options)
|
194
|
+
asm = System::Reflection::Assembly.load_from(output_file)
|
195
|
+
main = asm.get_type("#{module_name}.EntryPoint").get_method('Main')
|
196
|
+
assert_not_nil(main)
|
197
|
+
main_rb = <<-RB
|
198
|
+
exit($DEBUG ? 0 : 1)
|
199
|
+
RB
|
200
|
+
create_package('main.rb' => main_rb) do |package|
|
201
|
+
res = main.invoke(nil, System::Array[System::Object].new([package, System::Array[System::String].new(0)]))
|
202
|
+
assert_equal(0, res)
|
203
|
+
end
|
204
|
+
end
|
205
|
+
|
206
|
+
def test_profile
|
207
|
+
output_file = tempfilename('.dll')
|
208
|
+
module_name = 'TestModule'
|
209
|
+
entry_file = 'main.rb'
|
210
|
+
references = ironruby_assemblies
|
211
|
+
runtime_options = {
|
212
|
+
Profile: true,
|
213
|
+
}
|
214
|
+
|
215
|
+
IRPack::EntryPoint.compile(output_file, module_name, entry_file, references, runtime_options)
|
216
|
+
asm = System::Reflection::Assembly.load_from(output_file)
|
217
|
+
main = asm.get_type("#{module_name}.EntryPoint").get_method('Main')
|
218
|
+
assert_not_nil(main)
|
219
|
+
main_rb = <<-RB
|
220
|
+
begin
|
221
|
+
IronRuby::Clr.profile { 1 + 1 }
|
222
|
+
exit 0
|
223
|
+
rescue SystemCallError
|
224
|
+
exit 1
|
225
|
+
end
|
226
|
+
RB
|
227
|
+
create_package('main.rb' => main_rb) do |package|
|
228
|
+
res = main.invoke(nil, System::Array[System::Object].new([package, System::Array[System::String].new(0)]))
|
229
|
+
assert_equal(0, res)
|
230
|
+
end
|
231
|
+
end
|
232
|
+
|
233
|
+
def test_enable_tracing
|
234
|
+
output_file = tempfilename('.dll')
|
235
|
+
module_name = 'TestModule'
|
236
|
+
entry_file = 'main.rb'
|
237
|
+
references = ironruby_assemblies
|
238
|
+
runtime_options = {
|
239
|
+
EnableTracing: true,
|
240
|
+
}
|
241
|
+
|
242
|
+
IRPack::EntryPoint.compile(output_file, module_name, entry_file, references, runtime_options)
|
243
|
+
asm = System::Reflection::Assembly.load_from(output_file)
|
244
|
+
main = asm.get_type("#{module_name}.EntryPoint").get_method('Main')
|
245
|
+
assert_not_nil(main)
|
246
|
+
main_rb = <<-RB
|
247
|
+
begin
|
248
|
+
set_trace_func(proc { nil })
|
249
|
+
exit 0
|
250
|
+
rescue System::NotSupportedException
|
251
|
+
exit 1
|
252
|
+
end
|
253
|
+
RB
|
254
|
+
create_package('main.rb' => main_rb) do |package|
|
255
|
+
res = main.invoke(nil, System::Array[System::Object].new([package, System::Array[System::String].new(0)]))
|
256
|
+
assert_equal(0, res)
|
257
|
+
end
|
258
|
+
end
|
259
|
+
|
260
|
+
def test_pass_exceptions
|
261
|
+
output_file = tempfilename('.dll')
|
262
|
+
module_name = 'TestModule'
|
263
|
+
entry_file = 'main.rb'
|
264
|
+
references = ironruby_assemblies
|
265
|
+
runtime_options = {
|
266
|
+
PassExceptions: true,
|
267
|
+
}
|
268
|
+
|
269
|
+
IRPack::EntryPoint.compile(output_file, module_name, entry_file, references, runtime_options)
|
270
|
+
asm = System::Reflection::Assembly.load_from(output_file)
|
271
|
+
main = asm.get_type("#{module_name}.EntryPoint").get_method('Main')
|
272
|
+
assert_not_nil(main)
|
273
|
+
main_rb = <<-RB
|
274
|
+
raise System::ApplicationException, 'Exception Test'
|
275
|
+
RB
|
276
|
+
create_package('main.rb' => main_rb) do |package|
|
277
|
+
assert_raise(System::ApplicationException) do
|
278
|
+
begin
|
279
|
+
main.invoke(nil, System::Array[System::Object].new([package, System::Array[System::String].new(0)]))
|
280
|
+
rescue System::Reflection::TargetInvocationException => e
|
281
|
+
raise e.InnerException
|
282
|
+
end
|
283
|
+
end
|
284
|
+
end
|
285
|
+
end
|
118
286
|
end
|
119
287
|
|
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.5
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- kumaryu
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-
|
13
|
+
date: 2011-11-09 00:00:00 +09:00
|
14
14
|
default_executable:
|
15
15
|
dependencies: []
|
16
16
|
|
@@ -23,8 +23,8 @@ executables:
|
|
23
23
|
- irpack
|
24
24
|
extensions: []
|
25
25
|
|
26
|
-
extra_rdoc_files:
|
27
|
-
|
26
|
+
extra_rdoc_files:
|
27
|
+
- README.rdoc
|
28
28
|
files:
|
29
29
|
- bin/irpack
|
30
30
|
- lib/irpack/application.rb
|
@@ -42,13 +42,15 @@ files:
|
|
42
42
|
- test/test_missing.rb
|
43
43
|
- test/test_packager.rb
|
44
44
|
- test/utils.rb
|
45
|
+
- README.rdoc
|
45
46
|
has_rdoc: true
|
46
47
|
homepage: http://github.com/kumaryu/irpack
|
47
48
|
licenses: []
|
48
49
|
|
49
50
|
post_install_message:
|
50
|
-
rdoc_options:
|
51
|
-
|
51
|
+
rdoc_options:
|
52
|
+
- --main
|
53
|
+
- README.rdoc
|
52
54
|
require_paths:
|
53
55
|
- lib
|
54
56
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -70,5 +72,12 @@ rubygems_version: 1.6.2
|
|
70
72
|
signing_key:
|
71
73
|
specification_version: 3
|
72
74
|
summary: Generate a standalone executable file from IronRuby scripts.
|
73
|
-
test_files:
|
74
|
-
|
75
|
+
test_files:
|
76
|
+
- test/test_application.rb
|
77
|
+
- test/test_bootloader.rb
|
78
|
+
- test/test_cscompiler.rb
|
79
|
+
- test/test_entrypoint.rb
|
80
|
+
- test/test_irpack.rb
|
81
|
+
- test/test_missing.rb
|
82
|
+
- test/test_packager.rb
|
83
|
+
- test/utils.rb
|