forked from buildfarm/buildfarm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bazel.Tiltfile
28 lines (21 loc) · 838 Bytes
/
bazel.Tiltfile
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
# -*- mode: Python -*-
# This file was derived from Tilt's bazel example:
# https://github.com/tilt-dev/tilt-example-bazel/blob/main/3-recommended/bazel.Tiltfile
# In order to achieve proper live-reload we need a function to query bazel dependencies.
BAZEL_SOURCES_CMD_TEMPLATE = """
bazel query 'filter("^//", kind("source file", deps(set(%s))))' --order_output=no
""".strip()
def bazel_labels_to_files(labels):
files = {}
for l in labels:
if l.startswith("//external/") or l.startswith("//external:"):
continue
elif l.startswith("//"):
l = l[2:]
path = l.replace(":", "/")
if path.startswith("/"):
path = path[1:]
files[path] = None
return files.keys()
def bazel_sourcefile_deps(target):
return bazel_labels_to_files(str(local(BAZEL_SOURCES_CMD_TEMPLATE % target)).splitlines())