Fix test failure introduced several commits ago
[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';
9577371b
MG
27 copy $name, $basename when ['PERL', 'PYTHON']
28 }
da905f9e 29}
69c25408
MG
30
31__END__
32
33=encoding utf-8
34
35=head1 NAME
36
37gruntmaster-compile - Gruntmaster 6000 compiler frontend
38
39=head1 SYNOPSIS
40
41 gruntmaster-compile CPP file.cpp
42 gruntmaster-compile JAVA file.java
43
44=head1 DESCRIPTION
45
46gruntmaster-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.
47
48Compile commands for each format:
49
50=over
51
52=item C
53
54 gcc -DONLINE_JUDGE -std=gnu11 -Wall -Wextra -O2 -o $output $input
55
56=item CPP
57
498646e0 58 g++ -DONLINE_JUDGE -std=gnu++11 -fabi-version=6 -Wall -Wextra -O2 -o $output $input
69c25408
MG
59
60=item MONO
61
62 gmcs -d:ONLINE_JUDGE $input
63
64=item JAVA
65
66 javac $input
67
68=item PASCAL
69
0005d3ad 70 fpc -dONLINE_JUDGE -O2 $input
69c25408 71
498646e0
MG
72=item GOLANG
73
74 go build -compiler gc $input
75
76=item GCCGO
77
78 go build -compiler gccgo $input
79
80=item HASKELL
81
82 ghc -DONLINE_JUDGE -Wall -O2 -o $output $input
83
69c25408
MG
84=item PERL
85
86 cp $input $output
87
88=item PYTHON
89
90 cp $input $output
91
92=back
93
94=head1 AUTHOR
95
96Marius Gavrilescu E<lt>marius@ieval.roE<gt>
97
98=head1 COPYRIGHT AND LICENSE
99
100Copyright (C) 2014 by Marius Gavrilescu
101
102This program is free software: you can redistribute it and/or modify
103it under the terms of the GNU Affero General Public License as published by
104the Free Software Foundation, either version 3 of the License, or
105(at your option) any later version.
106
107
108=cut
This page took 0.038268 seconds and 4 git commands to generate.