]> iEval git - gruntmaster-daemon.git/blame_incremental - gruntmaster-compile
Run user programs as nobody:nogroup
[gruntmaster-daemon.git] / gruntmaster-compile
... / ...
CommitLineData
1#!/usr/bin/perl -w
2use v5.14;
3no if $] > 5.017011, warnings => 'experimental::smartmatch';
4
5use File::Copy qw/copy/;
6use File::Basename qw/fileparse/;
7
8my ($format, $name) = @ARGV;
9my $basename = fileparse $name, qr/\..*/;
10
11my $ret = fork // die $!;
12if ($ret) {
13 $SIG{ALRM} = sub {kill KILL => $ret};
14 alarm 5;
15 wait;
16 exit $? >> 8
17} else {
18 given ($format){
19 exec 'gcc', qw/-DONLINE_JUDGE -std=gnu11 -Wall -Wextra -O2 -o/, $basename, $name when 'C';
20 exec 'g++', qw/-DONLINE_JUDGE -std=gnu++11 -fabi-version=6 -Wall -Wextra -O2 -o/, $basename, $name when 'CPP';
21 exec 'gmcs', '-d:ONLINE_JUDGE', $name when 'MONO';
22 exec 'javac', $name when 'JAVA';
23 exec 'fpc', qw/-dONLINE_JUDGE -O2/, $name when 'PASCAL';
24 exec 'go', qw/build -compiler gc/, $name when 'GOLANG';
25 exec 'go', qw/build -compiler gccgo/, $name, when 'GCCGO';
26 exec 'ghc', qw/-DONLINE_JUDGE -Wall -O2 -o/, $basename, $name when 'HASKELL';
27
28 when ([qw/PERL PYTHON/]){
29 copy $name, $basename;
30 exit
31 }
32 }
33}
34
35exit 1;
36__END__
37
38=encoding utf-8
39
40=head1 NAME
41
42gruntmaster-compile - Gruntmaster 6000 compiler frontend
43
44=head1 SYNOPSIS
45
46 gruntmaster-compile CPP file.cpp
47 gruntmaster-compile JAVA file.java
48
49=head1 DESCRIPTION
50
51gruntmaster-compile is a very simple frontend to various comilers. It takes two arguments: the file format and the file name, and produces a compiled executable. The executable's name is the basename of the input file.
52
53Compile commands for each format:
54
55=over
56
57=item C
58
59 gcc -DONLINE_JUDGE -std=gnu11 -Wall -Wextra -O2 -o $output $input
60
61=item CPP
62
63 g++ -DONLINE_JUDGE -std=gnu++11 -fabi-version=6 -Wall -Wextra -O2 -o $output $input
64
65=item MONO
66
67 gmcs -d:ONLINE_JUDGE $input
68
69=item JAVA
70
71 javac $input
72
73=item PASCAL
74
75 fpc -dONLINE_JUDGE -O2 $input
76
77=item GOLANG
78
79 go build -compiler gc $input
80
81=item GCCGO
82
83 go build -compiler gccgo $input
84
85=item HASKELL
86
87 ghc -DONLINE_JUDGE -Wall -O2 -o $output $input
88
89=item PERL
90
91 cp $input $output
92
93=item PYTHON
94
95 cp $input $output
96
97=back
98
99=head1 AUTHOR
100
101Marius Gavrilescu E<lt>marius@ieval.roE<gt>
102
103=head1 COPYRIGHT AND LICENSE
104
105Copyright (C) 2014 by Marius Gavrilescu
106
107This program is free software: you can redistribute it and/or modify
108it under the terms of the GNU Affero General Public License as published by
109the Free Software Foundation, either version 3 of the License, or
110(at your option) any later version.
111
112
113=cut
This page took 0.021897 seconds and 4 git commands to generate.