neri 0.1.7 → 0.9.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/README.ja.md +17 -14
- data/README.md +1 -0
- data/lib/neri/build.rb +336 -157
- data/lib/neri/runtime.rb +2 -2
- data/lib/neri/version.rb +1 -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: 5c6c2f6b6dad9643634b34c873219f02c7507828
|
4
|
+
data.tar.gz: c491cd7f829aa66a13edeaab659d73ff7703968f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 73e8ae13f438b7891a20dfcececde76bc12a95a1df2c16f3c69db10b45fbcc597aa52b88eb9964ac9fe32f8c97a116a348c78cabd283978e98c6e28b1863640e
|
7
|
+
data.tar.gz: 3c568b9700a5229007571809484236e07d20f49adc56d881bdfd63f0d70508f878c3826da10022412c7d71f130901e68ed4d7b3e87f47fed050a3517ba2d9d63
|
data/README.ja.md
CHANGED
@@ -8,15 +8,18 @@ Neri は、Ruby スクリプトを Ruby 未インストール環境向けに配
|
|
8
8
|
- 展開しない分、起動が速い。
|
9
9
|
- 実行ファイルを複数作りたいとき、OCRA ではサイズの大きな実行ファイルを複数生成することになってしまうが、Neri ではシステムファイルを共有できるので、全体のサイズが大きくならずに済む。
|
10
10
|
- OCRA には「日本語を含むユーザー名の環境では起動できない」という問題があるが、Neri にはない。
|
11
|
-
- ただし Ruby
|
11
|
+
- ただし Ruby のバージョンによっては、日本語を含むパス上では起動できない。(この点は OCRA も同様。)
|
12
12
|
- OCRA に比べての短所
|
13
|
-
-
|
14
|
-
-
|
13
|
+
- exe ファイルを作成するには、次のどちらかが必要。
|
14
|
+
- gcc と windres(Ruby の拡張ライブラリをコンパイルできる環境ならばおそらく大丈夫。)
|
15
|
+
- [Bat To Exe Converter](http://www.f2ko.de/en/b2e.php) ver.3
|
15
16
|
|
16
17
|
## インストール
|
17
18
|
|
18
19
|
$ gem install neri
|
19
20
|
|
21
|
+
現状、bundler での使用は保証できません。
|
22
|
+
|
20
23
|
## 使い方
|
21
24
|
|
22
25
|
$ neri [options] script.rb (other_files...) -- script_arguments
|
@@ -96,10 +99,10 @@ Neri はデフォルトでは、enc フォルダ内の文字コードライブ
|
|
96
99
|
|
97
100
|
<dl>
|
98
101
|
<dt>--output-dir <dirname></dt>
|
99
|
-
<dd
|
102
|
+
<dd>出力先フォルダ名を指定します。省略すると、カレントフォルダ(./)になります。</dd>
|
100
103
|
<dt>--system-dir <dirname></dt>
|
101
104
|
<dd>ruby 等がコピーされる、システムフォルダ名を指定します。デフォルトは "system" です。</dd>
|
102
|
-
<dt>--
|
105
|
+
<dt>--datafile <filename></dt>
|
103
106
|
<dd>データファイル名を指定します。省略した場合、実行スクリプトファイルのファイル名の拡張子を ".dat" に変更したものになります。
|
104
107
|
なお、このオプションを省略&実行スクリプトファイル以外にデータファイルに入れるファイルが無い場合、データファイルは作成されず、実行スクリプトファイルがそのままシステムフォルダ内にコピーされます。</dd>
|
105
108
|
<dt>--encryption-key <key></dt>
|
@@ -107,13 +110,13 @@ Neri はデフォルトでは、enc フォルダ内の文字コードライブ
|
|
107
110
|
暗号化は簡単なものなので、解読されては困るような重要なデータには用いないでください。</dd>
|
108
111
|
</dl>
|
109
112
|
|
110
|
-
####
|
111
|
-
|
112
|
-
Neri は単独では bat ファイルを作成するのみですが、Bat To Exe Converter(ver.3) があれば exe ファイルを作成できます。
|
113
|
+
#### exe ファイルの作成
|
113
114
|
|
114
115
|
<dl>
|
115
116
|
<dt>--no-exe</dt>
|
116
|
-
<dd>exe
|
117
|
+
<dd>exe ファイルは作成せず、bat ファイルを作成します。</dd>
|
118
|
+
<dt>--use-b2ec</dt>
|
119
|
+
<dd>exe ファイルの作成を、Bat To Exe Converter を用いて行うようにします。</dd>
|
117
120
|
<dt>--b2ec-path <bat_to_exe_converter_path></dt>
|
118
121
|
<dd>Bat To Exe Converter がパスの通ったところにない場合、このオプションで場所を指定してください。</dd>
|
119
122
|
<dt>--icon <iconfile></dt>
|
@@ -125,9 +128,9 @@ Neri は単独では bat ファイルを作成するのみですが、Bat To Exe
|
|
125
128
|
省略した場合、実行スクリプトファイルの拡張子が ".rbw" の場合、あるいは DXRuby を使用する場合にはウィンドウアプリになります。
|
126
129
|
そうでない場合はコンソールアプリになります。</dd>
|
127
130
|
<dt>--x64</dt>
|
128
|
-
<dd>64bit の exe ファイルを作成します。省略した場合、ruby 自体の bit
|
131
|
+
<dd>64bit の exe ファイルを作成します。省略した場合、ruby 自体の bit 数に合わせます。 ※ Bat To Exe Converter 使用時のみ有効</dd>
|
129
132
|
<dt>--uac-admin</dt>
|
130
|
-
<dd>管理者として実行する exe
|
133
|
+
<dd>管理者として実行する exe ファイルを作成します。 ※ Bat To Exe Converter 使用時のみ有効</dd>
|
131
134
|
<dt>--fileversion <version></dt>
|
132
135
|
<dt>--productversion <version></dt>
|
133
136
|
<dd>ファイルバージョン・製品バージョンを設定します。
|
@@ -162,7 +165,7 @@ Neri は単独では bat ファイルを作成するのみですが、Bat To Exe
|
|
162
165
|
|
163
166
|
#### 7-Zip
|
164
167
|
|
165
|
-
[7-Zip](http://7-zip.org/)
|
168
|
+
[7-Zip](http://7-zip.org/) を使用することで、出力ファイルをまとめて zip ファイルにすることができます。
|
166
169
|
|
167
170
|
<dl>
|
168
171
|
<dt>--zipfile <filename></dt>
|
@@ -173,7 +176,7 @@ Neri は単独では bat ファイルを作成するのみですが、Bat To Exe
|
|
173
176
|
|
174
177
|
#### Inno Setup
|
175
178
|
|
176
|
-
[Inno Setup](http://www.jrsoftware.org/isinfo.php)
|
179
|
+
[Inno Setup](http://www.jrsoftware.org/isinfo.php) を使用することで、インストーラーを作成することができます。※ あまりテストしていません。
|
177
180
|
|
178
181
|
<dl>
|
179
182
|
<dt>--innosetup <inno_script></dt>
|
@@ -211,7 +214,7 @@ Neri.file_exist?(filename) # -> bool
|
|
211
214
|
ファイルが「データファイル内」または「実際に」存在すれば true を、無ければ false を返します。
|
212
215
|
|
213
216
|
```ruby
|
214
|
-
Neri.file_read
|
217
|
+
Neri.file_read(filename, encoding = Encoding::BINARY) # -> String
|
215
218
|
```
|
216
219
|
|
217
220
|
「データファイル内」または「実際に」存在するファイルをまるごと読み込みます(読み込むサイズは指定できません)。データファイル内にも実ファイルとしても存在する場合、データファイル内のものが優先されます。
|
data/README.md
CHANGED
data/lib/neri/build.rb
CHANGED
@@ -5,12 +5,13 @@ require "neri"
|
|
5
5
|
|
6
6
|
module Neri
|
7
7
|
@data_files = []
|
8
|
-
@system_files = []
|
9
8
|
|
10
9
|
@options = {
|
11
10
|
quiet: false,
|
12
11
|
verbose: false,
|
13
12
|
|
13
|
+
external_encoding: nil,
|
14
|
+
|
14
15
|
dlls: [],
|
15
16
|
libs: [],
|
16
17
|
gems: [],
|
@@ -22,14 +23,15 @@ module Neri
|
|
22
23
|
pause_last: nil,
|
23
24
|
pause_text: nil,
|
24
25
|
|
25
|
-
output_dir:
|
26
|
+
output_dir: "./",
|
26
27
|
system_dir: "system",
|
27
28
|
|
28
|
-
|
29
|
+
datafile: nil,
|
29
30
|
encryption_key: nil,
|
30
31
|
|
31
|
-
no_exe:
|
32
|
-
|
32
|
+
no_exe: false,
|
33
|
+
use_b2ec: false,
|
34
|
+
b2ec_path: "Bat_To_Exe_Converter",
|
33
35
|
b2ec: {
|
34
36
|
icon: "#{File.expand_path(File.dirname(__FILE__) + '/../../share/default.ico')}",
|
35
37
|
invisible: nil,
|
@@ -50,23 +52,24 @@ module Neri
|
|
50
52
|
},
|
51
53
|
|
52
54
|
use_upx: false,
|
53
|
-
upx_path: "upx
|
55
|
+
upx_path: "upx",
|
54
56
|
upx_targets: ["bin/**/*.dll"],
|
55
57
|
upx_options: "",
|
56
58
|
|
57
59
|
zipfile: nil,
|
58
|
-
sevenzip_path: "7z
|
60
|
+
sevenzip_path: "7z",
|
59
61
|
|
60
62
|
inno_script: nil,
|
61
63
|
iscc_path: "iscc",
|
62
64
|
}
|
63
65
|
@rubyopt = ENV["RUBYOPT"].to_s
|
66
|
+
@args = ""
|
64
67
|
@encryption_key = nil
|
65
68
|
|
66
69
|
@use_dxruby = false
|
67
70
|
@use_dxruby_tiled = false
|
68
71
|
@use_ayame = false
|
69
|
-
|
72
|
+
|
70
73
|
class << self
|
71
74
|
|
72
75
|
attr_reader :options
|
@@ -80,11 +83,13 @@ module Neri
|
|
80
83
|
return File::ALT_SEPARATOR ? path.tr(File::SEPARATOR, File::ALT_SEPARATOR) : path
|
81
84
|
end
|
82
85
|
|
83
|
-
def bindir(
|
84
|
-
def rubydir(
|
85
|
-
def rubyexe(
|
86
|
-
def
|
87
|
-
def
|
86
|
+
def bindir( ); RbConfig::CONFIG["bindir"] || File.join(rubydir, "bin"); end
|
87
|
+
def rubydir( ); File.join(RbConfig::TOPDIR, ""); end
|
88
|
+
def rubyexe( ); RbConfig.ruby; end
|
89
|
+
def scriptfile(); @data_files.first; end
|
90
|
+
def basename( ); File.basename(scriptfile, ".*"); end
|
91
|
+
def basepath( ); File.join(options[:output_dir], basename); end
|
92
|
+
def datafile( ); File.join(options[:output_dir], options[:system_dir], options[:datafile]); end
|
88
93
|
|
89
94
|
# --help
|
90
95
|
def output_help
|
@@ -97,6 +102,8 @@ options:
|
|
97
102
|
--quiet
|
98
103
|
--verbose
|
99
104
|
|
105
|
+
--external-encoding <encoding>
|
106
|
+
|
100
107
|
--dll <dll1>,<dll2>,...
|
101
108
|
--lib <lib1>,<lib2>,...
|
102
109
|
--gem <gem1>,<gem2>,...
|
@@ -113,10 +120,11 @@ options:
|
|
113
120
|
|
114
121
|
--output-dir <dirname>
|
115
122
|
--system-dir <dirname>
|
116
|
-
--
|
123
|
+
--datafile <filename>
|
117
124
|
--encryption-key <key>
|
118
125
|
|
119
126
|
--no-exe
|
127
|
+
--use-b2ec
|
120
128
|
--b2ec-path <bat_to_exe_converter_path>
|
121
129
|
--icon <iconfile>
|
122
130
|
--windows or --invisible
|
@@ -167,9 +175,7 @@ options:
|
|
167
175
|
file.puts "#{pre}[:#{key}] = #{value}"
|
168
176
|
when NilClass
|
169
177
|
file.puts "#{pre}[:#{key}] = nil"
|
170
|
-
when String
|
171
|
-
file.puts "#{pre}[:#{key}] = '#{value.gsub("\\", "\\\\").gsub("'", "\\'")}'"
|
172
|
-
when Array
|
178
|
+
when String, Array
|
173
179
|
file.puts "#{pre}[:#{key}] = " + JSON.generate(value)
|
174
180
|
end
|
175
181
|
end
|
@@ -190,12 +196,14 @@ options:
|
|
190
196
|
options[:quiet] = true
|
191
197
|
when "--verbose", "-v"
|
192
198
|
options[:verbose] = true
|
199
|
+
when "--external_encoding"
|
200
|
+
options[:external_encoding] = ARGV.shift
|
193
201
|
when "--dll"
|
194
|
-
options[:dlls] += ARGV.shift.split(
|
202
|
+
options[:dlls] += ARGV.shift.split(",").map(&:strip)
|
195
203
|
when "--lib"
|
196
|
-
options[:libs] += ARGV.shift.split(
|
204
|
+
options[:libs] += ARGV.shift.split(",").map(&:strip)
|
197
205
|
when "--gem"
|
198
|
-
options[:gems] += ARGV.shift.split(
|
206
|
+
options[:gems] += ARGV.shift.split(",").map(&:strip)
|
199
207
|
when "--no-enc"
|
200
208
|
options[:encoding] = nil
|
201
209
|
when "--encoding"
|
@@ -211,22 +219,24 @@ options:
|
|
211
219
|
when "--no-pause-last"
|
212
220
|
options[:pause_last] = false
|
213
221
|
when "--pause-text"
|
214
|
-
options[:pause_text] = ARGV.shift
|
222
|
+
options[:pause_text] = ARGV.shift.encode("utf-8")
|
215
223
|
options[:pause_last] = true
|
216
224
|
when "--output-dir"
|
217
|
-
options[:output_dir] = ARGV.shift
|
225
|
+
options[:output_dir] = ARGV.shift.encode("utf-8")
|
218
226
|
when "--system-dir"
|
219
|
-
options[:system_dir] = ARGV.shift
|
220
|
-
when "--
|
221
|
-
options[:
|
227
|
+
options[:system_dir] = ARGV.shift.encode("utf-8")
|
228
|
+
when "--datafile"
|
229
|
+
options[:datafile] = ARGV.shift.encode("utf-8")
|
222
230
|
when "--encryption-key"
|
223
|
-
options[:encryption_key] = ARGV.shift
|
231
|
+
options[:encryption_key] = ARGV.shift.encode("utf-8")
|
224
232
|
when "--no-exe"
|
225
233
|
options[:no_exe] = true
|
234
|
+
when "--use-b2ec"
|
235
|
+
options[:use_b2ec] = true
|
226
236
|
when "--b2ec-path"
|
227
|
-
options[:b2ec_path] = ARGV.shift
|
237
|
+
options[:b2ec_path] = ARGV.shift.encode("utf-8")
|
228
238
|
when "--icon"
|
229
|
-
options[:b2ec][:icon] = ARGV.shift
|
239
|
+
options[:b2ec][:icon] = ARGV.shift.encode("utf-8")
|
230
240
|
when "--windows", "--invisible"
|
231
241
|
options[:b2ec][:invisible] = true
|
232
242
|
when "--console", "--visible"
|
@@ -240,70 +250,75 @@ options:
|
|
240
250
|
when "--productversion"
|
241
251
|
options[:b2ec][:productversion] = ARGV.shift
|
242
252
|
when "--productname"
|
243
|
-
options[:b2ec][:productname] = ARGV.shift
|
253
|
+
options[:b2ec][:productname] = ARGV.shift.encode("utf-8")
|
244
254
|
when "--originalfilename"
|
245
|
-
options[:b2ec][:originalfilename] = ARGV.shift
|
255
|
+
options[:b2ec][:originalfilename] = ARGV.shift.encode("utf-8")
|
246
256
|
when "--internalname"
|
247
|
-
options[:b2ec][:internalname] = ARGV.shift
|
257
|
+
options[:b2ec][:internalname] = ARGV.shift.encode("utf-8")
|
248
258
|
when "--description"
|
249
|
-
options[:b2ec][:description] = ARGV.shift
|
259
|
+
options[:b2ec][:description] = ARGV.shift.encode("utf-8")
|
250
260
|
when "--company"
|
251
|
-
options[:b2ec][:company] = ARGV.shift
|
261
|
+
options[:b2ec][:company] = ARGV.shift.encode("utf-8")
|
252
262
|
when "--trademarks"
|
253
|
-
options[:b2ec][:trademarks] = ARGV.shift
|
263
|
+
options[:b2ec][:trademarks] = ARGV.shift.encode("utf-8")
|
254
264
|
when "--copyright"
|
255
|
-
options[:b2ec][:copyright] = ARGV.shift
|
265
|
+
options[:b2ec][:copyright] = ARGV.shift.encode("utf-8")
|
256
266
|
when "--privatebuild"
|
257
|
-
options[:b2ec][:privatebuild] = ARGV.shift
|
267
|
+
options[:b2ec][:privatebuild] = ARGV.shift.encode("utf-8")
|
258
268
|
when "--specialbuild"
|
259
|
-
options[:b2ec][:specialbuild] = ARGV.shift
|
269
|
+
options[:b2ec][:specialbuild] = ARGV.shift.encode("utf-8")
|
260
270
|
when "--comments"
|
261
|
-
options[:b2ec][:comments] = ARGV.shift
|
271
|
+
options[:b2ec][:comments] = ARGV.shift.encode("utf-8")
|
262
272
|
when "--use-upx"
|
263
273
|
options[:use_upx] = true
|
264
274
|
when "--upx-path"
|
265
|
-
options[:upx_path] = ARGV.shift
|
275
|
+
options[:upx_path] = ARGV.shift.encode("utf-8")
|
266
276
|
when "--upx-targets"
|
267
|
-
options[:upx_targets] += ARGV.shift.split(
|
277
|
+
options[:upx_targets] += ARGV.shift.split(",").map(&:strip)
|
268
278
|
when "--upx-options"
|
269
279
|
options[:upx_options] = ARGV.shift
|
270
280
|
when "--zipfile"
|
271
|
-
options[:zipfile] = ARGV.shift
|
281
|
+
options[:zipfile] = ARGV.shift.encode("utf-8").sub(/\.zip$/, "") + ".zip"
|
272
282
|
when "--7zip-path"
|
273
|
-
options[:sevenzip_path] = ARGV.shift
|
283
|
+
options[:sevenzip_path] = ARGV.shift.encode("utf-8")
|
274
284
|
when "--innosetup"
|
275
|
-
options[:inno_script] = ARGV.shift
|
285
|
+
options[:inno_script] = ARGV.shift.encode("utf-8")
|
276
286
|
when "--iscc-path"
|
277
|
-
options[:iscc_path] = ARGV.shift
|
287
|
+
options[:iscc_path] = ARGV.shift.encode("utf-8")
|
278
288
|
when "--create-recipe"
|
279
289
|
require "json"
|
280
|
-
filename = ARGV.shift
|
290
|
+
filename = ARGV.shift.encode("utf-8")
|
281
291
|
nputs "Creating recipe_file '#{filename}'."
|
282
|
-
open(filename, "w:utf-8"){|file| create_recipe(file)}
|
292
|
+
open(filename, "w:utf-8"){ |file| create_recipe(file) }
|
283
293
|
exit
|
284
294
|
when "--recipe"
|
285
|
-
filename = ARGV.shift
|
295
|
+
filename = ARGV.shift.encode("utf-8")
|
286
296
|
nputs_v "Loading recipe_file '#{filename}'."
|
287
|
-
load filename
|
297
|
+
load File.expand_path(filename)
|
288
298
|
when "--"
|
289
299
|
break
|
290
300
|
when /^(--.+)/
|
291
|
-
|
301
|
+
error "Invalid Option '#{arg}'!"
|
292
302
|
output_help
|
293
303
|
exit
|
294
304
|
else
|
295
|
-
@data_files.push(arg)
|
305
|
+
@data_files.push(arg.encode("utf-8"))
|
296
306
|
end
|
297
307
|
end
|
298
308
|
|
299
309
|
if @data_files.empty?
|
300
|
-
|
310
|
+
error "No Script File!"
|
301
311
|
output_help
|
302
312
|
exit
|
303
313
|
end
|
304
314
|
|
305
|
-
|
306
|
-
|
315
|
+
@args = ARGV.map{ |arg| %[ "#{arg}"] }.join("")
|
316
|
+
@options[:external_encoding] ||= Encoding::default_external.name
|
317
|
+
unless options[:enable_gems]
|
318
|
+
@rubyopt += " --disable-gems" unless @rubyopt.index("--disable-gems")
|
319
|
+
end
|
320
|
+
unless options[:enable_did_you_mean]
|
321
|
+
@rubyopt += " --disable-did_you_mean" unless @rubyopt.index("--disable-did_you_mean")
|
307
322
|
end
|
308
323
|
end
|
309
324
|
|
@@ -397,7 +412,7 @@ options:
|
|
397
412
|
dependencies = []
|
398
413
|
enc_dir = Dir.glob(File.join(RbConfig::CONFIG["archdir"] || RbConfig::TOPDIR, "**", "enc")).first
|
399
414
|
|
400
|
-
options[:encoding].split(
|
415
|
+
options[:encoding].split(",").map(&:strip).each do |enc|
|
401
416
|
case enc
|
402
417
|
when "ja"
|
403
418
|
%w[windows_31j.so japanese_sjis.so encdb.so].each do |enc_name|
|
@@ -413,17 +428,16 @@ options:
|
|
413
428
|
end
|
414
429
|
|
415
430
|
def check_dependencies()
|
416
|
-
nputs "Running script '#{
|
431
|
+
nputs "Running script '#{scriptfile}' to check dependencies."
|
417
432
|
begin
|
418
|
-
load
|
419
|
-
rescue SystemExit
|
433
|
+
load File.expand_path(scriptfile)
|
434
|
+
rescue SystemExit, Interrupt
|
420
435
|
end
|
421
|
-
nputs "Script '#{
|
422
|
-
|
436
|
+
nputs "Script '#{scriptfile}' end."
|
437
|
+
|
423
438
|
if defined? DXRuby
|
424
439
|
require "neri/dxruby"
|
425
440
|
@use_dxruby = true
|
426
|
-
options[:b2ec][:invisible] = true if options[:b2ec][:invisible] == nil
|
427
441
|
end
|
428
442
|
if defined? DXRuby::Tiled
|
429
443
|
require "neri/dxruby_tiled"
|
@@ -433,9 +447,10 @@ options:
|
|
433
447
|
require "neri/ayame"
|
434
448
|
@use_ayame = true
|
435
449
|
end
|
436
|
-
|
437
|
-
if options[:b2ec][:invisible] == nil
|
438
|
-
|
450
|
+
|
451
|
+
if options[:b2ec][:invisible] == nil &&
|
452
|
+
(File.extname(scriptfile) == ".rbw" || @use_dxruby)
|
453
|
+
options[:b2ec][:invisible] = true
|
439
454
|
end
|
440
455
|
if options[:pause_last] == nil
|
441
456
|
options[:pause_last] = true unless options[:b2ec][:invisible]
|
@@ -451,7 +466,7 @@ options:
|
|
451
466
|
dependencies += additional_gems_dependencies
|
452
467
|
dependencies += encoding_dependencies
|
453
468
|
dependencies = select_dependencies(dependencies)
|
454
|
-
|
469
|
+
|
455
470
|
size = dependencies.map{|d| File.size(d)}.inject(&:+)
|
456
471
|
nputs "#{dependencies.size} files, #{size} bytes dependencies."
|
457
472
|
if options[:verbose]
|
@@ -459,13 +474,13 @@ options:
|
|
459
474
|
nputs_v " - #{dependency}"
|
460
475
|
end
|
461
476
|
end
|
462
|
-
|
477
|
+
|
463
478
|
return dependencies
|
464
479
|
end
|
465
480
|
|
466
481
|
def select_dependencies(dependencies)
|
467
482
|
dependencies.select! do |dependency|
|
468
|
-
dependency.start_with?(rubydir
|
483
|
+
dependency.start_with?(rubydir)
|
469
484
|
end
|
470
485
|
|
471
486
|
@data_files.each do |file|
|
@@ -492,165 +507,307 @@ options:
|
|
492
507
|
def copy_files(dependencies)
|
493
508
|
nputs "Copying dependencies."
|
494
509
|
require "fileutils"
|
495
|
-
|
496
|
-
src_dir = File.join(rubydir, "")
|
510
|
+
src_dir = rubydir
|
497
511
|
desc_dir = File.join(options[:output_dir], options[:system_dir], "")
|
498
512
|
|
499
|
-
|
513
|
+
system_files = dependencies.map do |file|
|
500
514
|
[file, file.sub(src_dir, desc_dir)]
|
501
515
|
end
|
502
516
|
unless options[:enable_gems]
|
503
|
-
|
517
|
+
system_files.each do |src, desc|
|
504
518
|
desc.sub!(/\/gems(\/\d+\.\d+\.\d+\/)gems\/(.+?)\-[^\/]+\/lib\//, "/vendor_ruby\\1")
|
505
519
|
end
|
506
520
|
end
|
507
521
|
|
508
|
-
|
522
|
+
system_files.each do |src, desc|
|
509
523
|
FileUtils.makedirs(File.dirname(desc))
|
510
524
|
if File.file?(src)
|
511
525
|
FileUtils.copy(src, desc)
|
512
526
|
nputs_v " #{src}\n -> #{desc}"
|
513
527
|
end
|
514
528
|
end
|
515
|
-
FileUtils.copy(
|
529
|
+
FileUtils.copy(scriptfile, desc_dir) unless options[:datafile]
|
516
530
|
end
|
517
531
|
|
518
532
|
|
519
|
-
def
|
520
|
-
|
521
|
-
|
522
|
-
enc = system(%(ruby --disable-gems -e "'#{@data_files.first}'" >NUL 2>&1)) ?
|
523
|
-
'' : ' -e "# coding: utf-8"'
|
524
|
-
|
525
|
-
unless options[:enable_gems]
|
526
|
-
@rubyopt += " --disable-gems" unless @rubyopt.match("--disable-gems")
|
533
|
+
def create_datafile()
|
534
|
+
if @data_files.size > 1 || options[:encryption_key]
|
535
|
+
options[:datafile] ||= basename + ".dat"
|
527
536
|
end
|
537
|
+
return unless options[:datafile]
|
528
538
|
|
529
|
-
|
539
|
+
nputs "Creating datafile '#{datafile}'."
|
540
|
+
data_files = @data_files.select { |file| File.file? file }
|
541
|
+
@data_files.select { |file| File.directory? file }.each do |dir|
|
542
|
+
data_files += Dir.glob(dir + "/**/*").select { |file| File.file? file }
|
543
|
+
end
|
530
544
|
if options[:encryption_key]
|
531
545
|
require "digest/sha2"
|
532
546
|
@encryption_key = Digest::SHA2.hexdigest(options[:encryption_key])
|
533
|
-
ruby_code = "Neri.key='#{@encryption_key}';"
|
534
547
|
end
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
|
548
|
+
Neri.key = @encryption_key || "0" * 64
|
549
|
+
open(datafile, "wb") do |f|
|
550
|
+
pos = 0
|
551
|
+
files_str = data_files.map{|file|
|
552
|
+
filename = File.expand_path(file)
|
553
|
+
filename = relative_path(filename, rubydir, "*neri*" + File::SEPARATOR)
|
554
|
+
filename = relative_path(filename, Dir.pwd)
|
555
|
+
filedata = [filename, File.size(file), pos]
|
556
|
+
pos += File.size(file)
|
557
|
+
pos += BLOCK_LENGTH - pos % BLOCK_LENGTH unless pos % BLOCK_LENGTH == 0
|
558
|
+
nputs_v " - #{filename}:#{File.size(file)} bytes"
|
559
|
+
filedata.join("\t")
|
560
|
+
}.join("\n").encode(Encoding::UTF_8)
|
561
|
+
|
562
|
+
f.write(sprintf("%#{BLOCK_LENGTH}d", files_str.bytesize))
|
563
|
+
f.write(xor(files_str))
|
564
|
+
data_files.each do |file|
|
565
|
+
f.write(xor(File.binread(file)))
|
566
|
+
end
|
541
567
|
end
|
568
|
+
end
|
569
|
+
|
570
|
+
|
571
|
+
def create_batfile()
|
572
|
+
nputs "Creating batch_file '#{basepath}.bat'."
|
542
573
|
|
543
|
-
|
574
|
+
pause_command = ""
|
544
575
|
if options[:pause_last]
|
576
|
+
pause_command += "echo.\n"
|
545
577
|
if options[:pause_text]
|
546
|
-
|
578
|
+
pause_command += "echo #{options[:pause_text]}\n" +
|
579
|
+
"pause > nul"
|
547
580
|
else
|
548
|
-
|
581
|
+
pause_command += "pause"
|
549
582
|
end
|
550
583
|
end
|
584
|
+
chdir = options[:chdir_first] ? 'cd /d "%~dp0"' : ""
|
551
585
|
|
552
|
-
|
553
|
-
r += " -rneri/dxruby" if @use_dxruby
|
554
|
-
r += " -rneri/dxruby_tiled" if @use_dxruby_tiled
|
555
|
-
r += " -rneri/ayame" if @use_ayame
|
556
|
-
|
557
|
-
open(batchfile, "w:#{Encoding.default_external.name}") do |f|
|
586
|
+
open(basepath + ".bat", "w:#{options[:external_encoding]}") do |f|
|
558
587
|
f.puts <<-EOF
|
559
588
|
@echo off
|
560
589
|
setlocal
|
561
590
|
set PATH=%~dp0#{options[:system_dir]}\\#{relative_path(bindir)};%PATH%
|
562
|
-
#{
|
591
|
+
#{chdir}
|
563
592
|
if %~x0 == .exe ( shift )
|
564
|
-
#{
|
565
|
-
#{
|
593
|
+
#{ruby_command("%~dp0")} %1 %2 %3 %4 %5 %6 %7 %8 %9
|
594
|
+
#{pause_command}
|
566
595
|
endlocal
|
567
596
|
EOF
|
568
597
|
end
|
569
598
|
end
|
570
599
|
|
571
|
-
|
572
|
-
|
573
|
-
|
574
|
-
|
575
|
-
|
576
|
-
data_files += Dir.glob(dir + "/**/*").select { |file| File.file? file }
|
600
|
+
def create_exefile()
|
601
|
+
unless system("gcc --version >nul 2>&1 && windres --version >nul 2>&1")
|
602
|
+
error "gcc or windres not found !"
|
603
|
+
create_batfile
|
604
|
+
return
|
577
605
|
end
|
578
|
-
|
579
|
-
|
580
|
-
|
581
|
-
|
582
|
-
|
583
|
-
|
584
|
-
|
585
|
-
|
586
|
-
|
587
|
-
|
588
|
-
|
589
|
-
|
590
|
-
|
591
|
-
|
592
|
-
|
593
|
-
|
594
|
-
|
595
|
-
|
606
|
+
|
607
|
+
exe_file = to_winpath(basepath + ".exe" )
|
608
|
+
c_file = to_winpath(basepath + "_tmp.c" )
|
609
|
+
o_file = to_winpath(basepath + "_tmp.o" )
|
610
|
+
rc_file = to_winpath(basepath + "_tmp.rc")
|
611
|
+
system_dir = escape_cstr(to_winpath(File.join(options[:system_dir], "")))
|
612
|
+
nputs "Creating exe_file '#{exe_file}'."
|
613
|
+
open(c_file, "w:#{options[:external_encoding]}") do |f|
|
614
|
+
f.puts <<-EOF
|
615
|
+
#include <stdio.h>
|
616
|
+
#include <windows.h>
|
617
|
+
#include <unistd.h>
|
618
|
+
|
619
|
+
int main(int argc, char *argv[])
|
620
|
+
{
|
621
|
+
char exepath[_MAX_PATH * 2 + 1],
|
622
|
+
drive [_MAX_DRIVE + 1],
|
623
|
+
dir [_MAX_DIR * 2 + 1],
|
624
|
+
fname [_MAX_FNAME * 2 + 1],
|
625
|
+
ext [_MAX_EXT * 2 + 1],
|
626
|
+
paths [_MAX_PATH * 32 + 1],
|
627
|
+
runruby[_MAX_PATH * 32 + 1];
|
628
|
+
PROCESS_INFORMATION pi;
|
629
|
+
STARTUPINFO si;
|
630
|
+
ZeroMemory(&si, sizeof(STARTUPINFO));
|
631
|
+
|
632
|
+
if(GetModuleFileName(NULL, exepath, MAX_PATH * 2) != 0){
|
633
|
+
_splitpath_s(exepath, drive, _MAX_DRIVE, dir, _MAX_DIR * 2, fname, _MAX_FNAME * 2, ext, _MAX_EXT * 2);
|
634
|
+
} else {
|
635
|
+
exit(EXIT_FAILURE);
|
636
|
+
}
|
637
|
+
sprintf(paths, "PATH=%s%s#{system_dir}bin;%s", drive, dir, getenv("PATH"));
|
638
|
+
putenv(paths);
|
639
|
+
#{options[:chdir_first] ? 'sprintf(paths, "%s%s", drive, dir);chdir(paths);' : ''}
|
640
|
+
sprintf(runruby, "#{escape_cstr(ruby_command("%s%s"))} %s %s %s %s %s %s %s %s %s",
|
641
|
+
drive,
|
642
|
+
dir,
|
643
|
+
argc > 1 ? argv[1] : "",
|
644
|
+
argc > 2 ? argv[2] : "",
|
645
|
+
argc > 3 ? argv[3] : "",
|
646
|
+
argc > 4 ? argv[4] : "",
|
647
|
+
argc > 5 ? argv[5] : "",
|
648
|
+
argc > 6 ? argv[6] : "",
|
649
|
+
argc > 7 ? argv[7] : "",
|
650
|
+
argc > 8 ? argv[8] : "",
|
651
|
+
argc > 9 ? argv[9] : ""
|
652
|
+
);
|
653
|
+
EOF
|
654
|
+
if options[:b2ec][:invisible]
|
655
|
+
f.puts %[ CreateProcess(NULL, runruby, NULL, NULL, FALSE, NORMAL_PRIORITY_CLASS | CREATE_NO_WINDOW, NULL, NULL, &si, &pi);]
|
656
|
+
else
|
657
|
+
f.puts %[ system(runruby);]
|
596
658
|
end
|
659
|
+
if options[:pause_last]
|
660
|
+
f.puts %[ system("echo.");]
|
661
|
+
if options[:pause_text]
|
662
|
+
f.puts %[ system("echo #{escape_cstr(options[:pause_text])}");]
|
663
|
+
f.puts %[ system("pause >nul");]
|
664
|
+
else
|
665
|
+
f.puts %[ system("pause");]
|
666
|
+
end
|
667
|
+
end
|
668
|
+
f.puts " return 0;\n}"
|
669
|
+
end
|
670
|
+
|
671
|
+
open(rc_file, "w:#{options[:external_encoding]}") do |f|
|
672
|
+
f.puts <<-EOF
|
673
|
+
#include <winver.h>
|
674
|
+
|
675
|
+
1 VERSIONINFO
|
676
|
+
#{options[:b2ec][:fileversion ] ? "FILEVERSION " + escape_cstr(options[:b2ec][:fileversion ]) : ""}
|
677
|
+
#{options[:b2ec][:productversion] ? "PRODUCTVERSION " + escape_cstr(options[:b2ec][:productversion]) : ""}
|
678
|
+
FILETYPE VFT_APP
|
679
|
+
BEGIN
|
680
|
+
BLOCK "StringFileInfo"
|
681
|
+
BEGIN
|
682
|
+
BLOCK "000004b0"
|
683
|
+
BEGIN
|
684
|
+
#{options[:b2ec][:fileversion ] ? 'VALUE "FileVersion", "' + escape_cstr(options[:b2ec][:fileversion ]) + '\0"' : ''}
|
685
|
+
#{options[:b2ec][:productversion ] ? 'VALUE "ProductVersion", "' + escape_cstr(options[:b2ec][:productversion ]) + '\0"' : ''}
|
686
|
+
#{options[:b2ec][:productname ] ? 'VALUE "ProductName", "' + escape_cstr(options[:b2ec][:productname ]) + '\0"' : ''}
|
687
|
+
#{options[:b2ec][:originalfilename] ? 'VALUE "OriginalFileName", "' + escape_cstr(options[:b2ec][:originalfilename]) + '\0"' : ''}
|
688
|
+
#{options[:b2ec][:internalname ] ? 'VALUE "InternalName", "' + escape_cstr(options[:b2ec][:internalname ]) + '\0"' : ''}
|
689
|
+
#{options[:b2ec][:description ] ? 'VALUE "FileDescription", "' + escape_cstr(options[:b2ec][:description ]) + '\0"' : ''}
|
690
|
+
#{options[:b2ec][:company ] ? 'VALUE "CompanyName", "' + escape_cstr(options[:b2ec][:company ]) + '\0"' : ''}
|
691
|
+
#{options[:b2ec][:trademarks ] ? 'VALUE "LegalTrademarks", "' + escape_cstr(options[:b2ec][:trademarks ]) + '\0"' : ''}
|
692
|
+
#{options[:b2ec][:copyright ] ? 'VALUE "LegalCopyright", "' + escape_cstr(options[:b2ec][:copyright ]) + '\0"' : ''}
|
693
|
+
#{options[:b2ec][:privatebuild ] ? 'VALUE "PrivateBuild", "' + escape_cstr(options[:b2ec][:privatebuild ]) + '\0"' : ''}
|
694
|
+
#{options[:b2ec][:specialbuild ] ? 'VALUE "SpecialBuild", "' + escape_cstr(options[:b2ec][:specialbuild ]) + '\0"' : ''}
|
695
|
+
#{options[:b2ec][:comments ] ? 'VALUE "Comments", "' + escape_cstr(options[:b2ec][:comments ]) + '\0"' : ''}
|
696
|
+
END
|
697
|
+
END
|
698
|
+
|
699
|
+
BLOCK "VarFileInfo"
|
700
|
+
BEGIN
|
701
|
+
VALUE "Translation", 0x0, 0x4b0
|
702
|
+
END
|
703
|
+
END
|
704
|
+
|
705
|
+
2 ICON "#{escape_cstr(options[:b2ec][:icon])}"
|
706
|
+
EOF
|
597
707
|
end
|
708
|
+
nsystem(%[windres -o "#{o_file}" "#{rc_file}"])
|
709
|
+
nsystem(%[gcc#{options[:b2ec][:invisible] ? " -mwindows" : ""} -o "#{exe_file}" "#{c_file}" "#{o_file}"])
|
710
|
+
nsystem(%[strip "#{exe_file}"])
|
711
|
+
File.delete(c_file, rc_file, o_file)
|
712
|
+
end
|
713
|
+
|
714
|
+
def ruby_command(path)
|
715
|
+
system_dir = "#{path}#{File.join(options[:system_dir], "")}"
|
716
|
+
ruby_code = ""
|
717
|
+
ruby_code = "Neri.key='#{@encryption_key}';" if @encryption_key
|
718
|
+
if options[:datafile]
|
719
|
+
ruby_code += "Neri.datafile='#{system_dir}' + #{unpack_filename(options[:datafile])};"
|
720
|
+
ruby_code += "load File.expand_path(#{unpack_filename(File.basename(scriptfile))})"
|
721
|
+
else
|
722
|
+
ruby_code += "load File.expand_path('#{system_dir}' + #{unpack_filename(scriptfile)})"
|
723
|
+
end
|
724
|
+
|
725
|
+
r = " -rneri"
|
726
|
+
r += " -rneri/dxruby" if @use_dxruby
|
727
|
+
r += " -rneri/dxruby_tiled" if @use_dxruby_tiled
|
728
|
+
r += " -rneri/ayame" if @use_ayame
|
729
|
+
|
730
|
+
ruby = to_winpath(relative_path(rubyexe, bindir))
|
731
|
+
return %[#{ruby}#{r} #{@rubyopt} -e "# coding:utf-8" -e "#{ruby_code}" #{@args}]
|
598
732
|
end
|
599
733
|
|
600
734
|
|
601
735
|
def bat_to_exe_converter()
|
602
|
-
|
603
|
-
|
604
|
-
|
605
|
-
|
736
|
+
create_batfile
|
737
|
+
begin
|
738
|
+
`#{options[:b2ec_path]} /help`
|
739
|
+
rescue
|
740
|
+
error "Bat To Exe Converter not found !"
|
741
|
+
return
|
742
|
+
end
|
743
|
+
|
744
|
+
batch_file = basepath + ".bat"
|
745
|
+
exe_file = basepath + ".exe"
|
746
|
+
nputs "Creating exe_file '#{exe_file}' with Bat To Exe Converter."
|
747
|
+
File.delete(exe_file) if File.exist?(exe_file)
|
606
748
|
if options[:b2ec][:x64] == nil
|
607
749
|
options[:b2ec][:x64] = true if RbConfig::CONFIG["target"].to_s.index("64")
|
608
750
|
end
|
609
|
-
|
751
|
+
args = %[ /bat "#{batch_file}" /exe "#{exe_file}"]
|
610
752
|
args += options[:b2ec].map{|key, value|
|
611
753
|
case value
|
612
|
-
when String; %[ /#{key.to_s.tr(
|
613
|
-
when true; %[ /#{key.to_s.tr(
|
754
|
+
when String; %[ /#{key.to_s.tr("_", "-")} "#{value}"]
|
755
|
+
when true; %[ /#{key.to_s.tr("_", "-")}]
|
614
756
|
else; %[]
|
615
757
|
end
|
616
758
|
}.join("")
|
617
|
-
|
618
|
-
|
619
|
-
|
620
|
-
|
621
|
-
rescue SystemCallError
|
622
|
-
end
|
623
|
-
if File.exist?(exefile)
|
624
|
-
File.delete(batchfile)
|
625
|
-
else
|
626
|
-
nputs "Failed to create exe_file."
|
759
|
+
|
760
|
+
|
761
|
+
unless nsystem "#{options[:b2ec_path]}#{args}"
|
762
|
+
error "Failed to create exe_file !"
|
627
763
|
end
|
628
764
|
end
|
629
765
|
|
630
766
|
|
631
767
|
def upx()
|
768
|
+
unless system("#{options[:upx_path]} --version >nul 2>&1")
|
769
|
+
error "UPX not found !"
|
770
|
+
return
|
771
|
+
end
|
772
|
+
|
632
773
|
nputs "Compressing with UPX."
|
633
774
|
options[:upx_targets].each do |target|
|
634
775
|
Dir.glob(File.join(options[:output_dir], options[:system_dir], target)).each do |target_path|
|
635
|
-
|
636
|
-
|
637
|
-
options[:quiet] ? `#{exec}` : system(exec)
|
776
|
+
command = %("#{options[:upx_path]}" #{options[:upx_options]} "#{target_path}")
|
777
|
+
nsystem command
|
638
778
|
end
|
639
779
|
end
|
640
780
|
end
|
641
781
|
|
642
782
|
|
643
783
|
def create_zipfile()
|
784
|
+
unless system("#{options[:sevenzip_path]} >nul 2>&1")
|
785
|
+
error "7-Zip not found !"
|
786
|
+
return
|
787
|
+
end
|
788
|
+
|
644
789
|
nputs "Creating zip_file '#{options[:zipfile]}'."
|
645
790
|
File.delete(options[:zipfile]) if File.exist?(options[:zipfile])
|
646
|
-
|
647
|
-
|
648
|
-
|
791
|
+
files = []
|
792
|
+
if options[:output_dir] == "./"
|
793
|
+
files.push(options[:system_dir])
|
794
|
+
files.push(File.exist?(basepath + ".exe") ? basepath + ".exe" : basepath + ".bat")
|
795
|
+
else
|
796
|
+
files.push(options[:output_dir])
|
797
|
+
end
|
798
|
+
command = %("#{options[:sevenzip_path]}" a "#{options[:zipfile]}" "#{files.join('" "')}")
|
799
|
+
nsystem command
|
649
800
|
end
|
650
801
|
|
651
802
|
|
652
803
|
def inno_setup()
|
804
|
+
unless system("#{options[:iscc_path]} /? >nul 2>&1")
|
805
|
+
error("Inno Setup not found !")
|
806
|
+
return
|
807
|
+
end
|
808
|
+
|
653
809
|
filename = options[:inno_script]
|
810
|
+
nputs "Creating Installer '#{filename}'."
|
654
811
|
script = "[Setup]\n"
|
655
812
|
if File.exist?(filename)
|
656
813
|
script = File.read(filename, encoding: Encoding::UTF_8)
|
@@ -681,30 +838,34 @@ endlocal
|
|
681
838
|
next unless File.file? file
|
682
839
|
dist_dir = to_winpath(File::SEPARATOR + File.dirname(relative_path(file, dir)))
|
683
840
|
dist_dir = "" if dist_dir == "\\."
|
684
|
-
files_str += "\nSource: \"#{to_winpath(file)}\"; DistDir: \"{app}#{dist_dir}
|
841
|
+
files_str += "\nSource: \"#{to_winpath(file)}\"; DistDir: \"{app}#{dist_dir}"
|
685
842
|
files_str += "; Flags: isreadme" if File.basename(file).match(/^readme/i)
|
686
843
|
end
|
687
844
|
script.sub!(/^(\[Files\])(\s*)/i){ "#{$1}#{files_str}#{$2}" }
|
688
845
|
|
689
846
|
File.write(filename, script)
|
690
|
-
|
691
|
-
|
692
|
-
options[:quiet] ? `#{exec}` : system(exec)
|
847
|
+
command = %(#{options[:iscc_path]} "#{filename}")
|
848
|
+
nsystem command
|
693
849
|
end
|
694
850
|
|
851
|
+
|
695
852
|
def run()
|
696
853
|
check_options
|
697
854
|
dependencies = check_dependencies
|
698
855
|
copy_files(dependencies)
|
699
|
-
|
700
|
-
|
701
|
-
|
702
|
-
|
703
|
-
|
704
|
-
|
856
|
+
create_datafile
|
857
|
+
if options[:no_exe]
|
858
|
+
create_batfile
|
859
|
+
else
|
860
|
+
options[:use_b2ec] ? bat_to_exe_converter : create_exefile
|
861
|
+
end
|
862
|
+
upx if options[:use_upx]
|
863
|
+
create_zipfile if options[:zipfile]
|
864
|
+
inno_setup if options[:inno_script]
|
705
865
|
nputs "Neri Finished."
|
706
866
|
end
|
707
867
|
|
868
|
+
|
708
869
|
private
|
709
870
|
|
710
871
|
def nputs(str)
|
@@ -714,5 +875,23 @@ endlocal
|
|
714
875
|
def nputs_v(str)
|
715
876
|
puts str if options[:verbose]
|
716
877
|
end
|
878
|
+
|
879
|
+
def error(str)
|
880
|
+
puts "\e[31m#{str}\e[0m"
|
881
|
+
end
|
882
|
+
|
883
|
+
def unpack_filename(filename)
|
884
|
+
"[" + filename.unpack("U*").map { |u| u.to_s }.join(",") + "].pack('U*')"
|
885
|
+
end
|
886
|
+
|
887
|
+
def escape_cstr(str)
|
888
|
+
str.gsub("\\"){ "\\\\" }.gsub('"'){ '\\"' }.gsub("'"){ "\\'" }
|
889
|
+
end
|
890
|
+
|
891
|
+
def nsystem(str)
|
892
|
+
nputs_v(str)
|
893
|
+
command = str.encode(options[:external_encoding])
|
894
|
+
return system(command + (options[:quiet] ? " >nul 2>&1" : ""))
|
895
|
+
end
|
717
896
|
end
|
718
897
|
end
|
data/lib/neri/runtime.rb
CHANGED
data/lib/neri/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: neri
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- nodai2hITC
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-08-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|