ucc 2.0.3 → 2.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/ucc.rb +13 -8
- data/lib/ucc/version.rb +1 -1
- metadata +1 -1
data/lib/ucc.rb
CHANGED
@@ -28,15 +28,19 @@ module Ucc
|
|
28
28
|
opts.banner = "Usage: #{CURRENT_EXECUTABLE} [options] file..."
|
29
29
|
|
30
30
|
options[:runopts] = nil
|
31
|
-
opts.on( '-r', '--runopts
|
31
|
+
opts.on( '-r', '--runopts STRING', 'Pass STRING as the command line argument to the compiled app' ) do |s|
|
32
32
|
options[:runopts] = s
|
33
33
|
end
|
34
34
|
|
35
35
|
options[:compileopts] = nil
|
36
|
-
opts.on( '-c', '--compileopts
|
36
|
+
opts.on( '-c', '--compileopts STRING', 'Pass STRING as the command line argument to the compiler' ) do |s|
|
37
37
|
options[:compileopts] = s
|
38
38
|
end
|
39
39
|
|
40
|
+
opts.on( '-o', '--output FILE', 'Use FILE as the output file' ) do |s|
|
41
|
+
@app_filename = s
|
42
|
+
end
|
43
|
+
|
40
44
|
options[:memcheck] = false
|
41
45
|
opts.on( '-V', '--valgrind', 'Run the app in valgrind' ) do
|
42
46
|
options[:memcheck] = true
|
@@ -67,7 +71,9 @@ module Ucc
|
|
67
71
|
# Filename to use when executing compiled app
|
68
72
|
def app_filename
|
69
73
|
return @app_filename if @app_filename
|
70
|
-
@app_filename = source_files
|
74
|
+
@app_filename = source_files.find{ |param| param !~ /^-/ }
|
75
|
+
return nil unless @app_filename
|
76
|
+
@app_filename = @app_filename.sub(/\.\w+$/, '')
|
71
77
|
@app_filename += ".exe" if WINDOWS
|
72
78
|
@app_filename
|
73
79
|
end
|
@@ -84,9 +90,9 @@ module Ucc
|
|
84
90
|
exit(1)
|
85
91
|
end
|
86
92
|
|
87
|
-
# Here we have already
|
93
|
+
# Here we have already clean ARGV
|
88
94
|
@source_files = ARGV
|
89
|
-
|
95
|
+
unless app_filename
|
90
96
|
puts "#{CURRENT_EXECUTABLE}: no input files"
|
91
97
|
exit(1)
|
92
98
|
end
|
@@ -94,8 +100,7 @@ module Ucc
|
|
94
100
|
|
95
101
|
# Everything special goes here
|
96
102
|
def work
|
97
|
-
compilation_params = %Q[#{@compiler} -Wall -o
|
98
|
-
compilation_params = "#{compilation_params} #{options[:compileopts]}" if options[:compileopts]
|
103
|
+
compilation_params = %Q[#{@compiler} #{options[:compileopts]} -Wall -o #{enquote(app_filename)} #{source_files.map{ |f| enquote(f) }.join(" ")}]
|
99
104
|
trace compilation_params
|
100
105
|
exit unless system compilation_params
|
101
106
|
|
@@ -104,7 +109,7 @@ module Ucc
|
|
104
109
|
exec_params = "#{exec_params} #{options[:runopts]}" if options[:runopts]
|
105
110
|
exec_params = "valgrind #{exec_params}" if options[:memcheck]
|
106
111
|
trace exec_params
|
107
|
-
puts "=== Compiled successfully, executing... ===
|
112
|
+
puts "=== Compiled successfully, executing... ==="
|
108
113
|
exec exec_params
|
109
114
|
end
|
110
115
|
|
data/lib/ucc/version.rb
CHANGED