-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathsystem_gcc.py
45 lines (32 loc) · 1.11 KB
/
system_gcc.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
from __future__ import absolute_import
import os.path
from sio.compilers.common import Compiler
from sio.workers.util import tempcwd
class CStyleCompiler(Compiler):
lang = 'c'
output_file = 'a.out'
# CStyleCompiler customization
compiler = 'gcc' # Compiler to use
options = [] # Compiler options
def _make_cmdline(self, executor):
cmdline = (
[self.compiler, tempcwd(self.source_file), '-o', tempcwd(self.output_file)]
+ self.options
+ list(self.extra_compilation_args)
)
cmdline.extend(
tempcwd(os.path.basename(source)) for source in self.additional_sources
)
return cmdline
class CCompiler(CStyleCompiler):
compiler = 'gcc'
# Without -static as there is no static compilation on Mac
options = ['-static', '-O2', '-s', '-lm']
class CPPCompiler(CStyleCompiler):
lang = 'cpp'
compiler = 'g++'
options = ['-std=gnu++0x', '-static', '-O2', '-s', '-lm']
def run_gcc(environ):
return CCompiler().compile(environ)
def run_gplusplus(environ):
return CPPCompiler().compile(environ)