]> iEval git - gruntmaster-daemon.git/blob - gruntmaster-compile
Run user programs as nobody:nogroup
[gruntmaster-daemon.git] / gruntmaster-compile
1 #!/usr/bin/perl -w
2 use v5.14;
3 no if $] > 5.017011, warnings => 'experimental::smartmatch';
4
5 use File::Copy qw/copy/;
6 use File::Basename qw/fileparse/;
7
8 my ($format, $name) = @ARGV;
9 my $basename = fileparse $name, qr/\..*/;
10
11 my $ret = fork // die $!;
12 if ($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
35 exit 1;
36 __END__
37
38 =encoding utf-8
39
40 =head1 NAME
41
42 gruntmaster-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
51 gruntmaster-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
53 Compile 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
101 Marius Gavrilescu E<lt>marius@ieval.roE<gt>
102
103 =head1 COPYRIGHT AND LICENSE
104
105 Copyright (C) 2014 by Marius Gavrilescu
106
107 This program is free software: you can redistribute it and/or modify
108 it under the terms of the GNU Affero General Public License as published by
109 the 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.056447 seconds and 4 git commands to generate.