Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

go_repository: don't pass default values on the command line #1294

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 13 additions & 10 deletions go/private/go_repository.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,18 @@ def _go_repository_impl(ctx):
# Build file generation is needed
_gazelle = "@io_bazel_rules_go_repository_tools//:bin/gazelle{}".format(executable_extension(ctx))
gazelle = ctx.path(Label(_gazelle))
cmds = [gazelle, '--go_prefix', ctx.attr.importpath, '--mode', 'fix',
'--repo_root', ctx.path(''),
"--build_tags", ",".join(ctx.attr.build_tags),
"--external", ctx.attr.build_external,
"--proto", ctx.attr.build_file_proto_mode]
cmd = [gazelle, '--go_prefix', ctx.attr.importpath, '--mode', 'fix',
'--repo_root', ctx.path('')]
if ctx.attr.build_file_name:
cmds.extend(["--build_file_name", ctx.attr.build_file_name])
cmds.append(ctx.path(''))
result = env_execute(ctx, cmds)
cmd.extend(["--build_file_name", ctx.attr.build_file_name])
if ctx.attr.build_tags:
cmd.extend(["--build_tags", ",".join(ctx.attr.build_tags)])
if ctx.attr.build_external:
cmd.extend(["--external", ctx.attr.build_external])
if ctx.attr.build_file_proto_mode:
cmd.extend(["--proto", ctx.attr.build_file_proto_mode])
cmd.append(ctx.path(''))
result = env_execute(ctx, cmd)
if result.return_code:
fail("failed to generate BUILD files for %s: %s" % (
ctx.attr.importpath, result.stderr))
Expand Down Expand Up @@ -129,8 +132,8 @@ go_repository = repository_rule(

# Attributes for a repository that needs automatic build file generation
"build_external": attr.string(
default = "external",
values = [
"",
"external",
"vendored",
],
Expand All @@ -146,8 +149,8 @@ go_repository = repository_rule(
),
"build_tags": attr.string_list(),
"build_file_proto_mode": attr.string(
default = "default",
values = [
"",
"default",
"disable",
"legacy",
Expand Down