Compare commits

...

82 Commits

Author SHA1 Message Date
Anatol Belski
cad50539cf improve crt usability check with multiple choices 2017-03-20 15:38:07 +01:00
Anatol Belski
6b50dabf00 fix condition 2017-03-13 18:39:15 +01:00
Anatol Belski
f5f5620c55 don't check for sdk 8.1 for vc15 and up, only vc14 is relevant 2017-03-13 18:22:19 +01:00
Anatol Belski
139ea9a86d extend readme with vc15 support 2017-03-09 15:29:12 +01:00
Anatol Belski
cf054fd362 version++ 2017-03-09 15:28:22 +01:00
Anatol Belski
2635a7936a add new line 2017-03-08 12:12:57 +01:00
Anatol Belski
9414d3a55c add dedicated vc15 starter scripts 2017-03-08 11:58:52 +01:00
Anatol Belski
36f67d7cce vc15 support, more to follow 2017-03-08 02:46:46 +01:00
Anatol Belski
e5b9fb320c add vswhere 2017-03-07 21:57:59 +01:00
Anatol Belski
edb52f1c34 add lemon to the list 2017-01-03 22:31:10 +01:00
Anatol Belski
aeeddd2e34 beta2 now 2017-01-03 20:47:26 +01:00
Anatol Belski
0236c6ec39 prepare for beta1 2017-01-03 20:44:30 +01:00
Anatol Belski
7eaaa4b6e9 provide lemon 2016-12-17 22:19:39 +01:00
Anatol Belski
72c2c103bc upgrade to 7.1.0, seems fine so far 2016-12-09 16:45:28 +01:00
Anatol Belski
71bf098e04 downgrade the bundled to 7.0.12 for now 2016-12-07 12:54:30 +01:00
Anatol Belski
b693b485b7 fix graceful exit 2016-11-28 17:28:42 +01:00
Anatol Belski
a4ab6b98d8 make php verbose 2016-11-28 16:39:14 +01:00
Anatol Belski
833eb864e8 alpha7 now 2016-11-21 18:03:22 +01:00
Anatol Belski
b56aa4c288 don't dump env for task build 2016-11-19 19:20:07 +01:00
Anatol Belski
9dc14d6f1e accept also task arguments 2016-11-19 16:49:39 +01:00
Anatol Belski
9134ee4718 upgrade PHP and add ext/mbstring needed for pickle 2016-11-16 20:19:17 +01:00
Anatol Belski
2849ea89a8 rename var for more clarity 2016-11-16 19:44:02 +01:00
Anatol Belski
c84a5d8303 rework the unattended build example 2016-11-16 19:16:21 +01:00
Anatol Belski
e350e99ba6 task could be also run, when the local setup doesn't exist 2016-11-16 18:58:49 +01:00
Anatol Belski
67bf1f579a add bsdtar 2016-11-16 18:48:27 +01:00
Anatol Belski
8fadf1d33d add deplister 2016-11-16 18:37:05 +01:00
Anatol Belski
f7d859266b add the standard set for tar/gz/bz2, etc. 2016-11-16 18:35:37 +01:00
Anatol Belski
c6c77737aa add tee 2016-11-16 17:49:46 +01:00
Anatol Belski
5ccc58cab5 improve wording 2016-11-16 16:47:20 +01:00
Anatol Belski
9c3d40ab02 extend the task script example 2016-11-15 14:10:26 +01:00
Anatol Belski
c0941efae5 extend on upgrading 2016-11-08 12:48:46 +01:00
Anatol Belski
49217155a3 clarify 2016-11-08 12:46:13 +01:00
Anatol Belski
b0f5cef8bd merge sentences 2016-11-08 12:44:14 +01:00
Anatol Belski
18d0b098ff version count up 2016-11-04 02:25:18 +01:00
Anatol Belski
fc185fd315 fix help msg 2016-10-31 19:05:27 +01:00
Anatol Belski
94ff7b53cf fix getopt check with no opt passed 2016-10-31 18:54:54 +01:00
Anatol Belski
217647a68e extend doc 2016-10-31 18:50:14 +01:00
Anatol Belski
52df9f9f4e fix phrase 2016-10-31 18:40:58 +01:00
Anatol Belski
4fb69d4c23 fix some doc 2016-10-31 16:57:41 +01:00
Anatol Belski
e99ec6722c expand on latest features 2016-10-31 16:54:26 +01:00
Anatol Belski
8fecd7c279 the is moved into doc already 2016-10-31 16:43:46 +01:00
Anatol Belski
97b62b2182 move some more stuff into doc 2016-10-31 16:42:50 +01:00
Anatol Belski
2d4aa4d54b bump version 2016-10-31 16:36:43 +01:00
Anatol Belski
0267758ff1 add task.exe tool 2016-10-31 16:36:11 +01:00
Anatol Belski
ca2ccd968a rework phpsdk-starter
- add argument names
- make possible to attach a task script for CI integration
2016-10-31 15:45:56 +01:00
Anatol Belski
422073f540 note about ConEmu 2016-10-30 12:19:51 +01:00
Anatol Belski
08fbbc7cd2 improve phrase 2016-10-29 23:45:00 +02:00
Anatol Belski
182f988f92 rework readme with more info 2016-10-29 23:43:47 +02:00
Anatol Belski
022eaba41e yet more edits 2016-10-29 23:01:44 +02:00
Anatol Belski
2a403e1820 some edits to the readme 2016-10-29 22:18:02 +02:00
Anatol Belski
07efa67e87 remove more unrelated tools 2016-10-29 22:01:42 +02:00
Anatol Belski
e74a98e253 add fixme 2016-10-28 16:13:24 +02:00
Anatol Belski
04aaf65cda accumulate return value 2016-10-28 15:18:36 +02:00
Anatol Belski
33c82a766f fix wording again 2016-10-28 14:14:27 +02:00
Anatol Belski
efb77f4589 add some vim folds 2016-10-28 14:09:01 +02:00
Anatol Belski
cddbe84fe3 add vim mode configs 2016-10-28 14:03:17 +02:00
Anatol Belski
6326bba7a1 rework pkg update msg 2016-10-28 13:27:38 +02:00
Anatol Belski
fdf6827c51 add FileOps trait and rework the deps update routine 2016-10-28 13:24:35 +02:00
Anatol Belski
feb2b675cb unset temp var 2016-10-28 02:18:57 +02:00
Anatol Belski
b60fd588d5 it's alpha4 now 2016-10-28 02:13:27 +02:00
Anatol Belski
4af7617b84 separate dumpenv out 2016-10-28 02:13:01 +02:00
Anatol Belski
7395237e33 edit error msg 2016-10-28 01:59:25 +02:00
Anatol Belski
2bd2595a16 add phpsdk-local example 2016-10-28 01:52:13 +02:00
Anatol Belski
3c204136a2 don't allow to append arbitrary code, but just a local file - that's
enough
2016-10-27 22:28:19 +02:00
Anatol Belski
ac205e153f do necessary followup ns renames 2016-10-27 16:08:29 +02:00
Anatol Belski
71f60852f8 move cache into the config space 2016-10-27 16:02:43 +02:00
Anatol Belski
5999098add check infos also in other scripts if run outside starter shell 2016-10-26 17:18:35 +02:00
Anatol Belski
9f8cf17928 fix phpsdk_deps dies when called with no SdK setup 2016-10-26 17:09:54 +02:00
Anatol Belski
496a4498a1 bump version 2016-10-26 16:49:48 +02:00
Anatol Belski
1162213596 fix order 2016-10-26 16:11:50 +02:00
Anatol Belski
c8e1563cd4 separate list and do it shorter 2016-10-26 16:10:00 +02:00
Anatol Belski
9b139a61c8 remove unnecessary sentence 2016-10-26 16:07:29 +02:00
Anatol Belski
bf84962182 more readme rework 2016-10-26 16:06:10 +02:00
Anatol Belski
d87c132a7e improve note 2016-10-26 16:04:35 +02:00
Anatol Belski
c781649433 add more readme notes 2016-10-26 15:59:05 +02:00
Anatol Belski
bd8b82579f fix starter arg passing, handle error from setshell script 2016-10-26 15:30:00 +02:00
Anatol Belski
d6b76e7f7d split out the phpsdk-starter part and make possible to append scripts 2016-10-26 15:19:03 +02:00
Anatol Belski
7f0015a68c rework the buildtree script 2016-10-26 13:40:14 +02:00
Anatol Belski
23a3eb2473 set console title when run from the starter script 2016-10-26 02:07:10 +02:00
Anatol Belski
296be1b3b4 make the prompt a bit more user friendly 2016-10-26 02:00:53 +02:00
Anatol Belski
3ec0ac9d0b extend .gitignore 2016-10-26 01:20:18 +02:00
Anatol Belski
baf09da395 remove unsupported branches 2016-10-26 01:17:33 +02:00
59 changed files with 736 additions and 242 deletions

4
.gitignore vendored
View File

@@ -14,3 +14,7 @@ logs
PFTT
\.tmp
\.cache
oracle
# either these two become submodules, or uncomment them
#pgo-build
#rmtools*

View File

@@ -4,53 +4,107 @@ PHP SDK is a tool kit for Windows PHP builds
# License
BSD
The PHP SDK itself and the SDK own tools are licensed under the BSD 2-Clause license. With the usage of the other tools, you accept the respective licenses.
# Notes
# Overview
This reworked SDK is compatible with PHP 7.0 and above. The compatibility with php-sdk-binary-tools-20110915.zip available from windows.php.net is kept, though some irrelevant tools was removed. Though, newer tools and workflows are now possible, and the work is in progress. The toolset consists on a mix of the hand written scripts, selected MSYS2 parts and standalone programs.
The PHP SDK 2.0 is compatible with PHP 7.0 and above. The compatibility with older versions, eq. php-sdk-binary-tools-20110915.zip available from windows.php.net previously, is kept. Though, some irrelevant tools was removed. Newer tools are now available, better workflows are now possible. The toolset consists on a mix of the hand written scripts, selected MSYS2 parts and standalone programs.
## SDK tools
# Requirements
- `Visual C++ 2015` or `Visual C++ 2017` must be installed prior SDK usage
- if `Cygwin` is installed, please read notes in the pitfalls section
- if a 64-bit build is intended, a 64-bit system is required. Cross compilation of 64-bit on 32-bit system is not supported at the moment
# Tools
All the tools included are either scripts or 32-bit binaries. They are therefore runable on any of x86 or x64 Windows system.
## SDK
- starter scripts, named phpsdk-<crt>-<arch>.bat
- `phpsdk_buildtree` - initialize the development filesystem structure
- `phpsdk_deps` - check and handle dependency libraries
- `phpsdk_deps` - handle dependency libraries
- `phpsdk_version` - show SDK version
- `phpsdk_dllmap` - create a JSON listing of DLLs contained in zip files
- `task.exe` - wrapper to hide the given command line
## Other available tools
## Other tools
- `bison` 3.0.2, `re2c` 0.15.3
- `bison` 3.0.2, `re2c` 0.15.3, `lemon`
- `awk`, `gawk`, `sed`, `grep`
- `diff`, `diff3`, `patch`
- `md5sum`, `sha1sum`, `sha224sum`, `sha256sum`, `sha384sum`, `sha512sum`
- `7za`, `zip`, `unzip`
- `7za`, `zip`, `unzip`, `unzipsfx`
- `wget`
## Not included
## Optional, not included
These are not included with the PHP SDK, but might be useful for the compilation and other tasks. While Visual C++ is the only required, the others might enable some additional functionality. Care yourself about making them available on your system.
These are not included with the PHP SDK, but might be useful. While Visual C++ is the only required, the others might enable some additional functionality. Care yourself about making them available on your system, if relevant.
- Visual C++
- clang
- ICC
- Git
- Cppcheck
- `Git` - useful for PHP source management
- `Cppcheck` - used for static analysis
- `clang` - useful for experimental builds and for static analysis
- `ICC` - useful for experimental builds
# Usage
## Basic usage
The PHP SDK should be unzipped into the shortest possible path, preferrably somewhere near the drive root.
Usually, the first step to start the PHP SDK is by invoking one of the suitable starter scripts. This automatically puts the console on the correct environment relevant for the desired PHP build configuration.
It is not required to hold the source in the PHP SDK directory. It could be useful, for example, to simplify the SDK updates.
## Basic usage example
- `git clone https://github.com/OSTC/php-sdk-binary-tools.git c:\php-sdk`
- `cd c:\php-sdk`
- `git checkout new_binary_tools`
- `cd` to c:\php-sdk and click one of the `phpsdk-*.bat` files in the SDK root, depending on the desired build parameters
- `phpsdk_buildtree && git clone https://github.com/php/php-src.git`, or fetch a zipball from windows.php.net
- while in php-src, run `phpsdk_deps --update --branch YOUR_BRANCH_NAME`
- invoke `phpsdk-vc14-x64.bat`
- `phpsdk_buildtree phpmaster`
- `git clone https://github.com/php/php-src.git && cd php-src`, or fetch a zipball
- `phpsdk_deps --update --branch master`
- do the build, eg. `buildconf && configure --enable-cli && nmake`
TODO more extensive documentation on the wiki
TODO more extensive documentation on the wiki.
## Staying compatible with the older version of the SDK
## The old way
- `git clone https://github.com/OSTC/php-sdk-binary-tools.git c:\php-sdk`
- follow the instructions on the PHP [wiki page](https://wiki.php.net/internals/windows/stepbystepbuild "PHP wiki page")
# Customizing
## Custom environment setup
A sript called phpsdk-local.bat has to be put into the PHP SDK root. If present, it will be automatically picked up by the starter script. A template for such a script is included with the PHP SDK. This allows to automatically meet any required preparations, that are not foreseen by the standard PHP SDK startup. Be careful while creating your own phpsdk-local. It's your responsibility to ensure the regular PHP SDK startup isn't broken after phpsdk-local was injected into the startup sequence.
## Console emulator integration
The starter scripts can be also easy integrated with the consoles other than standard cmd.exe. For the reference, here's an example ConEmu task
`C:\php-sdk\phpsdk-vc14-x64.bat -cur_console:d:C:\php-sdk\php70\vc14\x64\php-src`
## Unattended builds
An elementary functionality to run unattended builds is included. See an example on how to setup a simple unattended build task in the doc directory.
# Upgrading
- backup phpsdk-local.bat
- backup the source trees and any other custom files in the PHP SDK root
- move the PHP SDK folder into trash
- download, unpack and the new PHP SDK version under the same path
- move the custom files back into their respective places
# Extending
The SDK tools are based on the KISS principle and should be kept so. Basic tools are implemented as simple batch script. The minimalistic `PHP` is available for internal SDK purposes. It can be used, if more complexity is required. If you have an idea for some useful tool or workflow, please open a ticket or PR, so it can be discussed, implemented and added to the SDK. By contributing an implementation, you should also accept the SDK license.
# Pitfalls
- SDK or PHP sources put into paths including spaces might cause issue.
- SDK or PHP sources put into too long paths, will cause an issue.
- If Cygwin is installed, it might cause issues. If it's unavoidable, to have Cygwin on the same machine, ensure SDK preceeds it on the PATH.
- Tools, based on MSYS2, only accept paths with forward slashes.

View File

@@ -1 +1 @@
2.0.0alpha2
2.0.0beta3

BIN
bin/deplister.exe Normal file

Binary file not shown.

BIN
bin/lemon.exe Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -3,4 +3,9 @@ extension=php_curl.dll
extension=php_ftp.dll
extension=php_sqlite3.dll
extension=php_openssl.dll
memory_limit=1G
extension=php_mbstring.dll
memory_limit=1G
error_reporting=-1
display_errors=1
display_startup_errors=1

Binary file not shown.

Binary file not shown.

View File

@@ -4,33 +4,29 @@ IF "%1" EQU "" GOTO Help
IF "%2" NEQ "" SET _=%2\%1
IF "%2" EQU "" SET _=%CD%\%1
MD %_%\vc9\x86\deps\bin
MD %_%\vc9\x86\deps\lib
MD %_%\vc9\x86\deps\include
MD %_%\vc9\x64\deps\bin
MD %_%\vc9\x64\deps\lib
MD %_%\vc9\x64\deps\include
rem if we're in the starter script shell, create the only struct that corresponds to the current env
rem otherwise - retain the old behavior, create structs for all the known build combinations and don't cd
MD %_%\vc11\x86\deps\bin
MD %_%\vc11\x86\deps\lib
MD %_%\vc11\x86\deps\include
MD %_%\vc11\x64\deps\bin
MD %_%\vc11\x64\deps\lib
MD %_%\vc11\x64\deps\include
if "%PHP_SDK_ARCH%" NEQ "" (
if "%PHP_SDK_VC%" NEQ "" (
MD %_%\%PHP_SDK_VC%\%PHP_SDK_ARCH%\deps\bin
MD %_%\%PHP_SDK_VC%\%PHP_SDK_ARCH%\deps\lib
MD %_%\%PHP_SDK_VC%\%PHP_SDK_ARCH%\deps\include
cd %_%\%PHP_SDK_VC%\%PHP_SDK_ARCH%
goto exit
)
goto create_all
) else (
:create_all
MD %_%\vc14\x86\deps\bin
MD %_%\vc14\x86\deps\lib
MD %_%\vc14\x86\deps\include
MD %_%\vc14\x64\deps\bin
MD %_%\vc14\x64\deps\lib
MD %_%\vc14\x64\deps\include
)
MD %_%\vc12\x86\deps\bin
MD %_%\vc12\x86\deps\lib
MD %_%\vc12\x86\deps\include
MD %_%\vc12\x64\deps\bin
MD %_%\vc12\x64\deps\lib
MD %_%\vc12\x64\deps\include
MD %_%\vc14\x86\deps\bin
MD %_%\vc14\x86\deps\lib
MD %_%\vc14\x86\deps\include
MD %_%\vc14\x64\deps\bin
MD %_%\vc14\x64\deps\lib
MD %_%\vc14\x64\deps\include
set _=
GOTO EXIT

View File

@@ -1,8 +1,11 @@
@echo off
if "%PHP_SDK_PHP_CMD%"=="" (
echo PHP SDK is not setup
exit 3
call %~dp0phpsdk_setvars.bat
if "!PHP_SDK_PHP_CMD!"=="" (
echo PHP SDK is not setup
exit /b 3
)
)
call %PHP_SDK_PHP_CMD% %PHP_SDK_BIN_PATH%\phpsdk_deps.php %*

View File

@@ -224,3 +224,11 @@ function msg(string $s, int $code = 0) {
exit(0);
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: sw=4 ts=4 fdm=marker
* vim<600: sw=4 ts=4
*/

View File

@@ -1,8 +1,11 @@
@echo off
if "%PHP_SDK_PHP_CMD%"=="" (
echo PHP SDK is not setup
exit 3
call %~dp0phpsdk_setvars.bat
if "!PHP_SDK_PHP_CMD!"=="" (
echo PHP SDK is not setup
exit /b 3
)
)
call %PHP_SDK_PHP_CMD% %PHP_SDK_BIN_PATH%\phpsdk_dllmap.php %*

View File

@@ -102,3 +102,11 @@ foreach ($dirs as $path) {
echo json_encode($out);
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: sw=4 ts=4 fdm=marker
* vim<600: sw=4 ts=4
*/

View File

@@ -1,5 +1,12 @@
@echo off
if "%PHP_SDK_OS_ARCH%"=="" (
echo PHP SDK is not setup
exit /b 3
)
echo.
call %PHP_SDK_BIN_PATH%\phpsdk_version.bat
echo.
@@ -16,7 +23,7 @@ if "%PHP_SDK_ARCH%"=="x64" (
)
echo Visual C++: %PHP_SDK_VC:~2%
echo PHP-SDK path: %PHP_SDK_PATH%
echo PHP-SDK path: %PHP_SDK_ROOT_PATH%
exit /b

View File

@@ -1,7 +1,8 @@
@echo off
if not defined PHP_SDK_RUN_FROM_ROOT (
echo phpsdk_shell.bat should not be run directly, use starter scripts in the PHP SDK root
echo This script should not be run directly.
echo Use starter scripts looking like phpsdk-^<crt^>-^<arch^>.bat in the PHP SDK root instead.
goto out_error
)
@@ -13,8 +14,10 @@ if "%1"=="--help" goto :help
if "%2"=="" goto :help
if /i not "%1"=="vc14" (
if /i not "%1"=="vc15" (
echo Unsupported runtime "%1"
goto out_error
)
)
if /i not "%2"=="x64" (
@@ -42,41 +45,56 @@ if not errorlevel 1 (
set TMPKEY=
rem get vc base dir
if /i "%PHP_SDK_OS_ARCH%"=="x64" (
set TMPKEY=HKLM\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\%PHP_SDK_VC:~2%.0\Setup\VC
) else (
set TMPKEY=HKLM\SOFTWARE\Microsoft\VisualStudio\%PHP_SDK_VC:~2%.0\Setup\VC
)
reg query !TMPKEY! /v ProductDir >nul 2>&1
if errorlevel 1 (
echo Couldn't determine VC%PHP_SDK_VC:~2% directory
goto out_error;
)
for /f "tokens=2*" %%a in ('reg query !TMPKEY! /v ProductDir') do set PHP_SDK_VC_DIR=%%b
set TMPKEY=
rem get sdk dir
if /i "%PHP_SDK_OS_ARCH%"=="x64" (
set TMPKEY=HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Microsoft SDKs\Windows\v8.1
) else (
set TMPKEY=HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v8.1
)
for /f "tokens=2*" %%a in ('reg query "!TMPKEY!" /v InstallationFolder') do (
if exist "%%b\Include\um\Windows.h" (
set PHP_SDK_WIN_SDK_DIR=%%b
if /i "%1"=="vc14" (
if /i "%PHP_SDK_OS_ARCH%"=="x64" (
set TMPKEY=HKLM\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\%PHP_SDK_VC:~2%.0\Setup\VC
) else (
set TMPKEY=HKLM\SOFTWARE\Microsoft\VisualStudio\%PHP_SDK_VC:~2%.0\Setup\VC
)
)
if not defined PHP_SDK_WIN_SDK_DIR (
echo Windows SDK not found.
goto out_error;
reg query !TMPKEY! /v ProductDir >nul 2>&1
if errorlevel 1 (
echo Couldn't determine VC%PHP_SDK_VC:~2% directory
goto out_error;
)
for /f "tokens=2*" %%a in ('reg query !TMPKEY! /v ProductDir') do set PHP_SDK_VC_DIR=%%b
) else (
rem vc15 support only for now, could parse out and pass on later
for /f "tokens=1* delims=: " %%a in ('%~dp0\vswhere -nologo -version 15 -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath -format text') do set PHP_SDK_VC_DIR=%%b\VC
set VSCMD_ARG_no_logo=nologo
)
set TMPKEY=
if /i "%PHP_SDK_VC%"=="vc14" (
rem get sdk dir
if /i "%PHP_SDK_OS_ARCH%"=="x64" (
set TMPKEY=HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Microsoft SDKs\Windows\v8.1
) else (
set TMPKEY=HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v8.1
)
for /f "tokens=2*" %%a in ('reg query "!TMPKEY!" /v InstallationFolder') do (
if exist "%%b\Include\um\Windows.h" (
set PHP_SDK_WIN_SDK_DIR=%%b
)
)
if not defined PHP_SDK_WIN_SDK_DIR (
echo Windows SDK not found.
goto out_error;
)
set TMPKEY=
)
if /i "%PHP_SDK_ARCH%"=="x64" (
set PHP_SDK_VC_SHELL_CMD="!PHP_SDK_VC_DIR!\vcvarsall.bat" amd64
if /i "%1"=="vc14" (
set PHP_SDK_VC_SHELL_CMD="!PHP_SDK_VC_DIR!\vcvarsall.bat" amd64
) else (
set PHP_SDK_VC_SHELL_CMD="!PHP_SDK_VC_DIR!\Auxiliary\Build\vcvarsall.bat" amd64
)
) else (
set PHP_SDK_VC_SHELL_CMD="!PHP_SDK_VC_DIR!\vcvarsall.bat" x86
if /i "%1"=="vc14" (
set PHP_SDK_VC_SHELL_CMD="!PHP_SDK_VC_DIR!\vcvarsall.bat" x86
) else (
set PHP_SDK_VC_SHELL_CMD="!PHP_SDK_VC_DIR!\Auxiliary\Build\vcvarsall.bat" x86
)
)
rem echo Visual Studio path %PHP_SDK_VC_DIR%

View File

@@ -6,11 +6,11 @@ set PHP_SDK_BIN_PATH=%~dp0
rem remove trailing slash
set PHP_SDK_BIN_PATH=%PHP_SDK_BIN_PATH:~0,-1%
for %%a in ("%PHP_SDK_BIN_PATH%") do set PHP_SDK_PATH=%%~dpa
for %%a in ("%PHP_SDK_BIN_PATH%") do set PHP_SDK_ROOT_PATH=%%~dpa
rem remove trailing slash
set PHP_SDK_PATH=%PHP_SDK_PATH:~0,-1%
set PHP_SDK_ROOT_PATH=%PHP_SDK_ROOT_PATH:~0,-1%
set PHP_SDK_MSYS2_PATH=%PHP_SDK_PATH%\msys2\usr\bin
set PHP_SDK_MSYS2_PATH=%PHP_SDK_ROOT_PATH%\msys2\usr\bin
set PHP_SDK_PHP_CMD=%PHP_SDK_BIN_PATH%\php\do_php.bat
set PATH=%PHP_SDK_BIN_PATH%;%PHP_SDK_MSYS2_PATH%;%PATH%

View File

@@ -1,6 +1,14 @@
@echo off
%PHP_SDK_PHP_CMD% -r "echo 'PHP SDK ' . file_get_contents(getenv('PHP_SDK_PATH') . '\\VERSION');"
if "%PHP_SDK_PHP_CMD%"=="" (
call %~dp0phpsdk_setvars.bat
if "!PHP_SDK_PHP_CMD!"=="" (
echo PHP SDK is not setup
exit /b 3
)
)
%PHP_SDK_PHP_CMD% -r "echo 'PHP SDK ' . file_get_contents(getenv('PHP_SDK_ROOT_PATH') . '\\VERSION');"
exit /b

BIN
bin/task.exe Normal file

Binary file not shown.

BIN
bin/vswhere.exe Normal file

Binary file not shown.

View File

@@ -0,0 +1,20 @@
@echo off
set PGSQL_TEST_CONNSTR=host=127.0.0.1 dbname=test port=5432 user=test password=test
set PDO_PGSQL_TEST_DSN=pgsql:host=127.0.0.1 port=5432 dbname=test user=test password=test
set PHP_SDK_FIREBIRD_PATH=
if "%PHP_SDK_ARCH%"=="x64" (
set PHP_SDK_FIREBIRD_PATH=E:\local_programs\Firebird-2.5.5.26952-0_x64\bin;
set PDO_FIREBIRD_TEST_DSN=firebird:dbname=127.0.0.1:E:\local_programs\Firebird-2.5.5.26952-0_x64\examples\empbuild\EMPLOYEE.FDB
set PDO_FIREBIRD_TEST_USER=SYSDBA
set PDO_FIREBIRD_TEST_PASS=masterkey
)
set PATH=%PHP_SDK_FIREBIRD_PATH%%PATH%
set ODBC_TEST_USER=php_test2
set ODBC_TEST_PASS=php_test2
set ODBC_TEST_DSN=Driver={SQL Server};Server={W530-PHP-DEV\TEST2014};Database={php_test2};uid=%ODBC_TEST_USER%;pwd=%ODBC_TEST_PASS%
set PDOTEST_DSN=odbc:%ODBC_TEST_DSN%

72
doc/task.c Normal file
View File

@@ -0,0 +1,72 @@
/**
* Run the passed command line hidden, suitable for a scheduled task.
* Author: Anatol Belski <ab@php.net>
* License: BSD 2-Clause
*/
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#define CMD_PRE "cmd.exe /c "
#define CMD_PRE_LEN (sizeof(CMD_PRE)-1)
#ifdef DEBUG
int
main(int argc, char **argv)
#else
int
APIENTRY WinMain(HINSTANCE inst, HINSTANCE prev_inst, LPTSTR in_cmd, int show)
#endif
{
STARTUPINFO si;
PROCESS_INFORMATION pi;
DWORD exit_code;
char *cmd = NULL;
size_t cmd_len = 0, arg_len = 0;
char *arg = strchr(GetCommandLine(), ' ');
if (!arg) {
return 3;
}
#ifdef DEBUG
printf("passed cmd: '%s'\n", arg);
#endif
arg_len = strlen(arg);
cmd_len = CMD_PRE_LEN + arg_len + 1;
cmd = malloc(cmd_len * sizeof(char));
memmove(cmd, CMD_PRE, CMD_PRE_LEN);
memmove(cmd + CMD_PRE_LEN, arg, arg_len);
cmd[cmd_len-1] = '\0';
#ifdef DEBUG
printf("constructed cmd: '%s'\n", cmd);
#endif
ZeroMemory( &si, sizeof(si) );
si.cb = sizeof(si);
si.dwFlags = STARTF_USESHOWWINDOW;
si.wShowWindow = SW_HIDE;
ZeroMemory( &pi, sizeof(pi) );
if (CreateProcess(NULL, cmd, NULL, NULL, FALSE, CREATE_NO_WINDOW, NULL, NULL, &si, &pi)) {
CloseHandle( pi.hThread );
} else {
free(cmd);
printf( "Error: CreatePracess 0x%08lx \n", GetLastError() );
return 3;
}
WaitForSingleObject( pi.hProcess, INFINITE );
GetExitCodeProcess(pi.hProcess, &exit_code);
CloseHandle( pi.hProcess );
free(cmd);
return exit_code;
}

View File

@@ -0,0 +1,26 @@
rem Task batch example.
rem Create a task, put an action with the following data:
rem Action: start a program
rem Program/script: C:\php-sdk\bin\task.exe
rem Add arguments: "C:\php-sdk\phpsdk-starter.bat -c vc14 -a x64 -t C:\php-sdk\unattended-build-task.bat"
rem Run the task
set LOG_NAME=%PHP_SDK_VC%-%PHP_SDK_ARCH%-task.log
pushd C:\php-sdk\php70\vc14\x64\php-src
git pull --rebase > %LOG_NAME% 2>&1
call phpsdk_deps -u -s staging >> %LOG_NAME% 2>&1
call buildconf >> %LOG_NAME% 2>&1
call configure --enable-snapshot-build --enable-debug-pack >> %LOG_NAME% 2>&1
nmake clean >> %LOG_NAME% 2>&1
nmake >> %LOG_NAME% 2>&1
popd
exit

View File

@@ -1,8 +1,9 @@
<?php
namespace SDK\Dependency;
namespace SDK;
use SDK\Config;
use SDK\Cache;
use SDK\Exception;
class Cache
@@ -11,14 +12,14 @@ class Cache
protected $hash;
public function __construct(string $id)
{
{/*{{{*/
$this->id = $id;
$this->hash = md5($id);
/* XXX pass as arg, fine for now. */
}
}/*}}}*/
protected function getCacheablePath(string $path, bool $relative = false) : string
{
{/*{{{*/
if ($relative) {
$dir = Config::getCacheDir();
$name = $path;
@@ -28,15 +29,15 @@ class Cache
}
return $dir . DIRECTORY_SEPARATOR . $this->hash . "." . $name;
}
}/*}}}*/
public function fileIsCached(string $path, bool $relative = false) : bool
{
{/*{{{*/
return file_exists($this->getCacheablePath($path, $relative));
}
}/*}}}*/
public function cachedContentDiffers(string $path, string $content, bool $relative = false) : bool
{
{/*{{{*/
$p = $this->getCacheablePath($path, $relative);
if (!file_exists($p)) {
@@ -47,19 +48,19 @@ class Cache
$new_sum = md5($content);
return $old_sum != $new_sum;
}
}/*}}}*/
public function cacheContent(string $path, string $content, bool $relative = false)
{
{/*{{{*/
$p = $this->getCacheablePath($path, $relative);
if (strlen($content) !== file_put_contents($p, $content)) {
throw new Exception("Couldn't cache '$p'");
}
}
}/*}}}*/
public function getCachedContent(string $path, bool $relative = false)
{
{/*{{{*/
$p = $this->getCacheablePath($path, $relative);
if ($this->isFileCached($p)) {
@@ -67,6 +68,14 @@ class Cache
}
return "";
}
}/*}}}*/
}
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: sw=4 ts=4 fdm=marker
* vim<600: sw=4 ts=4
*/

View File

@@ -3,7 +3,7 @@
namespace SDK;
use SDK\Dependency\Fetcher;
use SDK\Dependency\Cache;
use SDK\Cache;
use SDK\Exception;
class Config
@@ -25,50 +25,52 @@ class Config
protected static $depsLocalPath = NULL;
public static function getDepsHost() : string
{
{/*{{{*/
return self::$depsHost;
}
}/*}}}*/
public static function getDepsPort() : string
{
{/*{{{*/
return self::$depsPort;
}
}/*}}}*/
public static function getDepsBaseUri() : string
{
{/*{{{*/
return self::$depsBaseUri;
}
}/*}}}*/
public static function setCurrentArchName(string $arch)
{
{/*{{{*/
self::$currentArchName = $arch;
}
} /*}}}*/
public static function getCurrentArchName()
{
{/*{{{*/
return self::$currentArchName;
}
} /*}}}*/
public static function setCurrentCrtName(string $crt)
{
{/*{{{*/
self::$currentCrtName = $crt;
}
} /*}}}*/
public static function getCurrentCrtName()
{
{/*{{{*/
return self::$currentCrtName;
}
} /*}}}*/
public static function setCurrentStabilityName(string $stability)
{
{/*{{{*/
self::$currentStabilityName = $stability;
}
} /*}}}*/
public static function getCurrentStabilityName()
{
{/*{{{*/
return self::$currentStabilityName;
}
} /*}}}*/
public static function getKnownBranches() : array
{
{/*{{{*/
if (empty(self::$knownBranches)) {
$cache_file = "known_branches.txt";
$cache = new Cache(self::getDepsLocalPath());
@@ -101,24 +103,24 @@ class Config
}
return self::$knownBranches;
}
}/*}}}*/
public static function setCurrentBranchName(string $name)
{
{/*{{{*/
if (!array_key_exists($name, self::getKnownBranches())) {
// throw new Exception("Unsupported branch '$name'");
}
self::$currentBranchName = $name;
}
}/*}}}*/
public static function getCurrentBranchName()
{
{/*{{{*/
return self::$currentBranchName;
}
}/*}}}*/
public static function getCurrentBranchData() : array
{
{/*{{{*/
$ret = array();
$branches = self::getKnownBranches();
@@ -132,8 +134,14 @@ class Config
throw new Exception("More than one CRT is available for branch '" . self::$currentBranchName . "', pass one explicitly.");
}
$crt = array_keys($branches[self::$currentBranchName])[0];
if ($cur_crt != $crt) {
$cur_crt_usable = false;
foreach (array_keys($branches[self::$currentBranchName]) as $crt) {
if ($cur_crt == $crt) {
$cur_crt_usable = true;
break;
}
}
if (!$cur_crt_usable) {
throw new Exception("The passed CRT '$cur_crt' doesn't match any availbale for branch '" . self::$currentBranchName . "'");
}
$data = $branches[self::$currentBranchName][$cur_crt];
@@ -166,19 +174,19 @@ class Config
}
return $ret;
}
}/*}}}*/
public static function getSdkNugetFeedUrl() : string
{
{/*{{{*/
return self::$sdkNugetFeedUrl;
}
}/*}}}*/
public static function getSdkPath()
{
$path = getenv("PHP_SDK_PATH");
{/*{{{*/
$path = getenv("PHP_SDK_ROOT_PATH");
if (!$path) {
throw new Exception("PHP_SDK_PATH isn't set!");
throw new Exception("PHP_SDK_ROOT_PATH isn't set!");
}
$path = realpath($path);
@@ -187,10 +195,10 @@ class Config
}
return $path;
}
}/*}}}*/
public static function getSdkVersion() : string
{
{/*{{{*/
$path = self::getSdkPath() . DIRECTORY_SEPARATOR . "VERSION";
if (!file_exists($path)) {
@@ -198,20 +206,20 @@ class Config
}
return file_get_contents($path);
}
}/*}}}*/
public static function getDepsLocalPath()
{
{/*{{{*/
return self::$depsLocalPath;
}
}/*}}}*/
public static function setDepsLocalPath(string $path)
{
{/*{{{*/
self::$depsLocalPath = $path;
}
}/*}}}*/
public static function getCacheDir() : string
{
{/*{{{*/
$path = self::getSdkPath() . DIRECTORY_SEPARATOR . ".cache";
if (!file_exists($path)) {
@@ -221,10 +229,10 @@ class Config
}
return $path;
}
}/*}}}*/
public static function getTmpDir() : string
{
{/*{{{*/
$path = self::getSdkPath() . DIRECTORY_SEPARATOR . ".tmp";
if (!file_exists($path)) {
@@ -234,6 +242,14 @@ class Config
}
return $path;
}
}/*}}}*/
}
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: sw=4 ts=4 fdm=marker
* vim<600: sw=4 ts=4
*/

View File

@@ -15,27 +15,27 @@ class Fetcher
public function __construct(string $host, int $port, string $arch = NULL, string $stability = NULL, Series $series = NULL)
{
{/*{{{*/
$this->stability = $stability;
$this->arch = $arch;
$this->host = $host;
$this->port = $port;
}
}/*}}}*/
public function getSeries() : Series
{
{/*{{{*/
return $this->series;
}
}/*}}}*/
public function setSeries(Series $series)
{
{/*{{{*/
$this->series = $series;
}
}/*}}}*/
/* TODO more robust implementation. */
/* TODO implement indicator. */
public function getByUri($uri) : string
{
{/*{{{*/
$url = "http://{$this->host}:{$this->port}$uri";
$s = file_get_contents($url);
@@ -44,7 +44,7 @@ class Fetcher
}
return $s;
}
}/*}}}*/
/*protected function fetch($uri) : string
{
@@ -80,3 +80,11 @@ class Fetcher
}
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: sw=4 ts=4 fdm=marker
* vim<600: sw=4 ts=4
*/

View File

@@ -3,10 +3,14 @@
namespace SDK\Dependency;
use SDK\Config;
use SDK\Cache;
use SDK\Exception;
use SDK\FileOps;
class Manager
{
use FileOps;
protected $stability;
protected $arch;
protected $path;
@@ -14,7 +18,7 @@ class Manager
protected $fetcher;
public function __construct(string $path, string $stability, string $arch)
{
{/*{{{*/
$this->stability = $stability;
$this->arch = $arch;
$this->path = $path;
@@ -29,21 +33,22 @@ class Manager
$this->fetcher = $fetcher;
$this->series = $series;
}
}/*}}}*/
protected function getTmpSeriesPath()
{
{/*{{{*/
return Config::getTmpDir() . DIRECTORY_SEPARATOR . $this->series->getname();
}
}/*}}}*/
public function updatesAvailable() : bool
{
{/*{{{*/
return $this->series->updatesAvailable();
}
}/*}}}*/
/* TODO and implement --force. */
/* FIXME implement rollback */
public function performUpdate(string &$msg = NULL)
{
{/*{{{*/
if (!$this->updatesAvailable()) {
$msg = "No updates are available";
return;
@@ -51,12 +56,9 @@ class Manager
$series_data = $this->series->getData();
$tmp_dir = Config::getTmpDir() . DIRECTORY_SEPARATOR . md5(uniqid());
$tmp_dir_packs = $tmp_dir . DIRECTORY_SEPARATOR . "packs";
$tmp_dir_deps = $tmp_dir . DIRECTORY_SEPARATOR . "deps";
mkdir($tmp_dir);
mkdir($tmp_dir_packs);
mkdir($tmp_dir_deps);
$tmp_dir = $this->md("", true);
$tmp_dir_packs = $this->md($tmp_dir . DIRECTORY_SEPARATOR . "packs");
$tmp_dir_deps = $this->md($tmp_dir . DIRECTORY_SEPARATOR . "deps");
foreach ($series_data as $item) {
echo "Processing package $item", PHP_EOL;
@@ -69,46 +71,53 @@ class Manager
unset($pkg);
}
if (file_exists($this->path)) {
$suffix = date("YmdHi");
$new_path = "{$this->path}.$suffix";
if (!rename($this->path, $new_path)) {
throw new Exception("Unable to rename '{$this->path}' to '$new_path'");
}
} else {
$up = dirname($this->path);
if (!file_exists($up)) {
if (!mkdir($up, 0755, true)) {
throw new Exception("Unable to create '{$this->path}'");
}
}
}
/* Clear, it is an extra handling. So far it's the only case, doing it this way. And, we have
no package definitions ATM to handle it otherwise. */
$extra = $tmp_dir_deps . DIRECTORY_SEPARATOR . "openssl.cnf";
if (file_exists($extra)) {
$tdir = $tmp_dir_deps . DIRECTORY_SEPARATOR . "template" . DIRECTORY_SEPARATOR . "ssl";
mkdir($tdir, 0755, true);
rename($extra, $tdir . DIRECTORY_SEPARATOR . "openssl.cnf");
$this->md($tdir);
$this->mv($extra, $tdir . DIRECTORY_SEPARATOR . "openssl.cnf");
}
if (!rename($tmp_dir_deps, $this->path)) {
throw new Exception("Unable to rename '$tmp_dir_deps' to '{$this->path}'");
if (file_exists($this->path)) {
$suffix = date("YmdHi");
$new_path = "{$this->path}.$suffix";
/* This is fine, it's gonna be on the same drive. */
if (!$this->mv($this->path, $new_path)) {
throw new Exception("Unable to rename '{$this->path}' to '$new_path'");
}
} else {
$up = dirname($this->path);
if (!file_exists($up)) {
if (!$this->md($up)) {
throw new Exception("Unable to create '{$this->path}'");
}
}
}
rmdir($tmp_dir_packs);
rmdir($tmp_dir);
$this->mv($tmp_dir_deps, $this->path);
$this->rm($tmp_dir_packs);
$this->rm($tmp_dir);
$this->series->cache();
/* save new series file, move the updated deps and backup the old ones, cleanup.*/
$msg = "Updates performed successfully. ";
$msg .= "Updated dependencies was saved to '{$this->path}'. ";
$msg = "Updates performed successfully. " . PHP_EOL;
if (isset($new_path)) {
$msg .= "Old dependencies dir is moved to '$new_path'.";
$msg .= "Old dependencies backed up into '$new_path'.";
}
}
}/*}}}*/
}
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: sw=4 ts=4 fdm=marker
* vim<600: sw=4 ts=4
*/

View File

@@ -13,23 +13,23 @@ class Package
protected $filepath;
public function __construct(string $name, Series $series, Fetcher $fetcher)
{
{/*{{{*/
$this->name = $name;
$this->series = $series;
$this->fetcher = $fetcher;
}
}/*}}}*/
public function getUri() : string
{
{/*{{{*/
$base = Config::getDepsBaseUri();
$branch_data = Config::getCurrentBranchData();
$arch = $this->series->getArch();
return "$base/{$branch_data['crt']}/$arch/{$this->name}";
}
}/*}}}*/
public function retrieve(string $path)
{
{/*{{{*/
$this->filepath = $path . DIRECTORY_SEPARATOR . $this->name;
$cont = $this->fetcher->getByUri($this->getUri());
@@ -37,10 +37,10 @@ class Package
$fd = fopen($this->filepath, "wb");
fwrite($fd, $cont);
fclose($fd);
}
}/*}}}*/
public function unpack(string $path)
{
{/*{{{*/
if (!$this->filepath || !file_exists($this->filepath)) {
throw new Exception("Invalid filepath '{$this->filepath}'");
}
@@ -53,11 +53,19 @@ class Package
} else {
throw new Exception("Failed to unpack, error code '$ret'");
}
}
}/*}}}*/
public function cleanup()
{
{/*{{{*/
unlink($this->filepath);
}
}/*}}}*/
}
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: sw=4 ts=4 fdm=marker
* vim<600: sw=4 ts=4
*/

View File

@@ -3,6 +3,7 @@
namespace SDK\Dependency;
use SDK\Config;
use SDK\Cache;
use SDK\Exception;
class Series
@@ -14,53 +15,53 @@ class Series
protected $cache;
public function __construct(string $stability, string $arch, Cache $cache, Fetcher $fetcher = NULL)
{
{/*{{{*/
$this->fetcher = $fetcher;
$this->stability = $stability;
$this->arch = $arch;
$this->cache = $cache;
}
}/*}}}*/
public function getFetcher() : Fetcher
{
{/*{{{*/
return $this->fetcher;
}
}/*}}}*/
public function setFetcher(Fetcher $fetcher)
{
{/*{{{*/
$this->fetcher = $fetcher;
}
}/*}}}*/
public function getArch() : string
{
{/*{{{*/
return $this->arch;
}
}/*}}}*/
public function setArch(string $arch)
{
{/*{{{*/
$this->arch = $arch;
}
}/*}}}*/
public function getName() : string
{
{/*{{{*/
$base = Config::getDepsBaseUri();
$branch_data = Config::getCurrentBranchData();
$file = "packages-" . Config::getCurrentBranchName() . "-{$branch_data['crt']}-{$this->arch}-{$this->stability}.txt";
return $file;
}
}/*}}}*/
protected function getUri() : string
{
{/*{{{*/
$base = Config::getDepsBaseUri();
$file = $this->getName();
return "$base/series/$file";
}
}/*}}}*/
public function getData(bool $raw = false, bool $cache = true)
{
{/*{{{*/
if ($cache && $this->rawData) {
$ret = $this->rawData;
} else {
@@ -76,28 +77,36 @@ class Series
}
return $ret;
}
}/*}}}*/
public function getSavePath()
{
{/*{{{*/
return Config::getCacheDir() . DIRECTORY_SEPARATOR . $this->getname();
}
}/*}}}*/
public function updatesAvailable()
{
{/*{{{*/
$series_data = $this->getData(true);
$series_file = $this->getSavePath();
return $this->cache->cachedContentDiffers($series_file, $series_data);
}
}/*}}}*/
public function cache(string $path = NULL)
{
{/*{{{*/
if (!$path) {
$path = $this->getSavePath();
}
$this->cache->cacheContent($path, $this->getData(true));
}
}/*}}}*/
}
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: sw=4 ts=4 fdm=marker
* vim<600: sw=4 ts=4
*/

View File

@@ -7,3 +7,11 @@ class Exception extends \Exception
}
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: sw=4 ts=4 fdm=marker
* vim<600: sw=4 ts=4
*/

View File

@@ -0,0 +1,127 @@
<?php
namespace SDK;
use SDK\Config;
use SDK\Exception;
trait FileOps
{
protected function md(string $name = "", bool $tmp = false) : string
{/*{{{*/
$ret = $name;
if (!$name) {
if ($tmp) {
$pre = Config::getTmpDir();
$ret = $pre . DIRECTORY_SEPARATOR . md5(uniqid());
} else {
throw new Exception("Dir name is empty");
}
}
if (!is_dir($ret)) {
if (!mkdir($ret, 0755, true)) {
throw new Exception("Unable to create '$ret'");
}
}
return $ret;
}/*}}}*/
/* TODO is link and more checks. */
protected function rm(string $path) : bool
{/*{{{*/
if (!file_exists($path)) {
return false;
} else if (is_file($path)) {
return unlink($path);
}
$ret = true;
$iterator = new \RecursiveIteratorIterator(
new \RecursiveDirectoryIterator(
$path,
\FilesystemIterator::SKIP_DOTS
),
\RecursiveIteratorIterator::CHILD_FIRST
);
foreach ($iterator as $item) {
if ($item->isDir()) {
$ret = $ret && rmdir($item->getPathname());
} else {
$ret = $ret && unlink($item->getPathname());
}
}
return $ret && rmdir($path);
}/*}}}*/
/* TODO islink and more checks */
protected function cp_or_mv(string $src, string $dst, callable $cb) : bool
{/*{{{*/
if (!file_exists($src)) {
return false;
} else if (is_file($src)) {
return call_user_func($cb, $src, $dst);
}
if (!file_exists($dst)) {
$this->md($dst);
}
$iterator = new \RecursiveIteratorIterator(
new \RecursiveDirectoryIterator(
$src,
\FilesystemIterator::SKIP_DOTS
),
\RecursiveIteratorIterator::CHILD_FIRST
);
$cut_len = strlen($src)+1;
foreach ($iterator as $item) {
$src_path = $item->getPathname();
$sub = substr($src_path, $cut_len);
$dst_path = $dst . DIRECTORY_SEPARATOR . $sub;
$dst_parent = dirname($dst_path);
if (!is_dir($dst_parent)) {
if (!$this->md($dst_parent)) {
throw new Exception("Unable to create '$dst_parent'");
}
}
if ($item->isFile()) {
if (!call_user_func($cb, $src_path, $dst_path)) {
throw new Exception("Unable to $cb '$src_path' to '$dst_path'");
}
}
}
return true;
}/*}}}*/
protected function cp(string $src, string $dst) : bool
{/*{{{*/
return $this->cp_or_mv($src, $dst, "copy");
}/*}}}*/
protected function mv(string $src, string $dst) : bool
{/*{{{*/
$ret = $this->cp_or_mv($src, $dst, "rename");
$ret = $ret && $this->rm($src);
return $ret;
}/*}}}*/
}
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: sw=4 ts=4 fdm=marker
* vim<600: sw=4 ts=4
*/

View File

@@ -5,3 +5,11 @@ function __autoload($name)
require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . $name . ".php";
}
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: sw=4 ts=4 fdm=marker
* vim<600: sw=4 ts=4
*/

BIN
msys2/usr/bin/bsdtar.exe Normal file

Binary file not shown.

BIN
msys2/usr/bin/bzip2.exe Normal file

Binary file not shown.

Binary file not shown.

BIN
msys2/usr/bin/gzip.exe Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
msys2/usr/bin/tar.exe Normal file

Binary file not shown.

BIN
msys2/usr/bin/tee.exe Normal file

Binary file not shown.

BIN
msys2/usr/bin/xz.exe Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

64
phpsdk-starter.bat Normal file
View File

@@ -0,0 +1,64 @@
@echo off
setlocal enableextensions enabledelayedexpansion
set IMHERE=%~dp0
:getopt
if /i "%1" equ "-h" goto help
if /i "%1" equ "-c" set CRT=%2 & shift
if /i "%1" equ "-a" set ARCH=%2 & shift
if /i "%1" equ "-t" set TASK=%2 & shift
if /i "%1" equ "--task-args" set TASK_ARGS=%2 & shift
shift
if not (%1)==() goto getopt
if "%CRT%" equ "" goto help
if "%ARCH%" equ "" goto help
goto skip_help
:help
echo Usage: phpsdk-starter -c ^<crt^> -a ^<arch^> [-t ^<task_script.bat^>]
exit /b 0
:skip_help
set CRT=%CRT: =%
set ARCH=%ARCH: =%
set PHP_SDK_RUN_FROM_ROOT=1
title PHP SDK
call %IMHERE%bin\phpsdk_setshell.bat %CRT% %ARCH%
if errorlevel 3 (
exit /b %errorlevel%
)
if "%TASK%" neq "" (
if exist "%TASK%" (
set TASK_ARGS=%TASK_ARGS:"=%
if exist "%IMHERE%phpsdk-local.bat" (
cmd /c "!PHP_SDK_VC_SHELL_CMD! && %IMHERE%\bin\phpsdk_setvars.bat && %IMHERE%\phpsdk-local.bat && %TASK% !TASK_ARGS!"
) else (
cmd /c "!PHP_SDK_VC_SHELL_CMD! && %IMHERE%\bin\phpsdk_setvars.bat && %TASK% !TASK_ARGS!"
)
exit /b
) else (
echo could not find the task file
exit /b 3
)
)
if exist "%IMHERE%phpsdk-local.bat" (
cmd /k "!PHP_SDK_VC_SHELL_CMD! && %IMHERE%\bin\phpsdk_setvars.bat && %IMHERE%\bin\phpsdk_dumpenv.bat && %IMHERE%\phpsdk-local.bat && echo. && set prompt=$P$_$+$$$S"
) else (
cmd /k "!PHP_SDK_VC_SHELL_CMD! && %IMHERE%\bin\phpsdk_setvars.bat && %IMHERE%\bin\phpsdk_dumpenv.bat && set prompt=$P$_$+$$$S"
)
set PHP_SDK_RUN_FROM_ROOT=
exit /b

View File

@@ -1,14 +1,6 @@
@echo off
setlocal enableextensions enabledelayedexpansion
call %~dp0phpsdk-starter.bat -c vc14 -a x64 %*
set PHP_SDK_RUN_FROM_ROOT=1
call %~dp0bin\phpsdk_setshell.bat vc14 x64
cmd /k "%PHP_SDK_VC_SHELL_CMD% && %~dp0\bin\phpsdk_setvars.bat && %~dp0\bin\phpsdk_dumpenv.bat"
set PHP_SDK_RUN_FROM_ROOT=
exit
exit /b

View File

@@ -1,14 +1,6 @@
@echo off
setlocal enableextensions enabledelayedexpansion
call %~dp0phpsdk-starter.bat -c vc14 -a x86 %*
set PHP_SDK_RUN_FROM_ROOT=1
call %~dp0bin\phpsdk_setshell.bat vc14 x86
cmd /k "%PHP_SDK_VC_SHELL_CMD% && %~dp0\bin\phpsdk_setvars.bat && %~dp0\bin\phpsdk_dumpenv.bat"
set PHP_SDK_RUN_FROM_ROOT=
exit
exit /b

6
phpsdk-vc15-x64.bat Normal file
View File

@@ -0,0 +1,6 @@
@echo off
call %~dp0phpsdk-starter.bat -c vc15 -a x64 %*
exit /b

6
phpsdk-vc15-x86.bat Normal file
View File

@@ -0,0 +1,6 @@
@echo off
call %~dp0phpsdk-starter.bat -c vc15 -a x86 %*
exit /b