refactor(bazel): extract repository rule helpers
This commit is contained in:
12
bazel/utils.bzl
Normal file
12
bazel/utils.bzl
Normal file
@@ -0,0 +1,12 @@
|
||||
def require(repository_ctx, executable):
|
||||
path = repository_ctx.which(executable)
|
||||
if path == None:
|
||||
fail("{} must be available in PATH.".format(executable))
|
||||
return path
|
||||
|
||||
|
||||
def execute(repository_ctx, arguments):
|
||||
result = repository_ctx.execute(arguments)
|
||||
if result.return_code != 0:
|
||||
fail("command failed: {}\n{}".format(" ".join(arguments), result.stderr))
|
||||
return result.stdout.strip()
|
||||
Reference in New Issue
Block a user