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 efc3094
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions go/private/sdk.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit efc3094

Please sign in to comment.