Created
October 7, 2016 08:10
-
-
Save mlocati/825932ab38d2eca935c88b22db75de49 to your computer and use it in GitHub Desktop.
Script to compile PHP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
setlocal enabledelayedexpansion | |
rem Reference: https://wiki.php.net/internals/windows/stepbystepbuild | |
set MY_VSDIR=C:\Path\To\Microsoft Visual Studio 14.0 | |
set PATH=%SystemRoot%\System32 | |
echo # Compiling PHP | |
set CONFIG_FILE=%~dpn0.bits | |
set CURRENT= | |
if exist "%CONFIG_FILE%" ( | |
for /f "delims= " %%i in (%CONFIG_FILE%) do set CURRENT=%%i | |
) | |
set BITS=%CURRENT% | |
if "%1" equ "32" set BITS=32 | |
if "%1" equ "64" set BITS=64 | |
if "%BITS%" equ "" ( | |
echo Missing number of bits! | |
goto done | |
) | |
echo - Number of bits: %BITS% | |
echo - Setting local environment | |
if %BITS% equ 64 (set MY_ARC=amd64) else (set MY_ARC=x86) | |
set MY_TOOLSDIR=%~dp0tools | |
set MY_SOURCEDIR=%~dp0.. | |
set MY_DEPS=deps%BITS% | |
set MY_OUT=%~dp0bin%BITS% | |
if not exist "%MY_TOOLSDIR%\bin\bison.exe" ( | |
echo Missing php-sdk-binary-tools! | |
echo Download and extract them to %MY_TOOLSDIR% | |
goto done | |
) | |
if not exist "%MY_TOOLSDIR%\%MY_DEPS%\bin\curl.exe" ( | |
echo Missing deps for x%BITS%! | |
echo Download and extract them to %MY_TOOLSDIR% | |
echo renaming the "deps" folder to %MY_DEPS% | |
goto done | |
) | |
echo - Setting Visual Studio environment | |
call "%MY_VSDIR%\VC\vcvarsall.bat" %MY_ARC% | |
echo - Setting PHP environment | |
cd /D "%MY_TOOLSDIR%" | |
call bin\phpsdk_setvars.bat | |
set INITIALIZE=yes | |
if %BITS% equ %CURRENT% set INITIALIZE=no | |
if "%2" equ "initialize" set INITIALIZE=yes | |
echo - Inizialize requested: %INITIALIZE% | |
if %INITIALIZE% equ no goto compile | |
del "%CONFIG_FILE%" >NUL 2>NUL | |
echo - Removing output directory | |
rmdir /S /Q "%MY_OUT%" | |
echo - Creating output directory | |
mkdir "%MY_OUT%" | |
echo - Initializing %BITS%-bit compilation | |
cd /D "%MY_SOURCEDIR%" | |
call buildconf.bat --force >NUL | |
echo - Configuring | |
cd /D "%MY_SOURCEDIR%" | |
call configure.bat --enable-cli --enable-object-out-dir="%MY_OUT%" --enable-debug --with-prefix="%MY_OUT%" --with-php-build="%MY_TOOLSDIR%\%MY_DEPS%" >NUL 2>NUL | |
echo %BITS%>%CONFIG_FILE% | |
:compile | |
echo - Start compilation | |
mkdir "%MY_OUT%" >NUL 2>NUL | |
set CL=/MP | |
cd /D "%MY_SOURCEDIR%" | |
nmake /NOLOGO /S | |
:done | |
endlocal |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment