diff options
author | Fabian Meumertzheim <fabian@meumertzhe.im> | 2023-03-28 22:20:41 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-28 13:20:41 -0700 |
commit | 13aa4706394734625e441c9334d88dc3bd566e40 (patch) | |
tree | b5fc420865820d48800f97504bcbb7c2de669ec0 | |
parent | 515b5d03429098e93ae461d37ee5b55bdd42edb9 (diff) | |
download | bazelbuild-rules_go-13aa4706394734625e441c9334d88dc3bd566e40.tar.gz |
Use `ctx.readdir` instead of `ls` for SDK platform detection (#3497)
-rw-r--r-- | go/private/sdk.bzl | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/go/private/sdk.bzl b/go/private/sdk.bzl index 58f546ff..c7aa5132 100644 --- a/go/private/sdk.bzl +++ b/go/private/sdk.bzl @@ -494,15 +494,15 @@ def _detect_host_sdk(ctx): return root def _detect_sdk_platform(ctx, goroot): - path = goroot + "/pkg/tool" - res = ctx.execute(["ls", path]) - if res.return_code != 0: - fail("Could not detect SDK platform: unable to list %s: %s" % (path, res.stderr)) + path = ctx.path(goroot + "/pkg/tool") + if not path.exists: + fail("Could not detect SDK platform: failed to find " + str(path)) + tool_entries = path.readdir() platforms = [] - for f in res.stdout.strip().split("\n"): - if f.find("_") >= 0: - platforms.append(f) + for f in tool_entries: + if f.basename.find("_") >= 0: + platforms.append(f.basename) if len(platforms) == 0: fail("Could not detect SDK platform: found no platforms in %s" % path) |