Update default timeout to 10 seconds
[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
9c1ab914
MG
11given ($format){
12 exec 'gcc', qw/-DONLINE_JUDGE -std=gnu11 -Wall -Wextra -O2 -o/, $basename, $name when 'C';
13 exec 'g++', qw/-DONLINE_JUDGE -std=gnu++11 -Wall -Wextra -O2 -o/, $basename, $name when 'CPP';
14 when ('MONO') {
15 system 'gmcs', '-d:ONLINE_JUDGE', $name and die "gmcs failed: errno=$! return=$?";
16 rename "$basename.exe", $basename;
17 chmod 0755, $basename;
18 }
19 exec 'gmcs', '-d:ONLINE_JUDGE', $name when 'MONO';
20 when ('JAVA') {
21 system 'javac', $name and die "javac failed: errno=$! return=$?";
22 system 'jar', 'cfe', $basename, $basename, "$basename.class" and die "jar failed: errno=$! return=$?";
23 chmod 0755, $basename;
24 exit
25 }
26 exec 'fpc', qw/-dONLINE_JUDGE -O2/, $name when 'PASCAL';
27 exec 'go', qw/build -compiler gc/, $name when 'GOLANG';
28 exec 'go', qw/build -compiler gccgo/, $name, when 'GCCGO';
29 exec 'ghc', qw/-DONLINE_JUDGE -Wall -O2 -o/, $basename, $name when 'HASKELL';
30
31 when ([qw/PERL PYTHON/]){
32 open IN, '<', $name;
33 open OUT, '>', $basename;
34 print OUT "#!/usr/bin/perl\n" if $_ eq 'PERL';
35 print OUT "#!/usr/bin/python\n" if $_ eq 'PYTHON';
36 print OUT while <IN>;
37 close OUT;
38 close IN;
39 chmod 0755, $basename;
40 exit
9577371b 41 }
da905f9e 42}
69c25408 43
0e7e545a 44exit 1;
69c25408
MG
45__END__
46
47=encoding utf-8
48
49=head1 NAME
50
51gruntmaster-compile - Gruntmaster 6000 compiler frontend
52
53=head1 SYNOPSIS
54
55 gruntmaster-compile CPP file.cpp
56 gruntmaster-compile JAVA file.java
57
58=head1 DESCRIPTION
59
60gruntmaster-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.
61
62Compile commands for each format:
63
64=over
65
66=item C
67
68 gcc -DONLINE_JUDGE -std=gnu11 -Wall -Wextra -O2 -o $output $input
69
70=item CPP
71
498646e0 72 g++ -DONLINE_JUDGE -std=gnu++11 -fabi-version=6 -Wall -Wextra -O2 -o $output $input
69c25408
MG
73
74=item MONO
75
76 gmcs -d:ONLINE_JUDGE $input
77
78=item JAVA
79
80 javac $input
81
82=item PASCAL
83
0005d3ad 84 fpc -dONLINE_JUDGE -O2 $input
69c25408 85
498646e0
MG
86=item GOLANG
87
88 go build -compiler gc $input
89
90=item GCCGO
91
92 go build -compiler gccgo $input
93
94=item HASKELL
95
96 ghc -DONLINE_JUDGE -Wall -O2 -o $output $input
97
69c25408
MG
98=item PERL
99
100 cp $input $output
101
102=item PYTHON
103
104 cp $input $output
105
106=back
107
108=head1 AUTHOR
109
110Marius Gavrilescu E<lt>marius@ieval.roE<gt>
111
112=head1 COPYRIGHT AND LICENSE
113
114Copyright (C) 2014 by Marius Gavrilescu
115
116This program is free software: you can redistribute it and/or modify
117it under the terms of the GNU Affero General Public License as published by
118the Free Software Foundation, either version 3 of the License, or
119(at your option) any later version.
120
121
122=cut
This page took 0.022754 seconds and 4 git commands to generate.