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