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