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,30 +1,30 @@
1
- #include <windows.h>
2
-
3
- int main() {
4
- char command[] = "wscript.exe launcher.vbs";
5
-
6
- STARTUPINFO si = {0};
7
- PROCESS_INFORMATION pi = {0};
8
-
9
- if (CreateProcess(
10
- NULL,
11
- command,
12
- NULL,
13
- NULL,
14
- FALSE,
15
- 0,
16
- NULL,
17
- NULL,
18
- &si,
19
- &pi
20
- )) {
21
- WaitForSingleObject(pi.hProcess, INFINITE);
22
-
23
- CloseHandle(pi.hProcess);
24
- CloseHandle(pi.hThread);
25
- } else {
26
-
27
- }
28
-
29
- return 0;
1
+ #include <windows.h>
2
+
3
+ int main() {
4
+ char command[] = "wscript.exe launcher.vbs";
5
+
6
+ STARTUPINFO si = {0};
7
+ PROCESS_INFORMATION pi = {0};
8
+
9
+ if (CreateProcess(
10
+ NULL,
11
+ command,
12
+ NULL,
13
+ NULL,
14
+ FALSE,
15
+ 0,
16
+ NULL,
17
+ NULL,
18
+ &si,
19
+ &pi
20
+ )) {
21
+ WaitForSingleObject(pi.hProcess, INFINITE);
22
+
23
+ CloseHandle(pi.hProcess);
24
+ CloseHandle(pi.hThread);
25
+ } else {
26
+
27
+ }
28
+
29
+ return 0;
30
30
  }
@@ -1,31 +1,31 @@
1
- #include <windows.h>
2
- #include <iostream>
3
-
4
- int main() {
5
- const char* command = "wscript.exe LAUNCHER_FILE";
6
-
7
- STARTUPINFO si = {0};
8
- PROCESS_INFORMATION pi = {0};
9
-
10
- if (CreateProcess(
11
- NULL,
12
- const_cast<LPSTR>(command),
13
- NULL,
14
- NULL,
15
- FALSE,
16
- 0,
17
- NULL,
18
- NULL,
19
- &si,
20
- &pi
21
- )) {
22
- WaitForSingleObject(pi.hProcess, INFINITE);
23
-
24
- CloseHandle(pi.hProcess);
25
- CloseHandle(pi.hThread);
26
- } else {
27
- std::cerr << "CreateProcess failed with error code: " << GetLastError() << std::endl;
28
- }
29
-
30
- return 0;
31
- }
1
+ #include <windows.h>
2
+ #include <iostream>
3
+
4
+ int main() {
5
+ const char* command = "wscript.exe LAUNCHER_FILE";
6
+
7
+ STARTUPINFO si = {0};
8
+ PROCESS_INFORMATION pi = {0};
9
+
10
+ if (CreateProcess(
11
+ NULL,
12
+ const_cast<LPSTR>(command),
13
+ NULL,
14
+ NULL,
15
+ FALSE,
16
+ 0,
17
+ NULL,
18
+ NULL,
19
+ &si,
20
+ &pi
21
+ )) {
22
+ WaitForSingleObject(pi.hProcess, INFINITE);
23
+
24
+ CloseHandle(pi.hProcess);
25
+ CloseHandle(pi.hThread);
26
+ } else {
27
+ std::cerr << "CreateProcess failed with error code: " << GetLastError() << std::endl;
28
+ }
29
+
30
+ return 0;
31
+ }
@@ -1,7 +1,7 @@
1
- Set objShell = CreateObject("WScript.Shell")
2
-
3
- rubyPath = CreateObject("Scripting.FileSystemObject").GetParentFolderName(WScript.ScriptFullName) & "/STANDALONE_RUBY_PATH"
4
- scriptPath = CreateObject("Scripting.FileSystemObject").GetParentFolderName(WScript.ScriptFullName) & "/STANDALONE_MAIN_FILE"
5
-
6
- command = """" & rubyPath & """ """ & scriptPath & """"
7
- objShell.Run command, 1, False
1
+ Set objShell = CreateObject("WScript.Shell")
2
+
3
+ rubyPath = CreateObject("Scripting.FileSystemObject").GetParentFolderName(WScript.ScriptFullName) & "/STANDALONE_RUBY_PATH"
4
+ scriptPath = CreateObject("Scripting.FileSystemObject").GetParentFolderName(WScript.ScriptFullName) & "/STANDALONE_MAIN_FILE"
5
+
6
+ command = """" & rubyPath & """ """ & scriptPath & """"
7
+ objShell.Run command, 1, False
@@ -1,8 +1,8 @@
1
- Set objShell = CreateObject("WScript.Shell")
2
-
3
- rubyPath = CreateObject("Scripting.FileSystemObject").GetParentFolderName(WScript.ScriptFullName) & "\STANDALONE_RUBY_PATH"
4
- scriptPath = CreateObject("Scripting.FileSystemObject").GetParentFolderName(WScript.ScriptFullName) & "\STANDALONE_MAIN_FILE"
5
-
6
- command = """" & rubyPath & """ """ & scriptPath & """"
7
-
8
- objShell.Run command, 1, False
1
+ Set objShell = CreateObject("WScript.Shell")
2
+
3
+ rubyPath = CreateObject("Scripting.FileSystemObject").GetParentFolderName(WScript.ScriptFullName) & "\STANDALONE_RUBY_PATH"
4
+ scriptPath = CreateObject("Scripting.FileSystemObject").GetParentFolderName(WScript.ScriptFullName) & "\STANDALONE_MAIN_FILE"
5
+
6
+ command = """" & rubyPath & """ """ & scriptPath & """"
7
+
8
+ objShell.Run command, 1, False
@@ -1,17 +1,17 @@
1
- #include <windows.h>
2
-
3
- 1 VERSIONINFO
4
- FILEVERSION 1,0,0,0
5
- PRODUCTVERSION 1,0,0,0
6
- BEGIN
7
- BLOCK "StringFileInfo"
8
- BEGIN
9
- BLOCK "040904B0"
10
- BEGIN
11
- VALUE "CompanyName", "Developer\0"
12
- VALUE "FileDescription", "MyProgram\0"
13
- VALUE "FileVersion", "1.0.0.0\0"
14
- VALUE "ProductName", "MyProgram\0"
15
- END
16
- END
17
- END
1
+ #include <windows.h>
2
+
3
+ 1 VERSIONINFO
4
+ FILEVERSION 1,0,0,0
5
+ PRODUCTVERSION 1,0,0,0
6
+ BEGIN
7
+ BLOCK "StringFileInfo"
8
+ BEGIN
9
+ BLOCK "040904B0"
10
+ BEGIN
11
+ VALUE "CompanyName", "Developer\0"
12
+ VALUE "FileDescription", "MyProgram\0"
13
+ VALUE "FileVersion", "1.0.0.0\0"
14
+ VALUE "ProductName", "MyProgram\0"
15
+ END
16
+ END
17
+ END
data/lib/displayer.rb CHANGED
@@ -1,66 +1,64 @@
1
- require_relative 'logger_helper'
2
- require_relative 'version/version'
3
-
4
- class Displayer
5
- def initialize(params)
6
- @params = params
7
- @logger = LoggerHelper.instance
8
- end
9
-
10
- def display_params
11
- begin
12
- puts("Working With:")
13
-
14
- display_map = {
15
- "Project Path" => @params[:project_path],
16
- "Resource File" => @params[:resource_file],
17
- "Exe File" => @params[:exe],
18
- "Ruby Path" => @params[:ruby_path],
19
- "Ruby Folder" => @params[:ruby_path] ? File.basename(@params[:ruby_path]) : nil,
20
- "Main File" => @params[:main_file],
21
- "Launcher" => @params[:launcher],
22
- "Launcher Type" => @params[:launcher_type],
23
- "Template" => @params[:template] || "Default Template",
24
- "Log Path" => "Users Documents Directory"
25
- }
26
-
27
- display_text = display_map.map { |key, value| " - #{key}: #{value}" if value }.compact
28
-
29
- puts display_text.join("\n") unless display_text.empty?
30
-
31
- rescue => e
32
- print("Display Error: ".red); puts(e.message.red)
33
- @logger.error("Display Error: #{e.message}")
34
- end
35
- end
36
-
37
-
38
- def banner
39
- banner = -<<"BANNER"
40
- Standalone-Ruby v#{StandaloneRuby::VERSION} - Package your Ruby projects as exe!
41
- # Github: https://github.com/ardatetikbey/Standalone-Ruby
42
- # RubyGems: https://rubygems.org/gems/standalone-ruby
43
-
44
- BANNER
45
-
46
- puts banner
47
- end
48
- end
49
-
50
- class String
51
- def red
52
- "\e[31m#{self}\e[0m"
53
- end
54
-
55
- def green
56
- "\e[32m#{self}\e[0m"
57
- end
58
-
59
- def magenta
60
- "\e[35m#{self}\e[0m"
61
- end
62
-
63
- def yellow
64
- "\e[33m#{self}\e[0m"
65
- end
1
+ require_relative 'version/version'
2
+
3
+ class Displayer
4
+ def initialize(params)
5
+ @params = params
6
+ end
7
+
8
+ def display_params
9
+ begin
10
+ puts("Parameters:")
11
+
12
+ display_map = {
13
+ "Platform" => @params[:platform],
14
+ "Project Path" => @params[:project_path],
15
+ "Resource File" => @params[:resource_file],
16
+ "Exe File" => @params[:exe],
17
+ "Ruby Path" => @params[:ruby_path],
18
+ "Ruby Folder" => @params[:ruby_path] ? File.basename(@params[:ruby_path]) : nil,
19
+ "Main File" => @params[:main_file],
20
+ "Launcher" => @params[:launcher],
21
+ "Launcher Type" => @params[:launcher_type],
22
+ "Template" => @params[:template] || "Default Template",
23
+ "Log Path" => "Users Documents Directory"
24
+ }
25
+
26
+ display_text = display_map.map { |key, value| " - #{key}: #{value}" if value }.compact
27
+
28
+ puts display_text.join("\n") unless display_text.empty?
29
+
30
+ rescue => e
31
+ print("Display Error: ".red); puts(e.message.red)
32
+ end
33
+ end
34
+
35
+
36
+ def banner
37
+ banner = -<<"BANNER"
38
+ Standalone-Ruby v#{StandaloneRuby::VERSION} - Make Ruby independent!
39
+ # Github: https://github.com/ardatetikbey/Standalone-Ruby
40
+ # RubyGems: https://rubygems.org/gems/standalone-ruby
41
+
42
+ BANNER
43
+
44
+ puts banner
45
+ end
46
+ end
47
+
48
+ class String
49
+ def red
50
+ "\e[31m#{self}\e[0m"
51
+ end
52
+
53
+ def green
54
+ "\e[32m#{self}\e[0m"
55
+ end
56
+
57
+ def magenta
58
+ "\e[35m#{self}\e[0m"
59
+ end
60
+
61
+ def yellow
62
+ "\e[33m#{self}\e[0m"
63
+ end
66
64
  end
data/lib/exe_packer.rb CHANGED
@@ -1,82 +1,72 @@
1
- require_relative 'logger_helper'
2
-
3
- class ExePacker
4
- def initialize(params)
5
- @params = params
6
- @logger = LoggerHelper.instance
7
- end
8
-
9
- def pack
10
- begin
11
- stub_path = File.join(File.expand_path("data/exe_templates", __dir__), "launcher_stub.c")
12
- @logger.info("Reading stub template from: #{stub_path}")
13
-
14
- stub_content = File.read(stub_path)
15
-
16
- stub_output = "#{File.join(@params[:project_path].to_s, "launcher_stub.c")}"
17
- exe_path = "#{File.join(@params[:project_path].to_s, @params[:exe].to_s)}"
18
-
19
- File.open(stub_output, 'w') { |f| f.write(stub_content) }
20
-
21
- if @params[:use_gcc]
22
- puts "\nChecking GCC and Windres..."
23
- output = `where gcc`
24
- gcc_path = output.strip
25
-
26
- output = `where windres`
27
- windres_path = output.strip
28
-
29
- if File.exist?(output.strip)
30
- puts "GCC Path: #{gcc_path}"
31
- puts "Windres Path: #{windres_path}"
32
-
33
- windres_command = "#{windres_path} #{@params[:resource_file].to_s} -O coff -o #{File.join(@params[:project_path].to_s, "program.o")}"
34
- @logger.info("Running command: #{windres_command}")
35
- `#{windres_command}`
36
-
37
- gcc_command = "#{gcc_path} -o #{exe_path} #{File.join(@params[:project_path].to_s, "program.o")} #{stub_output}"
38
- @logger.info("Running command: #{gcc_command}")
39
- `#{gcc_command}`
40
-
41
- File.delete("#{File.join(@params[:project_path].to_s, 'program.o')}")
42
- @logger.info("program.o file deleted")
43
- else
44
- print("Error: ".red); puts("GCC could not be found!")
45
- exit!
46
- end
47
- else
48
- puts "\nUsing Tiny C Compiler (TCC)..."
49
-
50
- tcc_path = File.join(File.expand_path("data/c_compilers/tcc", __dir__), "tcc.exe")
51
- @logger.info("TCC Path: #{tcc_path}")
52
-
53
- command = "#{tcc_path} -o #{exe_path} #{stub_output} -lkernel32"
54
- @logger.info("Running command: #{command}")
55
- `#{command}`
56
- end
57
-
58
- File.delete(stub_output)
59
- @logger.info("Stub file deleted successfully")
60
-
61
- puts("\nExe file has been generated!".green_bold_dark)
62
- @logger.info("Exe file generated at: #{exe_path}")
63
- rescue Exception => err
64
- @logger.error("Error occurred: #{err.message}")
65
- print("Error: ".red); puts(err.message)
66
- end
67
- end
68
- end
69
-
70
- class String
71
- def red
72
- "\e[31m#{self}\e[0m"
73
- end
74
-
75
- def yellow
76
- "\e[33m#{self}\e[0m"
77
- end
78
-
79
- def green_bold_dark
80
- "\e[1m\e[38;5;28m#{self}\e[0m"
81
- end
82
- end
1
+ class ExePacker
2
+ def initialize(params)
3
+ @params = params
4
+ end
5
+
6
+ def pack_linux
7
+ puts
8
+ end
9
+
10
+ def pack_windows
11
+ begin
12
+ stub_path = File.join(File.expand_path("data/exe_templates", __dir__), "launcher_stub.c")
13
+ stub_content = File.read(stub_path)
14
+
15
+ stub_output = "#{File.join(@params[:project_path].to_s, "launcher_stub.c")}"
16
+ exe_path = "#{File.join(@params[:project_path].to_s, "program.exe")}"
17
+
18
+ File.open(stub_output, 'w') { |f| f.write(stub_content) }
19
+
20
+ if @params[:use_gcc]
21
+ puts "\nChecking GCC and Windres..."
22
+ output = `where gcc`
23
+ gcc_path = output.strip
24
+
25
+ output = `where windres`
26
+ windres_path = output.strip
27
+
28
+ if File.exist?(output.strip)
29
+ puts "GCC Path: #{gcc_path}"
30
+ puts "Windres Path: #{windres_path}"
31
+
32
+ windres_command = "#{windres_path} #{@params[:resource_file].to_s} -O coff -o #{File.join(@params[:project_path].to_s, "program.o")}"
33
+ `#{windres_command}`
34
+
35
+ gcc_command = "#{gcc_path} -o #{exe_path} #{File.join(@params[:project_path].to_s, "program.o")} #{stub_output}"
36
+ `#{gcc_command}`
37
+
38
+ File.delete("#{File.join(@params[:project_path].to_s, 'program.o')}")
39
+ else
40
+ print("Error: ".red); puts("GCC could not be found!")
41
+ exit!
42
+ end
43
+ else
44
+ puts "\nUsing Tiny C Compiler (TCC)..."
45
+
46
+ tcc_path = File.join(File.expand_path("data/c_compilers/tcc", __dir__), "tcc.exe")
47
+ command = "#{tcc_path} -o #{exe_path} #{stub_output} -lkernel32"
48
+ `#{command}`
49
+ end
50
+
51
+ File.delete(stub_output)
52
+
53
+ puts("\nExe file has been generated!")
54
+ rescue Exception => err
55
+ print("Error: ".red); puts(err.message)
56
+ end
57
+ end
58
+ end
59
+
60
+ class String
61
+ def red
62
+ "\e[31m#{self}\e[0m"
63
+ end
64
+
65
+ def yellow
66
+ "\e[33m#{self}\e[0m"
67
+ end
68
+
69
+ def green_bold_dark
70
+ "\e[1m\e[38;5;28m#{self}\e[0m"
71
+ end
72
+ end
data/lib/launcher.rb CHANGED
@@ -1,84 +1,58 @@
1
- require 'optparse'
2
-
3
- require_relative 'displayer'
4
- require_relative 'parameter_parser'
5
- require_relative 'ruby_copy'
6
- require_relative 'logger_helper'
7
- require_relative 'exe_packer'
8
- require_relative 'launcher_handler'
9
-
10
-
11
- class Launcher
12
- def initialize
13
- @parser = ParameterParser.new
14
- @parser.parse
15
- @params = @parser.params
16
-
17
- @displayer = Displayer.new(@params)
18
- @ruby_copy = RubyCopy.new(@params)
19
- @logger = LoggerHelper.instance
20
- @exe_packer = ExePacker.new(@params)
21
- @launcher_handler = LauncherHandler.new(@params)
22
- end
23
-
24
- def platform_analysis
25
- case RUBY_PLATFORM
26
- when /win32|mingw|cygwin/
27
- @params[:platform] = 'Windows'
28
- @logger.info("Working on windows platform.")
29
- else
30
- print("Error: ".red); puts("This platform is not supported! Exiting...")
31
- @logger.error("This platform is not supported! Exiting...")
32
- exit!
33
- end
34
- end
35
-
36
- def run
37
- begin
38
- Signal.trap("INT") do
39
- @logger.info("The program was closed because an interrupt command was detected.")
40
- puts "\nProgram interrupted. Shutting down..."
41
- exit(0)
42
- end
43
-
44
- platform_analysis
45
-
46
- @logger.info("the executor function is started.")
47
- @displayer.banner
48
- @logger.info("Banner display was made.")
49
- @displayer.display_params
50
- @logger.info("The parameters entered by the user are reflected on the screen.")
51
- @ruby_copy.robocopy_interpreter
52
- @logger.info("Ruby interpreter copy function completed.")
53
- @launcher_handler.handle
54
- @logger.info("Launcher handler finished.")
55
- @exe_packer.pack
56
- @logger.info("Exe pack finished.")
57
-
58
- if @params[:one_file_exe]
59
- require_relative 'sfx_generator'
60
- @sfx_generator = SFXGenerator.new(@params)
61
- @sfx_generator.generate_sfx
62
- end
63
-
64
- print("\nWARNING: ".yellow); puts("Instead of changing the path of the created exe file, create a shortcut. The same applies here as in every application.")
65
-
66
- puts("\nThis project is under development. If you encounter any errors, you can open an issue on Github.\nIf you want to make a suggestion, you can contact me.")
67
- puts "Thanks for using Standalone-Ruby! Don't forget to star the project on Github."
68
- @logger.info("Program finished.")
69
- rescue Exception => e
70
- @logger.error("Launcher Error: #{e.message}")
71
- print("Launcher Error: "); puts("#{e.message}".red)
72
- end
73
- end
74
- end
75
-
76
- class String
77
- def red
78
- "\e[31m#{self}\e[0m"
79
- end
80
-
81
- def yellow
82
- "\e[33m#{self}\e[0m"
83
- end
84
- end
1
+ require 'optparse'
2
+
3
+ require_relative 'displayer'
4
+ require_relative 'parameter_parser'
5
+ require_relative 'ruby_copy'
6
+ require_relative 'exe_packer'
7
+ require_relative 'launcher_handler'
8
+
9
+ class Launcher
10
+ def initialize
11
+ @parser = ParameterParser.new
12
+ @parser.parse
13
+ @params = @parser.params
14
+
15
+ @displayer = Displayer.new(@params)
16
+ @ruby_copy = RubyCopy.new(@params)
17
+ @exe_packer = ExePacker.new(@params)
18
+ @launcher_handler = LauncherHandler.new(@params)
19
+ end
20
+
21
+ def run
22
+ begin
23
+ Signal.trap("INT") do
24
+ puts "\nProgram interrupted. Shutting down..."
25
+ exit(0)
26
+ end
27
+
28
+ @displayer.banner
29
+ @displayer.display_params
30
+
31
+ if @params[:platform] == 'windows'
32
+ @ruby_copy.robocopy_interpreter
33
+ @launcher_handler.handle
34
+ @exe_packer.pack_windows
35
+ elsif @params[:platform] == 'linux'
36
+ @ruby_copy.rsync_interpreter
37
+ @exe_packer.pack_linux
38
+ end
39
+
40
+ print("\nWARNING: ".yellow); puts("Instead of changing the path of the created exe file, create a shortcut. The same applies here as in every application.")
41
+
42
+ puts("\nThis project is under development. If you encounter any errors, you can open an issue on Github.\nIf you want to make a suggestion, you can contact me.")
43
+ puts "Thanks for using Standalone-Ruby! Don't forget to star the project on Github."
44
+ rescue Exception => e
45
+ print("Launcher Error: "); puts("#{e.message}".red)
46
+ end
47
+ end
48
+ end
49
+
50
+ class String
51
+ def red
52
+ "\e[31m#{self}\e[0m"
53
+ end
54
+
55
+ def yellow
56
+ "\e[33m#{self}\e[0m"
57
+ end
58
+ end