Skip to content

Commit

Permalink
Improvement to the ship/ship.py script
Browse files Browse the repository at this point in the history
 * Reorder ship targets to prefer MSYS, then MSYS2, then Cygwin

   The MSYS build is much more likely to fail, both because its Cygwin
   environment is poor (e.g. no C++11, no std::wstring) and because its
   MinGW environment is poor (e.g. missing/broken SDDL APIs)

 * Use PowerShell instead of the pefile module, because it's much faster,
   even with the extra overhead of starting PowerShell.

 * For MSYS, instead of disabling parallel make, use mingw32-make.exe.
   Apparently, with this change, it's necessary to use forward slashes when
   passing the PREFIX to make, so change that as well.
  • Loading branch information
rprichard committed Jun 1, 2016
1 parent ee20ae4 commit 1b439b5
Showing 1 changed file with 18 additions and 25 deletions.
43 changes: 18 additions & 25 deletions ship/ship.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
#

import os
import pefile
import shutil
import subprocess

Expand All @@ -47,28 +46,20 @@
sys.exit("Error: ship.py should run outside a Cygwin environment.")

def dllVersion(path):
pe = pefile.PE(path)
ret = None
for fi in pe.FileInfo:
if fi.Key != "StringFileInfo":
continue
for st in fi.StringTable:
ret = st.entries.get("FileVersion")
break
assert ret is not None
return ret
version = subprocess.check_output(
["powershell.exe",
"[System.Diagnostics.FileVersionInfo]::GetVersionInfo(\"" + path + "\").FileVersion"])
return version.strip()

# Determine other build parameters.
print "Determining Cygwin/MSYS2 DLL versions..."
COMMIT_HASH = subprocess.check_output(["git.exe", "rev-parse", "HEAD"]).decode().strip()
BUILD_TARGETS = [
{
"name": "cygwin-" + dllVersion("C:\\cygwin\\bin\\cygwin1.dll") + "-ia32",
"path": "C:\\cygwin\\bin",
},
{
"name": "cygwin-" + dllVersion("C:\\cygwin64\\bin\\cygwin1.dll") + "-x64",
"path": "C:\\cygwin64\\bin",
"name": "msys",
"path": "C:\\MinGW\\bin;C:\\MinGW\\msys\\1.0\\bin",
# The parallel make.exe in the original MSYS/MinGW project hangs.
"make_binary": "mingw32-make.exe",
},
{
"name": "msys2-" + dllVersion("C:\\msys32\\usr\\bin\\msys-2.0.dll") + "-ia32",
Expand All @@ -79,10 +70,12 @@ def dllVersion(path):
"path": "C:\\msys64\\mingw64\\bin;C:\\msys64\\usr\\bin",
},
{
"name": "msys",
"path": "C:\\MinGW\\bin;C:\\MinGW\\msys\\1.0\\bin",
# The parallel make in the original MSYS/MinGW project hangs.
"allow_parallel_make": False,
"name": "cygwin-" + dllVersion("C:\\cygwin\\bin\\cygwin1.dll") + "-ia32",
"path": "C:\\cygwin\\bin",
},
{
"name": "cygwin-" + dllVersion("C:\\cygwin64\\bin\\cygwin1.dll") + "-x64",
"path": "C:\\cygwin64\\bin",
},
]

Expand All @@ -97,12 +90,12 @@ def buildTarget(target):
os.environ["PATH"] = target["path"] + ";" + oldPath
subprocess.check_call(["sh.exe", "configure"])
subprocess.check_call(["make.exe", "clean"])
buildArgs = ["make.exe", "USE_PCH=0", "all", "tests"]
if target.get("allow_parallel_make", True):
buildArgs += ["-j8"]
makeBinary = target.get("make_binary", "make.exe")
buildArgs = [makeBinary, "USE_PCH=0", "all", "tests"]
buildArgs += ["-j8"]
subprocess.check_call(buildArgs)
subprocess.check_call(["build\\trivial_test.exe"])
subprocess.check_call(["make.exe", "USE_PCH=0", "PREFIX=ship\\packages\\" + packageName, "install"])
subprocess.check_call([makeBinary, "USE_PCH=0", "PREFIX=ship/packages/" + packageName, "install"])
subprocess.check_call(["tar.exe", "cvfz",
packageName + ".tar.gz",
packageName], cwd=os.path.join(os.getcwd(), "ship", "packages"))
Expand Down

0 comments on commit 1b439b5

Please sign in to comment.