Browse Source

makepanda: Fix detecting flex version on macOS, more robust checking

rdb 5 years ago
parent
commit
fd2041d209
1 changed files with 11 additions and 4 deletions
  1. 11 4
      makepanda/makepandacore.py

+ 11 - 4
makepanda/makepandacore.py

@@ -558,10 +558,17 @@ def GetFlexVersion():
     if not flex:
         return None
 
-    handle = subprocess.Popen(["flex", "--version"], executable=flex, stdout=subprocess.PIPE)
-    version = handle.communicate()[0].strip().splitlines()[0].split(b' ')[-1]
-    version = tuple(map(int, version.split(b'.')))
-    return version
+    try:
+        handle = subprocess.Popen(["flex", "--version"], executable=flex, stdout=subprocess.PIPE)
+        words = handle.communicate()[0].strip().splitlines()[0].split(b' ')
+        if words[1] != "version":
+            version = words[1]
+        else:
+            version = words[2]
+        return tuple(map(int, version.split(b'.')))
+    except:
+        Warn("Unable to detect flex version")
+        return (0, 0, 0)
 
 ########################################################################
 ##