-
Notifications
You must be signed in to change notification settings - Fork 0
/
gcc.py
executable file
·32 lines (28 loc) · 1 KB
/
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
#!/usr/bin/env python
import os, sys, subprocess as sp
from pysrc import issues
import click
def f(string):
return f'\033[4m`{string}`\033[0m'
@click.command()
@click.argument('filename')
@click.option('-d', '--debug', is_flag='False', help='LLDB MODE TRIGGER')
@click.option('-r', '--run', is_flag='False', help='RUN AFTER COMPILE')
def main(filename, debug, run):
output = filename[:filename.find('.')] + '.out'
gcc = '/usr/local/bin/gcc-7'
if not os.path.exists(gcc):
gcc = '/usr/bin/gcc'
opt = f'-O3 -mtune=native -march=native -o {output}'
debugstr = f'-pg -g -fprofile-arcs -ftest-coverage'
if debug:
issues.execute([f'{gcc} {opt} {debugstr} {filename} -lm'])
issues.execute([f'lldb ./{output}'])
if click.confirm(f"Remove {f(output)} & related directory?"):
issues.execute([f'rm ./{output}', f'rm -r ./{output}.dSYM'])
else:
issues.execute([f'{gcc} {opt} {filename} -lm'])
if run:
issues.execute([f'time ./{output}'])
if __name__ == '__main__':
main()