[llvm-commits] CVS: llvm-www/demo/index.cgi
Chris Lattner
sabre at nondot.org
Sun Sep 30 15:23:53 PDT 2007
Changes in directory llvm-www/demo:
index.cgi updated: 1.74 -> 1.75
---
Log message:
Make stats generation work again, give an example to start people off,
make script relocatable, on error, give the user helpful hints.
---
Diffs of the changes: (+35 -24)
index.cgi | 59 +++++++++++++++++++++++++++++++++++------------------------
1 files changed, 35 insertions(+), 24 deletions(-)
Index: llvm-www/demo/index.cgi
diff -u llvm-www/demo/index.cgi:1.74 llvm-www/demo/index.cgi:1.75
--- llvm-www/demo/index.cgi:1.74 Thu Sep 27 10:40:41 2007
+++ llvm-www/demo/index.cgi Sun Sep 30 17:23:13 2007
@@ -1,12 +1,6 @@
#!/usr/dcs/software/supported/bin/perl -w
# LLVM Web Demo script
#
-# Originally written by Brian Gaeke as the CS326 Spring 2003 script for
-# doing remote web JO99C compilations. (It could still be used for that
-# purpose, though the two scripts have diverged somewhat.)
-#
-# Last modified $Date: 2007/09/27 15:40:41 $
-#
use strict;
use CGI;
@@ -15,11 +9,14 @@
$| = 1;
+my $ROOT = "/tmp/webcompile";
+#my $ROOT = "/home/vadve/lattner/webcompile";
+
open( STDERR, ">&STDOUT" ) or die "can't redirect stderr to stdout";
-if ( !-d "/tmp/webcompile" ) { mkdir( "/tmp/webcompile", 0777 ); }
+if ( !-d $ROOT ) { mkdir( $ROOT, 0777 ); }
-my $LOGFILE = '/tmp/webcompile/log.txt';
+my $LOGFILE = "$ROOT/log.txt";
my $FORM_URL = 'index.cgi';
my $CONTACT_ADDRESS = 'Questions or comments? Email the <a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev">LLVMdev mailing list</a>.';
my $LOGO_IMAGE_URL = 'cathead.png';
@@ -36,7 +33,7 @@
my ($extension) = @_;
for ( my $count = 0 ; ; $count++ ) {
my $name =
- sprintf( "/tmp/webcompile/_%d_%d%s", $$, $count, $extension );
+ sprintf( "$ROOT/_%d_%d%s", $$, $count, $extension );
if ( !-f $name ) { return $name; }
}
}
@@ -46,7 +43,7 @@
sub barf {
print "<b>", @_, "</b>\n";
print $c->end_html;
- system("rm -f /tmp/webcompile/locked");
+ system("rm -f $ROOT/locked");
exit 1;
}
@@ -92,12 +89,11 @@
sub syntaxHighlightLLVM {
my ($input) = @_;
- $input =~ s@\b(void|bool|sbyte|ubyte|short|ushort|int|uint|long|ulong|float|double|type|label|opaque)\b@<span class="llvm_type">$1</span>@g;
+ $input =~ s@\b(void|i8|i1|i16|i32|i64|float|double|type|label|opaque)\b@<span class="llvm_type">$1</span>@g;
$input =~ s@\b(add|sub|mul|div|rem|and|or|xor|setne|seteq|setlt|setgt|setle|setge|phi|tail|call|cast|to|shl|shr|vaarg|vanext|ret|br|switch|invoke|unwind|malloc|alloca|free|load|store|getelementptr|begin|end|true|false|declare|global|constant|const|internal|uninitialized|external|implementation|linkonce|weak|appending|null|to|except|not|target|endian|pointersize|big|little|volatile)\b@<span class="llvm_keyword">$1</span>@g;
# Add links to the FAQ.
$input =~ s@(_ZNSt8ios_base4Init[DC]1Ev)@<a href="../docs/FAQ.html#iosinit">$1</a>@g;
- $input =~ s@%__main@<a href="../docs/FAQ.html#__main">%__main</a>@g;
$input =~ s@\bundef\b@<a href="../docs/FAQ.html#undef">undef</a>@g;
return $input;
}
@@ -121,7 +117,7 @@
<title>Try out LLVM in your browser!</title>
<style>
\@import url("syntax.css");
- \@import url("../llvm.css");
+ \@import url("http://llvm.org/llvm.css");
</style>
</head>
<body leftmargin="10" marginwidth="10">
@@ -139,9 +135,9 @@
print "<img align=right width=100 height=111 src=\"$LOGO_IMAGE_URL\" />";
}
-if ( -f "/tmp/webcompile/locked" ) {
+if ( -f "$ROOT/locked" ) {
my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$locktime) =
- stat("/tmp/webcompile/locked");
+ stat("$ROOT/locked");
my $currtime = time();
if ($locktime + 60 > $currtime) {
print "<p>Bitter Melon the cat says, 'this page is already in use by someone else at this ";
@@ -150,7 +146,7 @@
}
}
-system("touch /tmp/webcompile/locked");
+system("touch $ROOT/locked");
print <<END;
@@ -165,18 +161,30 @@
print $c->start_multipart_form( 'POST', $FORM_URL );
-print "Upload a file: ";
-print $c->filefield( -name => 'uploaded_file', -default => '' );
-print "<p>Or type your source code in below:</p>\n";
+print "<p>Type your source code in below:</p>\n";
my $source = $c->param('source');
+
+
+# Start the user out with something valid.
+if (!defined($source)) {
+ $source = "#include <stdio.h>\n#include <stdlib.h>\n\n" .
+ "int power(int X) {\n if (X == 0) return 1;\n" .
+ " return X*power(X-1);\n}\n\n" .
+ "int main(int argc, char **argv) {\n" .
+ " printf(\"%d\\n\", power(atoi(argv[0])));\n}\n";
+}
+
print $c->textarea(
-name => "source",
- -rows => 12,
- -columns => 80,
+ -rows => 16,
+ -columns => 60,
-default => $source
);
+print "<p>Or upload a file: ";
+print $c->filefield( -name => 'uploaded_file', -default => '' );
+
print "<p />\n";
print "<p>By the way, what language is this code in?: ",
@@ -288,7 +296,9 @@
#print "<p>Finished dumping command output.</p>\n";
if ( WIFEXITED($retcode) && WEXITSTATUS($retcode) != 0 ) {
barf(
-"$program exited with an error. Please correct source and resubmit.\n"
+"$program exited with an error. Please correct source and resubmit.<p>\n" .
+"Please note that this form only allows fully formed and correct source" .
+" files. It will not compile fragments of code.<p>"
);
}
if ( WIFSIGNALED($retcode) != 0 ) {
@@ -368,7 +378,8 @@
"stkrc $stats -o $bytecodeFile $inputFile > $outputFile 2>&1",
$outputFile );
} else {
- $stats = "-Wa,--stats,--time-passes,--info-output-file=$timerFile"
+ #$stats = "-Wa,--stats,--time-passes,--info-output-file=$timerFile"
+ $stats = "-ftime-report"
if ( $c->param('showstats') );
try_run( "llvm C/C++ front-end (llvm-gcc)",
"llvm-gcc -emit-llvm -W -Wall -O2 $stats -o $bytecodeFile -c $inputFile > $outputFile 2>&1",
@@ -459,5 +470,5 @@
}
print $c->hr, "<address>$CONTACT_ADDRESS</address>", $c->end_html;
-system("rm /tmp/webcompile/locked");
+system("rm $ROOT/locked");
exit 0;
More information about the llvm-commits
mailing list