Factor some code out of make_msvc_package.py into a simpler vcbuild.bat
This commit is contained in:
parent
ce5c95cd4f
commit
7c9a7c8745
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -1,4 +1,5 @@
|
||||
* text=auto
|
||||
*.bat text eol=crlf
|
||||
*.c text
|
||||
*.cc text
|
||||
*.gyp text
|
||||
|
@ -37,12 +37,22 @@ def mkdir(path):
|
||||
if not os.path.isdir(path):
|
||||
os.makedirs(path)
|
||||
|
||||
def requireExe(name):
|
||||
def requireExe(name, guesses):
|
||||
if find_executable(name) is None:
|
||||
for guess in guesses:
|
||||
if os.path.exists(guess):
|
||||
newDir = os.path.dirname(guess)
|
||||
print "Adding " + newDir + " to Path to provide " + name
|
||||
os.environ["Path"] = newDir + ";" + os.environ["Path"]
|
||||
ret = find_executable(name)
|
||||
if ret is None:
|
||||
sys.exit("Error: required EXE is missing from Path: " + name)
|
||||
return ret
|
||||
|
||||
requireExe("git.exe")
|
||||
requireExe("git.exe", [
|
||||
"C:\\Program Files\\Git\\cmd\\git.exe",
|
||||
"C:\\Program Files (x86)\\Git\\cmd\\git.exe"
|
||||
])
|
||||
|
||||
commitHash = subprocess.check_output(["git.exe", "rev-parse", "HEAD"]).decode().strip()
|
||||
defaultPathEnviron = "C:\\Windows\\System32;C:\\Windows"
|
||||
|
@ -23,10 +23,6 @@
|
||||
#
|
||||
# Run with native CPython 2.7.
|
||||
#
|
||||
# These programs must be in your Path:
|
||||
# - 7z.exe
|
||||
# - git.exe
|
||||
#
|
||||
# This script looks for MSVC using a version-specific environment variable,
|
||||
# such as VS140COMNTOOLS for MSVC 2015.
|
||||
#
|
||||
@ -40,7 +36,10 @@ import subprocess
|
||||
import sys
|
||||
|
||||
os.chdir(common_ship.topDir)
|
||||
ZIP_TOOL = common_ship.requireExe("7z.exe")
|
||||
ZIP_TOOL = common_ship.requireExe("7z.exe", [
|
||||
"C:\\Program Files\\7-Zip\7z.exe",
|
||||
"C:\\Program Files (x86)\\7-Zip\7z.exe",
|
||||
])
|
||||
|
||||
MSVC_VERSION_TABLE = {
|
||||
"2015" : {
|
||||
@ -97,23 +96,21 @@ def build(arch, packageDir, xp=False):
|
||||
archInfo = ARCH_TABLE[arch]
|
||||
versionInfo = MSVC_VERSION_TABLE[ARGS.msvc_version]
|
||||
|
||||
subprocess.check_call([
|
||||
sys.executable,
|
||||
"../build-gyp/gyp_main.py",
|
||||
"winpty.gyp",
|
||||
"-I", "configurations.gypi",
|
||||
"-G", "msvs_version=" + versionInfo["gyp_version"],
|
||||
"-D", "VERSION_SUFFIX=__none__"] +
|
||||
(["-D", "WINPTY_MSBUILD_TOOLSET=" + versionInfo["xp_toolset"]] if xp else []),
|
||||
cwd="src")
|
||||
devCmdPath = os.path.join(os.environ[versionInfo["common_tools_env"]], "VsDevCmd.bat")
|
||||
if not os.path.isfile(devCmdPath):
|
||||
sys.exit("Error: MSVC environment script missing: " + devCmdPath)
|
||||
subprocess.check_call(
|
||||
'"' + devCmdPath + '" && ' +
|
||||
"msbuild winpty.sln /m /p:Platform=" + ARCH_TABLE[arch]["msvc_platform"],
|
||||
shell=True,
|
||||
cwd="src")
|
||||
|
||||
newEnv = os.environ.copy()
|
||||
newEnv["Path"] = os.path.dirname(sys.executable) + ";" + common_ship.defaultPathEnviron
|
||||
commandLine = (
|
||||
'"' + devCmdPath + '" && '
|
||||
" vcbuild.bat" +
|
||||
" --gyp-msvs-version " + versionInfo["gyp_version"] +
|
||||
" --version-suffix __none__" +
|
||||
" --msvc-platform " + archInfo["msvc_platform"]
|
||||
)
|
||||
|
||||
subprocess.check_call(commandLine, shell=True, env=newEnv)
|
||||
|
||||
archPackageDir = os.path.join(packageDir, arch)
|
||||
if xp:
|
||||
|
87
vcbuild.bat
Executable file
87
vcbuild.bat
Executable file
@ -0,0 +1,87 @@
|
||||
@echo off
|
||||
|
||||
REM -- Script requirements:
|
||||
REM --
|
||||
REM -- * git This program must be in the Path to check out
|
||||
REM -- build-gyp. If that directory already exists, then
|
||||
REM -- git isn't necessary, but if it is missing, no
|
||||
REM -- commit hash will be embedded into binaries.
|
||||
REM --
|
||||
REM -- * python A non-Cygwin Python 2 python.exe must be in the
|
||||
REM -- Path to run gyp.
|
||||
REM --
|
||||
REM -- * msbuild msbuild must be in the Path. It is probably
|
||||
REM -- important to have msbuild from the correct MSVC
|
||||
REM -- release.
|
||||
REM --
|
||||
REM -- The script's output binaries are in the src/Release/{Win32,x64}
|
||||
REM -- directory.
|
||||
|
||||
REM -------------------------------------------------------------------------
|
||||
REM -- Parse arguments
|
||||
|
||||
setlocal
|
||||
cd %~dp0
|
||||
set GYP_ARGS=
|
||||
set MSVC_PLATFORM=x64
|
||||
|
||||
:ParamLoop
|
||||
if "%1" == "" goto :ParamDone
|
||||
if "%1" == "--msvc-platform" (
|
||||
REM -- One of Win32 or x64.
|
||||
set MSVC_PLATFORM=%2
|
||||
shift && shift
|
||||
goto :ParamLoop
|
||||
)
|
||||
if "%1" == "--gyp-msvs-version" (
|
||||
set GYP_ARGS=%GYP_ARGS% -G msvs_version=%2
|
||||
shift && shift
|
||||
goto :ParamLoop
|
||||
)
|
||||
if "%1" == "--toolset" (
|
||||
set GYP_ARGS=%GYP_ARGS% -D WINPTY_MSBUILD_TOOLSET=%2
|
||||
shift && shift
|
||||
goto :ParamLoop
|
||||
)
|
||||
if "%1" == "--version-suffix" (
|
||||
if x%2 == x"" (
|
||||
set GYP_ARGS=%GYP_ARGS% -D VERSION_SUFFIX=__none__
|
||||
) else (
|
||||
set GYP_ARGS=%GYP_ARGS% -D VERSION_SUFFIX=%2
|
||||
)
|
||||
shift && shift
|
||||
goto :ParamLoop
|
||||
)
|
||||
echo error: Unrecognized argument: %1
|
||||
exit /b 1
|
||||
:ParamDone
|
||||
|
||||
REM -------------------------------------------------------------------------
|
||||
REM -- Check out GYP. GYP doesn't seem to have releases, so just use the
|
||||
REM -- current master commit.
|
||||
|
||||
if not exist build-gyp (
|
||||
git clone https://chromium.googlesource.com/external/gyp build-gyp || (
|
||||
echo error: GYP clone failed
|
||||
exit /b 1
|
||||
)
|
||||
)
|
||||
|
||||
REM -------------------------------------------------------------------------
|
||||
REM -- Run gyp to generate MSVC project files.
|
||||
|
||||
cd src
|
||||
|
||||
call ..\build-gyp\gyp.bat winpty.gyp -I configurations.gypi %GYP_ARGS%
|
||||
if errorlevel 1 (
|
||||
echo error: GYP failed
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
REM -------------------------------------------------------------------------
|
||||
REM -- Compile the project.
|
||||
|
||||
msbuild winpty.sln /m /p:Platform=%MSVC_PLATFORM% || (
|
||||
echo error: msbuild failed
|
||||
exit /b 1
|
||||
)
|
Loading…
Reference in New Issue
Block a user