-
Notifications
You must be signed in to change notification settings - Fork 1
/
edit_spack.py
executable file
·39 lines (31 loc) · 1.07 KB
/
edit_spack.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
#!/usr/bin/env python3
import yaml
import argparse
import json
p = argparse.ArgumentParser(description="Add Flags to Spack Compilers File In Place")
p.add_argument("filename", type=str, help="Name of the file to perform the replacement")
p.add_argument("compiler", type=str, help="Approximate name of the compiler to run for")
args = p.parse_args()
fflags = "-heap-arrays 8192"
print("Spack Compiler Editor", flush=True)
print(
"Begin adding flags to selected compiler: {:s}, {:s}".format(
args.compiler, fflags, args.filename
),
flush=True,
)
with open(args.filename, "r") as f:
yml = yaml.safe_load(f)
for c in yml["compilers"]:
if args.compiler in c["compiler"]["spec"]:
print(
"Found compiler in spec: {:s}, Adding flags {:s}".format(
c["compiler"]["spec"], fflags
),
flush=True,
)
c["compiler"]["flags"]["fflags"] = fflags
print("Modified compilers.yaml below: ", flush=True)
print(json.dumps(yml, indent=2), flush=True)
with open(args.filename, "w") as f:
yaml.dump(yml, f)