]> granicus.if.org Git - llvm/commitdiff
gn build: Unbreak get.py and gn.py on Windows
authorNico Weber <nicolasweber@gmx.de>
Fri, 8 Mar 2019 12:45:50 +0000 (12:45 +0000)
committerNico Weber <nicolasweber@gmx.de>
Fri, 8 Mar 2019 12:45:50 +0000 (12:45 +0000)
`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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@355693 91177308-0d34-0410-b5e6-96231b3b80d8

utils/gn/get.py
utils/gn/gn.py

index defeac98f2c1f3ce349ccc74212d1032db596478..4015d5986c9d7c16559b29b5db88d996efd1ca4d 100755 (executable)
@@ -33,7 +33,8 @@ def set_executable_bit(path):
 
 
 def get_platform():
-    if os.uname()[4] != 'x86_64':
+    import platform
+    if platform.machine() not in ('AMD64', 'x86_64'):
         return None
     if sys.platform.startswith('linux'):
         return 'linux-amd64'
index 73f2c80fe9dbe5719cade00914974ce8e61f5262..62cbaa91e0760636a0f1aac59df47745e87b9acd 100755 (executable)
@@ -16,7 +16,8 @@ ROOT_DIR = os.path.join(THIS_DIR, '..', '..', '..')
 
 
 def get_platform():
-    if os.uname()[4] != 'x86_64':
+    import platform
+    if platform.machine() not in ('AMD64', 'x86_64'):
         return None
     if sys.platform.startswith('linux'):
         return 'linux-amd64'
@@ -46,7 +47,7 @@ def main():
         if not platform:
             return print_no_gn(mention_get=False)
         gn = os.path.join(os.path.dirname(__file__), 'bin', platform, 'gn')
-        if not os.path.exists(gn + ('.exe' if platform == 'windows' else '')):
+        if not os.path.exists(gn + ('.exe' if sys.platform == 'win32' else '')):
             return print_no_gn(mention_get=True)
 
     # Compute --dotfile= and --root= args to add.