aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/test/shell/bazel/list_source_repository.bzl
diff options
context:
space:
mode:
authorGravatar vladmos <vladmos@google.com>2018-06-01 04:51:21 -0700
committerGravatar Copybara-Service <copybara-piper@google.com>2018-06-01 04:52:44 -0700
commit20a042faa91acf8db78684de9f38c4e628d61dd6 (patch)
treec2fc5c6d30cb51cb3f6e30ed0fb2d25f5525585f /src/test/shell/bazel/list_source_repository.bzl
parent2269ee2af91b7df13820381d61e8e4e26a257b3a (diff)
Format all bzl files with buildifier
This CL aslo enables a presubmit check for correct formatting of all bzl files in //third_party/bazel. PiperOrigin-RevId: 198857055
Diffstat (limited to 'src/test/shell/bazel/list_source_repository.bzl')
-rw-r--r--src/test/shell/bazel/list_source_repository.bzl30
1 files changed, 16 insertions, 14 deletions
diff --git a/src/test/shell/bazel/list_source_repository.bzl b/src/test/shell/bazel/list_source_repository.bzl
index bb19a6011d..d114dae4fe 100644
--- a/src/test/shell/bazel/list_source_repository.bzl
+++ b/src/test/shell/bazel/list_source_repository.bzl
@@ -19,20 +19,21 @@
"""A repository definition to fetch all sources in Bazel."""
def _impl(rctx):
- workspace = rctx.path(Label("//:BUILD")).dirname
- srcs_excludes = "XXXXXXXXXXXXXX1268778dfsdf4"
- # Depending in ~/.git/logs/HEAD is a trick to depends on something that
- # change everytime the workspace content change.
- r = rctx.execute(["test", "-f", "%s/.git/logs/HEAD" % workspace])
- if r.return_code == 0:
- # We only add the dependency if it exists.
- unused_var = rctx.path(Label("//:.git/logs/HEAD")) # pylint: disable=unused-variable
+ workspace = rctx.path(Label("//:BUILD")).dirname
+ srcs_excludes = "XXXXXXXXXXXXXX1268778dfsdf4"
- if "SRCS_EXCLUDES" in rctx.os.environ:
- srcs_excludes = rctx.os.environ["SRCS_EXCLUDES"]
- r = rctx.execute(["find", str(workspace), "-type", "f"])
- rctx.file("find.result.raw", r.stdout.replace(str(workspace) + "/", ""))
- rctx.file("BUILD", """
+ # Depending in ~/.git/logs/HEAD is a trick to depends on something that
+ # change everytime the workspace content change.
+ r = rctx.execute(["test", "-f", "%s/.git/logs/HEAD" % workspace])
+ if r.return_code == 0:
+ # We only add the dependency if it exists.
+ unused_var = rctx.path(Label("//:.git/logs/HEAD")) # pylint: disable=unused-variable
+
+ if "SRCS_EXCLUDES" in rctx.os.environ:
+ srcs_excludes = rctx.os.environ["SRCS_EXCLUDES"]
+ r = rctx.execute(["find", str(workspace), "-type", "f"])
+ rctx.file("find.result.raw", r.stdout.replace(str(workspace) + "/", ""))
+ rctx.file("BUILD", """
genrule(
name = "sources",
outs = ["sources.txt"],
@@ -49,7 +50,8 @@ genrule(
list_source_repository = repository_rule(
implementation = _impl,
- environ = ["SRCS_EXCLUDES"])
+ environ = ["SRCS_EXCLUDES"],
+)
"""Create a //:sources target containing the list of sources of Bazel.
SRCS_EXCLUDES give a regex of files to excludes in the list."""