瀏覽代碼

do not fail if building from a non-git checkout

Ashish Kulkarni 11 年之前
父節點
當前提交
134d3ca979
共有 1 個文件被更改,包括 6 次插入3 次删除
  1. 6 3
      scripts/build.py

+ 6 - 3
scripts/build.py

@@ -214,10 +214,13 @@ def get_version(basedir):
     text = open(os.path.join(basedir, '..', 'VERSION'), 'r').read()
     if '-' not in text:
         return (text, text)
-    text = text[:text.index('-')]
+    version = text[:text.index('-')]
     os.chdir(os.path.join(basedir, '..'))
-    hash = subprocess.check_output(['git', 'rev-parse', '--short', 'HEAD']).strip()
-    return ('%s-%s' % (text, hash), text)
+    try:
+        hash = subprocess.check_output(['git', 'rev-parse', '--short', 'HEAD'], stderr=subprocess.STDOUT).strip()
+    except subprocess.CalledProcessError:
+        return (text, version)
+    return ('%s-%s' % (version, hash), version)
 
 def build_openssl(config, basedir):
     cfg = None