-
Notifications
You must be signed in to change notification settings - Fork 8
/
.hie-bios
executable file
·42 lines (38 loc) · 1.26 KB
/
.hie-bios
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
#!/usr/bin/env python3
import os
import re
import subprocess
import sys
def skip(line: str) -> bool:
# Ignore linker flags (don't need them for HLS).
# Ignore preprocessor defines (they can differ per project).
return line.startswith("-l") or line.startswith("-D")
if "--regenerate" in sys.argv:
subprocess.run(["tools/haskell/gen_haskell_targets"], check=True)
subprocess.run(["bazel", "build", "//tools/haskell:hie-bios@bios"], check=True)
result = subprocess.run(
[
"bazel", "run", "//tools/haskell:hie-bios@bios",
"--output_groups=hie_bios"
],
check=True,
capture_output=True,
)
with open(os.environ["HIE_BIOS_OUTPUT"], "w") as fh:
prev = None
for line in result.stdout.decode("utf-8").splitlines(keepends=True):
line = re.sub(
"/home/builder/.cache/bazel/_bazel_builder/[0-9a-f]+/execroot/toktok/bazel-out/k8-fastbuild/bin/",
"/src/workspace/bazel-bin/",
line,
)
line = re.sub(
"/home/builder/.cache/bazel/_bazel_builder/[0-9a-f]+/execroot/toktok/",
"/src/workspace/",
line,
)
if line != prev and not skip(line):
fh.write(line)
prev = line
# Make warnings non-fatal
fh.write("-Wwarn\n")