Compare commits

...

50 Commits

Author SHA1 Message Date
Anatol Belski
af769d9604 prepare 2.0.8 2017-07-20 21:56:22 +02:00
Anatol Belski
8e3d43905b Support also preview releases
But for now - only as a fallback if no other VS install could be found.
2017-07-13 11:15:38 +02:00
Anatol Belski
ebf3928220 upgrade bundled php 2017-07-12 15:51:42 +02:00
Anatol Belski
f96329c0fd back to dev 2017-07-10 21:39:46 +02:00
Anatol Belski
7cc831e6aa prepare 2.0.7 2017-07-10 21:38:56 +02:00
Anatol Belski
24e2464d8c improve branch name guessing 2017-07-10 12:02:17 +02:00
Anatol Belski
738abd255e fixed option handling, thanks Kalle 2017-07-08 18:55:06 +02:00
Anatol Belski
691d70fc09 upgrade to vswhere 2.0.2 2017-07-05 17:34:46 +02:00
Anatol Belski
412c512208 extend deps update comment 2017-06-29 00:02:19 +02:00
Anatol Belski
97a436c3fc task.exe commen 2017-06-28 23:54:56 +02:00
Anatol Belski
9e5e7e6c17 back to dev 2017-06-16 02:42:12 +02:00
Anatol Belski
e17b752c19 prepare 2.0.6 2017-06-16 02:40:35 +02:00
Jan-E
527b18189c Include CRT & ARCH in title
The command box has a title 'PHP SDK' now.
Make it descriptive like 'PHP SDK vc15 x86'
2017-06-16 02:38:27 +02:00
Anatol Belski
f4e3f68ce5 fix current arch setter 2017-06-16 02:34:57 +02:00
Anatol Belski
99efb73f17 back to dev 2017-06-05 20:40:43 +02:00
Anatol Belski
9d55fdee58 version up 2017-06-05 20:39:59 +02:00
Anatol Belski
492de099e7 forcibly propagate errorlevel
(cherry picked from commit 7d8bd88b029b3c05e072f77d2c287bee51f58672)
2017-06-05 14:02:14 +02:00
Anatol Belski
29453a9072 forcibly propagate errorlevel
(cherry picked from commit d2f3bb5245640e3f5a1b44530be3ed2df775ee53)
2017-06-05 14:01:54 +02:00
Anatol Belski
ac27d0e62e forcibly propagate exit code 2017-06-05 14:00:49 +02:00
Anatol Belski
d413fe0899 add license
(cherry picked from commit d2227d31799030334b0a635ea1fb0474dea23416)
2017-06-05 13:47:30 +02:00
Anatol Belski
bcb9c7346a group ns
(cherry picked from commit f1aeb9ac43dd817c0ac208714943162117329e3f)
2017-06-05 13:47:02 +02:00
Anatol Belski
43a11d2552 use curl for fetches
(cherry picked from commit f92a4b45a58f6969fdb139278157ff5556cc9879)
2017-06-05 13:45:30 +02:00
Anatol Belski
73eb340687 fix branch name recognition when no cli opt passed
(cherry picked from commit 09e01d62cb74aba6158943e0418c94f09e136248)
2017-06-05 13:45:14 +02:00
Anatol Belski
f4067b3439 group namespace 2017-05-22 15:51:43 +02:00
Anatol Belski
adfc922c09 don't ignore pgo 2017-05-22 15:47:18 +02:00
Anatol Belski
c8c80a07f7 more refactoring to simplify config 2017-05-22 13:22:06 +02:00
Anatol Belski
65bc0a8552 refactor config stuff 2017-05-22 12:47:42 +02:00
Anatol Belski
d46b74b51b remove comment that doesn't match anymore 2017-05-20 22:00:49 +02:00
Anatol Belski
af2134b486 improve error check 2017-05-20 17:43:32 +02:00
Anatol Belski
a2debffacc more on return type decls 2017-05-20 14:04:34 +02:00
Anatol Belski
ad14edb0bf next dev 2017-05-20 13:42:15 +02:00
Anatol Belski
6b9f6bd7e5 prepare 2.0.4 2017-05-20 13:41:21 +02:00
Anatol Belski
f33ebdf261 Revert "recognize pgo stuff automatically if it's put into a subdir"
This reverts commit 010ae42362.
2017-05-20 13:05:51 +02:00
Anatol Belski
079185a0d6 Revert "move pgo tools setup and do setup paths, etc. conditionally"
This reverts commit ffa802812b.
2017-05-20 13:05:43 +02:00
Anatol Belski
59c082a8f4 sync namespace 2017-05-20 12:51:48 +02:00
Anatol Belski
078554f4a6 update namespaces 2017-05-20 12:35:56 +02:00
Anatol Belski
f6e507fb5e more precise namespace 2017-05-20 12:28:03 +02:00
Anatol Belski
14df5a921a ups, this shouldn't have been here 2017-05-17 10:40:22 +02:00
Anatol Belski
7cc9c62cae make us also recognize pure build tools installation, too 2017-05-17 10:29:37 +02:00
Anatol Belski
7370f1c5b0 there could have been no backup for the very first deps fetch 2017-05-13 23:09:23 +02:00
Anatol Belski
bb745349a9 reuse msys2 certs for curl 2017-05-12 22:18:00 +02:00
Anatol Belski
a2277e746d extend .gitignore 2017-05-11 15:29:53 +02:00
Anatol Belski
c6bcad86e9 add pwgen utility 2017-05-11 15:24:19 +02:00
Anatol Belski
af74264b8f extend help msg 2017-05-11 01:58:37 +02:00
Anatol Belski
37fa9bb323 add mysqli to bundled php 2017-05-11 01:51:18 +02:00
Anatol Belski
d5d2cf1c9d upgrade bundled php 2017-05-10 15:56:32 +02:00
Anatol Belski
ffa802812b move pgo tools setup and do setup paths, etc. conditionally 2017-05-09 16:56:54 +02:00
Anatol Belski
010ae42362 recognize pgo stuff automatically if it's put into a subdir 2017-05-09 15:55:11 +02:00
Anatol Belski
bcd7690d78 Revert back to 14 as lowest to avoid WTFs
The tools won't act as expected on lower than 7.0, so spare the false
bug reports.
2017-05-09 14:52:02 +02:00
Anatol Belski
52932ecdeb 2.0.4 next 2017-05-08 19:30:23 +02:00
30 changed files with 240 additions and 146 deletions

2
.gitignore vendored
View File

@@ -18,4 +18,4 @@ oracle
# either these two become submodules, or uncomment them
#pgo-build
#rmtools*
pgo
phpsdk-local.bat

9
LICENSE Normal file
View File

@@ -0,0 +1,9 @@
Copyright 2017 Anatol Belski
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

View File

@@ -64,7 +64,7 @@ It is not required to hold the source in the PHP SDK directory. It could be usef
- 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`
- `phpsdk_deps --update --branch master`, use PHP-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").
@@ -112,4 +112,6 @@ The SDK tools are based on the KISS principle and should be kept so. Basic tools
- Tools, based on MSYS2, only accept paths with forward slashes.
- Both Visual C++ toolset and the Windows SDK components have to be installed for the PHP SDK to work properly.
- 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.

View File

@@ -1 +1 @@
2.0.3
2.0.8

View File

@@ -1,3 +1,3 @@
@echo ofF
%~dp0php.exe -c %~dp0php.ini -d extension_dir=%~dp0ext %*
%~dp0php.exe -c %~dp0php.ini -d curl.cainfo=%PHP_SDK_ROOT_PATH%\msys2\usr\ssl\cert.pem -d extension_dir=%~dp0ext %*

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
bin/php/ext/php_mysqli.dll Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -4,6 +4,7 @@ extension=php_ftp.dll
extension=php_sqlite3.dll
extension=php_openssl.dll
extension=php_mbstring.dll
extension=php_mysqli.dll
memory_limit=1G
error_reporting=-1

Binary file not shown.

View File

@@ -2,8 +2,7 @@
include dirname(__FILE__) . "/../lib/php/libsdk/autoload.php";
use SDK\Config;
use SDK\Exception;
use SDK\{Config, Exception};
$sopt = "s:cuhb:a:d:t:fn";
$lopt = array(
@@ -29,6 +28,8 @@ $backup = true;
try {
$branch = NULL;
$opt = getopt($sopt, $lopt);
foreach ($opt as $name => $val) {
switch ($name) {
@@ -43,22 +44,18 @@ try {
case "b":
case "branch":
/* Branch config depends on other information. We can set it
right away, because the option order can't be guaranteed. */
$branch = $val;
break;
case "s":
case "stability":
if ("stable" != $val && "staging" != $val) {
throw new Exception("Unknown stability keyword, either stable or staging is accepted");
}
Config::setCurrentStabilityName($val);
break;
case "a":
case "arch":
if ("x64" != $val && "x86" != $val) {
throw new Exception("Unknown arch keyword, either x86 or x64 is accepted");
}
Config::setCurrentArchName($val);
break;
@@ -93,81 +90,34 @@ try {
}
}
if (NULL == $branch) {
$branch = Config::guessCurrentBranchName();
if (NULL == $branch) {
throw new Exception("Couldn't determine current branch name, expect an explicit input.");
}
}
Config::setCurrentBranchName($branch);
if (NULL === $cmd) {
usage();
}
if (!Config::getDepsLocalPath()) {
if (file_exists("../deps")) {
Config::setDepsLocalPath(realpath("../deps"));
} else if (file_exists("main/php_version.h")) {
/* Deps dir might not exist. */
Config::setDepsLocalPath(realpath("..") . DIRECTORY_SEPARATOR . "deps");
} else {
usage(3);
}
if (NULL === Config::getDepsLocalPath()) {
usage(3);
}
if ($branch) {
Config::setCurrentBranchName($branch);
}
if (!Config::getCurrentBranchName()) {
/* Try to figure out the branch. For now it only works if CWD is in php-src. */
$fl = "main/php_version.h";
if (file_exists($fl)) {
$s = file_get_contents($fl);
$major = $minor = NULL;
if (preg_match(",PHP_MAJOR_VERSION (\d+),", $s, $m)) {
$major = $m[1];
}
if (preg_match(",PHP_MINOR_VERSION (\d+),", $s, $m)) {
$minor = $m[1];
}
if (is_numeric($major) && is_numeric($minor)) {
Config::setCurrentBranchName("$major.$minor");
} else {
usage(3);
}
} else {
usage(3);
}
$branch = Config::getCurrentBranchName();
if (NULL == $branch) {
usage(3);
}
if (NULL === Config::getCurrentArchName()) {
/* XXX this might be not true for other compilers! */
passthru("where cl.exe >nul", $status);
if (!$status) {
exec("cl.exe /? 2>&1", $a, $status);
if (!$status) {
if (preg_match(",x64,", $a[0])) {
Config::setCurrentArchName("x64");
} else {
Config::setCurrentArchName("x86");
}
} else {
usage(3);
}
} else {
usage(3);
}
$arch = Config::getCurrentArchName();
$arch = Config::getCurrentArchName();
if (NULL === $arch) {
usage(3);
}
if (NULL === Config::getCurrentCrtName()) {
$all_branches = Config::getKnownBranches();
if (!isset($all_branches[Config::getCurrentBranchName()])) {
throw new Exception("Couldn't find any configuration for branch '" . Config::getCurrentBranchName() . "'");
}
$branch = $all_branches[Config::getCurrentBranchName()];
if (count($branch) > 1) {
throw new Exception("Multiple CRTs are available for this branch, please choose one from " . implode(",", array_keys($branch)));
} else {
Config::setCurrentCrtName(array_keys($branch)[0]);
}
usage(3);
}
/* The current CRT needs to match the config one. */
$active_crt = getenv("PHP_SDK_VC");
@@ -187,7 +137,7 @@ try {
echo "\nConfiguration: " . Config::getCurrentBranchName() . "-$branch_data[crt]-$branch_data[arch]-$branch_data[stability]\n\n";
/* Let the dep manager to run the command. */
$dm = new SDK\Dependency\Manager(Config::getDepsLocalPath(), $branch_data["stability"], $branch_data["arch"]);
$dm = new SDK\Build\Dependency\Manager(Config::getDepsLocalPath(), $branch_data["stability"], $branch_data["arch"]);
switch ($cmd) {
default:
throw new Exception("Unknown command '$cmd'");

View File

@@ -24,7 +24,7 @@ if ""=="%PHP_SDK_VC:~2%" (
goto malformed_vc_string
)
set /a TMP_CHK=%PHP_SDK_VC:~2%
if 11 gtr %TMP_CHK% (
if 14 gtr %TMP_CHK% (
if "0"=="%TMP_CHK%" (
if not "0"=="%PHP_SDK_VC:~2%" (
set TMP_CHK=
@@ -79,11 +79,18 @@ if 15 gtr %PHP_SDK_VC_NUM% (
) 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 %PHP_SDK_VC_NUM% -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
if not exist "!PHP_SDK_VC_DIR!" (
echo Could not determine '%PHP_SDK_VC%' directory
goto out_error;
for /f "tokens=1* delims=: " %%a in ('%~dp0\vswhere -nologo -version %PHP_SDK_VC_NUM% -products Microsoft.VisualStudio.Product.BuildTools -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath -format text') do set PHP_SDK_VC_DIR=%%b\VC
if not exist "!PHP_SDK_VC_DIR!" (
rem check for a preview release
for /f "tokens=1* delims=: " %%a in ('%~dp0\vswhere -nologo -version %PHP_SDK_VC_NUM% -prerelease -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath -format text') do set PHP_SDK_VC_DIR=%%b\VC
if not exist "!PHP_SDK_VC_DIR!" (
echo Could not determine '%PHP_SDK_VC%' directory
goto out_error;
)
)
)
set VSCMD_ARG_no_logo=nologo
)
set TMPKEY=

Binary file not shown.

View File

@@ -1,12 +1,13 @@
<?php
namespace SDK\Dependency;
namespace SDK\Build\Dependency;
use SDK\Config;
use SDK\Exception;
use SDK\{Config, Exception, FileOps};
class Fetcher
{
use FileOps;
protected $host;
protected $port;
protected $stability;
@@ -27,7 +28,7 @@ class Fetcher
return $this->series;
}/*}}}*/
public function setSeries(Series $series)
public function setSeries(Series $series) : void
{/*{{{*/
$this->series = $series;
}/*}}}*/
@@ -37,13 +38,8 @@ class Fetcher
public function getByUri($uri) : string
{/*{{{*/
$url = "http://{$this->host}:{$this->port}$uri";
$s = file_get_contents($url);
if (false === $s) {
throw new Exception("failed to fetch $url");
}
return $s;
return $this->download($url);
}/*}}}*/
/*protected function fetch($uri) : string

View File

@@ -1,11 +1,8 @@
<?php
namespace SDK\Dependency;
namespace SDK\Build\Dependency;
use SDK\Config;
use SDK\Cache;
use SDK\Exception;
use SDK\FileOps;
use SDK\{Config, Cache, Exception, FileOps};
class Manager
{
@@ -35,7 +32,7 @@ class Manager
$this->series = $series;
}/*}}}*/
protected function getTmpSeriesPath()
protected function getTmpSeriesPath() : string
{/*{{{*/
return Config::getTmpDir() . DIRECTORY_SEPARATOR . $this->series->getname();
}/*}}}*/
@@ -45,9 +42,8 @@ class Manager
return $this->series->updatesAvailable();
}/*}}}*/
/* TODO and implement --force. */
/* FIXME implement rollback */
public function performUpdate(string &$msg = NULL, bool $force = false, bool $backup = true)
public function performUpdate(string &$msg = NULL, bool $force = false, bool $backup = true) : void
{/*{{{*/
if (!$force) {
if (!$this->updatesAvailable()) {
@@ -116,7 +112,9 @@ class Manager
/* save new series file, move the updated deps and backup the old ones, cleanup.*/
$msg .= "Updates performed successfully. " . PHP_EOL;
if ($backup) {
$msg .= "Old dependencies backed up into '$new_path'.";
if (isset($new_path)) {
$msg .= "Old dependencies backed up into '$new_path'.";
}
} else {
$msg .= "No backup was created.";
}

View File

@@ -1,6 +1,6 @@
<?php
namespace SDK\Dependency;
namespace SDK\Build\Dependency;
use SDK\Config;
use SDK\Exception;
@@ -28,7 +28,7 @@ class Package
return "$base/{$branch_data['crt']}/$arch/{$this->name}";
}/*}}}*/
public function retrieve(string $path)
public function retrieve(string $path) : void
{/*{{{*/
$this->filepath = $path . DIRECTORY_SEPARATOR . $this->name;
@@ -39,7 +39,7 @@ class Package
fclose($fd);
}/*}}}*/
public function unpack(string $path)
public function unpack(string $path) : void
{/*{{{*/
if (!$this->filepath || !file_exists($this->filepath)) {
throw new Exception("Invalid filepath '{$this->filepath}'");
@@ -55,7 +55,7 @@ class Package
}
}/*}}}*/
public function cleanup()
public function cleanup() : void
{/*{{{*/
unlink($this->filepath);
}/*}}}*/

View File

@@ -1,6 +1,6 @@
<?php
namespace SDK\Dependency;
namespace SDK\Build\Dependency;
use SDK\Config;
use SDK\Cache;
@@ -27,7 +27,7 @@ class Series
return $this->fetcher;
}/*}}}*/
public function setFetcher(Fetcher $fetcher)
public function setFetcher(Fetcher $fetcher) : void
{/*{{{*/
$this->fetcher = $fetcher;
}/*}}}*/
@@ -37,7 +37,7 @@ class Series
return $this->arch;
}/*}}}*/
public function setArch(string $arch)
public function setArch(string $arch) : void
{/*{{{*/
$this->arch = $arch;
}/*}}}*/
@@ -52,7 +52,7 @@ class Series
return $file;
}/*}}}*/
protected function getUri() : string
protected function getUri() : string
{/*{{{*/
$base = Config::getDepsBaseUri();
$file = $this->getName();
@@ -79,12 +79,12 @@ class Series
return $ret;
}/*}}}*/
public function getSavePath()
public function getSavePath() : string
{/*{{{*/
return Config::getCacheDir() . DIRECTORY_SEPARATOR . $this->getname();
}/*}}}*/
public function updatesAvailable()
public function updatesAvailable() : bool
{/*{{{*/
$series_data = $this->getData(true);
$series_file = $this->getSavePath();
@@ -92,7 +92,7 @@ class Series
return $this->cache->cachedContentDiffers($series_file, $series_data);
}/*}}}*/
public function cache(string $path = NULL)
public function cache(string $path = NULL) : void
{/*{{{*/
if (!$path) {
$path = $this->getSavePath();

View File

@@ -50,7 +50,7 @@ class Cache
return $old_sum != $new_sum;
}/*}}}*/
public function cacheContent(string $path, string $content, bool $relative = false)
public function cacheContent(string $path, string $content, bool $relative = false) : void
{/*{{{*/
$p = $this->getCacheablePath($path, $relative);
@@ -59,7 +59,7 @@ class Cache
}
}/*}}}*/
public function getCachedContent(string $path, bool $relative = false)
public function getCachedContent(string $path, bool $relative = false) : ?string
{/*{{{*/
$p = $this->getCacheablePath($path, $relative);
@@ -67,7 +67,7 @@ class Cache
return file_get_contents($p);
}
return "";
return NULL;
}/*}}}*/
}

View File

@@ -2,7 +2,7 @@
namespace SDK;
use SDK\Dependency\Fetcher;
use SDK\Build\Dependency\Fetcher;
use SDK\Cache;
use SDK\Exception;
@@ -39,33 +39,85 @@ class Config
return self::$depsBaseUri;
}/*}}}*/
public static function setCurrentArchName(string $arch)
public static function setCurrentArchName(string $arch) : void
{/*{{{*/
$arch = strtolower($arch);
if ("x64" != $arch && "x86" != $arch) {
throw new Exception("Unknown arch keyword, either x86 or x64 is accepted");
}
self::$currentArchName = $arch;
} /*}}}*/
public static function getCurrentArchName()
public static function getCurrentArchName() : string
{/*{{{*/
if (NULL === self::$currentArchName) {
/* XXX this might be not true for other compilers! */
passthru("where cl.exe >nul", $status);
if ($status) {
throw new Exception("Couldn't find cl.exe.");
}
exec("cl.exe /? 2>&1", $a, $status);
if ($status) {
throw new Exception("Couldn't execute cl.exe.");
}
if (preg_match(",x64,", $a[0])) {
self::setCurrentArchName("x64");
} else {
self::setCurrentArchName("x86");
}
}
return self::$currentArchName;
} /*}}}*/
public static function setCurrentCrtName(string $crt)
public static function setCurrentCrtName(string $crt) : void
{/*{{{*/
self::$currentCrtName = $crt;
} /*}}}*/
public static function getCurrentCrtName()
public static function getCurrentCrtName() : ?string
{/*{{{*/
if (NULL === self::$currentCrtName) {
$all_branches = Config::getKnownBranches();
if (!isset($all_branches[Config::getCurrentBranchName()])) {
throw new Exception("Couldn't find any configuration for branch '" . Config::getCurrentBranchName() . "'");
}
$branch = $all_branches[Config::getCurrentBranchName()];
if (count($branch) > 1) {
throw new Exception("Multiple CRTs are available for this branch, please choose one from " . implode(",", array_keys($branch)));
}
self::setCurrentCrtName(array_keys($branch)[0]);
}
return self::$currentCrtName;
} /*}}}*/
public static function setCurrentStabilityName(string $stability)
public static function setCurrentStabilityName(string $stability) : void
{/*{{{*/
if ("stable" != $stability && "staging" != $stability) {
throw new Exception("Unknown stability keyword, either stable or staging is accepted");
}
self::$currentStabilityName = $stability;
} /*}}}*/
public static function getCurrentStabilityName()
public static function getCurrentStabilityName() : ?string
{/*{{{*/
if (NULL === self::$currentStabilityName) {
if ("master" == Config::getCurrentBranchName()) {
Config::setCurrentStabilityName("staging");
} else {
Config::setCurrentStabilityName("stable");
}
}
return self::$currentStabilityName;
} /*}}}*/
@@ -93,6 +145,9 @@ class Config
} else {
/* It might be ok to use cached branches list, if a fetch failed. */
$tmp = $cache->getCachedContent($cache_file, true);
if (NULL == $tmp) {
throw new Exception("No cached branches list found");
}
$data = json_decode($tmp, true);
}
@@ -105,17 +160,47 @@ class Config
return self::$knownBranches;
}/*}}}*/
public static function setCurrentBranchName(string $name)
public static function setCurrentBranchName(string $name) : void
{/*{{{*/
if (!array_key_exists($name, self::getKnownBranches())) {
// throw new Exception("Unsupported branch '$name'");
throw new Exception("Unsupported branch '$name'");
}
self::$currentBranchName = $name;
}/*}}}*/
public static function getCurrentBranchName()
public static function guessCurrentBranchName() : ?string
{/*{{{*/
$branch = NULL;
/* Try to figure out the branch. For now it only works if CWD is in php-src. */
$fl = "main/php_version.h";
if (file_exists($fl)) {
$s = file_get_contents($fl);
$major = $minor = NULL;
if (preg_match(",PHP_MAJOR_VERSION (\d+),", $s, $m)) {
$major = $m[1];
}
if (preg_match(",PHP_MINOR_VERSION (\d+),", $s, $m)) {
$minor = $m[1];
}
if (is_numeric($major) && is_numeric($minor)) {
$branch = "$major.$minor";
}
}
return $branch;
}/*}}}*/
public static function getCurrentBranchName() : string
{/*{{{*/
if (NULL == self::$currentBranchName) {
$branch = self::guessCurrentBranchName();
self::setCurrentBranchName($branch);
}
return self::$currentBranchName;
}/*}}}*/
@@ -124,36 +209,37 @@ class Config
$ret = array();
$branches = self::getKnownBranches();
if (!array_key_exists(self::$currentBranchName, $branches)) {
throw new Exception("Unknown branch '" . self::$currentBranchName . "'");
$current_branch_name = self::getCurrentBranchName();
if (!array_key_exists($current_branch_name, $branches)) {
throw new Exception("Unknown branch '$current_branch_name'");
}
$cur_crt = Config::getCurrentCrtName();
if (count($branches[self::$currentBranchName]) > 1) {
if (count($branches[$current_branch_name]) > 1) {
if (NULL === $cur_crt) {
throw new Exception("More than one CRT is available for branch '" . self::$currentBranchName . "', pass one explicitly.");
throw new Exception("More than one CRT is available for branch '$current_branch_name', pass one explicitly.");
}
$cur_crt_usable = false;
foreach (array_keys($branches[self::$currentBranchName]) as $crt) {
foreach (array_keys($branches[$current_branch_name]) 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 . "'");
throw new Exception("The passed CRT '$cur_crt' doesn't match any availbale for branch '$current_branch_name'");
}
$data = $branches[self::$currentBranchName][$cur_crt];
$data = $branches[$current_branch_name][$cur_crt];
} else {
/* Evaluate CRTs, to avoid ambiquity. */
list($crt, $data) = each($branches[self::$currentBranchName]);
list($crt, $data) = each($branches[$current_branch_name]);
if ($crt != $cur_crt) {
throw new Exception("The passed CRT '$cur_crt' doesn't match any availbale for branch '" . self::$currentBranchName . "'");
throw new Exception("The passed CRT '$cur_crt' doesn't match any availbale for branch '$current_branch_name'");
}
}
$ret["name"] = self::$currentBranchName;
$ret["name"] = $current_branch_name;
$ret["crt"] = $crt;
/* Last step, filter by arch and stability. */
@@ -181,7 +267,7 @@ class Config
return self::$sdkNugetFeedUrl;
}/*}}}*/
public static function getSdkPath()
public static function getSdkPath() : string
{/*{{{*/
$path = getenv("PHP_SDK_ROOT_PATH");
@@ -208,12 +294,21 @@ class Config
return file_get_contents($path);
}/*}}}*/
public static function getDepsLocalPath()
public static function getDepsLocalPath() : ?string
{/*{{{*/
if (NULL == self::$depsLocalPath) {
if (file_exists("../deps")) {
self::setDepsLocalPath(realpath("../deps"));
} else if (file_exists("main/php_version.h")) {
/* Deps dir might not exist. */
self::setDepsLocalPath(realpath("..") . DIRECTORY_SEPARATOR . "deps");
}
}
return self::$depsLocalPath;
}/*}}}*/
public static function setDepsLocalPath(string $path)
public static function setDepsLocalPath(string $path) : void
{/*{{{*/
self::$depsLocalPath = $path;
}/*}}}*/

View File

@@ -115,6 +115,42 @@ trait FileOps
return $ret;
}/*}}}*/
protected function download(string $url, string $dest = NULL) : ?string
{
$fd = NULL;
$ch = curl_init($url);
if ($dest) {
$fd = fopen($dest, "w+");
curl_setopt($ch, CURLOPT_FILE, $fd);
} else {
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
}
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$ret = curl_exec($ch);
if (false === $ret) {
$err = curl_error();
curl_close($ch);
if ($dest) {
fclose($fd);
}
throw new Exception($err);
}
curl_close($ch);
if ($dest) {
fclose($fd);
return NULL;
}
return $ret;
}
}
/*

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

Binary file not shown.

View File

@@ -20,7 +20,7 @@ if "%ARCH%" equ "" goto help
goto skip_help
:help
echo Usage: phpsdk-starter -c ^<crt^> -a ^<arch^> [-t ^<task_script.bat^>]
echo Usage: phpsdk-starter -c ^<crt^> -a ^<arch^> [-t ^<task_script.bat^> [task script args]]
exit /b 0
:skip_help
@@ -31,7 +31,7 @@ set ARCH=%ARCH: =%
set PHP_SDK_RUN_FROM_ROOT=1
title PHP SDK
title PHP SDK %CRT% %ARCH%
call %PHP_SDK_ROOT_PATH%\bin\phpsdk_setshell.bat %CRT% %ARCH%
@@ -40,7 +40,7 @@ set CRT=
set ARCH=
if errorlevel 3 (
exit /b %errorlevel%
exit /b !ERRORLEVEL!
)
if "%TASK%" neq "" (
@@ -53,7 +53,7 @@ if "%TASK%" neq "" (
cmd /c "!PHP_SDK_VC_SHELL_CMD! && %PHP_SDK_ROOT_PATH%\bin\phpsdk_setvars.bat && %TASK% !TASK_ARGS!"
)
set TASK=
exit /b
exit /b !ERRORLEVEL!
) else (
echo could not find the task file
set TASK=
@@ -67,5 +67,5 @@ if exist "%PHP_SDK_ROOT_PATH%\phpsdk-local.bat" (
cmd /k "!PHP_SDK_VC_SHELL_CMD! && %PHP_SDK_ROOT_PATH%\bin\phpsdk_setvars.bat && %PHP_SDK_ROOT_PATH%\bin\phpsdk_dumpenv.bat && set prompt=$P$_$+$$$S"
)
exit /b
exit /b !ERRORLEVEL!

View File

@@ -2,5 +2,5 @@
call %~dp0phpsdk-starter.bat -c vc14 -a x64 %*
exit /b
exit /b %ERRORLEVEL%

View File

@@ -2,5 +2,5 @@
call %~dp0phpsdk-starter.bat -c vc14 -a x86 %*
exit /b
exit /b %ERRORLEVEL%

View File

@@ -2,5 +2,5 @@
call %~dp0phpsdk-starter.bat -c vc15 -a x64 %*
exit /b
exit /b %ERRORLEVEL%

View File

@@ -2,5 +2,5 @@
call %~dp0phpsdk-starter.bat -c vc15 -a x86 %*
exit /b
exit /b %ERRORLEVEL%