Run user programs as nobody:nogroup
[gruntmaster-daemon.git] / gruntmaster-compile
CommitLineData
da905f9e
MG
1#!/usr/bin/perl -w
2use v5.14;
3no if $] > 5.017011, warnings => 'experimental::smartmatch';
4
9577371b 5use File::Copy qw/copy/;
496fffaa
MG
6use File::Basename qw/fileparse/;
7
8my ($format, $name) = @ARGV;
9my $basename = fileparse $name, qr/\..*/;
9577371b 10
da905f9e
MG
11my $ret = fork // die $!;
12if ($ret) {
9577371b
MG
13 $SIG{ALRM} = sub {kill KILL => $ret};
14 alarm 5;
15 wait;
16 exit $? >> 8
da905f9e 17} else {
9577371b 18 given ($format){
69c25408
MG
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';
9577371b
MG
21 exec 'gmcs', '-d:ONLINE_JUDGE', $name when 'MONO';
22 exec 'javac', $name when 'JAVA';
4e02269f 23 exec 'fpc', qw/-dONLINE_JUDGE -O2/, $name when 'PASCAL';
5a4392d5
MG
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';
0e7e545a
MG
27
28 when ([qw/PERL PYTHON/]){
29 copy $name, $basename;
30 exit
31 }
9577371b 32 }
da905f9e 33}
69c25408 34
0e7e545a 35exit 1;
69c25408
MG
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
498646e0 63 g++ -DONLINE_JUDGE -std=gnu++11 -fabi-version=6 -Wall -Wextra -O2 -o $output $input
69c25408
MG
64
65=item MONO
66
67 gmcs -d:ONLINE_JUDGE $input
68
69=item JAVA
70
71 javac $input
72
73=item PASCAL
74
0005d3ad 75 fpc -dONLINE_JUDGE -O2 $input
69c25408 76
498646e0
MG
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
69c25408
MG
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.064383 seconds and 4 git commands to generate.