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

Avoid calling go_path rule in source mode #3121

Merged
merged 4 commits into from
Apr 18, 2022
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
buildifer
  • Loading branch information
linzhp committed Apr 16, 2022
commit 47b508baaaea2db9771648b28e7b2080f8737eb7
12 changes: 7 additions & 5 deletions extras/gomock.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,15 @@ def _gomock_source_impl(ctx):
# create GOPATH and copy source into GOPATH
source_relative_path = paths.join("src", ctx.attr.library[GoLibrary].importmap, ctx.file.source.basename)
source = ctx.actions.declare_file(paths.join("gopath", source_relative_path))

# trim the relative path of source to get GOPATH
gopath = source.path[:-len(source_relative_path)]
ctx.actions.run_shell(
outputs=[source],
inputs=[ctx.file.source],
outputs = [source],
inputs = [ctx.file.source],
command = "mkdir -p {0} && cp -L {1} {0}".format(source.dirname, ctx.file.source.path),
)

# passed in source needs to be in gopath to not trigger module mode
args = ["-source", source.path]

Expand All @@ -50,9 +52,9 @@ def _gomock_source_impl(ctx):
f = target.files.to_list()[0]
aux = ctx.actions.declare_file(paths.join(gopath, "src", pkg, f.basename))
ctx.actions.run_shell(
outputs=[aux],
inputs=[f],
command = "mkdir -p {0} && cp -L {1} {0}".format(aux.dirname, f.path)
outputs = [aux],
inputs = [f],
command = "mkdir -p {0} && cp -L {1} {0}".format(aux.dirname, f.path),
)
aux_files.append("{0}={1}".format(pkg, aux.path))
needed_files.append(f)
Expand Down