Skip to content

Commit

Permalink
Use ctx.readdir instead of ls for SDK platform detection
Browse files Browse the repository at this point in the history
  • Loading branch information
fmeum committed Mar 28, 2023
1 parent afde360 commit 6c97f21
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions go/private/sdk.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -495,14 +495,12 @@ def _detect_host_sdk(ctx):

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))
tool_entries = ctx.path(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)
Expand Down

0 comments on commit 6c97f21

Please sign in to comment.