From 13aa4706394734625e441c9334d88dc3bd566e40 Mon Sep 17 00:00:00 2001 From: Fabian Meumertzheim Date: Tue, 28 Mar 2023 22:20:41 +0200 Subject: [PATCH] Use `ctx.readdir` instead of `ls` for SDK platform detection (#3497) --- go/private/sdk.bzl | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/go/private/sdk.bzl b/go/private/sdk.bzl index 58f546ffe0..c7aa5132e6 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)