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