installed pty
[VSoRC/.git] / node_modules / node-pty / deps / winpty / ship / ship.py
1 #!python
2
3 # Copyright (c) 2015 Ryan Prichard
4 #
5 # Permission is hereby granted, free of charge, to any person obtaining a copy
6 # of this software and associated documentation files (the "Software"), to
7 # deal in the Software without restriction, including without limitation the
8 # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
9 # sell copies of the Software, and to permit persons to whom the Software is
10 # furnished to do so, subject to the following conditions:
11 #
12 # The above copyright notice and this permission notice shall be included in
13 # all copies or substantial portions of the Software.
14 #
15 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21 # IN THE SOFTWARE.
22
23 #
24 # Run with native CPython 2.7 on a 64-bit computer.
25 #
26 # Each of the targets in BUILD_TARGETS must be installed to the default
27 # location.  Each target must have the appropriate MinGW and non-MinGW
28 # compilers installed, as well as make and tar.
29 #
30
31 import common_ship
32
33 import multiprocessing
34 import os
35 import shutil
36 import subprocess
37 import sys
38
39 os.chdir(common_ship.topDir)
40
41 def dllVersion(path):
42     version = subprocess.check_output(
43         ["powershell.exe",
44         "[System.Diagnostics.FileVersionInfo]::GetVersionInfo(\"" + path + "\").FileVersion"])
45     return version.strip()
46
47 # Determine other build parameters.
48 print "Determining Cygwin/MSYS2 DLL versions..."
49 sys.stdout.flush()
50 BUILD_TARGETS = [
51     # {
52     #     "name": "msys",
53     #     "path": "C:\\MinGW\\bin;C:\\MinGW\\msys\\1.0\\bin",
54     #     # The parallel make.exe in the original MSYS/MinGW project hangs.
55     #     "make_binary": "mingw32-make.exe",
56     # },
57     {
58         "name": "msys2-" + dllVersion("C:\\msys32\\usr\\bin\\msys-2.0.dll") + "-ia32",
59         "path": "C:\\msys32\\mingw32\\bin;C:\\msys32\\usr\\bin",
60     },
61     {
62         "name": "msys2-" + dllVersion("C:\\msys64\\usr\\bin\\msys-2.0.dll") + "-x64",
63         "path": "C:\\msys64\\mingw64\\bin;C:\\msys64\\usr\\bin",
64     },
65     {
66         "name": "cygwin-" + dllVersion("C:\\cygwin\\bin\\cygwin1.dll") + "-ia32",
67         "path": "C:\\cygwin\\bin",
68     },
69     {
70         "name": "cygwin-" + dllVersion("C:\\cygwin64\\bin\\cygwin1.dll") + "-x64",
71         "path": "C:\\cygwin64\\bin",
72     },
73 ]
74
75 def buildTarget(target):
76     packageName = "winpty-" + common_ship.winptyVersion + "-" + target["name"]
77     if os.path.exists("ship\\packages\\" + packageName):
78         shutil.rmtree("ship\\packages\\" + packageName)
79     oldPath = os.environ["PATH"]
80     os.environ["PATH"] = target["path"] + ";" + common_ship.defaultPathEnviron
81     subprocess.check_call(["sh.exe", "configure"])
82     makeBinary = target.get("make_binary", "make.exe")
83     subprocess.check_call([makeBinary, "clean"])
84     makeBaseCmd = [
85         makeBinary,
86         "USE_PCH=0",
87         "COMMIT_HASH=" + common_ship.commitHash,
88         "PREFIX=ship/packages/" + packageName
89     ]
90     subprocess.check_call(makeBaseCmd + ["all", "tests", "-j%d" % multiprocessing.cpu_count()])
91     subprocess.check_call(["build\\trivial_test.exe"])
92     subprocess.check_call(makeBaseCmd + ["install"])
93     subprocess.check_call(["tar.exe", "cvfz",
94         packageName + ".tar.gz",
95         packageName], cwd=os.path.join(os.getcwd(), "ship", "packages"))
96     os.environ["PATH"] = oldPath
97
98 def main():
99     oldPath = os.environ["PATH"]
100     for t in BUILD_TARGETS:
101         os.environ["PATH"] = t["path"] + ";" + common_ship.defaultPathEnviron
102         subprocess.check_output(["tar.exe", "--help"])
103         subprocess.check_output(["make.exe", "--help"])
104     for t in BUILD_TARGETS:
105         buildTarget(t)
106
107 if __name__ == "__main__":
108     main()