standalone-ruby 1.5.0 → 1.5.1
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/CHANGELOG.md +4 -0
- data/lib/displayer.rb +2 -4
- data/lib/exe_packer.rb +1 -15
- data/lib/launcher.rb +4 -17
- data/lib/launcher_handler.rb +0 -12
- data/lib/parameter_parser.rb +0 -9
- data/lib/ruby_copy.rb +0 -6
- data/lib/sfx_generator.rb +0 -2
- data/lib/version/version.rb +1 -1
- metadata +2 -87
- data/lib/data/bat-cmd/default_bat_cmd.txt +0 -9
- data/lib/data/exe_template/launcher_stub.c +0 -30
- data/lib/data/exe_template/launcher_stub.cpp +0 -9
- data/lib/data/tcc/include/_mingw.h +0 -54
- data/lib/data/tcc/include/assert.h +0 -71
- data/lib/data/tcc/include/conio.h +0 -159
- data/lib/data/tcc/include/ctype.h +0 -232
- data/lib/data/tcc/include/dir.h +0 -26
- data/lib/data/tcc/include/direct.h +0 -95
- data/lib/data/tcc/include/dirent.h +0 -96
- data/lib/data/tcc/include/dos.h +0 -110
- data/lib/data/tcc/include/errno.h +0 -117
- data/lib/data/tcc/include/excpt.h +0 -20
- data/lib/data/tcc/include/fcntl.h +0 -135
- data/lib/data/tcc/include/fenv.h +0 -85
- data/lib/data/tcc/include/float.h +0 -224
- data/lib/data/tcc/include/inttypes.h +0 -275
- data/lib/data/tcc/include/io.h +0 -296
- data/lib/data/tcc/include/limits.h +0 -115
- data/lib/data/tcc/include/locale.h +0 -100
- data/lib/data/tcc/include/malloc.h +0 -87
- data/lib/data/tcc/include/math.h +0 -438
- data/lib/data/tcc/include/mem.h +0 -8
- data/lib/data/tcc/include/memory.h +0 -9
- data/lib/data/tcc/include/process.h +0 -158
- data/lib/data/tcc/include/setjmp.h +0 -72
- data/lib/data/tcc/include/share.h +0 -44
- data/lib/data/tcc/include/signal.h +0 -111
- data/lib/data/tcc/include/stdarg.h +0 -16
- data/lib/data/tcc/include/stdbool.h +0 -10
- data/lib/data/tcc/include/stddef.h +0 -26
- data/lib/data/tcc/include/stdint.h +0 -184
- data/lib/data/tcc/include/stdio.h +0 -413
- data/lib/data/tcc/include/stdlib.h +0 -482
- data/lib/data/tcc/include/string.h +0 -206
- data/lib/data/tcc/include/sys/fcntl.h +0 -8
- data/lib/data/tcc/include/sys/file.h +0 -9
- data/lib/data/tcc/include/sys/locking.h +0 -52
- data/lib/data/tcc/include/sys/stat.h +0 -190
- data/lib/data/tcc/include/sys/time.h +0 -3
- data/lib/data/tcc/include/sys/timeb.h +0 -82
- data/lib/data/tcc/include/sys/types.h +0 -118
- data/lib/data/tcc/include/sys/unistd.h +0 -9
- data/lib/data/tcc/include/sys/utime.h +0 -89
- data/lib/data/tcc/include/tchar.h +0 -367
- data/lib/data/tcc/include/time.h +0 -219
- data/lib/data/tcc/include/unistd.h +0 -10
- data/lib/data/tcc/include/values.h +0 -4
- data/lib/data/tcc/include/varargs.h +0 -11
- data/lib/data/tcc/include/wchar.h +0 -318
- data/lib/data/tcc/include/wctype.h +0 -127
- data/lib/data/tcc/include/winapi/basetsd.h +0 -119
- data/lib/data/tcc/include/winapi/basetyps.h +0 -144
- data/lib/data/tcc/include/winapi/winbase.h +0 -1852
- data/lib/data/tcc/include/winapi/wincon.h +0 -207
- data/lib/data/tcc/include/winapi/windef.h +0 -240
- data/lib/data/tcc/include/winapi/windows.h +0 -176
- data/lib/data/tcc/include/winapi/winerror.h +0 -1054
- data/lib/data/tcc/include/winapi/wingdi.h +0 -2843
- data/lib/data/tcc/include/winapi/winnetwk.h +0 -346
- data/lib/data/tcc/include/winapi/winnls.h +0 -651
- data/lib/data/tcc/include/winapi/winnt.h +0 -2667
- data/lib/data/tcc/include/winapi/winreg.h +0 -159
- data/lib/data/tcc/include/winapi/winsvc.h +0 -309
- data/lib/data/tcc/include/winapi/winuser.h +0 -3472
- data/lib/data/tcc/include/winapi/winver.h +0 -133
- data/lib/data/tcc/lib/gdi32.def +0 -337
- data/lib/data/tcc/lib/kernel32.def +0 -763
- data/lib/data/tcc/lib/libtcc1.a +0 -0
- data/lib/data/tcc/lib/msvcrt.def +0 -782
- data/lib/data/tcc/lib/user32.def +0 -654
- data/lib/data/tcc/tcc.exe +0 -0
- data/lib/data/tcc/tiny_impdef.exe +0 -0
- data/lib/data/tcc/tiny_libmaker.exe +0 -0
- data/lib/data/vbs/default_vbs.txt +0 -7
- data/lib/data/vbs/vbs_gui.txt +0 -8
- data/lib/logger_helper.rb +0 -24
- data/lib/utils/config_generator.rb +0 -5
- data/lib/utils/displayer.rb +0 -64
- data/lib/utils/exe_packer.rb +0 -72
- data/lib/utils/launcher.rb +0 -77
- data/lib/utils/launcher_handler.rb +0 -111
- data/lib/utils/logger_helper.rb +0 -24
- data/lib/utils/parameter_parser.rb +0 -211
- data/lib/utils/ruby_copy.rb +0 -26
data/lib/utils/displayer.rb
DELETED
@@ -1,64 +0,0 @@
|
|
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
|
-
display_map = {
|
13
|
-
"Platform" => @params[:platform],
|
14
|
-
"Project Path" => @params[:project_path],
|
15
|
-
"Exe File" => @params[:exe],
|
16
|
-
"Ruby Path" => @params[:ruby_path],
|
17
|
-
"Ruby Folder" => @params[:ruby_path] ? File.basename(@params[:ruby_path]) : nil,
|
18
|
-
"Main File" => @params[:main_file],
|
19
|
-
"Launcher" => @params[:launcher],
|
20
|
-
"Launcher Type" => @params[:launcher_type],
|
21
|
-
"Template" => @params[:template] || "Default Template",
|
22
|
-
"Log Path" => "Users Documents Directory"
|
23
|
-
}
|
24
|
-
|
25
|
-
display_text = display_map.map { |key, value| "#{key}: #{value}" if value }.compact
|
26
|
-
|
27
|
-
puts display_text.join("\n") unless display_text.empty?
|
28
|
-
|
29
|
-
rescue => e
|
30
|
-
print("Display Error: ".red); puts(e.message.red)
|
31
|
-
@logger.error("Display Error: #{e.message}")
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
|
36
|
-
def banner
|
37
|
-
banner = -<<"BANNER"
|
38
|
-
Standalone-Ruby v#{StandaloneRuby::VERSION} - Package your Ruby projects as exe!
|
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
|
64
|
-
end
|
data/lib/utils/exe_packer.rb
DELETED
@@ -1,72 +0,0 @@
|
|
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_template", __dir__), "launcher_stub.c")
|
12
|
-
@logger.info("Reading stub template from: #{stub_path}")
|
13
|
-
|
14
|
-
stub_content = File.read(stub_path)
|
15
|
-
stub_content.gsub!("LAUNCHER_FILE", "#{File.basename(@params[:launcher])}")
|
16
|
-
|
17
|
-
stub_output = "#{File.join(@params[:project_path].to_s, "launcher_stub.c")}"
|
18
|
-
exe_path = "#{File.join(@params[:project_path].to_s, @params[:exe].to_s)}"
|
19
|
-
|
20
|
-
File.open(stub_output, 'w') { |f| f.write(stub_content) }
|
21
|
-
|
22
|
-
if @params[:use_gcc]
|
23
|
-
puts "\nChecking GCC..."
|
24
|
-
output = `where gcc`
|
25
|
-
|
26
|
-
if File.exist?(output.strip)
|
27
|
-
gcc_path = output.strip
|
28
|
-
puts "GCC Path: #{gcc_path}"
|
29
|
-
|
30
|
-
command = "#{gcc_path} -o #{exe_path} #{stub_output}"
|
31
|
-
@logger.info("Running command: #{command}")
|
32
|
-
`#{command}`
|
33
|
-
else
|
34
|
-
print("Error: ".red); puts("GCC could not be found!");
|
35
|
-
exit!
|
36
|
-
end
|
37
|
-
else
|
38
|
-
puts "\nUsing TCC..."
|
39
|
-
|
40
|
-
tcc_path = File.join(File.expand_path("../data/tcc", __dir__), "tcc.exe")
|
41
|
-
@logger.info("TCC Path: #{tcc_path}")
|
42
|
-
|
43
|
-
command = "#{tcc_path} -o #{exe_path} #{stub_output} -lkernel32"
|
44
|
-
@logger.info("Running command: #{command}")
|
45
|
-
`#{command}`
|
46
|
-
end
|
47
|
-
|
48
|
-
File.delete(stub_output)
|
49
|
-
@logger.info("Stub file deleted successfully")
|
50
|
-
|
51
|
-
puts("\nExe file has been generated!".green_bold_dark)
|
52
|
-
@logger.info("Exe file generated successfully at: #{exe_path}")
|
53
|
-
rescue Exception => err
|
54
|
-
@logger.error("Error occurred: #{err.message}")
|
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/utils/launcher.rb
DELETED
@@ -1,77 +0,0 @@
|
|
1
|
-
require 'optparse'
|
2
|
-
|
3
|
-
class Launcher
|
4
|
-
require_relative 'displayer'
|
5
|
-
require_relative 'parameter_parser'
|
6
|
-
require_relative 'ruby_copy'
|
7
|
-
require_relative 'logger_helper'
|
8
|
-
require_relative 'exe_packer'
|
9
|
-
require_relative 'launcher_handler'
|
10
|
-
# require_relative 'config_generator'
|
11
|
-
|
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
|
-
puts "Thanks for using Standalone-Ruby! Don't forget to star the project on Github."
|
59
|
-
|
60
|
-
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.")
|
61
|
-
@logger.info("Program finished.")
|
62
|
-
rescue Exception => e
|
63
|
-
@logger.error("Launcher Error: #{e.message}")
|
64
|
-
print("Launcher Error: "); puts("#{e.message}".red)
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
class String
|
70
|
-
def red
|
71
|
-
"\e[31m#{self}\e[0m"
|
72
|
-
end
|
73
|
-
|
74
|
-
def yellow
|
75
|
-
"\e[33m#{self}\e[0m"
|
76
|
-
end
|
77
|
-
end
|
@@ -1,111 +0,0 @@
|
|
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
|
-
# FileUtils.mkdir(File.join(@params[:project_path], "sRb_files"))
|
16
|
-
|
17
|
-
if @params[:template]
|
18
|
-
if @params[:gui] == true
|
19
|
-
ruby_file = "rubyw.exe"
|
20
|
-
else
|
21
|
-
ruby_file = "ruby.exe"
|
22
|
-
end
|
23
|
-
|
24
|
-
user_template = @params[:template].to_s
|
25
|
-
content = File.read(user_template)
|
26
|
-
@logger.info("The content of the user template has been read.")
|
27
|
-
|
28
|
-
content.gsub!("STANDALONE_RUBY_PATH", "#{File.join(File.basename(@params[:ruby_path].to_s), "bin", "#{ruby_file}")}")
|
29
|
-
@logger.info("Placed the defined Ruby interpreter path in the template.")
|
30
|
-
|
31
|
-
content.gsub!("STANDALONE_MAIN_FILE", "#{File.basename(@params[:main_file].to_s)}")
|
32
|
-
@logger.info("The main project file path defined in the template is placed.")
|
33
|
-
|
34
|
-
new_launcher_path = File.join(@params[:project_path].to_s, @params[:launcher_name].to_s)
|
35
|
-
File.open(new_launcher_path, "w") do |f_man|
|
36
|
-
f_man.puts content
|
37
|
-
end
|
38
|
-
|
39
|
-
@logger.info("New launcher file directory created as #{new_launcher_path.to_s}")
|
40
|
-
else
|
41
|
-
if @params[:launcher_type] == "vbs"
|
42
|
-
if @params[:gui] == true
|
43
|
-
vbs_template = File.join(File.expand_path("../data/vbs", __dir__), "vbs_gui.txt")
|
44
|
-
ruby_file = "rubyw.exe"
|
45
|
-
else
|
46
|
-
vbs_template = File.join(File.expand_path("../data/vbs", __dir__), "default_vbs.txt")
|
47
|
-
ruby_file = "ruby.exe"
|
48
|
-
end
|
49
|
-
|
50
|
-
puts "Using: #{vbs_template}"
|
51
|
-
|
52
|
-
if File.exist?(vbs_template)
|
53
|
-
content = File.read(vbs_template)
|
54
|
-
@logger.info("The content of the template has been read.")
|
55
|
-
|
56
|
-
content.gsub!("STANDALONE_RUBY_PATH", "#{File.join(File.basename(@params[:ruby_path].to_s), "bin", "#{ruby_file}")}")
|
57
|
-
@logger.info("Placed the defined Ruby interpreter path in the template.")
|
58
|
-
|
59
|
-
content.gsub!("STANDALONE_MAIN_FILE", "#{File.basename(@params[:main_file].to_s)}")
|
60
|
-
@logger.info("The main project file path defined in the template is placed.")
|
61
|
-
|
62
|
-
new_launcher_path = File.join(@params[:project_path].to_s, @params[:launcher_name].to_s)
|
63
|
-
File.open(new_launcher_path, "w") do |f_man|
|
64
|
-
f_man.puts content
|
65
|
-
end
|
66
|
-
|
67
|
-
@logger.info("New launcher file directory created as #{new_launcher_path.to_s}")
|
68
|
-
else
|
69
|
-
print("Handler Error: ".red); puts("The template file could not be found.")
|
70
|
-
@logger.error("Template file not found!")
|
71
|
-
exit!
|
72
|
-
end
|
73
|
-
else
|
74
|
-
if @params[:gui] == true
|
75
|
-
ruby_file = "rubyw.exe"
|
76
|
-
else
|
77
|
-
ruby_file = "ruby.exe"
|
78
|
-
end
|
79
|
-
|
80
|
-
bat_template = File.join(File.expand_path("../data/bat-cmd", __dir__), "default_bat_cmd.txt")
|
81
|
-
puts "Using: #{bat_template}"
|
82
|
-
|
83
|
-
if File.exist?(bat_template)
|
84
|
-
content = File.read(bat_template)
|
85
|
-
@logger.info("The content of the template has been read.")
|
86
|
-
|
87
|
-
content.gsub!("STANDALONE_RUBY_PATH", "#{File.join(File.basename(@params[:ruby_path].to_s), "bin", "#{ruby_file}")}")
|
88
|
-
@logger.info("Placed the defined Ruby interpreter path in the template.")
|
89
|
-
|
90
|
-
content.gsub!("STANDALONE_MAIN_FILE", "#{File.basename(@params[:main_file].to_s)}")
|
91
|
-
@logger.info("The main project file path defined in the template is placed.")
|
92
|
-
|
93
|
-
new_launcher_path = File.join(@params[:project_path].to_s, @params[:launcher_name].to_s)
|
94
|
-
File.open(new_launcher_path, "w") do |f_man|
|
95
|
-
f_man.puts content
|
96
|
-
end
|
97
|
-
|
98
|
-
@logger.info("New launcher file directory created as #{new_launcher_path.to_s}")
|
99
|
-
else
|
100
|
-
print("Handler Error: ".red); puts("The template file could not be found.")
|
101
|
-
@logger.error("Handler Error: Template file not found!")
|
102
|
-
exit!
|
103
|
-
end
|
104
|
-
end
|
105
|
-
end
|
106
|
-
rescue Exception => e
|
107
|
-
print("Handler Error: ".red); puts("#{e.message}")
|
108
|
-
@logger.error("Handler Error: #{e.message}")
|
109
|
-
end
|
110
|
-
end
|
111
|
-
end
|
data/lib/utils/logger_helper.rb
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
require 'logger'
|
2
|
-
require 'time'
|
3
|
-
require 'fileutils'
|
4
|
-
|
5
|
-
class LoggerHelper
|
6
|
-
def self.instance
|
7
|
-
documents_path = File.join(ENV['USERPROFILE'], 'Documents', 'standalone-ruby-logs')
|
8
|
-
|
9
|
-
FileUtils.mkdir_p(documents_path) unless Dir.exist?(documents_path)
|
10
|
-
|
11
|
-
timestamp = Time.now.strftime("%Y-%m-%d_%H-%M-%S")
|
12
|
-
log_file = File.join(documents_path, "standalone-ruby_#{timestamp}.log")
|
13
|
-
|
14
|
-
logger = Logger.new(log_file)
|
15
|
-
logger.level = Logger::INFO
|
16
|
-
|
17
|
-
logger.formatter = proc do |severity, datetime, progname, msg|
|
18
|
-
msg = "(empty message)" if msg.nil? || msg.strip.empty?
|
19
|
-
"#{datetime.strftime('%Y-%m-%d %H:%M:%S')} [#{severity}] #{msg}\n"
|
20
|
-
end
|
21
|
-
|
22
|
-
return logger
|
23
|
-
end
|
24
|
-
end
|
@@ -1,211 +0,0 @@
|
|
1
|
-
require 'fileutils'
|
2
|
-
require 'optparse'
|
3
|
-
|
4
|
-
require_relative 'logger_helper'
|
5
|
-
require_relative '../version/version'
|
6
|
-
|
7
|
-
class ParameterParser
|
8
|
-
def initialize
|
9
|
-
@params = {
|
10
|
-
threads: 5
|
11
|
-
}
|
12
|
-
|
13
|
-
@logger = LoggerHelper.instance
|
14
|
-
end
|
15
|
-
|
16
|
-
def normalize_paths!
|
17
|
-
@params.each do |key, value|
|
18
|
-
@params[key] = value.gsub('\\', '/') if value.is_a?(String)
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
def display_help
|
23
|
-
help_text = <<~EOT
|
24
|
-
Standalone-Ruby v#{StandaloneRuby::VERSION} - Package your Ruby projects as exe!
|
25
|
-
|
26
|
-
Usage: standalone-ruby [-h] [-p PROJECT_PATH] [-r RUBY_PATH] [-m MAIN_FILE] [-l LAUNCHER] [-t TEMPLATE] [-e EXE_FILE] [-c THREADS] [-g] [-v]
|
27
|
-
|
28
|
-
Options:
|
29
|
-
-p, --project PROJECT_PATH Target Ruby project path.
|
30
|
-
Ensures that the given project path exists. If not, an error is displayed.
|
31
|
-
|
32
|
-
-r, --ruby RUBY_PATH Path to the Ruby interpreter.
|
33
|
-
Ensures that the given Ruby path exists and contains a 'bin' directory.
|
34
|
-
|
35
|
-
-m, --main MAIN_FILE Path to the main Ruby file of the project.
|
36
|
-
Ensures that the specified Ruby file exists.
|
37
|
-
|
38
|
-
-l, --launcher LAUNCHER Launcher file name (either .vbs or .bat-cmd).
|
39
|
-
Ensure the launcher file exists and is of the correct type (either .vbs or .bat-cmd).
|
40
|
-
|
41
|
-
-t, --template TEMPLATE Template file for launcher.
|
42
|
-
Ensures that the specified template file exists.
|
43
|
-
|
44
|
-
-e, --exe EXE_FILE Name of the exe file to be used for output
|
45
|
-
|
46
|
-
-c, --threads THREADS Number of threads to use (default is 5).
|
47
|
-
Determines the number of threads used during the Ruby interpreter copy process and for Rubocopy operations.
|
48
|
-
A higher number of threads can speed up the process, but requires more system resources.
|
49
|
-
|
50
|
-
-g, --gui This option allows the rubyw.exe file in the bin folder to be used.
|
51
|
-
You can choose it for projects that include GUI.
|
52
|
-
|
53
|
-
-h, --help Show this help message.
|
54
|
-
|
55
|
-
-v, --version Show program version.
|
56
|
-
|
57
|
-
Notes:
|
58
|
-
- Make sure that the Ruby interpreter you are using includes all the gems required for the target project.
|
59
|
-
- The Ruby interpreter uses Robocopy for copying, and the number of threads given affects the speed of this operation.
|
60
|
-
|
61
|
-
For more details, please visit the documentation at:
|
62
|
-
https://github.com/ardatetikbey/Standalone-Ruby
|
63
|
-
|
64
|
-
EOT
|
65
|
-
|
66
|
-
puts help_text
|
67
|
-
end
|
68
|
-
|
69
|
-
def parse
|
70
|
-
begin
|
71
|
-
OptionParser.new do |opts|
|
72
|
-
note = "Note: https://github.com/ardatetikbey/Standalone-Ruby Don't forget to review my github document to get the best results."
|
73
|
-
opts.banner = "Usage: ruby #{$0} [options]\n#{note}"
|
74
|
-
|
75
|
-
opts.on("-p", "--project PROJECT_PATH", String, "Target Ruby project path") do |project_path|
|
76
|
-
project_path.strip!
|
77
|
-
if Dir.exist?("#{project_path}")
|
78
|
-
@params[:project_path] = project_path
|
79
|
-
else
|
80
|
-
print("Parser Error: ".red); puts("The specified project path #{project_path} could not be found!")
|
81
|
-
@logger.error("Parser Error: The project path #{project_path} could not be found!")
|
82
|
-
exit!
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
|
-
opts.on("-e", "--exe EXE", "Exe file name") do |exe|
|
87
|
-
@params[:exe] = exe
|
88
|
-
end
|
89
|
-
|
90
|
-
opts.on("-r", "--ruby RUBY_PATH", String, "Ruby interpreter path") do |ruby_path|
|
91
|
-
ruby_path.strip!
|
92
|
-
if Dir.exist?("#{ruby_path}")
|
93
|
-
if Dir.exist?(File.join(ruby_path, "bin"))
|
94
|
-
@params[:ruby_path] = ruby_path
|
95
|
-
end
|
96
|
-
else
|
97
|
-
print("Parser Error: ".red); puts("The specified Ruby path #{ruby_path} could not be found!")
|
98
|
-
@logger.error("Parser Error: The specified Ruby path #{ruby_path} could not be found!")
|
99
|
-
exit!
|
100
|
-
end
|
101
|
-
end
|
102
|
-
|
103
|
-
opts.on("--gcc") do
|
104
|
-
@params[:use_gcc] = true
|
105
|
-
end
|
106
|
-
|
107
|
-
opts.on("-m", "--main MAIN_FILE", String, "Path to the main ruby file of the project") do |main_file|
|
108
|
-
main_file.strip!
|
109
|
-
if File.exist?(main_file)
|
110
|
-
@params[:main_file] = main_file
|
111
|
-
else
|
112
|
-
print("Parser Error: ".red); puts("The specified file #{main_file} could not be found!")
|
113
|
-
@logger.error("Parser Error: The specified file #{main_file} could not be found!")
|
114
|
-
exit!
|
115
|
-
end
|
116
|
-
end
|
117
|
-
|
118
|
-
opts.on("-c", "--threads THREADS", Integer, "Number of threads to use (default is 5)") do |threads|
|
119
|
-
if threads.is_a?(Integer)
|
120
|
-
@params[:threads] = threads
|
121
|
-
else
|
122
|
-
print("Parser Error: ".red); puts("Invalid value for threads. Please provide an integer.")
|
123
|
-
@logger.error("Parser Error: Invalid value for threads.")
|
124
|
-
exit!
|
125
|
-
end
|
126
|
-
end
|
127
|
-
|
128
|
-
opts.on("-l", "--launcher LAUNCHER", String, "Launcher file name.type (vbs or bat-cmd)") do |launcher|
|
129
|
-
launcher.strip!
|
130
|
-
if launcher.include?(".vbs")
|
131
|
-
@params[:launcher] = launcher
|
132
|
-
@params[:launcher_type] = "vbs"
|
133
|
-
@params[:launcher_name] = File.basename(launcher)
|
134
|
-
elsif launcher.include?(".bat")
|
135
|
-
@params[:launcher] = launcher
|
136
|
-
@params[:launcher_type] = "bat"
|
137
|
-
@params[:launcher_name] = File.basename(launcher)
|
138
|
-
elsif launcher.include?(".cmd")
|
139
|
-
@params[:launcher] = launcher
|
140
|
-
@params[:launcher_type] = "cmd"
|
141
|
-
@params[:launcher_name] = File.basename(launcher)
|
142
|
-
else
|
143
|
-
print("Parser Error: ".red); puts("The supported launcher #{launcher} could not be found!")
|
144
|
-
@logger.error("Parser Error: The supported launcher path #{launcher} could not be found!")
|
145
|
-
exit!
|
146
|
-
end
|
147
|
-
end
|
148
|
-
|
149
|
-
opts.on("-t", "--template TEMPLATE", "Template file for launcher") do |template|
|
150
|
-
template.strip!
|
151
|
-
if File.exist?(template)
|
152
|
-
@params[:template] = template
|
153
|
-
else
|
154
|
-
print("Parser Error: ".red); puts("The specified template file #{template} could not be found!")
|
155
|
-
@logger.error("Parser Error: The specified template file #{template} could not be found!")
|
156
|
-
exit!
|
157
|
-
end
|
158
|
-
end
|
159
|
-
|
160
|
-
opts.on("-g", "--gui", "Project mode with visual interface") do
|
161
|
-
@params[:gui] = true
|
162
|
-
end
|
163
|
-
|
164
|
-
opts.on("-v", "--version") do
|
165
|
-
puts "Standalone Ruby Gem Version #{StandaloneRuby::VERSION}"
|
166
|
-
exit!
|
167
|
-
end
|
168
|
-
|
169
|
-
opts.on("-h", "--help", "Show this help message") do
|
170
|
-
display_help
|
171
|
-
exit!
|
172
|
-
end
|
173
|
-
|
174
|
-
normalize_paths!
|
175
|
-
end.parse!
|
176
|
-
|
177
|
-
if @params[:project_path].nil? || @params[:ruby_path].nil? || @params[:main_file].nil?
|
178
|
-
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.")
|
179
|
-
@logger.error("Parser Error: Missing required parameters.")
|
180
|
-
exit!
|
181
|
-
end
|
182
|
-
|
183
|
-
rescue Exception => e
|
184
|
-
print("Parser Error: ".red); puts("#{e.message}".red)
|
185
|
-
@logger.error("Parser Error: #{e.message}")
|
186
|
-
exit!
|
187
|
-
end
|
188
|
-
end
|
189
|
-
|
190
|
-
def params
|
191
|
-
@params
|
192
|
-
end
|
193
|
-
end
|
194
|
-
|
195
|
-
class String
|
196
|
-
def red
|
197
|
-
"\e[31m#{self}\e[0m"
|
198
|
-
end
|
199
|
-
|
200
|
-
def green
|
201
|
-
"\e[32m#{self}\e[0m"
|
202
|
-
end
|
203
|
-
|
204
|
-
def magenta
|
205
|
-
"\e[35m#{self}\e[0m"
|
206
|
-
end
|
207
|
-
|
208
|
-
def yellow
|
209
|
-
"\e[33m#{self}\e[0m"
|
210
|
-
end
|
211
|
-
end
|
data/lib/utils/ruby_copy.rb
DELETED
@@ -1,26 +0,0 @@
|
|
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
|