Show More
Commit Description:
add option -A <opt> to box. This options allow more argument to be explicitly passed to the program...
Commit Description:
add option -A <opt> to box. This options allow more argument to be explicitly passed to the program We have to use this because if the argument we wish to pass to the program is option (in -? format), box will intepret it as its option and failed accordingly. be noted that, by the definition of getopt, these options will be put after original argument (check the code for more info)
References:
File last commit:
Show/Diff file:
Action:
std-script/compile | 187 lines | 5.2 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"
add more languages, java and ruby...
r147 JAVA_COMPILER = "/usr/bin/javac"
quick fix for ruby...
r155 RUBY_INTERPRETER = "/usr/bin/ruby"
add python support...
r154 PYTHON_INTERPRETER = "/usr/bin/python"
PYTHON_CHECKER = "/usr/bin/pyflakes"
add php
r165 PHP_INTERPRETER = "/usr/bin/php"
jittat
import original files...
r0
Jittat Fakcharoenphol
rewrote std-scripts/compile with ruby
r107 C_OPTIONS = "-O2 -s -static -std=c99 -DCONTEST -lm -Wall"
add c++11 support to compile script
r162 CPLUSPLUS_OPTIONS = "-O2 -s -std=c++11 -static -DCONTEST -lm -Wall"
Jittat Fakcharoenphol
rewrote std-scripts/compile with ruby
r107 PASCAL_OPTIONS = "-O1 -XS -dCONTEST"
add more languages, java and ruby...
r147 JAVA_OPTIONS = ""
add python support...
r154 PYTHON_OPTIONS = ""
add php
r165 PHP_OPTIONS = "-l"
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]
add python support...
r154 when "c"
use redirection by system(, {out: , err: }) instead of by > or 2> in the command
r178 command = "#{C_COMPILER} #{params[:source_file]} -o #{params[:output_file]} #{C_OPTIONS}"
system(command, err: params[:message_file])
Jittat Fakcharoenphol
rewrote std-scripts/compile with ruby
r107
add python support...
r154 when "c++"
use redirection by system(, {out: , err: }) instead of by > or 2> in the command
r178 command = "#{CPLUSPLUS_COMPILER} #{params[:source_file]} -o #{params[:output_file]} #{CPLUSPLUS_OPTIONS}"
system(command, err: params[:message_file])
Jittat Fakcharoenphol
rewrote std-scripts/compile with ruby
r107
add python support...
r154 when "pas"
use redirection by system(, {out: , err: }) instead of by > or 2> in the command
r178 command = "#{PASCAL_COMPILER} #{params[:source_file]} -ooutpas #{PASCAL_OPTIONS}"
system(command,out: params[:message_file])
Jittat Fakcharoenphol
rewrote std-scripts/compile with ruby
r107 FileUtils.mv("output", params[:output_file])
add more languages, java and ruby...
r147
add python support...
r154 when "java"
add more languages, java and ruby...
r147 #rename the file to the public class name
#get the class name
classname = 'DUMMY'
change compile to remove package from java...
r167 source = Array.new
add more languages, java and ruby...
r147 File.foreach(params[:source_file]) do |line|
md = /\s*public\s*class\s*(\w*)/.match(line)
classname=md[1] if md
change compile to remove package from java...
r167 source << line unless line =~ /\s*package\s*\w+\s*\;/
add more languages, java and ruby...
r147 end
change compile to remove package from java...
r167 File.open("#{classname}.java","w") do |file|
source.each do |s|
file.puts s
end
end
#system("cp #{params[:source_file]} #{classname}.java")
use redirection by system(, {out: , err: }) instead of by > or 2> in the command
r178 command = "#{JAVA_COMPILER} #{classname}.java"
system(command, err: params[:message_file])
last commit is a dud...fixing it now.
r152 if File.exists?(classname + ".class")
fix java compiler and runner...
r158 File.open(params[:output_file],"w") {|file| file.write("#{classname}")}
end
if classname == 'DUMMY'
File.open(params[:message_file],"w") {|file| file.write("Cannot find any public class in the source code\n")}
fix java to show error when compile error
r151 end
add more languages, java and ruby...
r147
add python support...
r154 when "ruby"
use redirection by system(, {out: , err: }) instead of by > or 2> in the command
r178 command = "#{RUBY_INTERPRETER} -c #{params[:source_file]}"
if system(command, err: params[:message_file])
quick fix for ruby...
r155 File.open(params[:output_file],"w") do |out_file|
out_file.puts "#!#{RUBY_INTERPRETER}"
File.open(params[:source_file],"r").each do |line|
out_file.print line
end
add more languages, java and ruby...
r147 end
quick fix for ruby...
r155 File.chmod(0755, params[:output_file])
add more languages, java and ruby...
r147 end
add python support...
r154
when "python"
use redirection by system(, {out: , err: }) instead of by > or 2> in the command
r178 command = "#{PYTHON_CHECKER} #{params[:source_file]}"
if system(command, out: params[:message_file])
add python support...
r154 #compile to python bytecode
command = "#{PYTHON_INTERPRETER} -m py_compile #{params[:source_file]}"
puts "compile: #{command}"
system(command)
puts "pwd: " + Dir.pwd
Dir.new('.').each {|file| puts file}
File.open(params[:output_file],"w") do |out_file|
out_file.puts "#!#{PYTHON_INTERPRETER} #{params[:source_file]}c"
end
File.chmod(0755, params[:output_file])
clean up run command to check for running time / memory...
r161 FileUtils.cp("#{params[:source_file]}c",params[:output_file])
add python support...
r154 end
add php
r165
when "php"
use redirection by system(, {out: , err: }) instead of by > or 2> in the command
r178 command = "#{PHP_INTERPRETER} #{PHP_OPTIONS} #{params[:source_file]}"
if system(command, err: params[:message_file])
add php
r165 File.open(params[:output_file],"w") do |out_file|
out_file.puts "#!#{PHP_INTERPRETER}"
File.open(params[:source_file],"r").each do |line|
out_file.print line
end
end
File.chmod(0755, params[:output_file])
end
add python support...
r154 else
Jittat Fakcharoenphol
rewrote std-scripts/compile with ruby
r107 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