Skip to content

Commit 13aa470

Browse files
authored
Use ctx.readdir instead of ls for SDK platform detection (#3497)
1 parent 515b5d0 commit 13aa470

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

go/private/sdk.bzl

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -494,15 +494,15 @@ def _detect_host_sdk(ctx):
494494
return root
495495

496496
def _detect_sdk_platform(ctx, goroot):
497-
path = goroot + "/pkg/tool"
498-
res = ctx.execute(["ls", path])
499-
if res.return_code != 0:
500-
fail("Could not detect SDK platform: unable to list %s: %s" % (path, res.stderr))
497+
path = ctx.path(goroot + "/pkg/tool")
498+
if not path.exists:
499+
fail("Could not detect SDK platform: failed to find " + str(path))
500+
tool_entries = path.readdir()
501501

502502
platforms = []
503-
for f in res.stdout.strip().split("\n"):
504-
if f.find("_") >= 0:
505-
platforms.append(f)
503+
for f in tool_entries:
504+
if f.basename.find("_") >= 0:
505+
platforms.append(f.basename)
506506

507507
if len(platforms) == 0:
508508
fail("Could not detect SDK platform: found no platforms in %s" % path)

0 commit comments

Comments
 (0)