Show More
Commit Description:
Update Ruby version to 2.2.0
Commit Description:
Update Ruby version to 2.2.0
File last commit:
Show/Diff file:
Action:
std-script/compile | 113 lines | 2.8 KiB | text/plain | TextLexer |
Jittat Fakcharoenphol
fixed grader to work with ruby 1.9
r137 #!/usr/bin/env ruby
Jittat Fakcharoenphol
rewrote std-scripts/compile with ruby
r107
require 'fileutils'
jittat
import original files...
r0
##############################
#
# Standard Compile Script
#
# Supported compilers:
jittat
[grader] fixed to work with free pascal...
r53 # gcc, g++, and fpc.
jittat
import original files...
r0 #
##############################
fix logg() in compile, add more logging to engine.rb when the problem cannot be found
r148 def talk(str='')
Jittat Fakcharoenphol
rewrote std-scripts/compile with ruby
r107 if ENV['TALKATIVE']!=nil
puts str
end
if ENV['GRADER_LOGGING']!=nil
log_fname = ENV['GRADER_LOGGING']
fp = File.open(log_fname,"a")
fix logg() in compile, add more logging to engine.rb when the problem cannot be found
r148 fp.puts("run: #{Time.new.strftime("%H:%M")} #{str}")
Jittat Fakcharoenphol
rewrote std-scripts/compile with ruby
r107 fp.close
end
end
jittat
Merged new-arch-branch changes 61:73 into the trunk...
r22
Jittat Fakcharoenphol
rewrote std-scripts/compile with ruby
r107 C_COMPILER = "/usr/bin/gcc"
CPLUSPLUS_COMPILER = "/usr/bin/g++"
PASCAL_COMPILER = "/usr/bin/fpc"
jittat
import original files...
r0
Jittat Fakcharoenphol
rewrote std-scripts/compile with ruby
r107 C_OPTIONS = "-O2 -s -static -std=c99 -DCONTEST -lm -Wall"
CPLUSPLUS_OPTIONS = "-O2 -s -static -DCONTEST -lm -Wall"
PASCAL_OPTIONS = "-O1 -XS -dCONTEST"
jittat
import original files...
r0
# Check for the correct number of arguments. Otherwise, print usage.
Jittat Fakcharoenphol
rewrote std-scripts/compile with ruby
r107 if ARGV.length == 0 or ARGV.length > 4
puts "Usage: compile <language> [<source-file>] [<output-file>] [<message-file>]"
puts
puts "<source-file> is defaulted to \"source\"."
puts "<output-file> is defaulted to \"a.out\"."
puts "<message-file> is defaulted to \"compiler_message\"."
puts
exit(127)
end
jittat
import original files...
r0
Jittat Fakcharoenphol
rewrote std-scripts/compile with ruby
r107 PARAMS = {
:source_file => [1,'source'],
:output_file => [2,'a.out'],
:message_file => [3,'compiler_message']
}
jittat
import original files...
r0
Jittat Fakcharoenphol
rewrote std-scripts/compile with ruby
r107 params = {}
params[:prog_lang] = ARGV[0]
PARAMS.each_key do |param_name|
index, default = PARAMS[param_name]
if ARGV.length > index
params[param_name] = ARGV[index]
else
params[param_name] = default
end
talk "#{param_name}: #{params[param_name]}"
end
jittat
import original files...
r0
# Remove any remaining output files or message files.
Jittat Fakcharoenphol
rewrote std-scripts/compile with ruby
r107 if FileTest.exists? params[:output_file]
FileUtils.rm(params[:output_file])
end
if FileTest.exists? params[:message_file]
FileUtils.rm(params[:message_file])
end
jittat
import original files...
r0
# Check if the source file exists before attempt compiling.
Jittat Fakcharoenphol
rewrote std-scripts/compile with ruby
r107 if !FileTest.exists? params[:source_file]
talk("ERROR: The source file does not exist!")
open(params[:message_file],"w") do |f|
f.puts "ERROR: The source file did not exist."
end
exit(127)
end
jittat
import original files...
r0
Jittat Fakcharoenphol
fixed grader to work with ruby 1.9
r137 if params[:prog_lang]=='cpp'
params[:prog_lang] = 'c++'
Jittat Fakcharoenphol
fixed c++ compilation bug (thanks to Witchakorn Kamolpornwijit)
r119 end
jittat
import original files...
r0 # Compile.
Jittat Fakcharoenphol
rewrote std-scripts/compile with ruby
r107 case params[:prog_lang]
when "c"
command = "#{C_COMPILER} #{params[:source_file]} -o #{params[:output_file]} #{C_OPTIONS} 2> #{params[:message_file]}"
system(command)
when "c++"
command = "#{CPLUSPLUS_COMPILER} #{params[:source_file]} -o #{params[:output_file]} #{CPLUSPLUS_OPTIONS} 2> #{params[:message_file]}"
system(command)
when "pas"
command = "#{PASCAL_COMPILER} #{params[:source_file]} -ooutpas #{PASCAL_OPTIONS} > #{params[:message_file]}"
system(command)
FileUtils.mv("output", params[:output_file])
else
talk("ERROR: Invalid language specified!")
open(params[:message_file],"w") do |f|
f.puts "ERROR: Invalid language specified!"
end
exit(127)
end
jittat
import original files...
r0
# Report success or failure.
Jittat Fakcharoenphol
rewrote std-scripts/compile with ruby
r107 if FileTest.exists? params[:output_file]
talk "Compilation was successful!"
jittat
import original files...
r0 else
Jittat Fakcharoenphol
rewrote std-scripts/compile with ruby
r107 talk "ERROR: Something was wrong during the compilation!"
end