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