[llvm] r355693 - gn build: Unbreak get.py and gn.py on Windows

Nico Weber via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 8 04:45:50 PST 2019


Author: nico
Date: Fri Mar  8 04:45:50 2019
New Revision: 355693

URL: http://llvm.org/viewvc/llvm-project?rev=355693&view=rev
Log:
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

Modified:
    llvm/trunk/utils/gn/get.py
    llvm/trunk/utils/gn/gn.py

Modified: llvm/trunk/utils/gn/get.py
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/gn/get.py?rev=355693&r1=355692&r2=355693&view=diff
==============================================================================
--- llvm/trunk/utils/gn/get.py (original)
+++ llvm/trunk/utils/gn/get.py Fri Mar  8 04:45:50 2019
@@ -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'

Modified: llvm/trunk/utils/gn/gn.py
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/gn/gn.py?rev=355693&r1=355692&r2=355693&view=diff
==============================================================================
--- llvm/trunk/utils/gn/gn.py (original)
+++ llvm/trunk/utils/gn/gn.py Fri Mar  8 04:45:50 2019
@@ -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.




More information about the llvm-commits mailing list