exerb 6.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (179) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +8 -0
  3. data/ChangeLog.ja.rd +305 -0
  4. data/README.en.txt +12 -0
  5. data/README.ja.html +143 -0
  6. data/README.ja.txt +6 -0
  7. data/README.md +50 -0
  8. data/Rakefile +205 -0
  9. data/bin/exerb +185 -0
  10. data/bin/mkexy +47 -0
  11. data/doc/LGPL +513 -0
  12. data/doc/class.ja.html +92 -0
  13. data/doc/command.ja.html +109 -0
  14. data/doc/core.ja.html +72 -0
  15. data/doc/example.ja.html +89 -0
  16. data/doc/faq.ja.html +59 -0
  17. data/doc/inside.ja.rd +404 -0
  18. data/doc/license.ja.html +62 -0
  19. data/doc/logo.gif +0 -0
  20. data/doc/misc.ja.html +72 -0
  21. data/doc/navi.gif +0 -0
  22. data/doc/recipe.ja.html +317 -0
  23. data/doc/style.css +187 -0
  24. data/doc/tutorial.ja.html +182 -0
  25. data/example/Makefile +54 -0
  26. data/example/cat_n.rb +14 -0
  27. data/example/exception.rb +9 -0
  28. data/example/ext/Win32API.so +0 -0
  29. data/example/ext/swin.so +0 -0
  30. data/example/msgbox.rb +14 -0
  31. data/example/rubytk.rb +22 -0
  32. data/example/runtime.ico +0 -0
  33. data/example/runtime.rb +19 -0
  34. data/example/vr/clipboard.rb +106 -0
  35. data/example/vr/compat/rubycompat.rb +18 -0
  36. data/example/vr/compat/vrcomctl.rb +12 -0
  37. data/example/vr/compat/vrcontrol.rb +50 -0
  38. data/example/vr/compat/vrmmedia.rb +24 -0
  39. data/example/vr/contrib/inifile.rb +116 -0
  40. data/example/vr/contrib/msgboxconst.rb +55 -0
  41. data/example/vr/contrib/toolbar.rb +371 -0
  42. data/example/vr/contrib/vrctlcolor.rb +110 -0
  43. data/example/vr/contrib/vrhotkey.rb +35 -0
  44. data/example/vr/contrib/vrlistviewex.rb +71 -0
  45. data/example/vr/contrib/vrstdscrollbar.rb +414 -0
  46. data/example/vr/contrib/vrwincomponent.rb +54 -0
  47. data/example/vr/dragdropformat.rb +209 -0
  48. data/example/vr/rscutil.rb +168 -0
  49. data/example/vr/sysmod.rb +249 -0
  50. data/example/vr/vractivex.rb +56 -0
  51. data/example/vr/vrclipboard.rb +53 -0
  52. data/example/vr/vrcomctl.rb +1819 -0
  53. data/example/vr/vrcontrol.rb +1374 -0
  54. data/example/vr/vrdde.rb +623 -0
  55. data/example/vr/vrddrop.rb +190 -0
  56. data/example/vr/vrdialog.rb +406 -0
  57. data/example/vr/vrhandler.rb +195 -0
  58. data/example/vr/vrlayout.old.rb +209 -0
  59. data/example/vr/vrlayout.rb +173 -0
  60. data/example/vr/vrlayout2.rb +340 -0
  61. data/example/vr/vrmargin.rb +141 -0
  62. data/example/vr/vrmgdlayout.rb +381 -0
  63. data/example/vr/vrmmedia.rb +287 -0
  64. data/example/vr/vrolednd.rb +192 -0
  65. data/example/vr/vrowndraw.rb +108 -0
  66. data/example/vr/vrrichedit.rb +366 -0
  67. data/example/vr/vrtimer.rb +148 -0
  68. data/example/vr/vrtooltip.rb +273 -0
  69. data/example/vr/vrtray.rb +143 -0
  70. data/example/vr/vrtvitem.rb +118 -0
  71. data/example/vr/vrtwopane.rb +223 -0
  72. data/example/vr/vruby.rb +1051 -0
  73. data/example/vr/winconst.rb +158 -0
  74. data/example/vruby.rb +38 -0
  75. data/exerb.gemspec +26 -0
  76. data/extconf.rb +7 -0
  77. data/lib/exerb/archive.rb +143 -0
  78. data/lib/exerb/config.rb +51 -0
  79. data/lib/exerb/error.rb +15 -0
  80. data/lib/exerb/executable.rb +68 -0
  81. data/lib/exerb/file_table.rb +189 -0
  82. data/lib/exerb/mkexy.rb +81 -0
  83. data/lib/exerb/name_table.rb +120 -0
  84. data/lib/exerb/recipe.rb +465 -0
  85. data/lib/exerb/resource.rb +190 -0
  86. data/lib/exerb/resource/base.rb +29 -0
  87. data/lib/exerb/resource/binary.rb +31 -0
  88. data/lib/exerb/resource/dialog.rb +30 -0
  89. data/lib/exerb/resource/group_icon.rb +85 -0
  90. data/lib/exerb/resource/icon.rb +52 -0
  91. data/lib/exerb/resource/version_info.rb +155 -0
  92. data/lib/exerb/resource_library.rb +120 -0
  93. data/lib/exerb/utility.rb +95 -0
  94. data/lib/exerb/utility2.rb +122 -0
  95. data/lib/exerb/version.rb +13 -0
  96. data/lib/exerb/win32/const/resource.rb +51 -0
  97. data/lib/exerb/win32/icon_file.rb +78 -0
  98. data/lib/exerb/win32/pe_file.rb +59 -0
  99. data/lib/exerb/win32/resource_directory.rb +105 -0
  100. data/lib/exerb/win32/resource_directory_root.rb +67 -0
  101. data/lib/exerb/win32/resource_entry.rb +98 -0
  102. data/lib/exerb/win32/struct/base.rb +43 -0
  103. data/lib/exerb/win32/struct/icon_dir_entry.rb +83 -0
  104. data/lib/exerb/win32/struct/icon_header.rb +43 -0
  105. data/lib/exerb/win32/struct/icon_res_entry.rb +48 -0
  106. data/lib/exerb/win32/struct/image_dos_header.rb +73 -0
  107. data/lib/exerb/win32/struct/image_file_header.rb +47 -0
  108. data/lib/exerb/win32/struct/image_nt_headers32.rb +53 -0
  109. data/lib/exerb/win32/struct/image_optional_header32.rb +107 -0
  110. data/lib/exerb/win32/struct/image_resource_data_entry.rb +45 -0
  111. data/lib/exerb/win32/struct/image_resource_directory.rb +47 -0
  112. data/lib/exerb/win32/struct/image_resource_directory_entry.rb +72 -0
  113. data/lib/exerb/win32/struct/image_section_header.rb +53 -0
  114. data/lib/exerb/win32/struct/version_info_block.rb +75 -0
  115. data/lib/exerb/win32/struct/vs_fixed_file_info.rb +62 -0
  116. data/src/exerb/cui.c +48 -0
  117. data/src/exerb/default.rb +1 -0
  118. data/src/exerb/exerb.c +877 -0
  119. data/src/exerb/exerb.h +92 -0
  120. data/src/exerb/gui.c +176 -0
  121. data/src/exerb/module.c +138 -0
  122. data/src/exerb/module.h +7 -0
  123. data/src/exerb/patch.c +27 -0
  124. data/src/exerb/resource.h +22 -0
  125. data/src/exerb/resource.rc +121 -0
  126. data/src/exerb/ruby.ico +0 -0
  127. data/src/exerb/utility.c +263 -0
  128. data/src/exerb/utility.h +33 -0
  129. data/test/alltests.rb +16 -0
  130. data/test/test-argv.rb +26 -0
  131. data/test/test-argv/test-argv.rb +9 -0
  132. data/test/test-argv/test-argv.ret +1 -0
  133. data/test/test-dollarzero.rb +26 -0
  134. data/test/test-dollarzero/test-dollarzero.rb +10 -0
  135. data/test/test-dollarzero/test-dollarzero.ret +2 -0
  136. data/test/test-dot.rb +26 -0
  137. data/test/test-dot/dot.dot.dot.rb +9 -0
  138. data/test/test-dot/dot.dot.rb +9 -0
  139. data/test/test-dot/test-dot.rb +13 -0
  140. data/test/test-dot/test-dot.ret +5 -0
  141. data/test/test-exitcode.rb +28 -0
  142. data/test/test-exitcode/test-exitcode.rb +9 -0
  143. data/test/test-kcode.rb +43 -0
  144. data/test/test-kcode/euc.rb +10 -0
  145. data/test/test-kcode/euc.ret +2 -0
  146. data/test/test-kcode/none.rb +10 -0
  147. data/test/test-kcode/none.ret +2 -0
  148. data/test/test-kcode/sjis.rb +10 -0
  149. data/test/test-kcode/sjis.ret +2 -0
  150. data/test/test-kcode/utf8.rb +10 -0
  151. data/test/test-kcode/utf8.ret +2 -0
  152. data/test/test-loadpath.rb +24 -0
  153. data/test/test-loadpath/test-loadpath.rb +9 -0
  154. data/test/test-nest.rb +18 -0
  155. data/test/test-nest/foo.rb +1 -0
  156. data/test/test-nest/foo/bar.rb +2 -0
  157. data/test/test-nest/foo/foo.rb +1 -0
  158. data/test/test-nest/test-nest.rb +1 -0
  159. data/test/test-nest/test-nest.ret +1 -0
  160. data/test/test-preload.rb +24 -0
  161. data/test/test-preload/test-preload.rb +9 -0
  162. data/test/test-regexp.rb +26 -0
  163. data/test/test-regexp/test-regexp.rb +23 -0
  164. data/test/test-regexp/test-regexp.ret +13 -0
  165. data/test/test-require1.rb +26 -0
  166. data/test/test-require1/require1.rb +9 -0
  167. data/test/test-require1/require2.rb +9 -0
  168. data/test/test-require1/require3.rb +9 -0
  169. data/test/test-require1/require4.rb +9 -0
  170. data/test/test-require1/require5.rb +9 -0
  171. data/test/test-require1/require6.rb +9 -0
  172. data/test/test-require1/test-require1.rb +41 -0
  173. data/test/test-require1/test-require1.ret +27 -0
  174. data/test/test-socket.rb +26 -0
  175. data/test/test-socket/test-socket.rb +7 -0
  176. data/test/test-socket/test-socket.ret +1 -0
  177. data/test/testcase.rb +66 -0
  178. data/vendor/mkexports.rb +167 -0
  179. metadata +352 -0
@@ -0,0 +1,6 @@
1
+ $Id: README.ja.txt,v 1.1 2005/10/12 02:52:53 yuya Exp $
2
+
3
+ �@Exerb �́ARuby �X�N���v�g�� Windows ���s�`���t�@�C����
4
+ �ϊ����邽�߂̃\�t�g�E�F�A�ł��B
5
+
6
+ �ڂ����� README.ja.html �������������B
@@ -0,0 +1,50 @@
1
+ # Exerb
2
+
3
+ Packaged ruby source files and required other (*.rb *.so *.dll) to a .exe file.
4
+
5
+ ## Installation
6
+
7
+
8
+ 1. install RubyInstaller's DevKit
9
+
10
+ from `http://rubyinstaller.org/add-ons/devkit` download and install
11
+ cd %DEVKITPATH% # install path, like c:/rbmingw
12
+ ruby dk.rb init
13
+ notepad config.yml # edit config file, set ruby installed path
14
+ ruby install
15
+ ruby -e "require 'devkit'; puts ENV\['RI_DEVKIT']" # test, ensure the path is %DEVKITPATH%
16
+
17
+ 2. install gem
18
+
19
+ gem install exerb
20
+
21
+ ## Usage
22
+
23
+ 1. generate one or more ruby source files do some thing and test it
24
+
25
+ ruby r1.rb arg1 arg2 arg3
26
+
27
+ 2. make exy file from ruby source file
28
+
29
+ mkexy -- r1.rb arg1 arg2 arg3 # or
30
+ ruby -r exerb/mkexy r1.rb arg1 arg2 arg3
31
+
32
+ 3. check r1.exy file, check every required files.
33
+ can be change `general.core` to `cui/gui`, add `resource` , `path` section
34
+ more demo old_*.exy in example/ and test/ directory
35
+
36
+ 4. generate exe file
37
+
38
+ exerb -v r1.exy
39
+
40
+ 5. execute EXE file
41
+
42
+ r1.exe arg1 arg2 arg3 # can receive some result as ruby r1.rb arg1 arg2 arg3
43
+
44
+ ## Contributing
45
+
46
+ 1. Fork it ( https://github.com/[my-github-username]/exerb/fork )
47
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
48
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
49
+ 4. Push to the branch (`git push origin my-new-feature`)
50
+ 5. Create a new Pull Request
@@ -0,0 +1,205 @@
1
+ begin
2
+ require 'devkit'
3
+ raise LoadError unless ENV['RI_DEVKIT'] # need RubyInstaller's DevKit, not devkit gem.
4
+ rescue LoadError
5
+ msg = "You need to install the devkit to compile exerb-mingw.\n"
6
+ msg << " http://rubyinstaller.org/add-ons/devkit/"
7
+ abort msg
8
+ end
9
+ require 'rbconfig'
10
+ require 'ostruct'
11
+ require 'rake/clean'
12
+
13
+ unless RUBY_VERSION >= "1.9.3"
14
+ fail "You need at least Ruby 1.9.3 to compile exerb-mingw."
15
+ end
16
+
17
+ # Include vendored scripts
18
+ $LOAD_PATH.unshift File.expand_path("../vendor", __FILE__)
19
+ require "mkexports"
20
+
21
+ EXERB_CFLAGS = "-DRUBY19 -DRUBY19_COMPILED_CODE"
22
+
23
+ C = OpenStruct.new
24
+ c = RbConfig::CONFIG
25
+ c['CFLAGS'] = ' -Wall -std=gnu99 -O3 -g -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Werror=pointer-arith -Werror=write-strings '
26
+ C.arch = c["arch"]
27
+ C.cc = "#{c['CC'] || 'gcc'}"
28
+ C.cflags = "#{c['CFLAGS'] || '-Os'}"
29
+ C.xcflags = "#{c['XCFLAGS'] || '-DRUBY_EXPORT'}"
30
+ C.exerb_cflags = EXERB_CFLAGS
31
+ C.cppflags = c['CPPFLAGS']
32
+ if c['rubyhdrdir']
33
+ C.incflags = "-I#{c['rubyhdrdir']}/#{c['arch']} -I#{c['rubyhdrdir']}" if c['rubyhdrdir']
34
+ else
35
+ C.incflags = "-I#{c['archdir']}"
36
+ end
37
+ C.ldflags = "-L#{c['libdir']}"
38
+ C.xldflags = "#{c['XLDFLAGS'] || '-Wl,--stack=0x02000000,--wrap=rb_require_safe,--wrap=rb_require'}"
39
+ C.rubylib = "#{c['LIBRUBYARG_STATIC']}"
40
+ C.libs = "#{c['LIBS']}"
41
+ C.ver = RUBY_VERSION.gsub('.','')
42
+
43
+ def make_resource(target, source, type)
44
+ file target => source do
45
+ mkdir_p File.dirname(target)
46
+ sh "windres -D#{type} #{source} #{target}"
47
+ end
48
+ end
49
+
50
+ def compile_c(target, source)
51
+ cmdline = "#{C.cc} #{C.cflags} #{C.xcflags} #{C.cppflags} #{C.incflags} -c -o #{target} #{source}"
52
+ file target => source do
53
+ mkdir_p File.dirname(target)
54
+ sh cmdline
55
+ end
56
+ end
57
+
58
+ def link_cpp(target, options)
59
+ sources = options[:sources]
60
+ cc = 'gcc'
61
+ cflags = "#{C.cflags} #{C.xcflags} #{C.exerb_cflags} #{C.cppflags} #{C.incflags}"
62
+ ldflags = "#{C.ldflags} #{C.xldflags}"
63
+ dllflags = options[:isdll] ? "-shared" : ""
64
+ guiflags = options[:gui] ? "-mwindows" : ""
65
+ dldflags = options[:isdll] ? "-Wl,--enable-auto-image-base,--enable-auto-import,--export-all" : ""
66
+ impflags = options[:implib] ? "-Wl,--out-implib=#{options[:implib]}" : ""
67
+ rubylib = (options[:rubylib] || C.rubylib)
68
+ libs = C.libs
69
+ cmdline = "#{cc} #{cflags} #{ldflags} #{dllflags} #{guiflags} #{dldflags} #{impflags} -s -o #{target} #{sources.join(' ')} #{rubylib} #{libs}"
70
+ file target => sources + Array(options[:dependencies]) do
71
+ mkdir_p File.dirname(options[:implib]) if options[:implib]
72
+ mkdir_p File.dirname(target)
73
+ sh cmdline
74
+ sh "strip -R .reloc #{target}" unless options[:isdll]
75
+ end
76
+ file options[:implib] => target if options[:implib]
77
+ end
78
+
79
+ # FIXME: is not mapping all the exports
80
+ def make_def_proxy(target, source, proxy)
81
+ file target => source do
82
+ mkdir_p File.dirname(target)
83
+ File.open(target, "w") do |out|
84
+ File.open(source, "r").each_line do |line|
85
+ case line
86
+ when /\A\s*(LIBRARY|EXPORTS)/
87
+ out.puts line
88
+ when /\A(\s*)(\w+@\w+)=(rb_w32_\w+@.*)\Z/
89
+ out.puts "#{$1}#{$2} = #{proxy}.#{$3}"
90
+ when /\A(\s*)(\w+)=(rb_w32_\w+)\Z/
91
+ out.puts "#{$1}#{$2} = #{proxy}.#{$3}"
92
+ when /\A(\s*)(\w+@\w+)(\s+@.*)\Z/
93
+ out.puts "#{$1}#{$2} = #{proxy}.#{$2}#{$3}"
94
+ when /\A(\s*)(\w+)(\s+@.*)\Z/
95
+ out.puts "#{$1}#{$2} = #{proxy}.#{$2}#{$3}"
96
+ else
97
+ out.puts line
98
+ end
99
+ end
100
+ end
101
+ end
102
+ end
103
+
104
+ def make_def(target, source_lib)
105
+ file target => [source_lib] do
106
+ mkdir_p File.dirname(target)
107
+
108
+ puts "generating #{target}"
109
+ exports = Exports.extract([source_lib])
110
+ Exports.output(target) { |f| f.puts(*exports) }
111
+ end
112
+ end
113
+
114
+ def make_config(target, libruby_name, libruby_so)
115
+ file target do
116
+ puts "generating header #{target}"
117
+ File.open(target, "w") do |f|
118
+ f.write <<-EOH.gsub(/^\s+/, '')
119
+ #ifndef _EXERB_CONFIG_H_
120
+ #define _EXERB_CONFIG_H_
121
+
122
+ #define EXERB_LIBRUBY_NAME "#{libruby_name}"
123
+ #define EXERB_LIBRUBY_SO "#{libruby_so}"
124
+
125
+ #endif /* _EXERB_CONFIG_H_ */
126
+ EOH
127
+ end
128
+ end
129
+ CLEAN.include target
130
+ end
131
+
132
+ # Ruby 1.9.1 doesn't have SyncEnumerator
133
+ # This function is inspired by Python's zip
134
+ def zip(*enums)
135
+ r = block_given? ? nil : []
136
+ len = enums.collect { |x| x.size }.max
137
+ len.times do |i|
138
+ val = enums.collect { |x| x[i] }
139
+ if block_given?
140
+ yield val
141
+ else
142
+ r << val
143
+ end
144
+ end
145
+ r
146
+ end
147
+
148
+ exerb_dll_base = "exerb53"
149
+ exerb_config_header = "src/exerb/config.h"
150
+ file_resource_rc = "src/exerb/resource.rc"
151
+ file_resource_dll_o = "tmp/resource_dll.o"
152
+ file_resource_cui_o = "tmp/resource_cui.o"
153
+ file_resource_gui_o = "tmp/resource_gui.o"
154
+ file_exerb_def = "tmp/#{exerb_dll_base}.def"
155
+ file_exerb_lib = "tmp/#{exerb_dll_base}.dll.a"
156
+ file_exerb_rt_def = "tmp/#{exerb_dll_base}_rt.def"
157
+ file_exerb_dll = "data/exerb/#{exerb_dll_base}.dll"
158
+ file_ruby_cui = "data/exerb/ruby#{C.ver}c.exc"
159
+ file_ruby_cui_rt = "data/exerb/ruby#{C.ver}crt.exc"
160
+ file_ruby_gui = "data/exerb/ruby#{C.ver}g.exc"
161
+ file_ruby_gui_rt = "data/exerb/ruby#{C.ver}grt.exc"
162
+
163
+ lib_sources = Dir["src/exerb/{exerb,module,utility,patch}.c"]
164
+ dll_sources = [file_resource_dll_o]
165
+ cui_sources = ["src/exerb/cui.c", file_resource_cui_o]
166
+ gui_sources = ["src/exerb/gui.c", file_resource_gui_o]
167
+
168
+ make_resource file_resource_dll_o, file_resource_rc, "RUNTIME"
169
+
170
+ make_config exerb_config_header, c["RUBY_SO_NAME"], c["LIBRUBY_SO"]
171
+
172
+ make_def file_exerb_def, File.join(c["libdir"], c["LIBRUBY_A"])
173
+ make_def_proxy file_exerb_rt_def, file_exerb_def, exerb_dll_base
174
+
175
+ link_cpp file_exerb_dll, :sources => (dll_sources + lib_sources + [file_exerb_def]), :dependencies => exerb_config_header, :isdll => true, :implib => file_exerb_lib
176
+
177
+ make_resource file_resource_cui_o, file_resource_rc, "CUI"
178
+ link_cpp file_ruby_cui, :sources => (cui_sources + lib_sources + [file_exerb_def]), :dependencies => exerb_config_header
179
+ link_cpp file_ruby_cui_rt, :sources => (cui_sources + [file_exerb_lib]), :rubylib => "", :dependencies => exerb_config_header
180
+
181
+ make_resource file_resource_gui_o, file_resource_rc, "GUI"
182
+ link_cpp file_ruby_gui, :sources => (gui_sources + lib_sources + [file_exerb_def]), :gui => true, :dependencies => exerb_config_header
183
+ link_cpp file_ruby_gui_rt, :sources => (gui_sources + [file_exerb_lib]), :rubylib => "", :gui => true, :dependencies => exerb_config_header
184
+
185
+ task :rm_tmp do
186
+ FileUtils.rm_rf('tmp') if File.directory?('tmp')
187
+ end
188
+
189
+ desc "generate cui and gui exa data"
190
+ task :generate => [
191
+ file_ruby_cui,
192
+ file_ruby_cui_rt,
193
+ file_ruby_gui,
194
+ file_ruby_gui_rt,
195
+ :rm_tmp
196
+ ]
197
+
198
+ desc "show infomation"
199
+ task :default do
200
+ puts "Please use 'gem' to build and install gem."
201
+ puts " This Rakefile used by generate data."
202
+ end
203
+
204
+ CLEAN.include('tmp')
205
+ CLOBBER.include('data')
@@ -0,0 +1,185 @@
1
+ #! G:/Ruby193/bin/ruby.exe
2
+
3
+ #==============================================================================#
4
+ # $Id: exerb,v 1.36 2008/06/13 23:54:45 arton Exp $
5
+ #==============================================================================#
6
+
7
+ require 'getoptlong'
8
+ require 'exerb/version'
9
+ require 'exerb/config'
10
+ require 'exerb/recipe'
11
+ require 'exerb/executable'
12
+
13
+ #==============================================================================#
14
+
15
+ module ExerbCommand
16
+
17
+ OPTIONS = [
18
+ ['--corename', '-c', GetoptLong::REQUIRED_ARGUMENT, 'specifies exerb-core by defined name.'],
19
+ ['--corefile', '-C', GetoptLong::REQUIRED_ARGUMENT, 'specifies exerb-core by path.'],
20
+ ['--outfile', '-o', GetoptLong::REQUIRED_ARGUMENT, 'specifies output file.'],
21
+ ['--kcode', '-k', GetoptLong::REQUIRED_ARGUMENT, 'specifies character code-set. (none/euc/sjis/utf8)'],
22
+ ['--archive', '-a', GetoptLong::NO_ARGUMENT, 'create an archive only.'],
23
+ ['--verbose', '-v', GetoptLong::NO_ARGUMENT, 'enable verbose mode.'],
24
+ # ['--debug', '-g', GetoptLong::NO_ARGUMENT, 'enable debug mode.'],
25
+ ['--execute', '-e', GetoptLong::NO_ARGUMENT, 'execute an executable file after creation.'],
26
+ ['--config', '-i', GetoptLong::NO_ARGUMENT, 'display config information.'],
27
+ ['--version', '-V', GetoptLong::NO_ARGUMENT, 'display version number.'],
28
+ ['--help', '-h', GetoptLong::NO_ARGUMENT, 'display this information.'],
29
+ ]
30
+
31
+ def self.main(argv)
32
+ options = self.parse_options(argv)
33
+
34
+ self.print_config_and_exit if options[:config]
35
+ self.print_version_and_exit if options[:version]
36
+ self.print_usage_and_exit if options[:help] || argv.size < 1
37
+
38
+ arg_fname = argv.shift
39
+ arg_kcode = options[:kcode]
40
+ arg_core = options[:corefile]
41
+ arg_core ||= Exerb::Utility.find_core_by_name(options[:corename], true) if options[:corename]
42
+
43
+ recipe =
44
+ if /\.rbw?$/i =~ arg_fname
45
+ path1 = File.expand_path('../../lib', __FILE__)
46
+ system(Gem.ruby, "-I#{path1}", "-rexerb/mkexy", arg_fname)
47
+ Exerb::Recipe.load(arg_fname.chomp(File.extname(arg_fname)) + '.exy')
48
+ else
49
+ Exerb::Recipe.load(arg_fname)
50
+ end
51
+
52
+ # FIXME: arg priority
53
+ archive = recipe.create_archive(arg_kcode)
54
+ core_file = recipe.core_filepath(arg_core)
55
+ output_file = recipe.output_filepath(options[:outfile])
56
+ archive_file = recipe.archive_filepath(options[:outfile])
57
+
58
+ raise(Exerb::ExerbError, "a core file isn't specified") if core_file.nil?
59
+ raise(Exerb::ExerbError, "no such file -- #{core_file}") unless File.exist?(core_file)
60
+ raise(Exerb::ExerbError, "no such directory -- #{File.dirname(output_file)}") unless File.directory?(File.dirname(output_file))
61
+
62
+ if options[:verbose]
63
+ puts("Recipe File : #{arg_fname}")
64
+ puts("Core File : #{core_file}")
65
+ puts("Archive File : #{archive_file}") if options[:archive]
66
+ puts("Output File : #{output_file}")
67
+ end
68
+
69
+ if options[:archive]
70
+ archive.write_to_file(archive_file)
71
+ else
72
+ executable = Exerb::Executable.read(core_file)
73
+ executable.rsrc.add_archive(archive)
74
+ recipe.update_resource(executable.rsrc)
75
+ executable.write(output_file)
76
+
77
+ exec(File.expand_path(output_file)) if options[:execute]
78
+ end
79
+
80
+ exit(0)
81
+ rescue Exerb::ExerbError => e
82
+ STDERR.puts("exerb: #{e.message}")
83
+ exit(1)
84
+ end
85
+
86
+ def self.parse_options(argv)
87
+ options = {}
88
+ config = OPTIONS.collect { |ary| ary[0, 3] }
89
+
90
+ parser = GetoptLong.new
91
+ parser.set_options(*config)
92
+ parser.each_option { |name, argument|
93
+ options[name.sub(/^--/, '').intern] = argument
94
+ }
95
+
96
+ options[:archive] = !!options[:archive]
97
+ options[:verbose] = !!options[:verbose]
98
+ # options[:debug] = !!options[:debug]
99
+ options[:execute] = !!options[:execute]
100
+ options[:config] = !!options[:config]
101
+ options[:version] = !!options[:version]
102
+ options[:help] = !!options[:help]
103
+
104
+ return options
105
+ rescue GetoptLong::InvalidOption
106
+ exit(1)
107
+ end
108
+
109
+ def self.print_config_and_exit
110
+ puts "Exerb #{Exerb::VERSION}"
111
+
112
+ puts
113
+ puts "Search directories of Ruby library:"
114
+ $LOAD_PATH.each { |path| printf(" %s\n", File.expand_path(path)) }
115
+
116
+ puts
117
+ puts "Search directories of Exerb core:"
118
+ Exerb::CORE_PATH.each { |path| printf(" %s\n", File.expand_path(path)) }
119
+
120
+ name_max = Exerb::CORE_NAME.keys.collect { |name| name.size }.max
121
+
122
+ puts
123
+ puts "Defined names of Exerb core:"
124
+ Exerb::CORE_NAME.keys.sort.each { |name|
125
+ filename = Exerb::Utility.find_core_by_name(name)
126
+ message = (filename.nil? ? " (not found in search directories)" : "")
127
+ printf(" %s => %s%s\n", name.ljust(name_max), Exerb::CORE_NAME[name], message)
128
+ }
129
+
130
+ exit(1)
131
+ end
132
+
133
+ def self.print_version_and_exit
134
+ puts "Exerb #{Exerb::VERSION}"
135
+ exit(1)
136
+ end
137
+
138
+ def self.print_usage_and_exit
139
+ puts("Exerb #{Exerb::VERSION}")
140
+
141
+ puts
142
+ puts("Usage: exerb [options] {script-file|recipe-file}")
143
+
144
+ puts
145
+ puts("Options:")
146
+ OPTIONS.each { |long, short, arg, comment|
147
+ printf(" %s %-10s %s\n", short, long, comment)
148
+ }
149
+
150
+ exit(1)
151
+ end
152
+
153
+ =begin
154
+ def self.make_filename(filename, extension)
155
+ return filename.sub(/(\.exr$|$)/i, '.' + extension)
156
+ end
157
+
158
+ def self.select_core_file(options, recipe)
159
+ core_file = options[:corefile]
160
+ core_file ||= Exerb::Utility.find_core_by_name(options[:corename], true) if options[:corename]
161
+ core_file ||= recipe.corefile
162
+ core_file ||= Exerb::Utility.find_core_by_name('cui')
163
+ core_file ||= Exerb::Utility.find_core_by_name('gui')
164
+ core_file ||= raise(Exerb::ExerbError, "a core file isn't specified in the recipe file and command line options.")
165
+
166
+ return core_file
167
+ end
168
+
169
+ def self.select_out_file(options, recipe, recipe_file)
170
+ out_file = options[:outfile]
171
+ out_file ||= recipe.outfile
172
+ out_file ||= self.make_filename(recipe_file, 'exe')
173
+
174
+ return out_file
175
+ end
176
+ =end
177
+
178
+ end
179
+
180
+ #==============================================================================#
181
+
182
+ ExerbCommand.main(ARGV)
183
+
184
+ #==============================================================================#
185
+ #==============================================================================#
@@ -0,0 +1,47 @@
1
+ #! G:/Ruby193/bin/ruby.exe
2
+
3
+ #==============================================================================#
4
+ # $Id: mkexy,v 1.4 2008/06/13 23:54:45 arton Exp $
5
+ #==============================================================================#
6
+
7
+ require 'rubygems'
8
+ require 'optparse'
9
+
10
+ path1 = File.expand_path('../../lib', __FILE__)
11
+ ENV['old_exy'] = nil
12
+ ENV['exy_zipd'] = nil
13
+
14
+ OptionParser.new do |opts|
15
+ opts.banner = "MKEXY from ruby source file generate exy file\n\n" +
16
+ "Usage:\n" +
17
+ " mkexy [mkexy_options] [-- ruby_options] ruby_script ===(same as)\n" +
18
+ " ruby -r exerb/mkexy [ ruby_options] ruby_script\n"
19
+
20
+ opts.separator ""
21
+ opts.separator "mkexy specific options:"
22
+
23
+ opts.on("-o", "--old xxx.exy", "from old EXY file find core/resource/path info") do |exy|
24
+ ENV['old_exy'] = exy
25
+ end
26
+
27
+ opts.on("-c", "--compress", "use zlib deflate ruby source file") do |zipd|
28
+ ENV['exy_zipd'] = 'true'
29
+ end
30
+
31
+ opts.on("-h", "--help", "Show this message") do |v|
32
+ puts opts
33
+ exit 0
34
+ end
35
+
36
+ opts.on("-v", "--version", "Show version") do |v|
37
+ require "#{path1}/exerb/version"
38
+ puts "mkexy version: #{Exerb::VERSION}"
39
+ exit 0
40
+ end
41
+ end.parse!
42
+
43
+
44
+ exec(Gem.ruby, *(["-I#{path1}", "-rexerb/mkexy"] + ARGV))
45
+
46
+ #==============================================================================#
47
+ #==============================================================================#