]>
Commit | Line | Data |
---|---|---|
da905f9e MG |
1 | #!/usr/bin/perl -w |
2 | use v5.14; | |
3 | no if $] > 5.017011, warnings => 'experimental::smartmatch'; | |
4 | ||
9577371b | 5 | use File::Copy qw/copy/; |
496fffaa MG |
6 | use File::Basename qw/fileparse/; |
7 | ||
8 | my ($format, $name) = @ARGV; | |
9 | my $basename = fileparse $name, qr/\..*/; | |
9577371b | 10 | |
9c1ab914 | 11 | given ($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 | ||
c4d90e6f | 32 | when ([qw/PERL PYTHON RUBY 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'; | |
c4d90e6f | 37 | print OUT "#!/usr/bin/ruby\n" if $_ eq 'RUBY'; |
dbd5d64f | 38 | print OUT "#!/usr/bin/sbcl --script\n" if $_ eq 'SBCL'; |
9c1ab914 MG |
39 | print OUT while <IN>; |
40 | close OUT; | |
41 | close IN; | |
42 | chmod 0755, $basename; | |
43 | exit | |
9577371b | 44 | } |
da905f9e | 45 | } |
69c25408 | 46 | |
0e7e545a | 47 | exit 1; |
69c25408 MG |
48 | __END__ |
49 | ||
50 | =encoding utf-8 | |
51 | ||
52 | =head1 NAME | |
53 | ||
54 | gruntmaster-compile - Gruntmaster 6000 compiler frontend | |
55 | ||
56 | =head1 SYNOPSIS | |
57 | ||
58 | gruntmaster-compile CPP file.cpp | |
59 | gruntmaster-compile JAVA file.java | |
60 | ||
61 | =head1 DESCRIPTION | |
62 | ||
63 | gruntmaster-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. | |
64 | ||
65 | Compile commands for each format: | |
66 | ||
67 | =over | |
68 | ||
69 | =item C | |
70 | ||
71 | gcc -DONLINE_JUDGE -std=gnu11 -Wall -Wextra -O2 -o $output $input | |
72 | ||
73 | =item CPP | |
74 | ||
498646e0 | 75 | g++ -DONLINE_JUDGE -std=gnu++11 -fabi-version=6 -Wall -Wextra -O2 -o $output $input |
69c25408 MG |
76 | |
77 | =item MONO | |
78 | ||
79 | gmcs -d:ONLINE_JUDGE $input | |
80 | ||
81 | =item JAVA | |
82 | ||
83 | javac $input | |
84 | ||
85 | =item PASCAL | |
86 | ||
0005d3ad | 87 | fpc -dONLINE_JUDGE -O2 $input |
69c25408 | 88 | |
498646e0 MG |
89 | =item GOLANG |
90 | ||
91 | go build -compiler gc $input | |
92 | ||
93 | =item GCCGO | |
94 | ||
95 | go build -compiler gccgo $input | |
96 | ||
97 | =item HASKELL | |
98 | ||
99 | ghc -DONLINE_JUDGE -Wall -O2 -o $output $input | |
100 | ||
69c25408 MG |
101 | =item PERL |
102 | ||
103 | cp $input $output | |
104 | ||
105 | =item PYTHON | |
106 | ||
107 | cp $input $output | |
108 | ||
109 | =back | |
110 | ||
111 | =head1 AUTHOR | |
112 | ||
113 | Marius Gavrilescu E<lt>marius@ieval.roE<gt> | |
114 | ||
115 | =head1 COPYRIGHT AND LICENSE | |
116 | ||
117 | Copyright (C) 2014 by Marius Gavrilescu | |
118 | ||
119 | This program is free software: you can redistribute it and/or modify | |
120 | it under the terms of the GNU Affero General Public License as published by | |
121 | the Free Software Foundation, either version 3 of the License, or | |
122 | (at your option) any later version. | |
123 | ||
124 | ||
125 | =cut |