mirror of
https://github.com/php-win-ext/php-sdk-binary-tools.git
synced 2026-03-24 09:02:12 +01:00
Compare commits
133 Commits
php-sdk-2.
...
php-sdk-2.
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9345164d3a | ||
|
|
d2b2d58f84 | ||
|
|
9da65f2386 | ||
|
|
1f48f48b94 | ||
|
|
0cd8d902c0 | ||
|
|
c7c874e9b4 | ||
|
|
97112e4dd0 | ||
|
|
098f6457de | ||
|
|
a5afa11cff | ||
|
|
6b58f91d9d | ||
|
|
bb5ff05cc5 | ||
|
|
4b51347c35 | ||
|
|
7d48cafe29 | ||
|
|
d802183581 | ||
|
|
741063cdf1 | ||
|
|
a97d0bd292 | ||
|
|
5507b37b7d | ||
|
|
7c72855fd0 | ||
|
|
b5829cd502 | ||
|
|
de669c7610 | ||
|
|
f96fbeddab | ||
|
|
ceececf83f | ||
|
|
64c2ac973c | ||
|
|
79116d5051 | ||
|
|
c3bb9777bb | ||
|
|
eae3aab2ae | ||
|
|
e7e92b35d0 | ||
|
|
d158c3c032 | ||
|
|
69fb69fd93 | ||
|
|
aee165fe05 | ||
|
|
022333118e | ||
|
|
821c0d7c73 | ||
|
|
7d72596e85 | ||
|
|
2b317c62e1 | ||
|
|
61d589c424 | ||
|
|
eaa6ff57fa | ||
|
|
5efd876bb3 | ||
|
|
0319dc061f | ||
|
|
40fe451c8d | ||
|
|
55fddef1a3 | ||
|
|
af769d9604 | ||
|
|
8e3d43905b | ||
|
|
ebf3928220 | ||
|
|
f96329c0fd | ||
|
|
7cc831e6aa | ||
|
|
24e2464d8c | ||
|
|
738abd255e | ||
|
|
691d70fc09 | ||
|
|
412c512208 | ||
|
|
97a436c3fc | ||
|
|
9e5e7e6c17 | ||
|
|
e17b752c19 | ||
|
|
527b18189c | ||
|
|
f4e3f68ce5 | ||
|
|
99efb73f17 | ||
|
|
9d55fdee58 | ||
|
|
492de099e7 | ||
|
|
29453a9072 | ||
|
|
ac27d0e62e | ||
|
|
d413fe0899 | ||
|
|
bcb9c7346a | ||
|
|
43a11d2552 | ||
|
|
73eb340687 | ||
|
|
f4067b3439 | ||
|
|
adfc922c09 | ||
|
|
c8c80a07f7 | ||
|
|
65bc0a8552 | ||
|
|
d46b74b51b | ||
|
|
af2134b486 | ||
|
|
a2debffacc | ||
|
|
ad14edb0bf | ||
|
|
6b9f6bd7e5 | ||
|
|
f33ebdf261 | ||
|
|
079185a0d6 | ||
|
|
59c082a8f4 | ||
|
|
078554f4a6 | ||
|
|
f6e507fb5e | ||
|
|
14df5a921a | ||
|
|
7cc9c62cae | ||
|
|
7370f1c5b0 | ||
|
|
bb745349a9 | ||
|
|
a2277e746d | ||
|
|
c6bcad86e9 | ||
|
|
af74264b8f | ||
|
|
37fa9bb323 | ||
|
|
d5d2cf1c9d | ||
|
|
ffa802812b | ||
|
|
010ae42362 | ||
|
|
bcd7690d78 | ||
|
|
52932ecdeb | ||
|
|
4074dc7e18 | ||
|
|
bef5693b20 | ||
|
|
09a5e2bedc | ||
|
|
49f6a761e2 | ||
|
|
c385a12d58 | ||
|
|
07546d9304 | ||
|
|
79da1ed7af | ||
|
|
5ccdabeb39 | ||
|
|
31291b5aba | ||
|
|
dc0a5cce5b | ||
|
|
af67c49c46 | ||
|
|
513dd29f8a | ||
|
|
1a8c2e03b7 | ||
|
|
866ffa7b3c | ||
|
|
0b764877b2 | ||
|
|
9523a991d8 | ||
|
|
b2e434d5a1 | ||
|
|
42682a421b | ||
|
|
3dfcb7ccd1 | ||
|
|
b79e4ba51b | ||
|
|
1ce16ca360 | ||
|
|
80e2aec078 | ||
|
|
f88e36cc2b | ||
|
|
524f27bd17 | ||
|
|
e0d0c67953 | ||
|
|
6c2eee890e | ||
|
|
1e51c38c22 | ||
|
|
14c2e7f32e | ||
|
|
2329abeefb | ||
|
|
0050de4131 | ||
|
|
71cf47f6f2 | ||
|
|
4abd44bae4 | ||
|
|
d552f7118b | ||
|
|
f77a7e791a | ||
|
|
024c694807 | ||
|
|
5c7c222e8f | ||
|
|
9fe493edf7 | ||
|
|
5d51577cd5 | ||
|
|
cad50539cf | ||
|
|
6b50dabf00 | ||
|
|
f5f5620c55 | ||
|
|
139ea9a86d | ||
|
|
cf054fd362 |
7
.gitattributes
vendored
Normal file
7
.gitattributes
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
*.m4 text eol=lf
|
||||
*.awk text eol=lf
|
||||
*.c text eol=lf
|
||||
*.h text eol=lf
|
||||
*.php text eol=lf
|
||||
*.json text eol=lf
|
||||
*.md text eol=lf
|
||||
2
.gitignore
vendored
2
.gitignore
vendored
@@ -4,6 +4,7 @@ php55
|
||||
php56
|
||||
php70
|
||||
php71
|
||||
php72
|
||||
phpmaster
|
||||
php
|
||||
!lib/php
|
||||
@@ -18,3 +19,4 @@ oracle
|
||||
# either these two become submodules, or uncomment them
|
||||
#pgo-build
|
||||
#rmtools*
|
||||
phpsdk-local.bat
|
||||
|
||||
9
LICENSE
Normal file
9
LICENSE
Normal 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.
|
||||
228
README.md
228
README.md
@@ -1,110 +1,118 @@
|
||||
# PHP SDK
|
||||
|
||||
PHP SDK is a tool kit for Windows PHP builds
|
||||
|
||||
# License
|
||||
|
||||
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.
|
||||
|
||||
# Overview
|
||||
|
||||
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.
|
||||
|
||||
# Requirements
|
||||
|
||||
- `Visual C++ 2015` 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` - 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 tools
|
||||
|
||||
- `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`, `unzipsfx`
|
||||
- `wget`
|
||||
|
||||
## Optional, not included
|
||||
|
||||
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.
|
||||
|
||||
- `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
|
||||
|
||||
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`
|
||||
- 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.
|
||||
|
||||
## 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.
|
||||
|
||||
# PHP SDK
|
||||
|
||||
PHP SDK is a tool kit for Windows PHP builds
|
||||
|
||||
# License
|
||||
|
||||
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.
|
||||
|
||||
# Overview
|
||||
|
||||
The PHP SDK 2.0 is compatible with PHP 7.0 and above. The compatibility with [older versions](http://windows.php.net/downloads/php-sdk/php-sdk-binary-tools-20110915.zip "php-sdk-binary-tools-20110915.zip") is kept, also available from the [legacy branch](https://github.com/OSTC/php-sdk-binary-tools/tree/legacy). The toolset was significantly revamped. 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.
|
||||
|
||||
# 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
|
||||
- The PHP SDK was successfully tested on Windows 7 or later, earlier versions might work but are not recommended
|
||||
|
||||
# Tools
|
||||
|
||||
All the tools included are either scripts or 32-bit binaries. They are therefore runable on any of x86 or x64 supported Windows system.
|
||||
|
||||
## SDK
|
||||
|
||||
- starter scripts, named phpsdk-<crt>-<arch>.bat
|
||||
- `phpsdk_buildtree` - initialize the development filesystem structure
|
||||
- `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 tools
|
||||
|
||||
- `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`, `unzipsfx`
|
||||
- `wget`, `pwgen`
|
||||
|
||||
## Optional, not included
|
||||
|
||||
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.
|
||||
|
||||
- `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
|
||||
|
||||
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 php-sdk-2.0.0` 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
|
||||
- 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").
|
||||
|
||||
## 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.bat 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, if any present
|
||||
- move the PHP SDK folder into trash
|
||||
- download, unpack and the new PHP SDK version under the same path
|
||||
- move the custom files back in their respective places
|
||||
|
||||
If the PHP SDK is kept as a git checkout, merely what is needed instead is to git fetch and to checkout an updated git tag.
|
||||
|
||||
# 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.
|
||||
- When fetching from git, git `core.autocrlf` configuration directive set to `false` is recommended.
|
||||
- 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.
|
||||
|
||||
|
||||
|
||||
@@ -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
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.
BIN
bin/php/nghttp2.dll
Normal file
BIN
bin/php/nghttp2.dll
Normal file
Binary file not shown.
BIN
bin/php/php.exe
BIN
bin/php/php.exe
Binary file not shown.
@@ -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
|
||||
|
||||
BIN
bin/php/php7.dll
BIN
bin/php/php7.dll
Binary file not shown.
Binary file not shown.
@@ -7,6 +7,8 @@ IF "%2" EQU "" SET _=%CD%\%1
|
||||
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
|
||||
|
||||
cmd /c "exit /b 0"
|
||||
|
||||
if "%PHP_SDK_ARCH%" NEQ "" (
|
||||
if "%PHP_SDK_VC%" NEQ "" (
|
||||
MD %_%\%PHP_SDK_VC%\%PHP_SDK_ARCH%\deps\bin
|
||||
@@ -35,3 +37,5 @@ echo phpsdk_buildtree ^<nameofthetree^> [PATH]
|
||||
echo Create the common directory structure used by the PHP SDK
|
||||
|
||||
:EXIT
|
||||
exit /b %errorlevel%
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
@echo off
|
||||
|
||||
cmd /c "exit /b 0"
|
||||
|
||||
if "%PHP_SDK_PHP_CMD%"=="" (
|
||||
call %~dp0phpsdk_setvars.bat
|
||||
if "!PHP_SDK_PHP_CMD!"=="" (
|
||||
@@ -10,5 +12,5 @@ if "%PHP_SDK_PHP_CMD%"=="" (
|
||||
|
||||
call %PHP_SDK_PHP_CMD% %PHP_SDK_BIN_PATH%\phpsdk_deps.php %*
|
||||
|
||||
exit /b
|
||||
exit /b %errorlevel%
|
||||
|
||||
|
||||
@@ -2,10 +2,9 @@
|
||||
|
||||
include dirname(__FILE__) . "/../lib/php/libsdk/autoload.php";
|
||||
|
||||
use SDK\Config;
|
||||
use SDK\Exception;
|
||||
use SDK\{Config, Exception};
|
||||
|
||||
$sopt = "s:cuhb:a:d:t:";
|
||||
$sopt = "s:cuhb:a:d:t:fnp";
|
||||
$lopt = array(
|
||||
"branch:",
|
||||
"update",
|
||||
@@ -15,6 +14,9 @@ $lopt = array(
|
||||
"crt:",
|
||||
"help",
|
||||
"deps:",
|
||||
"force",
|
||||
"no-backup",
|
||||
"pack",
|
||||
);
|
||||
|
||||
$cmd = NULL;
|
||||
@@ -22,9 +24,13 @@ $stability = NULL;
|
||||
$arch = NULL;
|
||||
$branch = NULL;
|
||||
$crt = NULL;
|
||||
$force = false;
|
||||
$backup = true;
|
||||
|
||||
try {
|
||||
|
||||
$branch = NULL;
|
||||
|
||||
$opt = getopt($sopt, $lopt);
|
||||
foreach ($opt as $name => $val) {
|
||||
switch ($name) {
|
||||
@@ -39,22 +45,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;
|
||||
|
||||
@@ -76,84 +78,57 @@ try {
|
||||
case "crt":
|
||||
Config::setCurrentCrtName($val);
|
||||
break;
|
||||
|
||||
case "f":
|
||||
case "force":
|
||||
$force = true;
|
||||
break;
|
||||
|
||||
case "n":
|
||||
case "no-backup":
|
||||
$backup = false;
|
||||
break;
|
||||
|
||||
case "p":
|
||||
case "pack":
|
||||
$cmd = "pack";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
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");
|
||||
if (Config::getCurrentCrtName() != $active_crt && !$force) {
|
||||
throw new Exception("Active CRT '$active_crt' differs from the branch CRT '" . Config::getCurrentCrtName() . "'.");
|
||||
}
|
||||
|
||||
if (NULL === Config::getCurrentStabilityName()) {
|
||||
@@ -168,7 +143,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'");
|
||||
@@ -182,9 +157,22 @@ try {
|
||||
}
|
||||
break;
|
||||
case "update":
|
||||
$dm->performUpdate($msg);
|
||||
if ($force) {
|
||||
print "Replacing the current deps by the force option.\n\n";
|
||||
}
|
||||
$dm->performUpdate($msg, $force, $backup);
|
||||
msg($msg);
|
||||
break;
|
||||
case "pack":
|
||||
$path_to_pack = Config::getDepsLocalPath();
|
||||
$pack_path = dirname($path_to_pack) . DIRECTORY_SEPARATOR . "deps-$branch-$branch_data[crt]-$branch_data[arch].7z";
|
||||
print "Packaging '$path_to_pack' as '$pack_path'.\n\n";
|
||||
if ($force && is_file($pack_path)) {
|
||||
unlink($pack_path);
|
||||
}
|
||||
system("7za a $pack_path $path_to_pack", $st);
|
||||
exit((int)$st);
|
||||
break;
|
||||
}
|
||||
|
||||
} catch (Throwable $e) {
|
||||
@@ -199,15 +187,18 @@ function usage(int $code = -1)
|
||||
echo "PHP SDK dependency handling tool.", PHP_EOL;
|
||||
echo "Usage: ", PHP_EOL, PHP_EOL;
|
||||
echo "Configuration:", PHP_EOL;
|
||||
echo " -b --branch Branch name, eg. 7.0, 7.1, etc. If omited, CWD is used to guess.", PHP_EOL;
|
||||
echo " -b --branch Branch name, eg. 7.0, 7.1, etc. If omited, several guess methods apply.", PHP_EOL;
|
||||
echo " -a --arch Architecture, x86 or x64. If omited, cl.exe is used to guess.", PHP_EOL;
|
||||
echo " -t --crt CRT, marked by the corresponding VC++ version, eg. vc11, vc14, etc.", PHP_EOL;
|
||||
echo " -s --stability One of stable or staging.", PHP_EOL, PHP_EOL;
|
||||
echo "Commands:", PHP_EOL;
|
||||
echo " -c --check Check for dependency updates. If updates are available, the exit code is set to 7.", PHP_EOL;
|
||||
echo " -u --update Update dependencies. If deps directory already exists, backup copy is created automatically.", PHP_EOL, PHP_EOL;
|
||||
echo " -u --update Update dependencies. If deps directory already exists, backup copy is created automatically.", PHP_EOL;
|
||||
echo " -p --pack Archive the dependency directory.", PHP_EOL, PHP_EOL;
|
||||
echo "Misc:", PHP_EOL;
|
||||
echo " -d --deps Path to the dependencies directory. If omited, CWD is used to guess.", PHP_EOL;
|
||||
echo " -f --force Force the operation even if there are no upgrades available.", PHP_EOL;
|
||||
echo " -n --no-backup Replace the current dependencies without creating backup.", PHP_EOL;
|
||||
echo " -h --help Show help message.", PHP_EOL, PHP_EOL;
|
||||
echo "Example: ", PHP_EOL;
|
||||
echo " phpsdk_deps -c -b master", PHP_EOL;
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
@echo off
|
||||
|
||||
cmd /c "exit /b 0"
|
||||
|
||||
if "%PHP_SDK_PHP_CMD%"=="" (
|
||||
call %~dp0phpsdk_setvars.bat
|
||||
if "!PHP_SDK_PHP_CMD!"=="" (
|
||||
@@ -10,5 +12,5 @@ if "%PHP_SDK_PHP_CMD%"=="" (
|
||||
|
||||
call %PHP_SDK_PHP_CMD% %PHP_SDK_BIN_PATH%\phpsdk_dllmap.php %*
|
||||
|
||||
exit /b
|
||||
exit /b %errorlevel%
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
- create mappings between dll filename and zip filename
|
||||
|
||||
Usage:
|
||||
php dllmap.php path0 [ path1 ... ] > dllmapping.json
|
||||
php dllmap.php [--pretty] path0 [ path1 ... ] > dllmapping.json
|
||||
*/
|
||||
|
||||
|
||||
@@ -20,8 +20,25 @@
|
||||
"C:\\tmp\\libs",
|
||||
);*/
|
||||
|
||||
$sopt = "p";
|
||||
$lopt = array(
|
||||
"pretty",
|
||||
);
|
||||
|
||||
$flags = 0;
|
||||
$opt = getopt($sopt, $lopt);
|
||||
foreach ($opt as $name => $val) {
|
||||
switch ($name) {
|
||||
case "p":
|
||||
case "pretty":
|
||||
$flags = JSON_PRETTY_PRINT;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$dirs = array();
|
||||
foreach (array_slice($_SERVER["argv"], 1) as $item) {
|
||||
foreach (array_slice($_SERVER["argv"], (0 == $flags ? 1 : 2)) as $item) {
|
||||
if (file_exists($item) && is_dir($item)) {
|
||||
$dirs[] = $item;
|
||||
}
|
||||
@@ -32,26 +49,7 @@ if (empty($dirs)) {
|
||||
die;
|
||||
}
|
||||
|
||||
|
||||
$out = array(
|
||||
"vc9" => array(
|
||||
"x86" => array(),
|
||||
"x64" => array(),
|
||||
),
|
||||
"vc11" => array(
|
||||
"x86" => array(),
|
||||
"x64" => array(),
|
||||
),
|
||||
"vc12" => array(
|
||||
"x86" => array(),
|
||||
"x64" => array(),
|
||||
),
|
||||
"vc14" => array(
|
||||
"x86" => array(),
|
||||
"x64" => array(),
|
||||
),
|
||||
);
|
||||
|
||||
$out = array();
|
||||
|
||||
foreach ($dirs as $path) {
|
||||
$dir = new DirectoryIterator($path);
|
||||
@@ -74,6 +72,13 @@ foreach ($dirs as $path) {
|
||||
$crt = $m[1];
|
||||
$arch = $m[2];
|
||||
|
||||
if (!isset($out[$crt])) {
|
||||
$out[$crt] = array();
|
||||
}
|
||||
if (!isset($out[$crt][$arch])) {
|
||||
$out[$crt][$arch] = array();
|
||||
}
|
||||
|
||||
$zip = new ZipArchive();
|
||||
|
||||
$zip->open($pathname);
|
||||
@@ -100,7 +105,7 @@ foreach ($dirs as $path) {
|
||||
}
|
||||
}
|
||||
|
||||
echo json_encode($out);
|
||||
echo json_encode($out, $flags);
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
|
||||
@@ -5,6 +5,8 @@ if "%PHP_SDK_OS_ARCH%"=="" (
|
||||
exit /b 3
|
||||
)
|
||||
|
||||
cmd /c "exit /b 0"
|
||||
|
||||
echo.
|
||||
|
||||
call %PHP_SDK_BIN_PATH%\phpsdk_version.bat
|
||||
@@ -22,9 +24,9 @@ if "%PHP_SDK_ARCH%"=="x64" (
|
||||
echo Build architecture: 32-bit
|
||||
)
|
||||
|
||||
echo Visual C++: %PHP_SDK_VC:~2%
|
||||
echo Visual C++: %PHP_SDK_VC_NUM%
|
||||
echo PHP-SDK path: %PHP_SDK_ROOT_PATH%
|
||||
|
||||
|
||||
exit /b
|
||||
exit /b %errorlevel%
|
||||
|
||||
|
||||
@@ -13,12 +13,34 @@ if "%1"=="-h" goto :help
|
||||
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
|
||||
)
|
||||
cmd /c "exit /b 0"
|
||||
|
||||
set PHP_SDK_VC=%1
|
||||
if /i not "%PHP_SDK_VC:~0,2%"=="vc" (
|
||||
:malformed_vc_string
|
||||
echo Malformed CRT string "%1"
|
||||
set PHP_SDK_VC=
|
||||
goto out_error
|
||||
)
|
||||
if ""=="%PHP_SDK_VC:~2%" (
|
||||
goto malformed_vc_string
|
||||
)
|
||||
set /a TMP_CHK=%PHP_SDK_VC:~2%
|
||||
if 14 gtr %TMP_CHK% (
|
||||
if "0"=="%TMP_CHK%" (
|
||||
if not "0"=="%PHP_SDK_VC:~2%" (
|
||||
set TMP_CHK=
|
||||
goto malformed_vc_string
|
||||
)
|
||||
)
|
||||
|
||||
echo At least vc14 is required
|
||||
set PHP_SDK_VC=
|
||||
set TMP_CHK=
|
||||
goto out_error
|
||||
)
|
||||
set PHP_SDK_VC_NUM=%TMP_CHK%
|
||||
set TMP_CHK=
|
||||
|
||||
if /i not "%2"=="x64" (
|
||||
if /i not "%2"=="x86" (
|
||||
@@ -27,7 +49,6 @@ if /i not "%2"=="x64" (
|
||||
)
|
||||
)
|
||||
|
||||
set PHP_SDK_VC=%1
|
||||
set PHP_SDK_ARCH=%2
|
||||
|
||||
rem check OS arch
|
||||
@@ -45,7 +66,7 @@ if not errorlevel 1 (
|
||||
set TMPKEY=
|
||||
|
||||
rem get vc base dir
|
||||
if /i "%1"=="vc14" (
|
||||
if 15 gtr %PHP_SDK_VC_NUM% (
|
||||
if /i "%PHP_SDK_OS_ARCH%"=="x64" (
|
||||
set TMPKEY=HKLM\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\%PHP_SDK_VC:~2%.0\Setup\VC
|
||||
) else (
|
||||
@@ -59,37 +80,49 @@ if /i "%1"=="vc14" (
|
||||
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
|
||||
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
|
||||
if not exist "!PHP_SDK_VC_DIR!" (
|
||||
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=
|
||||
|
||||
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 15 gtr %PHP_SDK_VC_NUM% (
|
||||
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 not defined PHP_SDK_WIN_SDK_DIR (
|
||||
echo Windows SDK not found.
|
||||
goto out_error;
|
||||
)
|
||||
set TMPKEY=
|
||||
|
||||
|
||||
if /i "%PHP_SDK_ARCH%"=="x64" (
|
||||
if /i "%1"=="vc14" (
|
||||
if 15 gtr %PHP_SDK_VC_NUM% (
|
||||
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 (
|
||||
if /i "%1"=="vc14" (
|
||||
if 15 gtr %PHP_SDK_VC_NUM% (
|
||||
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
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
@echo off
|
||||
|
||||
cmd /c "exit /b 0"
|
||||
|
||||
rem Add necessary dirs to the path
|
||||
|
||||
set PHP_SDK_BIN_PATH=%~dp0
|
||||
@@ -15,5 +17,5 @@ set PHP_SDK_PHP_CMD=%PHP_SDK_BIN_PATH%\php\do_php.bat
|
||||
|
||||
set PATH=%PHP_SDK_BIN_PATH%;%PHP_SDK_MSYS2_PATH%;%PATH%
|
||||
|
||||
exit /b
|
||||
exit /b %errorlevel%
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
@echo off
|
||||
|
||||
cmd /c "exit /b 0"
|
||||
|
||||
if "%PHP_SDK_PHP_CMD%"=="" (
|
||||
call %~dp0phpsdk_setvars.bat
|
||||
if "!PHP_SDK_PHP_CMD!"=="" (
|
||||
@@ -10,5 +12,5 @@ if "%PHP_SDK_PHP_CMD%"=="" (
|
||||
|
||||
%PHP_SDK_PHP_CMD% -r "echo 'PHP SDK ' . file_get_contents(getenv('PHP_SDK_ROOT_PATH') . '\\VERSION');"
|
||||
|
||||
exit /b
|
||||
exit /b %errorlevel%
|
||||
|
||||
|
||||
BIN
bin/re2c.exe
BIN
bin/re2c.exe
Binary file not shown.
BIN
bin/vswhere.exe
BIN
bin/vswhere.exe
Binary file not shown.
@@ -1,5 +1,9 @@
|
||||
@echo off
|
||||
|
||||
rem edit if PGO scripts are present and are to be used
|
||||
rem set PHP_SDK_PGO_TOOLS_ROOT_PATH=%PHP_SDK_ROOT_PATH%\pgo
|
||||
rem set PATH=%PHP_SDK_PGO_TOOLS_ROOT_PATH%\bin;%PATH%
|
||||
|
||||
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
|
||||
|
||||
|
||||
@@ -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
|
||||
@@ -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, Lock};
|
||||
|
||||
class Manager
|
||||
{
|
||||
@@ -35,23 +32,33 @@ class Manager
|
||||
$this->series = $series;
|
||||
}/*}}}*/
|
||||
|
||||
protected function getTmpSeriesPath()
|
||||
protected function getTmpSeriesPath() : string
|
||||
{/*{{{*/
|
||||
return Config::getTmpDir() . DIRECTORY_SEPARATOR . $this->series->getname();
|
||||
}/*}}}*/
|
||||
|
||||
public function updatesAvailable() : bool
|
||||
{/*{{{*/
|
||||
return $this->series->updatesAvailable();
|
||||
return $this->series->updatesAvailable() || !file_exists(Config::getDepsLocalPath());
|
||||
}/*}}}*/
|
||||
|
||||
/* TODO and implement --force. */
|
||||
/* FIXME implement rollback */
|
||||
public function performUpdate(string &$msg = NULL)
|
||||
public function performUpdate(string &$msg = NULL, bool $force = false, bool $backup = true) : void
|
||||
{/*{{{*/
|
||||
if (!$this->updatesAvailable()) {
|
||||
$msg = "No updates are available";
|
||||
return;
|
||||
if (!$force) {
|
||||
if (!$this->updatesAvailable()) {
|
||||
$msg .= "No updates are available";
|
||||
return;
|
||||
}
|
||||
|
||||
$lock = new Lock(Config::getDepsLocalPath());
|
||||
if (!$lock->locked()) {
|
||||
$msg .= "Dependencies was updated by another process.";
|
||||
echo "Another process is updating same dependency path. I'm just going to wait for it to finish and then exit.", PHP_EOL;
|
||||
$lock->exclusive(true);
|
||||
unset($lock);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
$series_data = $this->series->getData();
|
||||
@@ -82,17 +89,32 @@ class Manager
|
||||
}
|
||||
|
||||
if (file_exists($this->path)) {
|
||||
$suffix = date("YmdHi");
|
||||
$new_path = "{$this->path}.$suffix";
|
||||
if ($backup) {
|
||||
$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'");
|
||||
/* This is fine, it's gonna be on the same drive. */
|
||||
if (!$this->mv($this->path, $new_path)) {
|
||||
if (!$force) {
|
||||
unset($lock);
|
||||
}
|
||||
throw new Exception("Unable to rename '{$this->path}' to '$new_path'");
|
||||
}
|
||||
} else {
|
||||
if (!$this->rm($this->path)) {
|
||||
if (!$force) {
|
||||
unset($lock);
|
||||
}
|
||||
throw new Exception("Unable to remove the current dependency dir at '{$this->path}'");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$up = dirname($this->path);
|
||||
if (!file_exists($up)) {
|
||||
if (!$this->md($up)) {
|
||||
if (!$force) {
|
||||
unset($lock);
|
||||
}
|
||||
throw new Exception("Unable to create '{$this->path}'");
|
||||
}
|
||||
}
|
||||
@@ -106,9 +128,17 @@ class Manager
|
||||
$this->series->cache();
|
||||
|
||||
/* save new series file, move the updated deps and backup the old ones, cleanup.*/
|
||||
$msg = "Updates performed successfully. " . PHP_EOL;
|
||||
if (isset($new_path)) {
|
||||
$msg .= "Old dependencies backed up into '$new_path'.";
|
||||
$msg .= "Updates performed successfully. " . PHP_EOL;
|
||||
if ($backup) {
|
||||
if (isset($new_path)) {
|
||||
$msg .= "Old dependencies backed up into '$new_path'.";
|
||||
}
|
||||
} else {
|
||||
$msg .= "No backup was created.";
|
||||
}
|
||||
|
||||
if (!$force) {
|
||||
unset($lock);
|
||||
}
|
||||
}/*}}}*/
|
||||
}
|
||||
@@ -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);
|
||||
}/*}}}*/
|
||||
@@ -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();
|
||||
@@ -36,6 +36,7 @@ class Cache
|
||||
return file_exists($this->getCacheablePath($path, $relative));
|
||||
}/*}}}*/
|
||||
|
||||
/* TODO Sometimes a timestamp comparison might make sense. */
|
||||
public function cachedContentDiffers(string $path, string $content, bool $relative = false) : bool
|
||||
{/*{{{*/
|
||||
$p = $this->getCacheablePath($path, $relative);
|
||||
@@ -50,16 +51,35 @@ 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);
|
||||
|
||||
if (strlen($content) !== file_put_contents($p, $content)) {
|
||||
$to_write = strlen($content);
|
||||
$wrote = 0;
|
||||
|
||||
$fd = fopen($p, "wb");
|
||||
|
||||
flock($fd, LOCK_EX);
|
||||
|
||||
do {
|
||||
$got = fwrite($fd, substr($content, $wrote));
|
||||
if (false == $got) {
|
||||
break;
|
||||
}
|
||||
$wrote += $got;
|
||||
} while ($wrote < $to_write);
|
||||
|
||||
flock($fd, LOCK_UN);
|
||||
|
||||
fclose($fd);
|
||||
|
||||
if ($to_write !== $wrote) {
|
||||
throw new Exception("Couldn't cache '$p'");
|
||||
}
|
||||
}/*}}}*/
|
||||
|
||||
public function getCachedContent(string $path, bool $relative = false)
|
||||
public function getCachedContent(string $path, bool $relative = false) : ?string
|
||||
{/*{{{*/
|
||||
$p = $this->getCacheablePath($path, $relative);
|
||||
|
||||
@@ -67,7 +87,7 @@ class Cache
|
||||
return file_get_contents($p);
|
||||
}
|
||||
|
||||
return "";
|
||||
return NULL;
|
||||
}/*}}}*/
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace SDK;
|
||||
|
||||
use SDK\Dependency\Fetcher;
|
||||
use SDK\Build\Dependency\Fetcher;
|
||||
use SDK\Cache;
|
||||
use SDK\Exception;
|
||||
|
||||
@@ -39,33 +39,84 @@ 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 execute cl.exe.");
|
||||
}
|
||||
|
||||
exec("cl.exe /? 2>&1", $out);
|
||||
|
||||
if (preg_match(",x64,", $out[0])) {
|
||||
self::setCurrentArchName("x64");
|
||||
} elseif (preg_match(",x86,", $out[0])) {
|
||||
self::setCurrentArchName("x86");
|
||||
} else {
|
||||
throw new Exception("Couldn't determine Arch.");
|
||||
}
|
||||
}
|
||||
|
||||
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 +144,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 +159,62 @@ 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;
|
||||
$found = false;
|
||||
|
||||
/* Try to figure out the branch. The worky scenarios are
|
||||
- CWD is in php-src
|
||||
- phpize is on the path
|
||||
FIXME for the dev package, there should be a php-config utility
|
||||
*/
|
||||
$fl = "main/php_version.h";
|
||||
$found = file_exists($fl);
|
||||
|
||||
if (!$found) {
|
||||
exec("where phpize", $out, $status);
|
||||
if (!$status) {
|
||||
$fl = dirname($out[0]) . DIRECTORY_SEPARATOR . "include" . DIRECTORY_SEPARATOR . $fl;
|
||||
$found = file_exists($fl);
|
||||
}
|
||||
}
|
||||
|
||||
if ($found) {
|
||||
$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,30 +223,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.");
|
||||
}
|
||||
|
||||
$crt = array_keys($branches[self::$currentBranchName])[0];
|
||||
if ($cur_crt != $crt) {
|
||||
throw new Exception("The passed CRT '$cur_crt' doesn't match any availbale for branch '" . self::$currentBranchName . "'");
|
||||
$cur_crt_usable = false;
|
||||
foreach (array_keys($branches[$current_branch_name]) as $crt) {
|
||||
if ($cur_crt == $crt) {
|
||||
$cur_crt_usable = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
$data = $branches[self::$currentBranchName][$cur_crt];
|
||||
if (!$cur_crt_usable) {
|
||||
throw new Exception("The passed CRT '$cur_crt' doesn't match any availbale for branch '$current_branch_name'");
|
||||
}
|
||||
$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. */
|
||||
@@ -175,7 +281,7 @@ class Config
|
||||
return self::$sdkNugetFeedUrl;
|
||||
}/*}}}*/
|
||||
|
||||
public static function getSdkPath()
|
||||
public static function getSdkPath() : string
|
||||
{/*{{{*/
|
||||
$path = getenv("PHP_SDK_ROOT_PATH");
|
||||
|
||||
@@ -202,12 +308,45 @@ class Config
|
||||
return file_get_contents($path);
|
||||
}/*}}}*/
|
||||
|
||||
public static function getDepsLocalPath()
|
||||
public static function getDepsLocalPath() : ?string
|
||||
{/*{{{*/
|
||||
if (NULL == self::$depsLocalPath) {
|
||||
if (file_exists("Makefile")) {
|
||||
$s = file_get_contents("Makefile");
|
||||
|
||||
if (preg_match(",PHP_BUILD=(.+),", $s, $m)) {
|
||||
if (isset($m[1])) {
|
||||
self::setDepsLocalPath(trim($m[1]));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (NULL == self::$depsLocalPath) {
|
||||
$tmp = dirname(getcwd()) . DIRECTORY_SEPARATOR . "deps";
|
||||
if (is_dir($tmp)) {
|
||||
self::setDepsLocalPath($tmp);
|
||||
}
|
||||
}
|
||||
|
||||
if (NULL == self::$depsLocalPath) {
|
||||
$tmp = realpath("../deps");
|
||||
if (is_dir($tmp)) {
|
||||
self::setDepsLocalPath($tmp);
|
||||
}
|
||||
}
|
||||
|
||||
if (NULL == self::$depsLocalPath) {
|
||||
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;
|
||||
}/*}}}*/
|
||||
|
||||
@@ -1,127 +1,163 @@
|
||||
<?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
|
||||
*/
|
||||
<?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;
|
||||
}/*}}}*/
|
||||
|
||||
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;
|
||||
}/*}}}*/
|
||||
}
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* End:
|
||||
* vim600: sw=4 ts=4 fdm=marker
|
||||
* vim<600: sw=4 ts=4
|
||||
*/
|
||||
|
||||
107
lib/php/libsdk/SDK/Lock.php
Normal file
107
lib/php/libsdk/SDK/Lock.php
Normal file
@@ -0,0 +1,107 @@
|
||||
<?php
|
||||
|
||||
namespace SDK;
|
||||
|
||||
use SDK\{Config, Exception};
|
||||
|
||||
class Lock
|
||||
{
|
||||
protected $fd;
|
||||
protected $fn;
|
||||
protected $locked = false;
|
||||
protected $wouldBlock = false;
|
||||
protected $shared = false;
|
||||
|
||||
public function __construct(string $tag, bool $auto = true, bool $autoShared = false)
|
||||
{/*{{{*/
|
||||
$hash = hash("sha256", $tag);
|
||||
$this->fn = Config::getTmpDir() . DIRECTORY_SEPARATOR . $hash . ".lock";
|
||||
|
||||
if ($auto) {
|
||||
if ($autoShared) {
|
||||
$this->shared();
|
||||
} else {
|
||||
$this->exclusive();
|
||||
}
|
||||
}
|
||||
}/*}}}*/
|
||||
|
||||
public function __destruct()
|
||||
{/*{{{*/
|
||||
$this->unlock();
|
||||
/* We don't really know no one else waits on the same lock yet.*/
|
||||
/*if (file_exists($this->fn) && !$this->shared) {
|
||||
@unlink($this->fn);
|
||||
}*/
|
||||
}/*}}}*/
|
||||
|
||||
public function shared(bool $block = false) : bool
|
||||
{/*{{{*/
|
||||
$flags = LOCK_SH;
|
||||
if (!$block) {
|
||||
$flags |= LOCK_NB;
|
||||
}
|
||||
|
||||
return $this->doLock($flags);
|
||||
}/*}}}*/
|
||||
|
||||
public function exclusive(bool $block = false) : bool
|
||||
{/*{{{*/
|
||||
$flags = LOCK_EX;
|
||||
if (!$block) {
|
||||
$flags |= LOCK_NB;
|
||||
}
|
||||
|
||||
return $this->doLock($flags);
|
||||
}/*}}}*/
|
||||
|
||||
protected function doLock(int $flags = LOCK_EX) : bool
|
||||
{/*{{{*/
|
||||
if ($this->locked) {
|
||||
/* Or throw an exception, as we don't know which lock type the outta world expected. */
|
||||
return true;
|
||||
}
|
||||
|
||||
$this->shared = $flags & LOCK_SH;
|
||||
if ($this->shared) {
|
||||
$this->fd = fopen($this->fn, "rb");
|
||||
} else {
|
||||
$this->fd = fopen($this->fn, "wb");
|
||||
}
|
||||
$this->locked = flock($this->fd, $flags, $this->wouldBlock);
|
||||
return $this->locked;
|
||||
}/*}}}*/
|
||||
|
||||
public function unlock() : bool
|
||||
{/*{{{*/
|
||||
if (!$this->locked) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$this->doLock(LOCK_UN);
|
||||
|
||||
fclose($this->fd);
|
||||
$this->fd = NULL;
|
||||
|
||||
return $this->locked;
|
||||
}/*}}}*/
|
||||
|
||||
public function locked() : bool
|
||||
{/*{{{*/
|
||||
return $this->locked;
|
||||
}/*}}}*/
|
||||
|
||||
public function wouldBlock() : bool
|
||||
{/*{{{*/
|
||||
return 1 === $this->wouldBlock;
|
||||
}/*}}}*/
|
||||
}
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* End:
|
||||
* vim600: sw=4 ts=4 fdm=marker
|
||||
* vim<600: sw=4 ts=4
|
||||
*/
|
||||
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.
BIN
msys2/usr/bin/msys-readline7.dll
Normal file
BIN
msys2/usr/bin/msys-readline7.dll
Normal file
Binary file not shown.
Binary file not shown.
BIN
msys2/usr/bin/msys-stdc++-6.dll
Normal file
BIN
msys2/usr/bin/msys-stdc++-6.dll
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
msys2/usr/bin/pwgen.exe
Normal file
BIN
msys2/usr/bin/pwgen.exe
Normal file
Binary file not shown.
BIN
msys2/usr/bin/re2c.exe
Normal file
BIN
msys2/usr/bin/re2c.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.
Binary file not shown.
Binary file not shown.
@@ -1,6 +1,6 @@
|
||||
# bison-i18n.m4 serial 2
|
||||
|
||||
dnl Copyright (C) 2005-2006, 2009-2013 Free Software Foundation, Inc.
|
||||
dnl Copyright (C) 2005-2006, 2009-2015 Free Software Foundation, Inc.
|
||||
|
||||
dnl This file is free software; the Free Software Foundation
|
||||
dnl gives unlimited permission to copy and/or distribute it,
|
||||
|
||||
@@ -52,7 +52,7 @@ into various formats.
|
||||
|
||||
-----
|
||||
|
||||
Copyright (C) 2002, 2008-2013 Free Software Foundation, Inc.
|
||||
Copyright (C) 2002, 2008-2015 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bison.
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
# Language-independent M4 Macros for Bison.
|
||||
|
||||
# Copyright (C) 2002, 2004-2013 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2002, 2004-2015 Free Software Foundation, Inc.
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@@ -437,7 +437,6 @@ m4_define([b4_symbol_action_location],
|
||||
# b4_symbol_action(SYMBOL-NUM, KIND)
|
||||
# ----------------------------------
|
||||
# Run the action KIND (destructor or printer) for SYMBOL-NUM.
|
||||
# Same as in C, but using references instead of pointers.
|
||||
m4_define([b4_symbol_action],
|
||||
[b4_symbol_if([$1], [has_$2],
|
||||
[b4_dollar_pushdef([(*yyvaluep)],
|
||||
@@ -1061,3 +1060,6 @@ b4_percent_define_ifdef([api.value.type],
|
||||
[['%s' and '%s' cannot be used together]],
|
||||
[%yacc],
|
||||
[%define api.value.type "union"])])])])
|
||||
|
||||
# api.value.union.name.
|
||||
b4_percent_define_check_kind([api.value.union.name], [keyword])
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
# C++ skeleton dispatching for Bison.
|
||||
|
||||
# Copyright (C) 2006-2007, 2009-2013 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2006-2007, 2009-2015 Free Software Foundation, Inc.
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
# C++ skeleton for Bison
|
||||
|
||||
# Copyright (C) 2002-2013 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2002-2015 Free Software Foundation, Inc.
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@@ -17,6 +17,11 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
# Sanity checks, before defaults installed by c.m4.
|
||||
b4_percent_define_ifdef([[api.value.union.name]],
|
||||
[b4_complain_at(b4_percent_define_get_loc([[api.value.union.name]]),
|
||||
[named %union is invalid in C++])])
|
||||
|
||||
m4_include(b4_pkgdatadir/[c.m4])
|
||||
|
||||
# b4_comment(TEXT, [PREFIX])
|
||||
@@ -169,9 +174,12 @@ m4_define([b4_public_types_declare],
|
||||
/// (External) token type, as returned by yylex.
|
||||
typedef token::yytokentype token_type;
|
||||
|
||||
/// Internal symbol number.
|
||||
/// Symbol type: an internal symbol number.
|
||||
typedef int symbol_number_type;
|
||||
|
||||
/// The symbol type number to denote an empty symbol.
|
||||
enum { empty_symbol = -2 };
|
||||
|
||||
/// Internal symbol number for tokens (subsumed by symbol_number_type).
|
||||
typedef ]b4_int_type_for([b4_translate])[ token_number_type;
|
||||
|
||||
@@ -204,8 +212,15 @@ m4_define([b4_public_types_declare],
|
||||
const semantic_type& v]b4_locations_if([,
|
||||
const location_type& l])[);
|
||||
|
||||
/// Destroy the symbol.
|
||||
~basic_symbol ();
|
||||
|
||||
/// Destroy contents, and record that is empty.
|
||||
void clear ();
|
||||
|
||||
/// Whether empty.
|
||||
bool empty () const;
|
||||
|
||||
/// Destructive move, \a s is emptied into this.
|
||||
void move (basic_symbol& s);
|
||||
|
||||
@@ -235,21 +250,23 @@ m4_define([b4_public_types_declare],
|
||||
/// Constructor from (external) token numbers.
|
||||
by_type (kind_type t);
|
||||
|
||||
/// Record that this symbol is empty.
|
||||
void clear ();
|
||||
|
||||
/// Steal the symbol type from \a that.
|
||||
void move (by_type& that);
|
||||
|
||||
/// The (internal) type number (corresponding to \a type).
|
||||
/// -1 when this symbol is empty.
|
||||
/// \a empty when empty.
|
||||
symbol_number_type type_get () const;
|
||||
|
||||
/// The token.
|
||||
token_type token () const;
|
||||
|
||||
enum { empty = 0 };
|
||||
|
||||
/// The symbol type.
|
||||
/// -1 when this symbol is empty.
|
||||
token_number_type type;
|
||||
/// \a empty_symbol when empty.
|
||||
/// An int, not token_number_type, to be able to store empty_symbol.
|
||||
int type;
|
||||
};
|
||||
|
||||
/// "External" symbols: returned by the scanner.
|
||||
@@ -318,9 +335,19 @@ m4_define([b4_public_types_define],
|
||||
template <typename Base>
|
||||
inline
|
||||
]b4_parser_class_name[::basic_symbol<Base>::~basic_symbol ()
|
||||
{
|
||||
clear ();
|
||||
}
|
||||
|
||||
template <typename Base>
|
||||
inline
|
||||
void
|
||||
]b4_parser_class_name[::basic_symbol<Base>::clear ()
|
||||
{]b4_variant_if([[
|
||||
// User destructor.
|
||||
symbol_number_type yytype = this->type_get ();
|
||||
basic_symbol<Base>& yysym = *this;
|
||||
(void) yysym;
|
||||
switch (yytype)
|
||||
{
|
||||
]b4_symbol_foreach([b4_symbol_destructor])dnl
|
||||
@@ -330,6 +357,15 @@ m4_define([b4_public_types_define],
|
||||
|
||||
// Type destructor.
|
||||
]b4_symbol_variant([[yytype]], [[value]], [[template destroy]])])[
|
||||
Base::clear ();
|
||||
}
|
||||
|
||||
template <typename Base>
|
||||
inline
|
||||
bool
|
||||
]b4_parser_class_name[::basic_symbol<Base>::empty () const
|
||||
{
|
||||
return Base::type_get () == empty_symbol;
|
||||
}
|
||||
|
||||
template <typename Base>
|
||||
@@ -347,7 +383,7 @@ m4_define([b4_public_types_define],
|
||||
// by_type.
|
||||
inline
|
||||
]b4_parser_class_name[::by_type::by_type ()
|
||||
: type (empty)
|
||||
: type (empty_symbol)
|
||||
{}
|
||||
|
||||
inline
|
||||
@@ -360,12 +396,19 @@ m4_define([b4_public_types_define],
|
||||
: type (yytranslate_ (t))
|
||||
{}
|
||||
|
||||
inline
|
||||
void
|
||||
]b4_parser_class_name[::by_type::clear ()
|
||||
{
|
||||
type = empty_symbol;
|
||||
}
|
||||
|
||||
inline
|
||||
void
|
||||
]b4_parser_class_name[::by_type::move (by_type& that)
|
||||
{
|
||||
type = that.type;
|
||||
that.type = empty;
|
||||
that.clear ();
|
||||
}
|
||||
|
||||
inline
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
# Common code for C-like languages (C, C++, Java, etc.)
|
||||
|
||||
# Copyright (C) 2012-2013 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2012-2015 Free Software Foundation, Inc.
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
# C skeleton dispatching for Bison.
|
||||
|
||||
# Copyright (C) 2006-2007, 2009-2013 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2006-2007, 2009-2015 Free Software Foundation, Inc.
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
# C M4 Macros for Bison.
|
||||
|
||||
# Copyright (C) 2002, 2004-2013 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2002, 2004-2015 Free Software Foundation, Inc.
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@@ -97,7 +97,8 @@ m4_define([b4_api_PREFIX],
|
||||
m4_define_default([b4_prefix], [b4_api_prefix])
|
||||
|
||||
# If the %union is not named, its name is YYSTYPE.
|
||||
m4_define_default([b4_union_name], [b4_api_PREFIX[]STYPE])
|
||||
b4_percent_define_default([[api.value.union.name]],
|
||||
[b4_api_PREFIX[][STYPE]])
|
||||
|
||||
|
||||
## ------------------------ ##
|
||||
@@ -560,15 +561,15 @@ b4_locations_if([, yylocationp])[]b4_user_args[);
|
||||
# b4_symbol_type_register(SYMBOL-NUM)
|
||||
# -----------------------------------
|
||||
# Symbol SYMBOL-NUM has a type (for variant) instead of a type-tag.
|
||||
# Extend the definition of %union's body with a field of that type,
|
||||
# and extend the symbol's "type" field to point to the field name,
|
||||
# instead of the type name.
|
||||
# Extend the definition of %union's body (b4_union_members) with a
|
||||
# field of that type, and extend the symbol's "type" field to point to
|
||||
# the field name, instead of the type name.
|
||||
m4_define([b4_symbol_type_register],
|
||||
[m4_define([b4_symbol($1, type_tag)],
|
||||
[b4_symbol_if([$1], [has_id],
|
||||
[b4_symbol([$1], [id])],
|
||||
[yytype_[]b4_symbol([$1], [number])])])dnl
|
||||
m4_append([b4_user_union_members],
|
||||
m4_append([b4_union_members],
|
||||
m4_expand([
|
||||
b4_symbol_tag_comment([$1])dnl
|
||||
b4_symbol([$1], [type]) b4_symbol([$1], [type_tag]);]))
|
||||
@@ -608,10 +609,9 @@ m4_copy_force([b4_symbol_value_union], [b4_symbol_value])
|
||||
])
|
||||
|
||||
|
||||
# ---------------- #
|
||||
# api.value.type. #
|
||||
# ---------------- #
|
||||
|
||||
# -------------------------- #
|
||||
# api.value.type = variant. #
|
||||
# -------------------------- #
|
||||
|
||||
# b4_value_type_setup_variant
|
||||
# ---------------------------
|
||||
@@ -686,11 +686,13 @@ typedef ]b4_percent_define_get([[api.value.type]])[ ]b4_api_PREFIX[STYPE;
|
||||
[m4_bmatch(b4_percent_define_get([[api.value.type]]),
|
||||
[union\|union-directive],
|
||||
[[#if ! defined ]b4_api_PREFIX[STYPE && ! defined ]b4_api_PREFIX[STYPE_IS_DECLARED
|
||||
typedef union ]b4_union_name[ ]b4_api_PREFIX[STYPE;
|
||||
union ]b4_union_name[
|
||||
]b4_percent_define_get_syncline([[api.value.union.name]])[
|
||||
union ]b4_percent_define_get([[api.value.union.name]])[
|
||||
{
|
||||
]b4_user_union_members[
|
||||
};
|
||||
]b4_percent_define_get_syncline([[api.value.union.name]])[
|
||||
typedef union ]b4_percent_define_get([[api.value.union.name]])[ ]b4_api_PREFIX[STYPE;
|
||||
# define ]b4_api_PREFIX[STYPE_IS_TRIVIAL 1
|
||||
# define ]b4_api_PREFIX[STYPE_IS_DECLARED 1
|
||||
#endif
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
# GLR skeleton for Bison
|
||||
|
||||
# Copyright (C) 2002-2013 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2002-2015 Free Software Foundation, Inc.
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@@ -178,9 +178,42 @@ m4_if(b4_skeleton, ["glr.c"],
|
||||
## Output files. ##
|
||||
## -------------- ##
|
||||
|
||||
# Unfortunately the order of generation between the header and the
|
||||
# implementation file matters (for glr.c) because of the current
|
||||
# implementation of api.value.type=union. In that case we still use a
|
||||
# union for YYSTYPE, but we generate the contents of this union when
|
||||
# setting up YYSTYPE. This is needed for other aspects, such as
|
||||
# defining yy_symbol_value_print, since we need to now the name of the
|
||||
# members of this union.
|
||||
#
|
||||
# To avoid this issue, just generate the header before the
|
||||
# implementation file. But we should also make them more independant.
|
||||
|
||||
# ----------------- #
|
||||
# The header file. #
|
||||
# ----------------- #
|
||||
|
||||
# glr.cc produces its own header.
|
||||
m4_if(b4_skeleton, ["glr.c"],
|
||||
[b4_defines_if(
|
||||
[b4_output_begin([b4_spec_defines_file])
|
||||
b4_copyright([Skeleton interface for Bison GLR parsers in C],
|
||||
[2002-2015])[
|
||||
|
||||
]b4_cpp_guard_open([b4_spec_defines_file])[
|
||||
]b4_shared_declarations[
|
||||
]b4_cpp_guard_close([b4_spec_defines_file])[
|
||||
]b4_output_end()
|
||||
])])
|
||||
|
||||
|
||||
# ------------------------- #
|
||||
# The implementation file. #
|
||||
# ------------------------- #
|
||||
|
||||
b4_output_begin([b4_parser_file_name])
|
||||
b4_copyright([Skeleton implementation for Bison GLR parsers in C],
|
||||
[2002-2013])[
|
||||
[2002-2015])[
|
||||
|
||||
/* C GLR parser skeleton written by Paul Hilfinger. */
|
||||
|
||||
@@ -2550,16 +2583,3 @@ m4_if(b4_prefix, [yy], [],
|
||||
|
||||
]b4_epilogue[]dnl
|
||||
b4_output_end()
|
||||
|
||||
# glr.cc produces its own header.
|
||||
m4_if(b4_skeleton, ["glr.c"],
|
||||
[b4_defines_if(
|
||||
[b4_output_begin([b4_spec_defines_file])
|
||||
b4_copyright([Skeleton interface for Bison GLR parsers in C],
|
||||
[2002-2013])[
|
||||
|
||||
]b4_cpp_guard_open([b4_spec_defines_file])[
|
||||
]b4_shared_declarations[
|
||||
]b4_cpp_guard_close([b4_spec_defines_file])[
|
||||
]b4_output_end()
|
||||
])])
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# C++ GLR skeleton for Bison
|
||||
|
||||
# Copyright (C) 2002-2013 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2002-2015 Free Software Foundation, Inc.
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@@ -329,7 +329,7 @@ b4_percent_define_flag_if([[global_tokens_and_yystype]],
|
||||
b4_defines_if(
|
||||
[b4_output_begin([b4_spec_defines_file])
|
||||
b4_copyright([Skeleton interface for Bison GLR parsers in C++],
|
||||
[2002-2013])[
|
||||
[2002-2015])[
|
||||
|
||||
// C++ GLR parser skeleton written by Akim Demaille.
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
# Java skeleton dispatching for Bison.
|
||||
|
||||
# Copyright (C) 2007, 2009-2013 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2007, 2009-2015 Free Software Foundation, Inc.
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
# Java language support for Bison
|
||||
|
||||
# Copyright (C) 2007-2013 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2007-2015 Free Software Foundation, Inc.
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# C++ skeleton for Bison
|
||||
|
||||
# Copyright (C) 2002-2013 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2002-2015 Free Software Foundation, Inc.
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@@ -131,7 +131,7 @@ m4_ifdef([b4_lex_param], [, ]b4_lex_param))])])
|
||||
|
||||
|
||||
m4_pushdef([b4_copyright_years],
|
||||
[2002-2013])
|
||||
[2002-2015])
|
||||
|
||||
m4_define([b4_parser_class_name],
|
||||
[b4_percent_define_get([[parser_class_name]])])
|
||||
@@ -149,10 +149,11 @@ b4_variant_if([m4_include(b4_pkgdatadir/[variant.hh])])
|
||||
m4_define([b4_shared_declarations],
|
||||
[b4_percent_code_get([[requires]])[
|
||||
]b4_parse_assert_if([# include <cassert>])[
|
||||
# include <vector>
|
||||
# include <cstdlib> // std::abort
|
||||
# include <iostream>
|
||||
# include <stdexcept>
|
||||
# include <string>]b4_defines_if([[
|
||||
# include <string>
|
||||
# include <vector>]b4_defines_if([[
|
||||
# include "stack.hh"
|
||||
]b4_bison_locations_if([[# include "location.hh"]])])[
|
||||
]b4_variant_if([b4_variant_includes])[
|
||||
@@ -214,9 +215,9 @@ b4_location_define])])[
|
||||
|
||||
/// Generate an error message.
|
||||
/// \param yystate the state where the error occurred.
|
||||
/// \param yytoken the lookahead token type, or yyempty_.
|
||||
/// \param yyla the lookahead token.
|
||||
virtual std::string yysyntax_error_ (state_type yystate,
|
||||
symbol_number_type yytoken) const;
|
||||
const symbol_type& yyla) const;
|
||||
|
||||
/// Compute post-reduction state.
|
||||
/// \param yystate the current state
|
||||
@@ -288,16 +289,21 @@ b4_location_define])])[
|
||||
/// Copy constructor.
|
||||
by_state (const by_state& other);
|
||||
|
||||
/// Record that this symbol is empty.
|
||||
void clear ();
|
||||
|
||||
/// Steal the symbol type from \a that.
|
||||
void move (by_state& that);
|
||||
|
||||
/// The (internal) type number (corresponding to \a state).
|
||||
/// "empty" when empty.
|
||||
/// \a empty_symbol when empty.
|
||||
symbol_number_type type_get () const;
|
||||
|
||||
enum { empty = 0 };
|
||||
/// The state number used to denote an empty symbol.
|
||||
enum { empty_state = -1 };
|
||||
|
||||
/// The state.
|
||||
/// \a empty when empty.
|
||||
state_type state;
|
||||
};
|
||||
|
||||
@@ -338,13 +344,12 @@ b4_location_define])])[
|
||||
/// Pop \a n symbols the three stacks.
|
||||
void yypop_ (unsigned int n = 1);
|
||||
|
||||
// Constants.
|
||||
/// Constants.
|
||||
enum
|
||||
{
|
||||
yyeof_ = 0,
|
||||
yylast_ = ]b4_last[, ///< Last index in yytable_.
|
||||
yynnts_ = ]b4_nterms_number[, ///< Number of nonterminal symbols.
|
||||
yyempty_ = -2,
|
||||
yyfinal_ = ]b4_final_state_number[, ///< Termination state number.
|
||||
yyterror_ = 1,
|
||||
yyerrcode_ = 256,
|
||||
@@ -464,7 +469,7 @@ m4_if(b4_prefix, [yy], [],
|
||||
#endif // !]b4_api_PREFIX[DEBUG
|
||||
|
||||
#define yyerrok (yyerrstatus_ = 0)
|
||||
#define yyclearin (yyempty = true)
|
||||
#define yyclearin (yyla.clear ())
|
||||
|
||||
#define YYACCEPT goto yyacceptlab
|
||||
#define YYABORT goto yyabortlab
|
||||
@@ -533,7 +538,7 @@ m4_if(b4_prefix, [yy], [],
|
||||
// by_state.
|
||||
inline
|
||||
]b4_parser_class_name[::by_state::by_state ()
|
||||
: state (empty)
|
||||
: state (empty_state)
|
||||
{}
|
||||
|
||||
inline
|
||||
@@ -541,12 +546,19 @@ m4_if(b4_prefix, [yy], [],
|
||||
: state (other.state)
|
||||
{}
|
||||
|
||||
inline
|
||||
void
|
||||
]b4_parser_class_name[::by_state::clear ()
|
||||
{
|
||||
state = empty_state;
|
||||
}
|
||||
|
||||
inline
|
||||
void
|
||||
]b4_parser_class_name[::by_state::move (by_state& that)
|
||||
{
|
||||
state = that.state;
|
||||
that.state = empty;
|
||||
that.clear ();
|
||||
}
|
||||
|
||||
inline
|
||||
@@ -558,7 +570,10 @@ m4_if(b4_prefix, [yy], [],
|
||||
]b4_parser_class_name[::symbol_number_type
|
||||
]b4_parser_class_name[::by_state::type_get () const
|
||||
{
|
||||
return state == empty ? 0 : yystos_[state];
|
||||
if (state == empty_state)
|
||||
return empty_symbol;
|
||||
else
|
||||
return yystos_[state];
|
||||
}
|
||||
|
||||
inline
|
||||
@@ -574,7 +589,7 @@ m4_if(b4_prefix, [yy], [],
|
||||
[value], [move], [that.value])],
|
||||
[[value = that.value;]])[
|
||||
// that is emptied.
|
||||
that.type = empty;
|
||||
that.type = empty_symbol;
|
||||
}
|
||||
|
||||
inline
|
||||
@@ -611,6 +626,10 @@ m4_if(b4_prefix, [yy], [],
|
||||
std::ostream& yyoutput = yyo;
|
||||
YYUSE (yyoutput);
|
||||
symbol_number_type yytype = yysym.type_get ();
|
||||
// Avoid a (spurious) G++ 4.8 warning about "array subscript is
|
||||
// below array bounds".
|
||||
if (yysym.empty ())
|
||||
std::abort ();
|
||||
yyo << (yytype < yyntokens_ ? "token" : "nterm")
|
||||
<< ' ' << yytname_[yytype] << " ("]b4_locations_if([
|
||||
<< yysym.location << ": "])[;
|
||||
@@ -695,9 +714,6 @@ m4_if(b4_prefix, [yy], [],
|
||||
int
|
||||
]b4_parser_class_name[::parse ()
|
||||
{
|
||||
/// Whether yyla contains a lookahead.
|
||||
bool yyempty = true;
|
||||
|
||||
// State.
|
||||
int yyn;
|
||||
/// Length of the RHS of the rule being reduced.
|
||||
@@ -754,7 +770,7 @@ b4_dollar_popdef])[]dnl
|
||||
goto yydefault;
|
||||
|
||||
// Read a lookahead token.
|
||||
if (yyempty)
|
||||
if (yyla.empty ())
|
||||
{
|
||||
YYCDEBUG << "Reading a token: ";
|
||||
try
|
||||
@@ -768,7 +784,6 @@ b4_dollar_popdef])[]dnl
|
||||
error (yyexc);
|
||||
goto yyerrlab1;
|
||||
}
|
||||
yyempty = false;
|
||||
}
|
||||
YY_SYMBOL_PRINT ("Next token is", yyla);
|
||||
|
||||
@@ -788,9 +803,6 @@ b4_dollar_popdef])[]dnl
|
||||
goto yyreduce;
|
||||
}
|
||||
|
||||
// Discard the token being shifted.
|
||||
yyempty = true;
|
||||
|
||||
// Count tokens shifted since error; after three, turn off error status.
|
||||
if (yyerrstatus_)
|
||||
--yyerrstatus_;
|
||||
@@ -873,8 +885,7 @@ b4_dollar_popdef])[]dnl
|
||||
{
|
||||
++yynerrs_;
|
||||
error (]b4_join(b4_locations_if([yyla.location]),
|
||||
[[yysyntax_error_ (yystack_[0].state,
|
||||
yyempty ? yyempty_ : yyla.type_get ())]])[);
|
||||
[[yysyntax_error_ (yystack_[0].state, yyla)]])[);
|
||||
}
|
||||
|
||||
]b4_locations_if([[
|
||||
@@ -887,10 +898,10 @@ b4_dollar_popdef])[]dnl
|
||||
// Return failure if at end of input.
|
||||
if (yyla.type_get () == yyeof_)
|
||||
YYABORT;
|
||||
else if (!yyempty)
|
||||
else if (!yyla.empty ())
|
||||
{
|
||||
yy_destroy_ ("Error: discarding", yyla);
|
||||
yyempty = true;
|
||||
yyla.clear ();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -966,7 +977,7 @@ b4_dollar_popdef])[]dnl
|
||||
goto yyreturn;
|
||||
|
||||
yyreturn:
|
||||
if (!yyempty)
|
||||
if (!yyla.empty ())
|
||||
yy_destroy_ ("Cleanup: discarding lookahead", yyla);
|
||||
|
||||
/* Do not reclaim the symbols of the rule whose action triggered
|
||||
@@ -986,7 +997,7 @@ b4_dollar_popdef])[]dnl
|
||||
<< std::endl;
|
||||
// Do not try to display the values of the reclaimed symbols,
|
||||
// as their printer might throw an exception.
|
||||
if (!yyempty)
|
||||
if (!yyla.empty ())
|
||||
yy_destroy_ (YY_NULLPTR, yyla);
|
||||
|
||||
while (1 < yystack_.size ())
|
||||
@@ -1008,10 +1019,9 @@ b4_dollar_popdef])[]dnl
|
||||
// Generate an error message.
|
||||
std::string
|
||||
]b4_parser_class_name[::yysyntax_error_ (]dnl
|
||||
b4_error_verbose_if([state_type yystate, symbol_number_type yytoken],
|
||||
[state_type, symbol_number_type])[) const
|
||||
b4_error_verbose_if([state_type yystate, const symbol_type& yyla],
|
||||
[state_type, const symbol_type&])[) const
|
||||
{]b4_error_verbose_if([[
|
||||
std::string yyres;
|
||||
// Number of reported tokens (one for the "unexpected", one per
|
||||
// "expected").
|
||||
size_t yycount = 0;
|
||||
@@ -1025,7 +1035,7 @@ b4_error_verbose_if([state_type yystate, symbol_number_type yytoken],
|
||||
the only way this function was invoked is if the default action
|
||||
is an error action. In that case, don't check for expected
|
||||
tokens because there are none.
|
||||
- The only way there can be no lookahead present (in yytoken) is
|
||||
- The only way there can be no lookahead present (in yyla) is
|
||||
if this state is a consistent state with a default action.
|
||||
Thus, detecting the absence of a lookahead is sufficient to
|
||||
determine that there is no unexpected or expected token to
|
||||
@@ -1045,8 +1055,9 @@ b4_error_verbose_if([state_type yystate, symbol_number_type yytoken],
|
||||
token that will not be accepted due to an error action in a
|
||||
later state.
|
||||
*/
|
||||
if (yytoken != yyempty_)
|
||||
if (!yyla.empty ())
|
||||
{
|
||||
int yytoken = yyla.type_get ();
|
||||
yyarg[yycount++] = yytname_[yytoken];
|
||||
int yyn = yypact_[yystate];
|
||||
if (!yy_pact_value_is_default_ (yyn))
|
||||
@@ -1089,6 +1100,7 @@ b4_error_verbose_if([state_type yystate, symbol_number_type yytoken],
|
||||
#undef YYCASE_
|
||||
}
|
||||
|
||||
std::string yyres;
|
||||
// Argument number.
|
||||
size_t yyi = 0;
|
||||
for (char const* yyp = yyformat; *yyp; ++yyp)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Java skeleton for Bison -*- autoconf -*-
|
||||
|
||||
# Copyright (C) 2007-2013 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2007-2015 Free Software Foundation, Inc.
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@@ -84,7 +84,7 @@ m4_define([b4_define_state],[[
|
||||
|
||||
b4_output_begin([b4_parser_file_name])
|
||||
b4_copyright([Skeleton implementation for Bison LALR(1) parsers in Java],
|
||||
[2007-2013])
|
||||
[2007-2015])
|
||||
|
||||
b4_percent_define_ifdef([package], [package b4_percent_define_get([package]);
|
||||
])[/* First part of user declarations. */
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# C++ skeleton for Bison
|
||||
|
||||
# Copyright (C) 2002-2013 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2002-2015 Free Software Foundation, Inc.
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@@ -16,7 +16,7 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
m4_pushdef([b4_copyright_years],
|
||||
[2002-2013])
|
||||
[2002-2015])
|
||||
|
||||
# b4_position_define
|
||||
# ------------------
|
||||
@@ -83,7 +83,7 @@ m4_define([b4_position_define],
|
||||
}
|
||||
};
|
||||
|
||||
/// Add and assign a position.
|
||||
/// Add \a width columns, in place.
|
||||
inline position&
|
||||
operator+= (position& res, int width)
|
||||
{
|
||||
@@ -91,21 +91,21 @@ m4_define([b4_position_define],
|
||||
return res;
|
||||
}
|
||||
|
||||
/// Add two position objects.
|
||||
/// Add \a width columns.
|
||||
inline position
|
||||
operator+ (position res, int width)
|
||||
{
|
||||
return res += width;
|
||||
}
|
||||
|
||||
/// Add and assign a position.
|
||||
/// Subtract \a width columns, in place.
|
||||
inline position&
|
||||
operator-= (position& res, int width)
|
||||
{
|
||||
return res += -width;
|
||||
}
|
||||
|
||||
/// Add two position objects.
|
||||
/// Subtract \a width columns.
|
||||
inline position
|
||||
operator- (position res, int width)
|
||||
{
|
||||
@@ -216,36 +216,42 @@ m4_define([b4_location_define],
|
||||
position end;
|
||||
};
|
||||
|
||||
/// Join two location objects to create a location.
|
||||
inline location operator+ (location res, const location& end)
|
||||
/// Join two locations, in place.
|
||||
inline location& operator+= (location& res, const location& end)
|
||||
{
|
||||
res.end = end.end;
|
||||
return res;
|
||||
}
|
||||
|
||||
/// Change end position in place.
|
||||
/// Join two locations.
|
||||
inline location operator+ (location res, const location& end)
|
||||
{
|
||||
return res += end;
|
||||
}
|
||||
|
||||
/// Add \a width columns to the end position, in place.
|
||||
inline location& operator+= (location& res, int width)
|
||||
{
|
||||
res.columns (width);
|
||||
return res;
|
||||
}
|
||||
|
||||
/// Change end position.
|
||||
/// Add \a width columns to the end position.
|
||||
inline location operator+ (location res, int width)
|
||||
{
|
||||
return res += width;
|
||||
}
|
||||
|
||||
/// Change end position in place.
|
||||
/// Subtract \a width columns to the end position, in place.
|
||||
inline location& operator-= (location& res, int width)
|
||||
{
|
||||
return res += -width;
|
||||
}
|
||||
|
||||
/// Change end position.
|
||||
inline location operator- (const location& begin, int width)
|
||||
/// Subtract \a width columns to the end position.
|
||||
inline location operator- (location res, int width)
|
||||
{
|
||||
return begin + -width;
|
||||
return res -= width;
|
||||
}
|
||||
]b4_percent_define_flag_if([[define_location_comparison]], [[
|
||||
/// Compare two location objects.
|
||||
@@ -273,8 +279,7 @@ m4_define([b4_location_define],
|
||||
operator<< (std::basic_ostream<YYChar>& ostr, const location& loc)
|
||||
{
|
||||
unsigned int end_col = 0 < loc.end.column ? loc.end.column - 1 : 0;
|
||||
ostr << loc.begin// << "(" << loc.end << ") "
|
||||
;
|
||||
ostr << loc.begin;
|
||||
if (loc.end.filename
|
||||
&& (!loc.begin.filename
|
||||
|| *loc.begin.filename != *loc.end.filename))
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# C++ skeleton for Bison
|
||||
|
||||
# Copyright (C) 2002-2013 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2002-2015 Free Software Foundation, Inc.
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@@ -16,7 +16,7 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
m4_pushdef([b4_copyright_years],
|
||||
[2002-2013])
|
||||
[2002-2015])
|
||||
|
||||
# b4_stack_define
|
||||
# ---------------
|
||||
@@ -32,12 +32,12 @@ m4_define([b4_stack_define],
|
||||
stack ()
|
||||
: seq_ ()
|
||||
{
|
||||
seq_.reserve (200);
|
||||
}
|
||||
|
||||
stack (unsigned int n)
|
||||
: seq_ (n)
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
inline
|
||||
T&
|
||||
@@ -114,8 +114,7 @@ m4_define([b4_stack_define],
|
||||
slice (const S& stack, unsigned int range)
|
||||
: stack_ (stack)
|
||||
, range_ (range)
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
inline
|
||||
const T&
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# C++ skeleton for Bison
|
||||
|
||||
# Copyright (C) 2002-2013 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2002-2015 Free Software Foundation, Inc.
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@@ -95,13 +95,13 @@ m4_define([b4_variant_define],
|
||||
|
||||
/// Empty construction.
|
||||
variant ()]b4_parse_assert_if([
|
||||
: yytname_ (YY_NULLPTR)])[
|
||||
: yytypeid_ (YY_NULLPTR)])[
|
||||
{}
|
||||
|
||||
/// Construct and fill.
|
||||
template <typename T>
|
||||
variant (const T& t)]b4_parse_assert_if([
|
||||
: yytname_ (typeid (T).name ())])[
|
||||
: yytypeid_ (&typeid (T))])[
|
||||
{
|
||||
YYASSERT (sizeof (T) <= S);
|
||||
new (yyas_<T> ()) T (t);
|
||||
@@ -110,7 +110,7 @@ m4_define([b4_variant_define],
|
||||
/// Destruction, allowed only if empty.
|
||||
~variant ()
|
||||
{]b4_parse_assert_if([
|
||||
YYASSERT (!yytname_);
|
||||
YYASSERT (!yytypeid_);
|
||||
])[}
|
||||
|
||||
/// Instantiate an empty \a T in here.
|
||||
@@ -118,9 +118,9 @@ m4_define([b4_variant_define],
|
||||
T&
|
||||
build ()
|
||||
{]b4_parse_assert_if([
|
||||
YYASSERT (!yytname_);
|
||||
YYASSERT (!yytypeid_);
|
||||
YYASSERT (sizeof (T) <= S);
|
||||
yytname_ = typeid (T).name ();])[
|
||||
yytypeid_ = & typeid (T);])[
|
||||
return *new (yyas_<T> ()) T;
|
||||
}
|
||||
|
||||
@@ -129,9 +129,9 @@ m4_define([b4_variant_define],
|
||||
T&
|
||||
build (const T& t)
|
||||
{]b4_parse_assert_if([
|
||||
YYASSERT (!yytname_);
|
||||
YYASSERT (!yytypeid_);
|
||||
YYASSERT (sizeof (T) <= S);
|
||||
yytname_ = typeid (T).name ();])[
|
||||
yytypeid_ = & typeid (T);])[
|
||||
return *new (yyas_<T> ()) T (t);
|
||||
}
|
||||
|
||||
@@ -140,7 +140,7 @@ m4_define([b4_variant_define],
|
||||
T&
|
||||
as ()
|
||||
{]b4_parse_assert_if([
|
||||
YYASSERT (yytname_ == typeid (T).name ());
|
||||
YYASSERT (*yytypeid_ == typeid (T));
|
||||
YYASSERT (sizeof (T) <= S);])[
|
||||
return *yyas_<T> ();
|
||||
}
|
||||
@@ -150,7 +150,7 @@ m4_define([b4_variant_define],
|
||||
const T&
|
||||
as () const
|
||||
{]b4_parse_assert_if([
|
||||
YYASSERT (yytname_ == typeid (T).name ());
|
||||
YYASSERT (*yytypeid_ == typeid (T));
|
||||
YYASSERT (sizeof (T) <= S);])[
|
||||
return *yyas_<T> ();
|
||||
}
|
||||
@@ -167,8 +167,8 @@ m4_define([b4_variant_define],
|
||||
void
|
||||
swap (self_type& other)
|
||||
{]b4_parse_assert_if([
|
||||
YYASSERT (yytname_);
|
||||
YYASSERT (yytname_ == other.yytname_);])[
|
||||
YYASSERT (yytypeid_);
|
||||
YYASSERT (*yytypeid_ == *other.yytypeid_);])[
|
||||
std::swap (as<T> (), other.as<T> ());
|
||||
}
|
||||
|
||||
@@ -198,7 +198,7 @@ m4_define([b4_variant_define],
|
||||
destroy ()
|
||||
{
|
||||
as<T> ().~T ();]b4_parse_assert_if([
|
||||
yytname_ = YY_NULLPTR;])[
|
||||
yytypeid_ = YY_NULLPTR;])[
|
||||
}
|
||||
|
||||
private:
|
||||
@@ -233,7 +233,7 @@ m4_define([b4_variant_define],
|
||||
} yybuffer_;]b4_parse_assert_if([
|
||||
|
||||
/// Whether the content is built: if defined, the name of the stored type.
|
||||
const char *yytname_;])[
|
||||
const std::type_info *yytypeid_;])[
|
||||
};
|
||||
]])
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<!--
|
||||
bison.xsl - common templates for Bison XSLT.
|
||||
|
||||
Copyright (C) 2007-2013 Free Software Foundation, Inc.
|
||||
Copyright (C) 2007-2015 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of Bison, the GNU Compiler Compiler.
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user