Skip to content

Commit 38e6bcc

Browse files
committedMar 8, 2019
gn build: Unbreak get.py and gn.py on Windows
`os.uname()` doesn't exist on Windows, so use `platform.machine()` which returns `os.uname()[4]` on non-Win and (on 64-bit systems) "AMD64" on Windows. Also use `sys.platform` instead of `platform` to check for Windows-ness for the file extension in gn.py (get.py got this right). Differential Revision: https://reviews.llvm.org/D59115 llvm-svn: 355693
1 parent a3c43cf commit 38e6bcc

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed
 

‎llvm/utils/gn/get.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ def set_executable_bit(path):
3333

3434

3535
def get_platform():
36-
if os.uname()[4] != 'x86_64':
36+
import platform
37+
if platform.machine() not in ('AMD64', 'x86_64'):
3738
return None
3839
if sys.platform.startswith('linux'):
3940
return 'linux-amd64'

‎llvm/utils/gn/gn.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616

1717

1818
def get_platform():
19-
if os.uname()[4] != 'x86_64':
19+
import platform
20+
if platform.machine() not in ('AMD64', 'x86_64'):
2021
return None
2122
if sys.platform.startswith('linux'):
2223
return 'linux-amd64'
@@ -46,7 +47,7 @@ def main():
4647
if not platform:
4748
return print_no_gn(mention_get=False)
4849
gn = os.path.join(os.path.dirname(__file__), 'bin', platform, 'gn')
49-
if not os.path.exists(gn + ('.exe' if platform == 'windows' else '')):
50+
if not os.path.exists(gn + ('.exe' if sys.platform == 'win32' else '')):
5051
return print_no_gn(mention_get=True)
5152

5253
# Compute --dotfile= and --root= args to add.

0 commit comments

Comments
 (0)
Please sign in to comment.