Skip to content

Commit cf20167

Browse files
authored
Getting architecture from JRE (#3282)
1 parent 4068712 commit cf20167

File tree

1 file changed

+10
-46
lines changed

1 file changed

+10
-46
lines changed

go/private/sdk.bzl

Lines changed: 10 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -258,53 +258,17 @@ def _sdk_build_file(ctx, platform, version):
258258
)
259259

260260
def _detect_host_platform(ctx):
261-
if ctx.os.name == "linux":
262-
goos, goarch = "linux", "amd64"
263-
res = ctx.execute(["uname", "-p"])
264-
if res.return_code == 0:
265-
uname = res.stdout.strip()
266-
if uname == "s390x":
267-
goarch = "s390x"
268-
elif uname == "i686":
269-
goarch = "386"
270-
271-
# uname -p is not working on Aarch64 boards
272-
# or for ppc64le on some distros
273-
res = ctx.execute(["uname", "-m"])
274-
if res.return_code == 0:
275-
uname = res.stdout.strip()
276-
if uname == "aarch64":
277-
goarch = "arm64"
278-
elif uname == "armv6l":
279-
goarch = "arm"
280-
elif uname == "armv7l":
281-
goarch = "arm"
282-
elif uname == "ppc64le":
283-
goarch = "ppc64le"
284-
285-
# Default to amd64 when uname doesn't return a known value.
286-
287-
elif ctx.os.name == "mac os x":
288-
goos, goarch = "darwin", "amd64"
289-
290-
res = ctx.execute(["uname", "-m"])
291-
if res.return_code == 0:
292-
uname = res.stdout.strip()
293-
if uname == "arm64":
294-
goarch = "arm64"
295-
296-
# Default to amd64 when uname doesn't return a known value.
297-
298-
elif ctx.os.name.startswith("windows"):
261+
goos = ctx.os.name
262+
if goos == "mac os x":
263+
goos = "darwin"
264+
elif goos.startswith("windows"):
299265
goos = "windows"
300-
if ctx.os.environ.get("PROCESSOR_ARCHITECTURE") == "ARM64" or ctx.os.environ.get("PROCESSOR_ARCHITEW6432") == "ARM64":
301-
goarch = "arm64"
302-
else:
303-
goarch = "amd64"
304-
elif ctx.os.name == "freebsd":
305-
goos, goarch = "freebsd", "amd64"
306-
else:
307-
fail("Unsupported operating system: " + ctx.os.name)
266+
267+
goarch = ctx.os.arch
268+
if goarch == "aarch64":
269+
goarch = "arm64"
270+
elif goarch == "x86_64":
271+
goarch = "amd64"
308272

309273
return goos, goarch
310274

0 commit comments

Comments
 (0)