standalone-ruby 1.5.0 → 1.5.2

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.
Files changed (170) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +53 -44
  3. data/bin/standalone-ruby +3 -3
  4. data/lib/data/c_compilers/tcc/include/_mingw.h +54 -54
  5. data/lib/data/c_compilers/tcc/include/assert.h +71 -71
  6. data/lib/data/c_compilers/tcc/include/conio.h +159 -159
  7. data/lib/data/c_compilers/tcc/include/ctype.h +232 -232
  8. data/lib/data/c_compilers/tcc/include/dir.h +26 -26
  9. data/lib/data/c_compilers/tcc/include/direct.h +95 -95
  10. data/lib/data/c_compilers/tcc/include/dirent.h +96 -96
  11. data/lib/data/c_compilers/tcc/include/dos.h +110 -110
  12. data/lib/data/c_compilers/tcc/include/errno.h +117 -117
  13. data/lib/data/c_compilers/tcc/include/excpt.h +20 -20
  14. data/lib/data/c_compilers/tcc/include/fcntl.h +135 -135
  15. data/lib/data/c_compilers/tcc/include/fenv.h +85 -85
  16. data/lib/data/c_compilers/tcc/include/float.h +224 -224
  17. data/lib/data/c_compilers/tcc/include/inttypes.h +275 -275
  18. data/lib/data/c_compilers/tcc/include/io.h +296 -296
  19. data/lib/data/c_compilers/tcc/include/limits.h +115 -115
  20. data/lib/data/c_compilers/tcc/include/locale.h +100 -100
  21. data/lib/data/c_compilers/tcc/include/malloc.h +87 -87
  22. data/lib/data/c_compilers/tcc/include/math.h +438 -438
  23. data/lib/data/c_compilers/tcc/include/mem.h +8 -8
  24. data/lib/data/c_compilers/tcc/include/memory.h +9 -9
  25. data/lib/data/c_compilers/tcc/include/process.h +158 -158
  26. data/lib/data/c_compilers/tcc/include/setjmp.h +72 -72
  27. data/lib/data/c_compilers/tcc/include/share.h +44 -44
  28. data/lib/data/c_compilers/tcc/include/signal.h +111 -111
  29. data/lib/data/c_compilers/tcc/include/stdarg.h +16 -16
  30. data/lib/data/c_compilers/tcc/include/stdbool.h +10 -10
  31. data/lib/data/c_compilers/tcc/include/stddef.h +26 -26
  32. data/lib/data/c_compilers/tcc/include/stdint.h +184 -184
  33. data/lib/data/c_compilers/tcc/include/stdio.h +413 -413
  34. data/lib/data/c_compilers/tcc/include/stdlib.h +482 -482
  35. data/lib/data/c_compilers/tcc/include/string.h +206 -206
  36. data/lib/data/c_compilers/tcc/include/sys/fcntl.h +8 -8
  37. data/lib/data/c_compilers/tcc/include/sys/file.h +9 -9
  38. data/lib/data/c_compilers/tcc/include/sys/locking.h +52 -52
  39. data/lib/data/c_compilers/tcc/include/sys/stat.h +190 -190
  40. data/lib/data/c_compilers/tcc/include/sys/time.h +3 -3
  41. data/lib/data/c_compilers/tcc/include/sys/timeb.h +82 -82
  42. data/lib/data/c_compilers/tcc/include/sys/types.h +118 -118
  43. data/lib/data/c_compilers/tcc/include/sys/unistd.h +9 -9
  44. data/lib/data/c_compilers/tcc/include/sys/utime.h +89 -89
  45. data/lib/data/c_compilers/tcc/include/tchar.h +367 -367
  46. data/lib/data/c_compilers/tcc/include/time.h +219 -219
  47. data/lib/data/c_compilers/tcc/include/unistd.h +10 -10
  48. data/lib/data/c_compilers/tcc/include/values.h +4 -4
  49. data/lib/data/c_compilers/tcc/include/varargs.h +11 -11
  50. data/lib/data/c_compilers/tcc/include/wchar.h +318 -318
  51. data/lib/data/c_compilers/tcc/include/wctype.h +127 -127
  52. data/lib/data/c_compilers/tcc/include/winapi/basetsd.h +119 -119
  53. data/lib/data/c_compilers/tcc/include/winapi/basetyps.h +144 -144
  54. data/lib/data/c_compilers/tcc/include/winapi/winbase.h +1852 -1852
  55. data/lib/data/c_compilers/tcc/include/winapi/wincon.h +207 -207
  56. data/lib/data/c_compilers/tcc/include/winapi/windef.h +240 -240
  57. data/lib/data/c_compilers/tcc/include/winapi/windows.h +176 -176
  58. data/lib/data/c_compilers/tcc/include/winapi/winerror.h +1054 -1054
  59. data/lib/data/c_compilers/tcc/include/winapi/wingdi.h +2843 -2843
  60. data/lib/data/c_compilers/tcc/include/winapi/winnetwk.h +346 -346
  61. data/lib/data/c_compilers/tcc/include/winapi/winnls.h +651 -651
  62. data/lib/data/c_compilers/tcc/include/winapi/winnt.h +2667 -2667
  63. data/lib/data/c_compilers/tcc/include/winapi/winreg.h +159 -159
  64. data/lib/data/c_compilers/tcc/include/winapi/winsvc.h +309 -309
  65. data/lib/data/c_compilers/tcc/include/winapi/winuser.h +3472 -3472
  66. data/lib/data/c_compilers/tcc/include/winapi/winver.h +133 -133
  67. data/lib/data/c_compilers/tcc/lib/gdi32.def +337 -337
  68. data/lib/data/c_compilers/tcc/lib/kernel32.def +763 -763
  69. data/lib/data/c_compilers/tcc/lib/msvcrt.def +782 -782
  70. data/lib/data/c_compilers/tcc/lib/user32.def +654 -654
  71. data/lib/data/exe_templates/launcher_stub.c +29 -29
  72. data/lib/data/exe_templates/launcher_stub.cpp +31 -31
  73. data/lib/data/launcher_templates/vbs/default_vbs.txt +7 -7
  74. data/lib/data/launcher_templates/vbs/vbs_gui.txt +8 -8
  75. data/lib/data/resource_files/default.rc +17 -17
  76. data/lib/displayer.rb +63 -65
  77. data/lib/exe_packer.rb +72 -82
  78. data/lib/launcher.rb +58 -84
  79. data/lib/launcher_handler.rb +40 -52
  80. data/lib/parameter_parser.rb +215 -210
  81. data/lib/ruby_copy.rb +48 -26
  82. data/lib/standalone_ruby.rb +6 -6
  83. data/lib/version/version.rb +2 -2
  84. metadata +3 -89
  85. data/lib/data/bat-cmd/default_bat_cmd.txt +0 -9
  86. data/lib/data/exe_template/launcher_stub.c +0 -30
  87. data/lib/data/exe_template/launcher_stub.cpp +0 -9
  88. data/lib/data/tcc/include/_mingw.h +0 -54
  89. data/lib/data/tcc/include/assert.h +0 -71
  90. data/lib/data/tcc/include/conio.h +0 -159
  91. data/lib/data/tcc/include/ctype.h +0 -232
  92. data/lib/data/tcc/include/dir.h +0 -26
  93. data/lib/data/tcc/include/direct.h +0 -95
  94. data/lib/data/tcc/include/dirent.h +0 -96
  95. data/lib/data/tcc/include/dos.h +0 -110
  96. data/lib/data/tcc/include/errno.h +0 -117
  97. data/lib/data/tcc/include/excpt.h +0 -20
  98. data/lib/data/tcc/include/fcntl.h +0 -135
  99. data/lib/data/tcc/include/fenv.h +0 -85
  100. data/lib/data/tcc/include/float.h +0 -224
  101. data/lib/data/tcc/include/inttypes.h +0 -275
  102. data/lib/data/tcc/include/io.h +0 -296
  103. data/lib/data/tcc/include/limits.h +0 -115
  104. data/lib/data/tcc/include/locale.h +0 -100
  105. data/lib/data/tcc/include/malloc.h +0 -87
  106. data/lib/data/tcc/include/math.h +0 -438
  107. data/lib/data/tcc/include/mem.h +0 -8
  108. data/lib/data/tcc/include/memory.h +0 -9
  109. data/lib/data/tcc/include/process.h +0 -158
  110. data/lib/data/tcc/include/setjmp.h +0 -72
  111. data/lib/data/tcc/include/share.h +0 -44
  112. data/lib/data/tcc/include/signal.h +0 -111
  113. data/lib/data/tcc/include/stdarg.h +0 -16
  114. data/lib/data/tcc/include/stdbool.h +0 -10
  115. data/lib/data/tcc/include/stddef.h +0 -26
  116. data/lib/data/tcc/include/stdint.h +0 -184
  117. data/lib/data/tcc/include/stdio.h +0 -413
  118. data/lib/data/tcc/include/stdlib.h +0 -482
  119. data/lib/data/tcc/include/string.h +0 -206
  120. data/lib/data/tcc/include/sys/fcntl.h +0 -8
  121. data/lib/data/tcc/include/sys/file.h +0 -9
  122. data/lib/data/tcc/include/sys/locking.h +0 -52
  123. data/lib/data/tcc/include/sys/stat.h +0 -190
  124. data/lib/data/tcc/include/sys/time.h +0 -3
  125. data/lib/data/tcc/include/sys/timeb.h +0 -82
  126. data/lib/data/tcc/include/sys/types.h +0 -118
  127. data/lib/data/tcc/include/sys/unistd.h +0 -9
  128. data/lib/data/tcc/include/sys/utime.h +0 -89
  129. data/lib/data/tcc/include/tchar.h +0 -367
  130. data/lib/data/tcc/include/time.h +0 -219
  131. data/lib/data/tcc/include/unistd.h +0 -10
  132. data/lib/data/tcc/include/values.h +0 -4
  133. data/lib/data/tcc/include/varargs.h +0 -11
  134. data/lib/data/tcc/include/wchar.h +0 -318
  135. data/lib/data/tcc/include/wctype.h +0 -127
  136. data/lib/data/tcc/include/winapi/basetsd.h +0 -119
  137. data/lib/data/tcc/include/winapi/basetyps.h +0 -144
  138. data/lib/data/tcc/include/winapi/winbase.h +0 -1852
  139. data/lib/data/tcc/include/winapi/wincon.h +0 -207
  140. data/lib/data/tcc/include/winapi/windef.h +0 -240
  141. data/lib/data/tcc/include/winapi/windows.h +0 -176
  142. data/lib/data/tcc/include/winapi/winerror.h +0 -1054
  143. data/lib/data/tcc/include/winapi/wingdi.h +0 -2843
  144. data/lib/data/tcc/include/winapi/winnetwk.h +0 -346
  145. data/lib/data/tcc/include/winapi/winnls.h +0 -651
  146. data/lib/data/tcc/include/winapi/winnt.h +0 -2667
  147. data/lib/data/tcc/include/winapi/winreg.h +0 -159
  148. data/lib/data/tcc/include/winapi/winsvc.h +0 -309
  149. data/lib/data/tcc/include/winapi/winuser.h +0 -3472
  150. data/lib/data/tcc/include/winapi/winver.h +0 -133
  151. data/lib/data/tcc/lib/gdi32.def +0 -337
  152. data/lib/data/tcc/lib/kernel32.def +0 -763
  153. data/lib/data/tcc/lib/libtcc1.a +0 -0
  154. data/lib/data/tcc/lib/msvcrt.def +0 -782
  155. data/lib/data/tcc/lib/user32.def +0 -654
  156. data/lib/data/tcc/tcc.exe +0 -0
  157. data/lib/data/tcc/tiny_impdef.exe +0 -0
  158. data/lib/data/tcc/tiny_libmaker.exe +0 -0
  159. data/lib/data/vbs/default_vbs.txt +0 -7
  160. data/lib/data/vbs/vbs_gui.txt +0 -8
  161. data/lib/logger_helper.rb +0 -24
  162. data/lib/sfx_generator.rb +0 -11
  163. data/lib/utils/config_generator.rb +0 -5
  164. data/lib/utils/displayer.rb +0 -64
  165. data/lib/utils/exe_packer.rb +0 -72
  166. data/lib/utils/launcher.rb +0 -77
  167. data/lib/utils/launcher_handler.rb +0 -111
  168. data/lib/utils/logger_helper.rb +0 -24
  169. data/lib/utils/parameter_parser.rb +0 -211
  170. data/lib/utils/ruby_copy.rb +0 -26
@@ -1,53 +1,41 @@
1
- require 'fileutils'
2
-
3
- require_relative 'logger_helper'
4
-
5
- class LauncherHandler
6
- def initialize(params)
7
- @params = params
8
- @logger = LoggerHelper.instance
9
- end
10
-
11
- def handle
12
- begin
13
- puts("\nThe template creation process has been started.")
14
-
15
- ruby_file = @params[:gui] ? "rubyw.exe" : "ruby.exe"
16
-
17
- if @params[:gui] == true
18
- vbs_template = File.join(File.expand_path("data/launcher_templates/vbs", __dir__), "vbs_gui.txt")
19
- ruby_file = "rubyw.exe"
20
- else
21
- vbs_template = File.join(File.expand_path("data/launcher_templates/vbs", __dir__), "default_vbs.txt")
22
- ruby_file = "ruby.exe"
23
- end
24
-
25
- puts "Using: #{vbs_template}"
26
-
27
- if File.exist?(vbs_template)
28
- content = File.read(vbs_template)
29
- @logger.info("The content of the template has been read.")
30
-
31
- content.gsub!("STANDALONE_RUBY_PATH", "#{File.join(File.basename(@params[:ruby_path].to_s), "bin", "#{ruby_file}")}")
32
- @logger.info("Placed the defined Ruby interpreter path in the template.")
33
-
34
- content.gsub!("STANDALONE_MAIN_FILE", "#{File.basename(@params[:main_file].to_s)}")
35
- @logger.info("The main project file path defined in the template is placed.")
36
-
37
- new_launcher_path = File.join(@params[:project_path].to_s, @params[:launcher_name].to_s)
38
- File.open(new_launcher_path, "w") do |f_man|
39
- f_man.puts content
40
- end
41
-
42
- @logger.info("New launcher file directory created as #{new_launcher_path.to_s}")
43
- else
44
- print("Handler Error: ".red); puts("The template file could not be found.")
45
- @logger.error("Template file not found!")
46
- exit!
47
- end
48
- rescue Exception => e
49
- print("Handler Error: ".red); puts("#{e.message}")
50
- @logger.error("Handler Error: #{e.message}")
51
- end
52
- end
1
+ require 'fileutils'
2
+
3
+ class LauncherHandler
4
+ def initialize(params)
5
+ @params = params
6
+ end
7
+
8
+ def handle
9
+ begin
10
+ puts("\nThe template creation process has been started.")
11
+
12
+ ruby_file = @params[:gui] ? "rubyw.exe" : "ruby.exe"
13
+
14
+ if @params[:gui] == true
15
+ vbs_template = File.join(File.expand_path("data/launcher_templates/vbs", __dir__), "vbs_gui.txt")
16
+ else
17
+ vbs_template = File.join(File.expand_path("data/launcher_templates/vbs", __dir__), "default_vbs.txt")
18
+ end
19
+
20
+ puts "Using: #{vbs_template}"
21
+
22
+ if File.exist?(vbs_template)
23
+ content = File.read(vbs_template)
24
+
25
+ content.gsub!("STANDALONE_RUBY_PATH", "#{File.join(File.basename(@params[:ruby_path].to_s), "bin", "#{ruby_file}")}")
26
+ content.gsub!("STANDALONE_MAIN_FILE", "#{File.basename(@params[:main_file].to_s)}")
27
+
28
+ new_launcher_path = File.join(@params[:project_path].to_s, @params[:launcher_name].to_s)
29
+ File.open(new_launcher_path, "w") do |f_man|
30
+ f_man.puts content
31
+ end
32
+
33
+ else
34
+ print("Handler Error: ".red); puts("The template file could not be found.")
35
+ exit!
36
+ end
37
+ rescue Exception => e
38
+ print("Handler Error: ".red); puts("#{e.message}")
39
+ end
40
+ end
53
41
  end
@@ -1,210 +1,215 @@
1
- require 'fileutils'
2
- require 'tmpdir'
3
- require 'optparse'
4
-
5
- require_relative 'logger_helper'
6
- require_relative 'version/version'
7
-
8
- class ParameterParser
9
- def initialize
10
- @params = {
11
- threads: 5,
12
- sfx_path: Dir.tmpdir,
13
- exe: "program.exe",
14
- resource_file: File.join(File.expand_path("data/resource_files", __dir__), "default.rc"),
15
- launcher: "launcher.vbs",
16
- launcher_name: "launcher.vbs",
17
- launcher_type: "vbs"
18
- }
19
-
20
- @logger = LoggerHelper.instance
21
- end
22
-
23
- def normalize_paths!
24
- @params.each do |key, value|
25
- @params[key] = value.gsub('\\', '/') if value.is_a?(String)
26
- end
27
- end
28
-
29
- def display_help
30
- help_text = <<~EOT
31
- Standalone-Ruby v#{StandaloneRuby::VERSION} - Convert your Ruby projects to exe files!
32
-
33
- Usage: standalone-ruby [--help] [--project-path PROJECT_PATH] [--ruby-path RUBY_PATH] [--main-file MAIN_FILE] [--launcher LAUNCHER] [--gui]
34
- [--template TEMPLATE] [--exe-file EXE_FILE] [--threads THREADS] [--resource-file resource_file] [--gcc] [--version]
35
-
36
- Required Options:
37
- --project-path PROJECT_PATH
38
- Target Ruby project path.
39
-
40
- --ruby RUBY_PATH
41
- Path to the Ruby interpreter.
42
-
43
- --main-file MAIN_FILE
44
- Path to the main Ruby file of the project.
45
-
46
- Extra Options:
47
- --exe-file EXE_FILE
48
- Name of the exe file to be used for output (default is program.exe).
49
-
50
- --threads THREADS
51
- Number of threads to use (default is 5). Determines the number of threads used during the Ruby interpreter
52
- copy process and for Robocopy operations. A higher number of threads can speed up the process, but requires more system resources.
53
-
54
- --resource-file RESOURCE_FILE
55
- Resource file (.rc) for the exe file to be created. Only possible with MinGW.
56
-
57
- --help
58
- Show this help message and exit.
59
-
60
- --version
61
- Show program version and exit.
62
-
63
- --gcc
64
- Use GCC compiler for exe file.
65
-
66
- --gui
67
- This option allows the rubyw.exe file in the bin folder to be used.
68
- You can choose it for projects that include GUI.
69
-
70
- Notes:
71
- - Make sure that the Ruby interpreter you are using includes all the gems required for the target project.
72
- - The Ruby interpreter uses Robocopy for copying, and the number of threads given affects the speed of this operation.
73
-
74
- For more details, please visit the documentation at:
75
- https://github.com/ardatetikbey/Standalone-Ruby
76
-
77
- EOT
78
-
79
- puts help_text
80
- end
81
-
82
- def parse
83
- begin
84
- OptionParser.new do |opts|
85
- note = "Note: https://github.com/ardatetikbey/Standalone-Ruby Don't forget to review my github document to get the best results."
86
- opts.banner = "Usage: ruby #{$0} [options]\n#{note}"
87
-
88
- opts.on("--sfx-path SFX_PATH") do |sfx_path|
89
- @params[:sfx_path] = sfx_path
90
- end
91
-
92
- opts.on("--resource-file RESOURCE_FILE") do |resource_file|
93
- if File.exist?(resource_file)
94
- @params[:resource_file] = resource_file
95
- else
96
- print("Parser Error: ".red); puts("The specified resource file #{resource_file} could not be found!")
97
- @logger.error("Parser Error: The specified resource file #{resource_file} could not be found!")
98
- exit!
99
- end
100
- end
101
-
102
- opts.on("--one-file-exe") do
103
- @params[:one_file_exe] = true
104
- end
105
-
106
- opts.on("--ruby-path RUBY_PATH") do |ruby_path|
107
- ruby_path.strip!
108
- if Dir.exist?("#{ruby_path}")
109
- if Dir.exist?(File.join(ruby_path, "bin"))
110
- @params[:ruby_path] = ruby_path
111
- end
112
- else
113
- print("Parser Error: ".red); puts("The specified Ruby path #{ruby_path} could not be found!")
114
- @logger.error("Parser Error: The specified Ruby path #{ruby_path} could not be found!")
115
- exit!
116
- end
117
- end
118
-
119
- opts.on("--project-path PROJECT_PATH", String) do |project_path|
120
- project_path.strip!
121
- if Dir.exist?("#{project_path}")
122
- @params[:project_path] = project_path
123
- else
124
- print("Parser Error: ".red); puts("The specified project path #{project_path} could not be found!")
125
- @logger.error("Parser Error: The project path #{project_path} could not be found!")
126
- exit!
127
- end
128
- end
129
-
130
- opts.on("--exe-file EXE_FILE") do |exe|
131
- @params[:exe] = exe
132
- end
133
-
134
- opts.on("--gcc") do
135
- @params[:use_gcc] = true
136
- end
137
-
138
- opts.on("--main-file MAIN_FILE", String) do |main_file|
139
- main_file.strip!
140
- if File.exist?(main_file)
141
- @params[:main_file] = main_file
142
- else
143
- print("Parser Error: ".red); puts("The specified file #{main_file} could not be found!")
144
- @logger.error("Parser Error: The specified file #{main_file} could not be found!")
145
- exit!
146
- end
147
- end
148
-
149
- opts.on("--threads THREADS", Integer) do |threads|
150
- if threads.is_a?(Integer)
151
- @params[:threads] = threads
152
- else
153
- print("Parser Error: ".red); puts("Invalid value for threads. Please provide an integer.")
154
- @logger.error("Parser Error: Invalid value for threads.")
155
- exit!
156
- end
157
- end
158
-
159
- opts.on("--gui") do
160
- @params[:gui] = true
161
- end
162
-
163
- opts.on("--version") do
164
- puts "Standalone Ruby Gem Version #{StandaloneRuby::VERSION}"
165
- exit!
166
- end
167
-
168
- opts.on("--help") do
169
- display_help
170
- exit!
171
- end
172
- end.parse!
173
-
174
- normalize_paths!
175
-
176
- if @params[:project_path].nil? || @params[:ruby_path].nil? || @params[:main_file].nil?
177
- print("Error: ".red); puts("Missing required parameters. Please provide the necessary parameters:\n -p, -r, -m.\nYou can use the -h parameter for the help menu.")
178
- @logger.error("Parser Error: Missing required parameters.")
179
- exit!
180
- end
181
-
182
- rescue Exception => e
183
- print("Parser Error: ".red); puts("#{e.message}".red)
184
- @logger.error("Parser Error: #{e.message}")
185
- exit!
186
- end
187
- end
188
-
189
- def params
190
- @params
191
- end
192
- end
193
-
194
- class String
195
- def red
196
- "\e[31m#{self}\e[0m"
197
- end
198
-
199
- def green
200
- "\e[32m#{self}\e[0m"
201
- end
202
-
203
- def magenta
204
- "\e[35m#{self}\e[0m"
205
- end
206
-
207
- def yellow
208
- "\e[33m#{self}\e[0m"
209
- end
210
- end
1
+ require 'fileutils'
2
+ require 'tmpdir'
3
+ require 'optparse'
4
+ require 'rbconfig'
5
+
6
+ require_relative 'version/version'
7
+
8
+ class ParameterParser
9
+ def initialize
10
+ platform =
11
+ case RUBY_PLATFORM
12
+ when /win32|mingw|cygwin/
13
+ 'windows'
14
+ when /linux/
15
+ puts "Linux support is on the way!"
16
+ exit!
17
+ else
18
+ print("Error: ".red); puts("unsupported platform")
19
+ exit!
20
+ end
21
+
22
+ @params = {
23
+ platform: platform,
24
+ threads: 5,
25
+ resource_file: File.join(File.expand_path("data/resource_files", __dir__), "default.rc"),
26
+ launcher: "launcher.vbs",
27
+ launcher_name: "launcher.vbs",
28
+ launcher_type: "vbs"
29
+ }
30
+
31
+ if platform == 'windows'
32
+ @params[:ruby_path] = RbConfig::CONFIG['prefix']
33
+ end
34
+ end
35
+
36
+
37
+ def normalize_paths!
38
+ @params.each do |key, value|
39
+ @params[key] = value.gsub('\\', '/') if value.is_a?(String)
40
+ end
41
+ end
42
+
43
+ def display_help
44
+ windows_help_text = <<~EOT
45
+ Standalone-Ruby v#{StandaloneRuby::VERSION} - Make Ruby independent!
46
+
47
+ Usage: standalone-ruby [--help] [--project-path PROJECT_PATH] [--ruby-path RUBY_PATH] [--main-file MAIN_FILE] [--launcher LAUNCHER] [--gui]
48
+ [--template TEMPLATE] [--exe-file EXE_FILE] [--threads THREADS] [--resource-file resource_file] [--gcc] [--version]
49
+
50
+ Example: standalone-ruby --main-file MAIN_FILE_PATH --project-path PROJECT_PATH
51
+
52
+ Required Options:
53
+ --project-path PROJECT_PATH
54
+ Target Ruby project path.
55
+
56
+ --main-file MAIN_FILE
57
+ Path to the main Ruby file of the project.
58
+
59
+ Extra Options:
60
+ --ruby RUBY_PATH
61
+ Path to the Ruby interpreter.
62
+
63
+ --threads THREADS
64
+ Number of threads to use (default is 5). Determines the number of threads used during the Ruby interpreter
65
+ copy process and for Robocopy operations. A higher number of threads can speed up the process, but requires more system resources.
66
+
67
+ --resource-file RESOURCE_FILE
68
+ Resource file (.rc) for the exe file to be created. Only possible with MinGW.
69
+
70
+ --help
71
+ Show this help message and exit.
72
+
73
+ --version
74
+ Show program version and exit.
75
+
76
+ --gcc
77
+ Use GCC compiler for exe file.
78
+
79
+ --gui
80
+ This option allows the rubyw.exe file in the bin folder to be used.
81
+ You can choose it for projects that include GUI.
82
+
83
+ Notes:
84
+ - Make sure that the Ruby interpreter you are using includes all the gems required for the target project.
85
+ - The Ruby interpreter uses Robocopy for copying, and the number of threads given affects the speed of this operation.
86
+
87
+ For more details, please visit the documentation at:
88
+ https://github.com/ardatetikbey/Standalone-Ruby
89
+ EOT
90
+
91
+ linux_help_text = <<~EOT
92
+
93
+ EOT
94
+
95
+ if @params[:platform] == 'windows'
96
+ puts windows_help_text
97
+ else
98
+ puts linux_help_text
99
+ end
100
+ end
101
+
102
+ def parse
103
+ begin
104
+ OptionParser.new do |opts|
105
+ note = "Note: https://github.com/ardatetikbey/Standalone-Ruby Don't forget to review my github document to get the best results."
106
+ opts.banner = "Usage: ruby #{$0} [options]\n#{note}"
107
+
108
+ opts.on("--sfx-path SFX_PATH") do |sfx_path|
109
+ @params[:sfx_path] = sfx_path
110
+ end
111
+
112
+ opts.on("--resource-file RESOURCE_FILE") do |resource_file|
113
+ if File.exist?(resource_file)
114
+ @params[:resource_file] = resource_file
115
+ else
116
+ print("Parser Error: ".red); puts("The specified resource file #{resource_file} could not be found!")
117
+ exit!
118
+ end
119
+ end
120
+
121
+ opts.on("--ruby-path RUBY_PATH") do |ruby_path|
122
+ ruby_path.strip!
123
+ if Dir.exist?("#{ruby_path}")
124
+ if Dir.exist?(File.join(ruby_path, "bin"))
125
+ @params[:ruby_path] = ruby_path
126
+ end
127
+ else
128
+ print("Parser Error: ".red); puts("The specified Ruby path #{ruby_path} could not be found!")
129
+ exit!
130
+ end
131
+ end
132
+
133
+ opts.on("--project-path PROJECT_PATH", String) do |project_path|
134
+ project_path.strip!
135
+ if Dir.exist?("#{project_path}")
136
+ @params[:project_path] = project_path
137
+ else
138
+ print("Parser Error: ".red); puts("The specified project path #{project_path} could not be found!")
139
+ exit!
140
+ end
141
+ end
142
+
143
+ opts.on("--gcc") do
144
+ @params[:use_gcc] = true
145
+ end
146
+
147
+ opts.on("--main-file MAIN_FILE", String) do |main_file|
148
+ main_file.strip!
149
+ if File.exist?(main_file)
150
+ @params[:main_file] = main_file
151
+ else
152
+ print("Parser Error: ".red); puts("The specified file #{main_file} could not be found!")
153
+ exit!
154
+ end
155
+ end
156
+
157
+ opts.on("--threads THREADS", Integer) do |threads|
158
+ if threads.is_a?(Integer)
159
+ @params[:threads] = threads
160
+ else
161
+ print("Parser Error: ".red); puts("Invalid value for threads. Please provide an integer.")
162
+ exit!
163
+ end
164
+ end
165
+
166
+ opts.on("--gui") do
167
+ @params[:gui] = true
168
+ end
169
+
170
+ opts.on("--version") do
171
+ puts "Standalone Ruby Gem Version #{StandaloneRuby::VERSION}"
172
+ exit!
173
+ end
174
+
175
+ opts.on("--help") do
176
+ display_help
177
+ exit!
178
+ end
179
+ end.parse!
180
+
181
+ normalize_paths!
182
+
183
+ if @params[:project_path].nil? || @params[:ruby_path].nil? || @params[:main_file].nil?
184
+ print("Error: ".red); puts("Missing required parameters. Please provide the necessary parameters:\n --project-path, --main-file.\nYou can use the -h parameter for the help menu.")
185
+ exit!
186
+ end
187
+
188
+ rescue Exception => e
189
+ print("Parser Error: ".red); puts("#{e.message}".red)
190
+ exit!
191
+ end
192
+ end
193
+
194
+ def params
195
+ @params
196
+ end
197
+ end
198
+
199
+ class String
200
+ def red
201
+ "\e[31m#{self}\e[0m"
202
+ end
203
+
204
+ def green
205
+ "\e[32m#{self}\e[0m"
206
+ end
207
+
208
+ def magenta
209
+ "\e[35m#{self}\e[0m"
210
+ end
211
+
212
+ def yellow
213
+ "\e[33m#{self}\e[0m"
214
+ end
215
+ end
data/lib/ruby_copy.rb CHANGED
@@ -1,26 +1,48 @@
1
- require_relative 'logger_helper'
2
-
3
- class RubyCopy
4
- def initialize(params)
5
- @params = params
6
- @logger = LoggerHelper.instance
7
- end
8
-
9
- def robocopy_interpreter
10
- begin
11
- puts("\nThe Ruby interpreter copying process has been started.")
12
- print("WARNING: ".yellow); puts("If you are using a development kit, the copying process may take a long time.")
13
-
14
- @logger.info("Robocopy process started using backticks.")
15
- copy_output = `robocopy "#{@params[:ruby_path]}" "#{File.join(@params[:project_path].to_s, File.basename(@params[:ruby_path].to_s))}" /E /MT:#{@params[:threads].to_i} /V /ETA /NFL /NDL /R:1000000 /W:30 /NP`
16
- puts "Robocopy Command: robocopy \"#{@params[:ruby_path]}\" \"#{File.join(@params[:project_path], File.basename(@params[:ruby_path]))}\" /E /MT:#{@params[:threads].to_i} /V /ETA /NFL /NDL /R:1000000 /W:30 /NP"
17
-
18
- @logger.info("Robocopy output printed to screen.")
19
-
20
- puts("The Ruby interpreter copying process has been completed.")
21
- rescue Exception => e
22
- print("Copy Error: ".red); puts("#{e.message}".red)
23
- @logger.error("Copy Error: #{e.message}")
24
- end
25
- end
26
- end
1
+ class RubyCopy
2
+ def initialize(params)
3
+ @params = params
4
+ end
5
+
6
+ def rsync_interpreter
7
+ begin
8
+ puts("\nRuby interpreter copying process started using rsync.")
9
+
10
+ source = @params[:ruby_path]
11
+ dest = File.join(@params[:project_path].to_s, File.basename(source.to_s))
12
+
13
+ rsync_command = "rsync -avh --progress \"#{source}/\" \"#{dest}/\""
14
+ puts "Rsync Command: #{rsync_command}"
15
+
16
+ `#{rsync_command}`
17
+
18
+ puts("The Ruby interpreter copying process has been completed.")
19
+ rescue Exception => e
20
+ print("Copy Error: ".red)
21
+ puts("#{e.message}".red)
22
+ end
23
+ end
24
+
25
+ def robocopy_interpreter
26
+ begin
27
+ puts("\nThe Ruby interpreter copying process has been started.")
28
+ print("WARNING: ".yellow)
29
+ puts("If you are using a development kit, the copying process may take a long time.")
30
+
31
+ source = @params[:ruby_path]
32
+ dest = File.join(@params[:project_path].to_s, File.basename(source.to_s))
33
+
34
+ robocopy_command = <<~CMD.strip
35
+ robocopy "#{source}" "#{dest}" /E /MT:#{@params[:threads].to_i} /R:2 /W:2 /NP /NFL /NDL
36
+ CMD
37
+
38
+ puts "Robocopy Command: #{robocopy_command}"
39
+
40
+ `#{robocopy_command}`
41
+
42
+ puts("The Ruby interpreter copying process has been completed.")
43
+ rescue Exception => e
44
+ print("Copy Error: ".red)
45
+ puts("#{e.message}".red)
46
+ end
47
+ end
48
+ end
@@ -1,7 +1,7 @@
1
- require_relative 'launcher'
2
-
3
- class Program
4
- def run
5
- Launcher.new.run
6
- end
1
+ require_relative 'launcher'
2
+
3
+ class Program
4
+ def run
5
+ Launcher.new.run
6
+ end
7
7
  end
@@ -1,3 +1,3 @@
1
- module StandaloneRuby
2
- VERSION = "1.5.0"
1
+ module StandaloneRuby
2
+ VERSION = "1.5.2"
3
3
  end