Compare commits

..

119 Commits

Author SHA1 Message Date
Anatol Belski
bebb84afd7 Prepare 2.1.10 2019-01-12 16:08:52 +01:00
Anatol Belski
841065efd4 One more version update 2019-01-08 17:57:31 +01:00
Anatol Belski
c726890170 Update versions in README 2019-01-08 17:55:26 +01:00
Anatol Belski
b2e52e36d8 Back to dev 2018-12-26 13:51:10 +01:00
Anatol Belski
b8713d8543 Prepare 2.1.10beta1 2018-12-26 13:49:56 +01:00
Anatol Belski
025290f6d3 Upgrade to re2c 1.1.1 2018-12-26 13:31:49 +01:00
Anatol Belski
1ed89bbba2 Upgrade to bison 3.2.4 2018-12-26 13:30:28 +01:00
Anatol Belski
1d4f4966af Convert eol 2018-09-29 21:01:31 +02:00
Anatol Belski
a5b1137938 Back to dev 2018-09-19 21:20:37 +02:00
Anatol Belski
908f5eeea7 Prepare 2.1.9 2018-09-19 21:19:41 +02:00
Anatol Belski
a7cc2823bf Back to dev 2018-09-12 12:04:30 +02:00
Anatol Belski
ff6a7245a3 Prepare 2.1.9beta1 2018-09-12 12:01:23 +02:00
Anatol Belski
9bb1377d59 Extend README 2018-09-10 17:26:47 +02:00
Anatol Belski
95d712bde7 Rebase MSYS2 DLLs 2018-09-10 17:22:44 +02:00
Anatol Belski
446f4272fe Add tool to rebase MSYS2 DLLs 2018-09-10 17:13:53 +02:00
Anatol Belski
f6b6bd96e0 Upgrade msys2 tools 2018-09-10 13:21:24 +02:00
Anatol Belski
94b3d07034 Upgrade grep 2018-09-10 12:12:14 +02:00
Anatol Belski
6797238516 Extend for MingW, too 2018-09-07 10:00:56 +02:00
Anatol Belski
02f2f372b6 Add note on child process debugging 2018-09-07 09:58:11 +02:00
Anatol Belski
04832718bb Extend debug notes 2018-09-07 09:47:03 +02:00
Anatol Belski
b52a0c281a Add note on debugging 2018-09-07 09:35:24 +02:00
Anatol Belski
bc3606fbaf Back to dev 2018-08-17 15:41:17 +02:00
Anatol Belski
41a63dc0b4 Prepare 2.1.8 2018-08-17 15:39:45 +02:00
Anatol Belski
99ae3ca016 Update MariaDB version 2018-08-17 12:35:35 +02:00
Anatol Belski
777542838c Update Nginx version 2018-08-17 12:35:01 +02:00
Anatol Belski
82987940a0 Update bundled PHP 2018-08-16 06:26:07 +02:00
Anatol Belski
45344d7691 Update wp-cli version 2018-08-16 06:21:57 +02:00
Anatol Belski
02a726256a Update Joomla version 2018-08-16 06:20:01 +02:00
Anatol Belski
0a7732ba09 Update Symfony demo version 2018-08-14 09:31:26 +02:00
Anatol Belski
8583bb4f00 Remove explicit composer requirement 2018-08-14 00:14:59 +02:00
Anatol Belski
d6fc46edfd Convert EOL 2018-08-08 16:16:38 +02:00
Anatol Belski
75740674e5 Extend the requirements note 2018-08-07 20:22:44 +02:00
Anatol Belski
e81199f9af Fix command 2018-08-07 17:55:42 +02:00
Anatol Belski
134556d419 Stick to a specific composer version
For now only, until Symfony demo app has fixed issues.
2018-08-07 17:22:18 +02:00
Anatol Belski
6121772665 Upgrade 7zip 2018-08-07 17:12:53 +02:00
Anatol Belski
61dff2296a Retry downloads 2018-08-07 15:46:00 +02:00
Gemorroj
1b8473489f some minor improvements drop unused imports, unused variables, dirname(__FILE__) -> __DIR__, cs fixes, ...
revert some non-obvious getters, explicit specification of abstract classes

null -> NULL

4 space -> tab
2018-08-07 15:43:01 +02:00
Anatol Belski
e494a28d4c Re-enable Drupal and Joomla training 2018-08-02 07:49:31 +02:00
Anatol Belski
22addaf53e Run more drupal training 2018-08-01 11:50:38 +02:00
Anatol Belski
bb8e318a4a Disable this specific URI for causing unnecessary 404s 2018-08-01 09:56:59 +02:00
Anatol Belski
87b60bc9d5 Handle rmtools branch guess through a short path 2018-08-01 09:10:32 +02:00
Anatol Belski
4936f1d7ca This works only if dealing with a git checkout 2018-07-31 21:31:31 +02:00
Anatol Belski
7d56095191 Add support section 2018-07-31 21:20:12 +02:00
Anatol Belski
27c3431e92 Add fallback for rmtools 2018-07-31 21:05:05 +02:00
Anatol Belski
e5ef707fa0 Missed semicolon 2018-07-31 20:21:20 +02:00
Anatol Belski
7df3de21ce Improve URL gathering 2018-07-31 19:57:37 +02:00
Anatol Belski
64b37312f7 Add special handling for master branch name 2018-07-31 19:29:43 +02:00
Anatol Belski
4a219a0d93 Deactivate Drupal training for now, need test 2018-07-31 19:19:19 +02:00
Anatol Belski
5d97e8e483 Add 7.4 ini 2018-07-31 17:36:25 +02:00
Anatol Belski
9a0f799055 Use normal verbosity 2018-07-26 15:27:32 +02:00
Anatol Belski
4f5028d87a Set some vars that are possible unavailable but required by some
frameworks
2018-07-26 14:58:52 +02:00
Anatol Belski
93437db5ae Fix typo 2018-07-26 14:24:10 +02:00
Anatol Belski
0572a3ec52 Rework initialization, use more default values 2018-07-26 13:05:30 +02:00
Anatol Belski
52badef774 Add more verbosity 2018-07-26 09:41:43 +02:00
Anatol Belski
b01fcd36e7 Remove false info 2018-07-26 09:36:20 +02:00
Anatol Belski
fbc6c40761 Redisable joomla case for now 2018-07-26 09:19:03 +02:00
Anatol Belski
7501f5e567 Disable app debug as that would make warnings to exceptions 2018-07-25 20:29:30 +02:00
Anatol Belski
e51c37a375 Fix EOL 2018-07-25 19:38:02 +02:00
Anatol Belski
bd0ab3474c Fix nginx config 2018-07-25 19:37:46 +02:00
Anatol Belski
056e5643fb Fix drupal init 2018-07-25 19:27:49 +02:00
Anatol Belski
e039de13c4 Further setup fixes 2018-07-25 17:43:33 +02:00
Anatol Belski
59926c2903 Fix method call 2018-07-25 17:27:51 +02:00
Anatol Belski
7d2b6cf86f MariaDB is not required 2018-07-25 17:24:35 +02:00
Anatol Belski
29d54c140e Add drupal, yet disabled 2018-07-25 17:17:31 +02:00
Anatol Belski
2ef8899939 Check also urls with appended query string 2018-07-25 15:21:17 +02:00
Anatol Belski
c259e440b6 Unblock Joomla training 2018-07-25 11:35:19 +02:00
Anatol Belski
5470b5ae58 Fix warning 2018-07-25 11:26:24 +02:00
Anatol Belski
795ac45864 Update Joomla URL 2018-07-25 11:00:06 +02:00
Anatol Belski
77408342bc Update version 2018-07-19 19:05:40 +02:00
Anatol Belski
f9aff35c14 Don't die hard if cleanup was failed.
For now at least. The core bug still needs to be fixed.
2018-07-12 12:12:27 +02:00
Anatol Belski
a827b2f18f Revert "Revert "Check return value""
This reverts commit 5352b3744a.
2018-07-12 10:38:00 +02:00
Anatol Belski
5352b3744a Revert "Check return value"
This reverts commit eb3904741a.
2018-07-11 19:13:54 +02:00
Anatol Belski
d816060d55 Make the random suffix shorter 2018-07-11 13:01:26 +02:00
Anatol Belski
da1e89d23a Append a unique string to the instance id 2018-07-11 11:49:47 +02:00
Anatol Belski
eb3904741a Check return value 2018-07-11 10:31:07 +02:00
Anatol Belski
6dc9fd3293 Update some versions 2018-07-09 19:22:15 +02:00
Anatol Belski
1d2dae619e Integrate file cache into the cache scenario 2018-07-09 19:21:46 +02:00
Anatol Belski
2a7f364792 Avoid terminating FCGI proceses after max requests
If a process is terminated before the data is dumped, it has two
consequences

- the data is possibly lost
- the shutdown sequence data are merged into db

Both cases are bad. Especially we don't want to optimize the shutdown
sequence as it is not relevant. Thus, let the processes run for a while,
get the training data dumped and then terminate those processes
manually.
2018-07-02 11:52:52 +02:00
Anatol Belski
36570ced8e Back to dev 2018-06-28 13:33:34 +02:00
Anatol Belski
7f75a93bdd Prepare 2.1.7beta1 2018-06-28 13:32:15 +02:00
Anatol Belski
44925fe946 It's a dev version 2018-06-28 12:51:50 +02:00
Anatol Belski
e8d07f824b Upgade README 2018-06-28 11:33:23 +02:00
Anatol Belski
a5426ba7bb Upgrade to bison 3.0.5 2018-06-28 11:15:39 +02:00
Anatol Belski
871816e56c Back to dev 2018-06-28 11:13:49 +02:00
Anatol Belski
70c3290c08 Prepare 2.1.6 2018-06-28 11:12:52 +02:00
Anatol Belski
d84784d37a Upgrade vswhere 2018-06-26 22:51:51 +02:00
Anatol Belski
8ad74abf3f Improve error handling for unknown cases 2018-05-11 17:05:39 +02:00
Anatol Belski
9ad145c154 Increase training runs number for symfony_demo_pdo_mysql 2018-05-11 14:11:37 +02:00
Anatol Belski
f3001d950e Fix option description 2018-05-11 13:45:33 +02:00
Anatol Belski
01ab6a1bad Add comment 2018-05-11 13:44:08 +02:00
Anatol Belski
659fb3a71d Produce a warning when unknown training case was requested 2018-05-11 13:31:02 +02:00
Anatol Belski
d7dcab4c2f Add comment 2018-05-11 12:35:42 +02:00
Anatol Belski
15ec0845c4 Allow selective training only with certain cases 2018-05-11 12:22:18 +02:00
Anatol Belski
a1bab3dc92 Back to dev 2018-05-09 11:23:46 +02:00
Anatol Belski
08b81a4ffc Prepare 2.1.5 2018-05-09 11:23:07 +02:00
Anatol Belski
569072060e Change the max runs values for perhaps colliding training scenarios 2018-05-04 14:46:42 +02:00
Anatol Belski
b13a2df162 Improve error handling for dependency path 2018-05-04 11:11:15 +02:00
Anatol Belski
96fa91e16a Back to dev 2018-05-02 14:16:19 +02:00
Anatol Belski
8ad971020a Prepare 2.1.4 2018-05-02 14:15:15 +02:00
Anatol Belski
386d36c251 Add Symfony training case with pdo_mysql 2018-04-04 15:32:46 +02:00
Anatol Belski
bd9c9ca4d8 Require pdo_mysql for pgo 2018-04-04 15:31:58 +02:00
Anatol Belski
1d6561c7d5 Add method to import an sql dump 2018-04-04 15:31:25 +02:00
Anatol Belski
307c5ed4bc Update fetch URLs for PGO servers 2018-04-04 12:40:18 +02:00
Anatol Belski
c6874e5109 Back to dev 2018-03-29 16:51:45 +02:00
Anatol Belski
c3cf4266ad Prepare 2.1.3 release 2018-03-29 16:50:36 +02:00
Anatol Belski
01e4fff84a Upgrade vswhere 2018-03-28 18:11:39 +02:00
Anatol Belski
4357adc956 Back to dev 2018-03-21 13:12:34 +01:00
Anatol Belski
0a33374aed Prepare 2.1.3beta1 2018-03-21 13:09:49 +01:00
Anatol Belski
ff16eebfce Update CA certs 2018-03-19 14:49:18 +01:00
Anatol Belski
afc302d27e Upgrade MSYS2 tools at once 2018-03-19 14:46:33 +01:00
Anatol Belski
e6c79ecad5 Update README 2018-03-19 13:03:44 +01:00
Anatol Belski
80dc35f668 Upgrade re2c 2018-03-19 13:03:22 +01:00
Anatol Belski
bd3e1603a9 Upgrade bundled PHP 2018-03-19 12:51:23 +01:00
Anatol Belski
8505dda9c4 Back to dev 2018-03-14 11:53:39 +01:00
Anatol Belski
b15cdb1f92 Prepare 2.1.2 2018-03-14 11:53:04 +01:00
Anatol Belski
91302e8142 Use SSL explicitly for communitation with windows.php.net 2018-03-12 14:03:00 +01:00
Anatol Belski
f655bcf7d1 Upgrade vswhere 2018-03-12 11:22:11 +01:00
Alexander Gabriel
89bc6e0eb8 Using PHP-X.Y would not work. 2018-03-05 11:29:18 +01:00
Anatol Belski
4d9b189d04 Increase version for dev 2018-02-20 15:33:05 +01:00
173 changed files with 11551 additions and 4244 deletions

View File

@@ -12,8 +12,8 @@ The PHP SDK 2.0+ is compatible with PHP 7.0 and above. The compatibility with [o
# 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
- `Visual C++ 2015` or `Visual C++ 2017` must be installed prior SDK usage (be sure to install both the C++ and the Windows SDK components)
- if `Cygwin`, `MingW` or any other cross solution 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
- The PHP SDK was successfully tested on Windows 7 or later, earlier versions might work but are not recommended
@@ -33,7 +33,7 @@ All the tools included are either scripts or 32-bit binaries. They are therefore
## Other tools
- `bison` 3.0.4, `re2c` 1.0.2, `lemon`
- `bison` 3.2.4, `re2c` 1.1.1, `lemon`
- `awk`, `gawk`, `sed`, `grep`
- `diff`, `diff3`, `patch`
- `md5sum`, `sha1sum`, `sha224sum`, `sha256sum`, `sha384sum`, `sha512sum`
@@ -62,11 +62,11 @@ It is not required to hold the source in the PHP SDK directory. It could be usef
- `git clone https://github.com/Microsoft/php-sdk-binary-tools.git c:\php-sdk`
- `cd c:\php-sdk`
- `git checkout php-sdk-2.0.12` or later
- `git checkout php-sdk-2.1.9` or later
- invoke `phpsdk-vc15-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`, use PHP-X.Y for a non master branch
- `phpsdk_deps --update --branch master`, use `phpsdk_deps --update --branch X.Y` for a non master branch
- do the build, eg. `buildconf && configure --enable-cli && nmake`
More extensive documentation can be found on the [wiki](https://wiki.php.net/internals/windows/stepbystepbuild_sdk_2 "PHP wiki page").
@@ -138,6 +138,51 @@ After a training case is implemented and put under `pgo/cases`, the work environ
To skip a training case, add a file named `inactive` into the case folder.
# Debugging PHP
This part covers debugging possibilities for the builds produced by the native VS compilers.
For the cross compiled builds produced with toolsets other than VC++, please check the
documentation for the corresponding toolsets. In any case, general principles on debugging
native programs apply.
Either a debug build of PHP or enabled debug symbols are required to be able to debug PHP.
A debug build is usually more suitable for the development process and can be produced by
adding `--enable-debug` to the configure options. A release build with debug symbols can
be produced by adding `--enable-debug-pack`. These options are mutually exclusive.
## Debugging with Visual Studio
- Configure with either `--enable-debug` or `--enable-debug-pack`.
- A debug build might bring better experience for dev, but sometimes you want to debug a release build.
- `nmake run ARGS=yourscript.php DEBUGGER=1`, that will open a Visual Studio window.
- Any additional runtime options for PHP or the script executed go to ARGS, too.
- Select `Debug -> New Breakpoint -> Function Breakpoint` and add a function where the debugger should break.
- Click `Start`.
Adding a breakpoint before starting debugging might be not necessary, if a crash is debugged. When such a script runs
under the debugger, the debugger will stop at the crashing point. In that case, a breakpoint can be added
around the crashed code directly.
## Debugging test suite with Visual Studio
The [Microsoft Child Process Debugging Power Tool](https://marketplace.visualstudio.com/items?itemName=vsdbgplat.MicrosoftChildProcessDebuggingPowerTool)
plugin for Visual Studio is required. After installing it, following these steps
- `nmake test TESTS=ext/myext/tests/sometest.phpt DEBUGGER=1`
- Select `Debug -> Other Debug Targets -> Child Process Debugging Settings` and enable child process debugging.
- If necessary, add a breakpoint and start debugging as described in the previous section.
## Debugging with WinDbg
PHP can also be debugged with the tools from the WinDbg package. There is currently no way
implemented in the Makefile to start the WinDbg integrated, so it needs to de done manually.
Either a debug build or a release build with debug symbols is still required, as described
previously.
# Support
- Join `#winphp-dev` on Freenode to discuss any ideas or questions
- File an issue on GitHub
# Pitfalls
@@ -150,5 +195,6 @@ To skip a training case, add a file named `inactive` into the case folder.
- The VC++ toolset is still requried, even if another compiler, fe. clang, is intended to be used.
- `task.exe` is not a console application, some systems might not propagate exit code except the batch is explicitly run from `cmd /c`, etc.
- `7za` should be prefered over `unzip` and `zip` for compatibility reasons.
- If you experince some strange crashes on MSYS2 tools, try the phpsdk_rebase_msys2 tool. MSYS2 tools might be have unstable
on ASLR enabled systems.

View File

@@ -1 +1 @@
2.1.1
2.1.10

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.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -1,6 +1,6 @@
<?php
include dirname(__FILE__) . "/../lib/php/autoload.php";
include __DIR__ . "/../lib/php/autoload.php";
use SDK\{Config, Exception};
@@ -36,7 +36,7 @@ try {
switch ($name) {
default:
throw new Exception("Unknown switch '$name'");
break;
break;
case "h":
case "help":

View File

@@ -29,10 +29,10 @@ $flags = 0;
$opt = getopt($sopt, $lopt);
foreach ($opt as $name => $val) {
switch ($name) {
case "p":
case "pretty":
$flags = JSON_PRETTY_PRINT;
break;
case "p":
case "pretty":
$flags = JSON_PRETTY_PRINT;
break;
}
}
@@ -85,16 +85,16 @@ foreach ($dirs as $path) {
$dlls = array();
for( $i = 0; $i < $zip->numFiles; $i++ ){
$stat = $zip->statIndex( $i );
for ($i = 0; $i < $zip->numFiles; $i++) {
$stat = $zip->statIndex($i);
if (substr($stat['name'], -3) != "dll") {
continue;
}
$dlls[] = basename($stat['name']);
}
$zip->close();
unset($zip);

View File

@@ -1,13 +1,13 @@
<?php
include dirname(__FILE__) . "/../lib/php/autoload.php";
include __DIR__ . "/../lib/php/autoload.php";
use SDK\Config;
use SDK\Exception;
use SDK\Build\PGO\Controller;
$sopt = "itudhs:fr";
$lopt = array("init", "train", "up", "down", "help", "scenario:", "force", "ready");
$sopt = "itudhs:frc:";
$lopt = array("init", "train", "up", "down", "help", "scenario:", "force", "ready", "cases:");
$cmd = NULL;
/* TODO For now we simply check the current php build, this could be extended to take arbitrary binaries. */
@@ -15,42 +15,48 @@ $deps_root = NULL;
$php_root = NULL;
$scenario = NULL;
$force = false;
$cases = NULL;
try {
$opt = getopt($sopt, $lopt);
foreach ($opt as $name => $val) {
switch ($name) {
case "i":
case "init":
$cmd = "init";
break;
case "ready":
$cmd = "check_init";
break;
case "t":
case "train":
$cmd = "train";
break;
case "u":
case "up":
$cmd = "up";
break;
case "d":
case "down":
$cmd = "down";
break;
case "s":
case "scenario":
$scenario = $val;
break;
case "f":
case "force":
$force = true;
break;
case "h": case "help":
usage(0);
break;
case "i":
case "init":
$cmd = "init";
break;
case "ready":
$cmd = "check_init";
break;
case "t":
case "train":
$cmd = "train";
break;
case "u":
case "up":
$cmd = "up";
break;
case "d":
case "down":
$cmd = "down";
break;
case "s":
case "scenario":
$scenario = $val;
break;
case "f":
case "force":
$force = true;
break;
/* XXX This option is for now only integrated for training. It
would make sense to integrate it also with init. */
case "c":
case "cases":
$cases = explode(",", $val);
break;
case "h": case "help":
usage(0);
break;
}
}
@@ -73,7 +79,7 @@ try {
}
}
$controller = new Controller($cmd, $scenario);
$controller = new Controller($cmd, $scenario, $cases);
$controller->handle($force);
if ("check_init" == $cmd) {
@@ -105,6 +111,7 @@ function usage(int $code = -1)
echo " -d --down Shutdown training environment.", PHP_EOL;
echo " -f --force Force requested operation. Not every option can be forced.", PHP_EOL;
echo " -s --scenario Run training with a specified scenario.", PHP_EOL;
echo " -c --cases Run training with specified cases only. If omited, all the active cases will be used.", PHP_EOL;
/*echo " -p --php-root PHP binary to train.", PHP_EOL;*/

View File

@@ -0,0 +1,40 @@
@echo off
setlocal enableextensions enabledelayedexpansion
set PHPSDK_MSYS2_BASE_ADDR=0x70000000
set PHPSDK_MSYS2_BASE_DYNAMIC=0
:getopt
if /i "%1" equ "--help" goto help
if /i "%1" equ "--addr" (
set PHPSDK_MSYS2_BASE_ADDR=%2 & shift
for /l %%a in (1,1,100) do if "!PHPSDK_MSYS2_BASE_ADDR:~-1!"==" " set PHPSDK_MSYS2_BASE_ADDR=!PHPSDK_MSYS2_BASE_ADDR:~0,-1!
)
shift
if /i "%1" equ "--dynamic" (
set PHPSDK_MSYS2_BASE_DYNAMIC=1
shift
)
if not (%1)==() goto getopt
IF "1" EQU "%PHPSDK_MSYS2_BASE_DYNAMIC%" (
echo Rebasing MSYS2 DLLs to load at a dynamic address
editbin /NOLOGO /DYNAMICBASE %PHP_SDK_ROOT_PATH%\msys2\usr\bin\*.dll
) else (
echo Rebasing MSYS2 DLLs to load at %PHPSDK_MSYS2_BASE_ADDR%
editbin /NOLOGO /REBASE:BASE=%PHPSDK_MSYS2_BASE_ADDR%,DOWN %PHP_SDK_ROOT_PATH%\msys2\usr\bin\*.dll
)
set PHPSDK_MSYS2_BASE_ADDR=
set PHPSDK_MSYS2_BASE_DYNAMIC=
GOTO EXIT
:help
echo phpsdk_rebase_msys2 ^<address^>
echo Rebase MSYS2 DLLs to the given address. If ommited, default is 0x70000000.
:EXIT
exit /b %errorlevel%

BIN
bin/sqlite3.exe Normal file

Binary file not shown.

Binary file not shown.

View File

@@ -1,72 +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;
}
/**
* 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

@@ -1,7 +1,7 @@
<?php
spl_autoload_register(function($name) {
$fl = dirname(__FILE__) . DIRECTORY_SEPARATOR . "libsdk" . DIRECTORY_SEPARATOR . $name . ".php";
$fl = __DIR__ . DIRECTORY_SEPARATOR . "libsdk" . DIRECTORY_SEPARATOR . $name . ".php";
if (file_exists($fl)) {
require_once $fl;

View File

@@ -2,7 +2,7 @@
namespace SDK\Build\Dependency;
use SDK\{Config, Exception, FileOps};
use SDK\{Exception, FileOps};
class Fetcher
{
@@ -13,14 +13,17 @@ class Fetcher
protected $stability;
protected $arch;
protected $series;
protected $scheme;
public function __construct(string $host, int $port, string $arch = NULL, string $stability = NULL, Series $series = NULL)
public function __construct(string $host, int $port, string $scheme = "https", string $arch = NULL, string $stability = NULL, Series $series = NULL)
{/*{{{*/
$this->stability = $stability;
$this->arch = $arch;
$this->host = $host;
$this->port = $port;
$this->scheme = $scheme;
$this->series = $series;
}/*}}}*/
public function getSeries() : Series
@@ -37,7 +40,7 @@ class Fetcher
/* TODO implement indicator. */
public function getByUri(string $uri, int $retries = 3) : string
{/*{{{*/
$url = "http://{$this->host}:{$this->port}$uri";
$url = "{$this->scheme}://{$this->host}:{$this->port}$uri";
$ret = false;
retry:

View File

@@ -11,6 +11,7 @@ class Manager
protected $stability;
protected $arch;
protected $path;
protected $cache;
protected $series;
protected $fetcher;
protected $updatesFlag = NULL;
@@ -24,7 +25,8 @@ class Manager
$host = Config::getDepsHost();
$port = Config::getDepsPort();
$fetcher = new Fetcher($host, $port, $this->arch, $this->stability);
$scheme = Config::getDepsUriScheme();
$fetcher = new Fetcher($host, $port, $scheme, $this->arch, $this->stability);
$series = new Series($this->stability, $this->arch, $this->cache, NULL);
$fetcher->setSeries($series);
$series->setFetcher($fetcher);
@@ -40,7 +42,7 @@ class Manager
public function updatesAvailable() : bool
{/*{{{*/
if (!is_null($this->updatesFlag)) {
if (NULL !== $this->updatesFlag) {
return $this->updatesFlag;
}

View File

@@ -44,7 +44,6 @@ class Series
public function getName() : string
{/*{{{*/
$base = Config::getDepsBaseUri();
$branch_data = Config::getCurrentBranchData();
$file = "packages-" . Config::getCurrentBranchName() . "-{$branch_data['crt']}-{$this->arch}-{$this->stability}.txt";

View File

@@ -2,15 +2,17 @@
namespace SDK\Build\PGO\Abstracts;
use SDK\Build\PGO\Interfaces\Server;
use SDK\Build\PGO\PHP\CLI;
use SDK\Build\PGO\Config as PGOConfig;
use SDK\{Config as SDKConfig, Exception, FileOps};
use SDK\{Config as SDKConfig, Exception};
abstract class PHP
{
protected $php_root;
protected $php_ext_root;
protected $opcache_file_cache;
protected $id;
protected $scenario;
protected $conf;
protected function setupPaths()
{
@@ -23,6 +25,9 @@ abstract class PHP
} else {
$this->php_ext_root = $this->php_root;
}
if ("cache" == $this->scenario) {
$this->opcache_file_cache = SDKConfig::getTmpDir() . DIRECTORY_SEPARATOR . $this->id;
}
}
/* TODO Might be improved. */
@@ -39,12 +44,22 @@ abstract class PHP
$deps_root = SDKConfig::getDepsLocalPath();
foreach ($env as $k => $v) {
if (strtoupper($k) == "PATH") {
$env[$k] = "$deps_root" . DIRECTORY_SEPARATOR . "bin;" . $env[$k];
$env[$k] = $deps_root . DIRECTORY_SEPARATOR . "bin;" . $env[$k];
break;
}
}
}
$drive = getenv("HOMEDRIVE");
$path = getenv("HOMEPATH");
if (!$drive || !$path) {
$p = SDKConfig::getTmpDir();
$drive = substr($p, 0, 2);
$path = substr($p, 2);
putenv("HOMEDRIVE=$drive");
putenv("HOMEPATH=$path");
}
return $env;
}
@@ -95,7 +110,7 @@ abstract class PHP
}
}
if (is_null($ret)) {
if (NULL === $ret) {
throw new Exception("Failed to determine the test PHP version.");
}
@@ -147,6 +162,11 @@ abstract class PHP
}
}
/* Special handling, otherwise it'll need functionality to extrapolate ini values. */
if ("cache" == $this->scenario) {
$tpl_vars[$this->conf->buildTplVarName("php", "opcache", "file_cache")] = $this->opcache_file_cache;
}
$this->conf->processTplFile(
$this->getIniTplFilename(),
$ret,
@@ -174,8 +194,8 @@ abstract class PHP
public function exec(string $php_cmd, string $args = NULL, array $extra_env = array()) : int
{
$env = $this->createEnv();
$exe = $this->getExeFilename();
$ini = $this->getIniFilename();
$exe = $this->getExeFilename();
$ini = $this->getIniFilename();
$cert_path = getenv("PHP_SDK_ROOT_PATH") . "\\msys2\\usr\\ssl\\cert.pem";
$ini .= " -d curl.cainfo=$cert_path";
@@ -203,7 +223,7 @@ abstract class PHP
$env[$k] = $v;
}
$cmd = "$exe -n -c $ini " . ($args ? "$args " : "") . "$php_cmd";
$cmd = "$exe -n -c $ini " . ($args ? "$args " : "") . $php_cmd;
$desc = array(
0 => array("file", "php://stdin", "r"),
@@ -214,5 +234,13 @@ abstract class PHP
return proc_close($p);
}
}
public function getIdString(): string
{
return $this->getVersion() . "-"
. SDKConfig::getCurrentCrtName() . "-"
. ($this->isThreadSafe() ? "ts" : "nts") . "-"
. ($this->is64bit() ? "x64" : "x86")
. "-" . substr(md5(uniqid()), 0, 8);
}
}

View File

@@ -4,7 +4,7 @@ namespace SDK\Build\PGO\Abstracts;
use SDK\Build\PGO\Interfaces;
class Server
abstract class Server
{
public function getName() : string
{
@@ -17,6 +17,3 @@ class Server
}
}

View File

@@ -2,11 +2,10 @@
namespace SDK\Build\PGO\Abstracts;
use SDK\Build\PGO\Config as PGOConfig;
use SDK\{Config as SDKConfig, Exception, FileOps};
use SDK\FileOps;
use SDK\Build\PGO\Tool;
class TrainingCase
abstract class TrainingCase
{
use FileOps;
@@ -14,6 +13,8 @@ class TrainingCase
const TYPE_CLI = "cli";
protected $stat = array();
/** @var \SDK\Build\PGO\Config */
protected $conf;
public function getType() : string
{
@@ -148,4 +149,3 @@ class TrainingCase
return $ret;
}
}

View File

@@ -2,7 +2,7 @@
namespace SDK\Build\PGO;
use SDK\{Config as SDKConfig, Exception};
use SDK\Exception;
class Config
{
@@ -18,7 +18,7 @@ class Config
protected $tpl_vars = array();
protected $srv = array();
public function __construct(int $mode = MODE_RUN)
public function __construct(int $mode = self::MODE_RUN)
{
if (self::MODE_CHECK_INIT == $mode) {
// XXX The check is simple right now, so this is sufficient.
@@ -40,7 +40,6 @@ class Config
$this->mode = $mode;
$base = getenv("PHP_SDK_ROOT_PATH");
if (self::MODE_INIT == $mode) {
foreach (array("nginx", "mariadb", "postgresql", "php") as $i) {
$this->importSectionFromDir($i, $this->getTplDir() . DIRECTORY_SEPARATOR . $i);
@@ -279,7 +278,7 @@ class Config
public function processTplFile(string $tpl_fn, string $dst_fn, array $additional_vars = array()) : void
{
if (!file_exists($tpl_fn)) {
throw new Exception("Template file '$fn' doesn't exist.");
throw new Exception("Template file '$tpl_fn' doesn't exist.");
}
$s = file_get_contents($tpl_fn);
@@ -368,4 +367,3 @@ class Config
return $ret;
}
}

View File

@@ -2,13 +2,12 @@
namespace SDK\Build\PGO;
use SDK\{Config as SDKConfig, Exception, Lock};
use SDK\{Exception, Lock};
use SDK\Build\PGO\Config as PGOConfig;
use SDK\Build\PGO\Server\{MariaDB, NGINX, PostgreSQL};
use SDK\Build\PGO\PHP;
use SDK\Build\PGO\Tool\{PGO, PackageWorkman};
use SDK\Build\PGO\Interfaces\TrainingCase;
use SDK\Build\PGO\TrainingCaseIterator;
/* TODO add bench action */
@@ -17,8 +16,9 @@ class Controller
protected $cmd;
protected $scenario;
protected $conf;
protected $cases;
public function __construct(string $cmd, ?string $scenario)
public function __construct(string $cmd, ?string $scenario, ?array $cases)
{
$this->cmd = $cmd;
@@ -26,6 +26,7 @@ class Controller
$scenario = "default";
}
$this->scenario = $scenario;
$this->cases = $cases;
}
protected function vitalizeSrv()
@@ -77,38 +78,38 @@ class Controller
$this->conf = $this->setupConfig($this->cmd);
switch ($this->cmd) {
default:
throw new Exception("Unknown action '{$this->cmd}'.");
break;
case "init":
$lk = new Lock("pgo_init");
if (!$lk->locked()) {
echo "Another process runs initialization right now, waiting.", PHP_EOL;
$lk->exclusive(true);
echo "Another process finished running initialization, I quit as well.", PHP_EOL;
return;
}
$this->init($force);
break;
case "train":
$lk = new Lock("pgo_train");
if (!$lk->locked()) {
echo "Another process runs training right now, I have to wait.", PHP_EOL;
$lk->exclusive(true);
echo "Another process finished training, I may continue.", PHP_EOL;
}
$this->train();
break;
case "up":
$this->up();
break;
default:
throw new Exception("Unknown action '{$this->cmd}'.");
break;
case "init":
$lk = new Lock("pgo_init");
if (!$lk->locked()) {
echo "Another process runs initialization right now, waiting.", PHP_EOL;
$lk->exclusive(true);
echo "Another process finished running initialization, I quit as well.", PHP_EOL;
return;
}
$this->init($force);
break;
case "train":
$lk = new Lock("pgo_train");
if (!$lk->locked()) {
echo "Another process runs training right now, I have to wait.", PHP_EOL;
$lk->exclusive(true);
echo "Another process finished training, I may continue.", PHP_EOL;
}
$this->train();
break;
case "up":
$this->up();
break;
case "down":
$this->down($force);
break;
case "check_init":
// pass
break;
case "down":
$this->down($force);
break;
case "check_init":
// pass
break;
}
}
@@ -139,6 +140,7 @@ class Controller
if (!file_exists($composer) || $force) {
/* XXX this needs to go into the config, specifically for composer maybe even separate class. */
$url = "https://getcomposer.org/installer";
/* XXX remove the explicit version option when symfony demo is fixed. */
$tool = $this->conf->getToolsDir() . DIRECTORY_SEPARATOR . "composer-setup.php";
$pw->fetch($url, $tool, $force);
$php->exec("$tool --install-dir=" . $this->conf->getToolsDir());
@@ -204,10 +206,24 @@ class Controller
$pgo->clean();
unset($pgo);
$cases = $this->cases;
foreach (new TrainingCaseIterator($this->conf) as $handler) {
$name = $handler->getName();
/* Just a white list handling for now. */
if (is_array($cases)) {
if (!in_array($name, $cases)) {
continue;
}
$key = array_search($name, $cases);
unset($cases[$key]);
}
echo "\n";
$handler->run();
}
if (is_array($cases) && !empty($cases)) {
echo "\n\033[31m WARNING: The cases " . implode(",", $cases) . " don't exist and was ignored!\033[0m\n\n";
}
/* All the PGC files are merged, simply clean them out. */
$pgo = new PGO($this->conf, $php);

View File

@@ -2,7 +2,6 @@
namespace SDK\Build\PGO\Interfaces;
use SDK\Build\PGO\Config;
use SDK\Build\PGO\Tool\PackageWorkman;
interface PHP
@@ -15,4 +14,3 @@ interface PHP
public function getVersion(bool $short = false) : string;
public function getExeFilename() : string;
}

View File

@@ -2,7 +2,6 @@
namespace SDK\Build\PGO\Interfaces;
use SDK\Build\PGO\Config;
use SDK\Build\PGO\Tool\PackageWorkman;
interface Server
@@ -14,4 +13,3 @@ interface Server
public function down(bool $force = false) : void;
public function getName() : string;
}

View File

@@ -10,4 +10,3 @@ interface DB extends Interfaces\Server
public function __construct(Config $conf);
public function query(string $s, string $db = NULL) : void;
}

View File

@@ -11,4 +11,3 @@ interface HTTP extends Interfaces\Server
public function getPhp() : Interfaces\PHP;
public function addServer(string $part_tpl_fn, array $tpl_vars = array());
}

View File

@@ -25,4 +25,3 @@ interface TrainingCase
/* Get training type, it's like "web", "cli", etc.*/
public function getType() : string;
}

View File

@@ -5,17 +5,19 @@ namespace SDK\Build\PGO\PHP;
use SDK\Build\PGO\Interfaces;
use SDK\Build\PGO\Abstracts;
use SDK\Build\PGO\Config as PGOConfig;
use SDK\{Config as SDKConfig, Exception, FileOps};
use SDK\{Exception};
use SDK\Build\PGO\Tool\PackageWorkman;
class CLI extends Abstracts\PHP implements Interfaces\PHP
{
protected $conf;
public function __construct(PGOConfig $conf)
{
$this->conf = $conf;
$this->scenario = $conf->getScenario();
// Don't do that, it'll be a recursive dependency.
// Once we need to train CLI, we'll need to split
// a new class, this one is a utility class.
//$this->id = $this->getIdString();
$this->setupPaths();
}
@@ -50,7 +52,4 @@ class CLI extends Abstracts\PHP implements Interfaces\PHP
return $exe;
}
}

View File

@@ -5,12 +5,13 @@ namespace SDK\Build\PGO\PHP;
use SDK\Build\PGO\Interfaces;
use SDK\Build\PGO\Abstracts;
use SDK\Build\PGO\Config as PGOConfig;
use SDK\{Config as SDKConfig, Exception, FileOps};
use SDK\{Exception, FileOps};
use SDK\Build\PGO\Tool\PackageWorkman;
class FCGI extends Abstracts\PHP implements Interfaces\PHP
{
protected $conf;
use FileOps;
protected $is_tcp;
public function __construct(PGOConfig $conf, bool $is_tcp)
@@ -22,6 +23,7 @@ class FCGI extends Abstracts\PHP implements Interfaces\PHP
$this->conf = $conf;
$this->is_tcp = $is_tcp;
$this->scenario = $conf->getScenario();
$this->id = $this->getIdString();
$this->setupPaths();
}
@@ -64,6 +66,15 @@ echo "PHP FCGI initialization done.\n";*/
{
echo "Starting PHP FCGI.\n";
if ("cache" == $this->scenario) {
if (file_exists($this->opcache_file_cache)) {
$this->rm($this->opcache_file_cache);
}
if (!mkdir($this->opcache_file_cache)) {
throw new Exception("Failed to create '{$this->opcache_file_cache}'");
}
}
$exe = $this->getExeFilename();
$ini = $this->getIniFilename();
$host = $this->conf->getSectionItem("php", "fcgi", "host");
@@ -82,6 +93,10 @@ echo "PHP FCGI initialization done.\n";*/
/* Give some time, it might be slow on PGI enabled proc. */
sleep(3);
/*while(false !== ($s = fread($pipes[2], 1024))) {
echo "$s";
}*/
$c = proc_close($p);
if ($c) {
@@ -99,7 +114,15 @@ echo "PHP FCGI initialization done.\n";*/
exec("taskkill /f /im php-cgi.exe >nul 2>&1");
/* XXX Add cleanup interface. */
if ("cache" == $this->scenario) {
try {
$this->rm($this->opcache_file_cache);
} catch (\UnexpectedValueException $e) {
echo $e->getMessage(), "\n";
}
}
echo "PHP FCGI stopped.\n";
}
}

View File

@@ -5,7 +5,7 @@ namespace SDK\Build\PGO\Server;
use SDK\Build\PGO\Interfaces\Server\DB;
use SDK\Build\PGO\Abstracts\Server;
use SDK\Build\PGO\Config as PGOConfig;
use SDK\{Config as SDKConfig, Exception, FileOps};
use SDK\{Exception, FileOps};
use SDK\Build\PGO\Tool\PackageWorkman;
class MariaDB extends Server implements DB
@@ -114,10 +114,30 @@ class MariaDB extends Server implements DB
$port = $this->conf->getSectionItem($this->name, "port");
$pass_arg = $pass ? "-p$pass " : "";
$ret = shell_exec(".\\bin\\mysql.exe -u $user $pass_arg -h $host -P $port -e \"$s\"");
$db_arg = $db ? "-D $db" : "";
shell_exec(".\\bin\\mysql.exe -u $user $pass_arg -h $host -P $port $db_arg -e \"$s\"");
//var_dump($this->base, getcwd(), ".\\bin\\mysql.exe -u $user $pass_arg -h $host -P $port -e \"$s\"");
chdir($cwd);
}
}
public function import(string $path, string $db = NULL) : void
{
$ret = NULL;
$cwd = getcwd();
chdir($this->base);
$user = $this->conf->getSectionItem($this->name, "user");
$pass = $this->conf->getSectionItem($this->name, "pass");
$host = $this->conf->getSectionItem($this->name, "host");
$port = $this->conf->getSectionItem($this->name, "port");
$pass_arg = $pass ? "-p$pass " : "";
$db_arg = $db ? "-D $db" : "";
shell_exec(".\\bin\\mysql.exe -u $user $pass_arg -h $host -P $port $db_arg < \"$path\"");
chdir($cwd);
}
}

View File

@@ -5,7 +5,7 @@ namespace SDK\Build\PGO\Server;
use SDK\Build\PGO\Interfaces;
use SDK\Build\PGO\Abstracts;
use SDK\Build\PGO\{Config as PGOConfig};
use SDK\{Config as SDKConfig, Exception, FileOps};
use SDK\{Exception, FileOps};
use SDK\Build\PGO\Tool\PackageWorkman;
class NGINX extends Abstracts\Server implements Interfaces\Server\HTTP
@@ -29,7 +29,6 @@ class NGINX extends Abstracts\Server implements Interfaces\Server\HTTP
$nginx_conf_in = $this->conf->getTplDir($this->name) . DIRECTORY_SEPARATOR . "nginx.conf";
$conf_fn = $this->base . DIRECTORY_SEPARATOR . "conf" . DIRECTORY_SEPARATOR . "nginx.conf";
$vars = array();
$port = $this->conf->getSectionItem($this->name, "port");
if (!$port) {
$port = $this->conf->getNextPort();
@@ -148,4 +147,3 @@ class NGINX extends Abstracts\Server implements Interfaces\Server\HTTP
}
}
}

View File

@@ -5,7 +5,7 @@ namespace SDK\Build\PGO\Server;
use SDK\Build\PGO\Interfaces\Server\DB;
use SDK\Build\PGO\Abstracts\Server;
use SDK\Build\PGO\Config as PGOConfig;
use SDK\{Config as SDKConfig, Exception, FileOps};
use SDK\{Exception, FileOps};
use SDK\Build\PGO\Tool\PackageWorkman;
class PostgreSQL extends Server implements DB
@@ -90,10 +90,6 @@ class PostgreSQL extends Server implements DB
echo "Stopping " . $this->name . ".\n";
$user = $this->conf->getSectionItem($this->name, "user");
$pass = $this->conf->getSectionItem($this->name, "pass");
$cmd = $this->base . DIRECTORY_SEPARATOR . "bin" . DIRECTORY_SEPARATOR . "pg_ctl.exe stop -D " . $this->data_dir . " -m fast";
exec($cmd);
@@ -108,7 +104,6 @@ class PostgreSQL extends Server implements DB
public function createDb(string $db_name) : void
{
$user = $this->conf->getSectionItem($this->name, "user");
$pass = $this->conf->getSectionItem($this->name, "pass");
$host = $this->conf->getSectionItem($this->name, "host");
$port = $this->conf->getSectionItem($this->name, "port");
@@ -119,7 +114,6 @@ class PostgreSQL extends Server implements DB
public function dropDb(string $db_name) : void
{
$user = $this->conf->getSectionItem($this->name, "user");
//$pass = $this->conf->getSectionItem($this->name, "pass");
$host = $this->conf->getSectionItem($this->name, "host");
$port = $this->conf->getSectionItem($this->name, "port");
@@ -132,13 +126,11 @@ class PostgreSQL extends Server implements DB
$ret = NULL;
$user = $this->conf->getSectionItem($this->name, "user");
//$pass = $this->conf->getSectionItem($this->name, "pass");
$host = $this->conf->getSectionItem($this->name, "host");
$port = $this->conf->getSectionItem($this->name, "port");
$db_arg = $db ? "-d $db" : "";
$cmd = $this->base . DIRECTORY_SEPARATOR . "bin" . DIRECTORY_SEPARATOR . "psql.exe -h $host -p $port -U $user $db_arg -c \"$s\"";
$ret = shell_exec($cmd);
shell_exec($cmd);
}
}

View File

@@ -2,7 +2,7 @@
namespace SDK\Build\PGO\Tool;
use SDK\{Config as SDKConfig, Exception};
use SDK\Exception;
use SDK\Build\PGO\Config as PGOConfig;
use SDK\Build\PGO\Interfaces;
@@ -63,11 +63,11 @@ class PGO
$pgc = $this->getPgcName($base);
$pgd = $this->getPgdName($base);
`pgosweep $base $pgc`;
shell_exec("pgosweep $base $pgc");
//passthru("pgosweep $base $pgc");
if ($merge) {
`pgomgr /merge:1000 $pgc $pgd`;
shell_exec("pgomgr /merge:1000 $pgc $pgd");
//passthru("pgomgr /merge:1000 $pgc $pgd");
/* File is already spent, no need to keep it.
If seeing linker warnings about no pgc
@@ -98,10 +98,9 @@ class PGO
$its = glob($this->php->getRootDir() . DIRECTORY_SEPARATOR . "*.pgd");
$its = array_merge($its, glob($this->php->getExtRootDir() . DIRECTORY_SEPARATOR . "*" . DIRECTORY_SEPARATOR . "*.pgd"));
foreach (array_unique($its) as $pgd) {
`pgomgr /clear $pgd`;
shell_exec("pgomgr /clear $pgd");
//passthru("pgomgr /clear $pgd");
}
}
}
}

View File

@@ -2,7 +2,7 @@
namespace SDK\Build\PGO\Tool;
use SDK\{Config as SDKConfig, Exception, FileOps};
use SDK\{Exception, FileOps};
use SDK\Build\PGO\Config as PGOConfig;
@@ -47,11 +47,10 @@ class PackageWorkman
echo "Unpacking '$cache_fn' to '$tgt_name'\n";
try {
$this->unzip($cache_fn, $zip_tgt_dn, $tgt_bn);
} catch (Throwable $e) {
} catch (\Throwable $e) {
$this->rm($cache_fn);
throw $e;
}
}
}
}

View File

@@ -4,7 +4,7 @@ namespace SDK\Build\PGO\Tool;
use SDK\{Config as SDKConfig, Exception};
use SDK\Build\PGO\Config as PGOConfig;
use SDK\Build\PGO\Interfaces\{TrainingCase, Server, Server\DB, PHP};
use SDK\Build\PGO\Interfaces\TrainingCase;
class Training
{
@@ -15,8 +15,9 @@ class Training
{
$this->conf = $conf;
$this->t_case = $t_case;
if (!in_array($this->t_case->getType(), array("web", "cli"))) {
$type = $this->t_case->getType();
if (!in_array($type, array("web", "cli"))) {
throw new Exception("Unknown training type '$type'.");
}
}
@@ -107,8 +108,7 @@ class Training
public function run(int $max_runs = 1, ?array &$stat = array()) : void
{
$type = $this->t_case->getType();
switch ($type)
{
switch ($type) {
case "web":
$this->runWeb($max_runs, $stat);
break;

View File

@@ -2,7 +2,6 @@
namespace SDK\Build\PGO;
use SDK\{Config as SDKConfig, Exception, FileOps};
use SDK\Build\PGO\Config as PGOConfig;
@@ -21,7 +20,7 @@ class TrainingCaseIterator implements \Iterator
$items = glob($this->conf->getCasesTplDir() . DIRECTORY_SEPARATOR . "*");
foreach ($items as $it) {
if(!is_dir($it)) {
if (!is_dir($it)) {
continue;
}
@@ -53,7 +52,7 @@ class TrainingCaseIterator implements \Iterator
public function current()
{
$base = $this->items[$this->idx];
$base = $this->items[$this->idx];
$ns = basename($base);
/* Don't overwrite generated config. */
@@ -97,6 +96,4 @@ class TrainingCaseIterator implements \Iterator
return $this->el->getName();
}
}

View File

@@ -2,10 +2,6 @@
namespace SDK;
use SDK\Config;
use SDK\Cache;
use SDK\Exception;
class Cache
{
protected $id;
@@ -48,7 +44,7 @@ class Cache
$old_sum = md5_file($p);
$new_sum = md5($content);
return $old_sum != $new_sum;
return $old_sum !== $new_sum;
}/*}}}*/
public function cacheContent(string $path, string $content, bool $relative = false) : void
@@ -64,7 +60,7 @@ class Cache
do {
$got = fwrite($fd, substr($content, $wrote));
if (false == $got) {
if (false === $got) {
break;
}
$wrote += $got;

View File

@@ -3,14 +3,13 @@
namespace SDK;
use SDK\Build\Dependency\Fetcher;
use SDK\Cache;
use SDK\Exception;
class Config
{
/* Config variables. */
protected static $depsHost = 'windows.php.net';
protected static $depsPort = 80;
protected static $depsPort = 443;
protected static $depsUriScheme = "https";
protected static $depsBaseUri = "/downloads/php-sdk/deps";
/* protected static $sdkNugetFeedUrl = "http://127.0.0.1/sdk/nuget"; */
@@ -34,6 +33,11 @@ class Config
return self::$depsPort;
}/*}}}*/
public static function getDepsUriScheme() : string
{/*{{{*/
return self::$depsUriScheme;
}/*}}}*/
public static function getDepsBaseUri() : string
{/*{{{*/
return self::$depsBaseUri;
@@ -124,8 +128,12 @@ class Config
{/*{{{*/
if (empty(self::$knownBranches)) {
$cache_file = "known_branches.txt";
$cache = new Cache(self::getDepsLocalPath());
$fetcher = new Fetcher(self::$depsHost, self::$depsPort);
$deps_path = self::getDepsLocalPath();
if (!$deps_path) {
throw new Exception("Couldn't determine dependencies path. Please either switch to the PHP source root or use -d option.");
}
$cache = new Cache($deps_path);
$fetcher = new Fetcher(self::$depsHost, self::$depsPort, self::$depsUriScheme);
$tmp = $fetcher->getByUri(self::$depsBaseUri . "/series/");
if (false !== $tmp) {
@@ -173,6 +181,11 @@ class Config
$branch = NULL;
$found = false;
$rmtools_branch = getenv("PHP_RMTOOLS_PHP_BUILD_BRANCH");
if ("master" == $rmtools_branch) {
return "master";
}
/* Try to figure out the branch. The worky scenarios are
- CWD is in php-src
- phpize is on the path
@@ -203,6 +216,19 @@ class Config
if (is_numeric($major) && is_numeric($minor)) {
$branch = "$major.$minor";
}
/* Verify that we use an available branch name. Master has some
version, but no dedicated series. For master, it rather
makes sense to use master as branch name. */
$git = trim(shell_exec("where git.exe"));
if ($git && is_dir(".git")) {
$cmd = "\"$git\" branch";
$ret = trim(shell_exec($cmd));
if (preg_match_all(",\*\s+master,", $ret) > 0) {
$branch = "master";
}
}
}
return $branch;
@@ -267,10 +293,10 @@ class Config
}
}
if (!$ret["stability"]) {
if (!@$ret["stability"]) {
throw new Exception("Failed to find config with stability '" . self::getCurrentStabilityName() . "'");
}
if (!$ret["crt"]) {
if (!@$ret["crt"]) {
throw new Exception("Failed to find config with arch '" . self::getCurrentArchName() . "'");
}

View File

@@ -2,9 +2,6 @@
namespace SDK;
use SDK\Config;
use SDK\Exception;
trait FileOps
{
protected function md(string $name = "", bool $tmp = false) : string
@@ -119,6 +116,9 @@ trait FileOps
protected function download(string $url, string $dest_fn = NULL) : ?string
{/*{{{*/
$fd = NULL;
$retry = 0;
retry:
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
@@ -146,6 +146,9 @@ trait FileOps
if ($dest_fn) {
fclose($fd);
}
if ($retry++ < 3) {
goto retry;
}
throw new Exception($err);
}
@@ -193,7 +196,7 @@ trait FileOps
$name = substr($name, 0, -1);*/
$name = rtrim($stat["name"], "/");
while (strchr($name, '/') !== false) {
while (strstr($name, '/') !== false) {
$name = dirname($name);
}

View File

@@ -2,8 +2,6 @@
namespace SDK;
use SDK\{Config, Exception};
class Lock
{
protected $fd;

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.

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.

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.

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.

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.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Some files were not shown because too many files have changed in this diff Show More