#!/usr/bin/perl #syntax one of: compile filename testfile asgn [redo] [seas] [only] #Where filename is the .java file to be compiled, test file is the name of the .java file to be #copied to each student directory and compiled, asgn is the name of the directory with the test #file in it and is also used as the prefix to the error and results files. # Example: compile JCal HW1 JCTest #would compile JCal.java with compilation output (ie errors) redirected to HW1-error, copy #JCTest.java from HW1 to each directory and compile it with errors going to HW1-errorTest. If #asgn-results exists it will be renamed (overwriting) asgn-results.bak so in the example this #would be HW1-results. Old filename.class and testfile.class files will be removed first. # If redo is the word redo, then compilation will be redone, otherwise students will be skipped if #testfile.class exists. If seas is present, then compilation will begin with the account #alphabetically AFTER seas. #Example: compile JCAl JCTest HW1 armen #would compile students whose seas accounts werel after armen, this is incase somebodies code #crashes the compiler. If only is present then compilation will be done ONLY for seas. $redo #can also be set to 1 manually to override that option. If seas is the word 'this' then it will do #ONLY the files in the current directory and $redo is set to true #@other_files is a list of other files from our directory (asgn) that should be copied to students #directory #This script is doing java compilation as that is the only compiled language used $redo=0; $home="/u/cs/class/cs131/cs131xx"; $filename=shift @ARGV; #"JCal"; $asgn=shift @ARGV; #"HW1"; $testfile=''; #$testfile="JCTest"; @other_files=(); if ($asgn eq "") { print "See Syntax comments\n"; exit; } $errorfile="$asgn-error"; $errorfileTest="$asgn-errorTest"; $script_dir="$home/$asgn"; if ($ARGV[0] eq "redo") { $redo=1; shift @ARGV; } $start=shift @ARGV; if ($ARGV[0] eq "redo") { $redo=1; shift @ARGV; } if ($start eq "this") { $redo=1; $files[0]=`pwd`; $files[0] =~ s:.*/(\w+):$1:; chop $files[0]; push @ARGV, "1"; } elsif (@ARGV) { $files[0]="$start"; } else { @files=`ls $home/*/$filename.java`; map {s:$home/(\w+)/$filename.java:$1:o} @files;#strips off filename so that it is now a directory chop @files; shift @files if ($files[0] eq "$asgn"); while ($start && $#files>=0) { $start="" if ($files[0] eq $start); shift @files; } } foreach $file (@other_files) {push @copies, "cp $script_dir/$file .\n";} $redo=1; #HW2 regrades @files=qw (agourian baig bosco cheng chienan chilun chio chiungye christiw chuangp covarrub cs131sxi cs131yus dennisn devinder dixin donigian elizabet fane freddy gribble harms ito jamesli jeep jessel jun junho kang kaoa lei markc minevich navin noori pacas pat paulino payam perez pichotta pingel quiros randeep rishig stephenh strongr suyu tannady tingkwan yusuf); push @commands, "#! /bin/sh\n"; #need this shell for odd reasons foreach $dir (@files) { next if (!$redo && (-e "$home/$dir/$filename.class") ); #already compiled push @commands, "echo \" $dir\"\ncd $home/$dir\n"; push @commands, "mv -f $asgn-results $asgn-results.bak\n" if (-f "$home/$dir/$asgn-results"); # push @commands, "mkdir -p lots_out\n"; push @commands, @copies; push @commands, "javac -nowarn -g:none $filename.java >$errorfile 2>&1\n"; if ($testfile) { push @commands, "rm -f $filename.class $testfile.class\n" if (-f "$home/$dir/$filename.class"); push @commands, "cp $script_dir/$testfile.java .\n"; push @commands, "javac -nowarn -g:none $testfile.java >$errorfileTest 2>&1\n"; } } #push @commands, "$home/Scripts/noncompiles $filename $testfile $asgn\n" unless (@ARGV); #print "@commands"; system "@commands" if $#commands;