-
Notifications
You must be signed in to change notification settings - Fork 4
/
ifh.py
executable file
·53 lines (42 loc) · 1.43 KB
/
ifh.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
46
47
48
49
50
51
52
53
#!/usr/bin/env python3
# Script to install the FibonHelper.hs file into the Fibon/Run directory of a benchmark
# The script does nothing unless the --force argument is given
import sys
import os
import glob
import shutil
import filecmp
def log(dry, msg):
out = msg
if dry:
out = "would "+out
print(out)
def install_file(dry, src, fibon_helper):
log(dry, "copy {0} to {1}".format(src, fibon_helper))
if not dry:
shutil.copyfile(src, fibon_helper)
def main(args):
dry = True # by default do nothing
if args.count('--force'):
dry = False
args.remove('--force')
src = '../../../tools/fibon-run/Fibon/Run/BenchmarkHelper.hs'
if len(args) > 0:
src = args[0]
if not os.path.exists(src):
print('ERROR: fibon helper '+src+' does not exist')
sys.exit(1)
fibon_dirs = filter(lambda d: not d.startswith('_'), glob.glob('*/*/Fibon'))
fibon_run_dirs = map(lambda d: os.path.join(d, 'Run'), fibon_dirs)
for d in fibon_run_dirs:
if not os.path.exists(d):
log(dry, "create dir "+d)
if not dry:
os.mkdir(d)
fibon_helper = os.path.join(d, os.path.basename(src))
if not os.path.exists(fibon_helper):
install_file(dry, src, fibon_helper)
elif not filecmp.cmp(src, fibon_helper):
install_file(dry, src, fibon_helper)
if __name__ == "__main__":
main(sys.argv[1:])