Lorenz Brun | 2073ce3 | 2021-02-03 18:52:59 +0100 | [diff] [blame^] | 1 | Copyright 2020 The Monogon Project Authors. |
| 2 | |
| 3 | Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | you may not use this file except in compliance with the License. |
| 5 | You may obtain a copy of the License at |
| 6 | |
| 7 | http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | |
| 9 | Unless required by applicable law or agreed to in writing, software |
| 10 | distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | See the License for the specific language governing permissions and |
| 13 | limitations under the License. |
| 14 | |
| 15 | |
| 16 | From 6313aef65ed37aa971737058af391f5be1ae976c Mon Sep 17 00:00:00 2001 |
| 17 | From: Lorenz Brun <lorenz@nexantic.com> |
| 18 | Date: Wed, 3 Feb 2021 18:11:03 +0100 |
| 19 | Subject: [PATCH] Don't use run_shell with list as cmd |
| 20 | |
| 21 | Going upstream at https://github.com/kubernetes/repo-infra/pull/225 |
| 22 | --- |
| 23 | defs/go.bzl | 26 ++++++++++++++------------ |
| 24 | 1 file changed, 14 insertions(+), 12 deletions(-) |
| 25 | |
| 26 | diff --git a/defs/go.bzl b/defs/go.bzl |
| 27 | index 21cffdd..f4617e1 100644 |
| 28 | --- a/defs/go.bzl |
| 29 | +++ b/defs/go.bzl |
| 30 | @@ -63,16 +63,7 @@ def _go_genrule_impl(ctx): |
| 31 | |
| 32 | srcs = [src for srcs in ctx.attr.srcs for src in srcs.files.to_list()] |
| 33 | |
| 34 | - deps = depset( |
| 35 | - gopath_files + srcs, |
| 36 | - transitive = |
| 37 | - # tools |
| 38 | - [dep.files for dep in ctx.attr.tools] + |
| 39 | - # go toolchain |
| 40 | - [depset(go.sdk.libs + go.sdk.srcs + go.sdk.tools + [go.sdk.go])], |
| 41 | - ) |
| 42 | - |
| 43 | - _, cmd, _ = ctx.resolve_command( |
| 44 | + inputs, cmd, input_manifests = ctx.resolve_command( |
| 45 | command = ctx.attr.cmd, |
| 46 | attribute = "cmd", |
| 47 | expand_locations = True, |
| 48 | @@ -83,6 +74,15 @@ def _go_genrule_impl(ctx): |
| 49 | tools = ctx.attr.tools, |
| 50 | ) |
| 51 | |
| 52 | + deps = depset( |
| 53 | + gopath_files + srcs + inputs, |
| 54 | + transitive = |
| 55 | + # tools |
| 56 | + [dep.files for dep in ctx.attr.tools] + |
| 57 | + # go toolchain |
| 58 | + [depset(go.sdk.libs + go.sdk.srcs + go.sdk.tools + [go.sdk.go])], |
| 59 | + ) |
| 60 | + |
| 61 | env = dict() |
| 62 | env.update(ctx.configuration.default_shell_env) |
| 63 | env.update(go.env) |
| 64 | @@ -92,11 +92,13 @@ def _go_genrule_impl(ctx): |
| 65 | "GOROOT": paths.dirname(go.sdk.root_file.path), |
| 66 | }) |
| 67 | |
| 68 | - ctx.actions.run_shell( |
| 69 | + ctx.actions.run( |
| 70 | inputs = deps, |
| 71 | outputs = ctx.outputs.outs, |
| 72 | env = env, |
| 73 | - command = cmd, |
| 74 | + executable = cmd[0], |
| 75 | + arguments = cmd[1:], |
| 76 | + input_manifests = input_manifests, |
| 77 | progress_message = "%s %s" % (ctx.attr.message, ctx), |
| 78 | mnemonic = "GoGenrule", |
| 79 | ) |
| 80 | -- |
| 81 | 2.25.1 |
| 82 | |