Compare commits

...

175 Commits

Author SHA1 Message Date
Anatol Belski
1048a4d346 Prepare 2.0.12 2017-10-26 19:30:06 +02:00
Anatol Belski
ed4f2d50d0 Reflect re2c version 2017-10-26 12:51:30 +02:00
Anatol Belski
75124abf52 Note about fetching 2017-10-25 22:55:32 +02:00
Anatol Belski
58d2c1a009 Add note about UNIX flavors 2017-10-25 22:53:41 +02:00
Anatol Belski
dfdea742dc Reflect bison version 2017-10-25 21:00:01 +02:00
Anatol Belski
0553f3219f Rephrase 2017-10-25 20:14:23 +02:00
Anatol Belski
2cbe03f44c Back to dev 2017-10-18 17:41:15 +02:00
Anatol Belski
550407fb29 Prepare beta3 2017-10-18 17:40:27 +02:00
Anatol Belski
dd4844b6d2 Rebase MSYS2 DLLs 2017-10-18 15:02:53 +02:00
Anatol Belski
ae51b4e28f Turn back to dev 2017-10-16 17:11:18 +02:00
Anatol Belski
6705c85ebd Prepare 2.0.12beta2 2017-10-16 17:10:09 +02:00
Anatol Belski
8fd8187d28 Add missing DLLs 2017-10-16 17:07:19 +02:00
Anatol Belski
353b184487 Back to dev 2017-10-11 20:23:01 +02:00
Anatol Belski
9345164d3a Prepare 2.0.12beta1 2017-10-11 20:21:32 +02:00
Anatol Belski
d2b2d58f84 Upgrade vswhere 2017-10-11 09:14:30 +02:00
Anatol Belski
9da65f2386 Upgrade msys2 tools
- re2c is upgraded manually to 1.0.2
2017-10-10 11:20:18 +02:00
Anatol Belski
1f48f48b94 Back to dev 2017-09-15 23:01:39 +02:00
Anatol Belski
0cd8d902c0 2.0.11 2017-09-15 23:00:47 +02:00
Anatol Belski
c7c874e9b4 Improve messaging for locked dependency path 2017-09-15 10:47:22 +02:00
Anatol Belski
97112e4dd0 Refactor lock also wrt shared/exclusive 2017-09-15 10:36:13 +02:00
Anatol Belski
098f6457de Folds 2017-09-15 09:23:48 +02:00
Anatol Belski
a5afa11cff Integrate locking into the dep update process 2017-09-14 18:49:14 +02:00
Anatol Belski
6b58f91d9d Fix and improve lock class 2017-09-14 18:48:43 +02:00
Anatol Belski
bb5ff05cc5 Add locker class 2017-09-14 18:07:37 +02:00
Anatol Belski
4b51347c35 Lock while caching 2017-09-14 16:54:03 +02:00
Anatol Belski
7d48cafe29 Folds 2017-09-14 16:25:35 +02:00
Anatol Belski
d802183581 Adjust description 2017-09-05 12:45:08 +02:00
Anatol Belski
741063cdf1 Support branch recognition when working under dev package 2017-09-05 12:38:02 +02:00
Jerry
a97d0bd292 Fix Arch determintion 2017-09-01 15:52:35 +02:00
Anatol Belski
5507b37b7d Add pretty option 2017-08-29 10:46:39 +02:00
Anatol Belski
7c72855fd0 Rework dllmap script 2017-08-28 16:11:49 +02:00
Anatol Belski
b5829cd502 Note pwgen presence 2017-08-28 14:36:26 +02:00
Anatol Belski
de669c7610 Back to dev 2017-08-28 13:08:32 +02:00
Anatol Belski
f96fbeddab 2.0.10 2017-08-28 13:07:34 +02:00
Anatol Belski
ceececf83f Improve the pack command, show more info and translate the exit code 2017-08-28 13:05:18 +02:00
Anatol Belski
64c2ac973c Fix deps path recognition 2017-08-23 00:19:10 +02:00
Anatol Belski
79116d5051 add deps package command 2017-08-21 11:48:08 +02:00
Anatol Belski
c3bb9777bb reset errorlevel before tool run, set the current on exit 2017-08-21 10:49:42 +02:00
Anatol Belski
eae3aab2ae revert the deps path reset part and sync 2017-08-17 18:19:07 +02:00
Anatol Belski
e7e92b35d0 yet more path recognition variant 2017-08-17 16:33:32 +02:00
Anatol Belski
d158c3c032 add possibility to reevaluate the deps path 2017-08-17 16:17:47 +02:00
Anatol Belski
69fb69fd93 no realpath needed 2017-08-17 15:33:38 +02:00
Anatol Belski
aee165fe05 refactor dependency dir recognition 2017-08-17 14:06:01 +02:00
Anatol Belski
022333118e upgrade vswhere 2017-08-12 14:30:55 +02:00
Anatol Belski
821c0d7c73 extend .gitignore 2017-07-26 17:14:46 +02:00
Anatol Belski
7d72596e85 back to dev 2017-07-24 23:00:09 +02:00
Anatol Belski
2b317c62e1 prepare 2.0.9 2017-07-24 22:51:26 +02:00
Anatol Belski
61d589c424 sync with eol change 2017-07-24 11:07:16 +02:00
Anatol Belski
eaa6ff57fa add more file types for eol mitigation 2017-07-23 20:57:55 +02:00
Anatol Belski
5efd876bb3 extend redme 2017-07-23 20:55:09 +02:00
Dylan K. Taylor
0319dc061f add gitattributes 2017-07-23 20:41:19 +02:00
Anatol Belski
40fe451c8d add comment 2017-07-22 02:26:10 +02:00
Anatol Belski
55fddef1a3 back to dev 2017-07-20 21:57:07 +02:00
Anatol Belski
af769d9604 prepare 2.0.8 2017-07-20 21:56:22 +02:00
Anatol Belski
8e3d43905b Support also preview releases
But for now - only as a fallback if no other VS install could be found.
2017-07-13 11:15:38 +02:00
Anatol Belski
ebf3928220 upgrade bundled php 2017-07-12 15:51:42 +02:00
Anatol Belski
f96329c0fd back to dev 2017-07-10 21:39:46 +02:00
Anatol Belski
7cc831e6aa prepare 2.0.7 2017-07-10 21:38:56 +02:00
Anatol Belski
24e2464d8c improve branch name guessing 2017-07-10 12:02:17 +02:00
Anatol Belski
738abd255e fixed option handling, thanks Kalle 2017-07-08 18:55:06 +02:00
Anatol Belski
691d70fc09 upgrade to vswhere 2.0.2 2017-07-05 17:34:46 +02:00
Anatol Belski
412c512208 extend deps update comment 2017-06-29 00:02:19 +02:00
Anatol Belski
97a436c3fc task.exe commen 2017-06-28 23:54:56 +02:00
Anatol Belski
9e5e7e6c17 back to dev 2017-06-16 02:42:12 +02:00
Anatol Belski
e17b752c19 prepare 2.0.6 2017-06-16 02:40:35 +02:00
Jan-E
527b18189c Include CRT & ARCH in title
The command box has a title 'PHP SDK' now.
Make it descriptive like 'PHP SDK vc15 x86'
2017-06-16 02:38:27 +02:00
Anatol Belski
f4e3f68ce5 fix current arch setter 2017-06-16 02:34:57 +02:00
Anatol Belski
99efb73f17 back to dev 2017-06-05 20:40:43 +02:00
Anatol Belski
9d55fdee58 version up 2017-06-05 20:39:59 +02:00
Anatol Belski
492de099e7 forcibly propagate errorlevel
(cherry picked from commit 7d8bd88b029b3c05e072f77d2c287bee51f58672)
2017-06-05 14:02:14 +02:00
Anatol Belski
29453a9072 forcibly propagate errorlevel
(cherry picked from commit d2f3bb5245640e3f5a1b44530be3ed2df775ee53)
2017-06-05 14:01:54 +02:00
Anatol Belski
ac27d0e62e forcibly propagate exit code 2017-06-05 14:00:49 +02:00
Anatol Belski
d413fe0899 add license
(cherry picked from commit d2227d31799030334b0a635ea1fb0474dea23416)
2017-06-05 13:47:30 +02:00
Anatol Belski
bcb9c7346a group ns
(cherry picked from commit f1aeb9ac43dd817c0ac208714943162117329e3f)
2017-06-05 13:47:02 +02:00
Anatol Belski
43a11d2552 use curl for fetches
(cherry picked from commit f92a4b45a58f6969fdb139278157ff5556cc9879)
2017-06-05 13:45:30 +02:00
Anatol Belski
73eb340687 fix branch name recognition when no cli opt passed
(cherry picked from commit 09e01d62cb74aba6158943e0418c94f09e136248)
2017-06-05 13:45:14 +02:00
Anatol Belski
f4067b3439 group namespace 2017-05-22 15:51:43 +02:00
Anatol Belski
adfc922c09 don't ignore pgo 2017-05-22 15:47:18 +02:00
Anatol Belski
c8c80a07f7 more refactoring to simplify config 2017-05-22 13:22:06 +02:00
Anatol Belski
65bc0a8552 refactor config stuff 2017-05-22 12:47:42 +02:00
Anatol Belski
d46b74b51b remove comment that doesn't match anymore 2017-05-20 22:00:49 +02:00
Anatol Belski
af2134b486 improve error check 2017-05-20 17:43:32 +02:00
Anatol Belski
a2debffacc more on return type decls 2017-05-20 14:04:34 +02:00
Anatol Belski
ad14edb0bf next dev 2017-05-20 13:42:15 +02:00
Anatol Belski
6b9f6bd7e5 prepare 2.0.4 2017-05-20 13:41:21 +02:00
Anatol Belski
f33ebdf261 Revert "recognize pgo stuff automatically if it's put into a subdir"
This reverts commit 010ae42362.
2017-05-20 13:05:51 +02:00
Anatol Belski
079185a0d6 Revert "move pgo tools setup and do setup paths, etc. conditionally"
This reverts commit ffa802812b.
2017-05-20 13:05:43 +02:00
Anatol Belski
59c082a8f4 sync namespace 2017-05-20 12:51:48 +02:00
Anatol Belski
078554f4a6 update namespaces 2017-05-20 12:35:56 +02:00
Anatol Belski
f6e507fb5e more precise namespace 2017-05-20 12:28:03 +02:00
Anatol Belski
14df5a921a ups, this shouldn't have been here 2017-05-17 10:40:22 +02:00
Anatol Belski
7cc9c62cae make us also recognize pure build tools installation, too 2017-05-17 10:29:37 +02:00
Anatol Belski
7370f1c5b0 there could have been no backup for the very first deps fetch 2017-05-13 23:09:23 +02:00
Anatol Belski
bb745349a9 reuse msys2 certs for curl 2017-05-12 22:18:00 +02:00
Anatol Belski
a2277e746d extend .gitignore 2017-05-11 15:29:53 +02:00
Anatol Belski
c6bcad86e9 add pwgen utility 2017-05-11 15:24:19 +02:00
Anatol Belski
af74264b8f extend help msg 2017-05-11 01:58:37 +02:00
Anatol Belski
37fa9bb323 add mysqli to bundled php 2017-05-11 01:51:18 +02:00
Anatol Belski
d5d2cf1c9d upgrade bundled php 2017-05-10 15:56:32 +02:00
Anatol Belski
ffa802812b move pgo tools setup and do setup paths, etc. conditionally 2017-05-09 16:56:54 +02:00
Anatol Belski
010ae42362 recognize pgo stuff automatically if it's put into a subdir 2017-05-09 15:55:11 +02:00
Anatol Belski
bcd7690d78 Revert back to 14 as lowest to avoid WTFs
The tools won't act as expected on lower than 7.0, so spare the false
bug reports.
2017-05-09 14:52:02 +02:00
Anatol Belski
52932ecdeb 2.0.4 next 2017-05-08 19:30:23 +02:00
Anatol Belski
4074dc7e18 release 2.0.3 2017-05-08 19:29:44 +02:00
Anatol Belski
bef5693b20 Allow down to vc11
It still can be coupled with sdk 8.1, so while no particularly practical
for PHP, still might be useful. We still keep on vc14 as lowest for PHP.
2017-05-08 19:09:26 +02:00
Anatol Belski
09a5e2bedc cut off trailing slash, so unify with setvars part 2017-05-08 18:35:16 +02:00
Anatol Belski
49f6a761e2 improve path check for vc15+ 2017-05-08 18:32:23 +02:00
Anatol Belski
c385a12d58 further improvements to crt version checks 2017-05-08 18:21:54 +02:00
Anatol Belski
07546d9304 simplify 2017-05-08 18:09:18 +02:00
Anatol Belski
79da1ed7af improve crt version check 2017-05-08 18:07:33 +02:00
Anatol Belski
5ccdabeb39 fix crt version check, be future compatible 2017-05-08 17:36:24 +02:00
Anatol Belski
31291b5aba fix previous breach, get path before shifts 2017-05-08 16:43:22 +02:00
Anatol Belski
dc0a5cce5b rework starter, so no intermediate vars are left on the env 2017-05-08 16:39:32 +02:00
Anatol Belski
af67c49c46 extend local template 2017-05-08 16:06:38 +02:00
Anatol Belski
513dd29f8a back to dev 2017-04-26 16:34:24 +02:00
Anatol Belski
1a8c2e03b7 prepare for tag 2017-04-26 16:33:10 +02:00
Anatol Belski
866ffa7b3c upgrade vswhere 2017-04-26 16:09:49 +02:00
Anatol Belski
0b764877b2 add pgo subdir to ignore 2017-04-25 18:53:49 +02:00
Anatol Belski
9523a991d8 some more readme 2017-04-25 16:50:40 +02:00
Anatol Belski
b2e434d5a1 extend notes 2017-04-25 16:42:03 +02:00
Anatol Belski
42682a421b move actual vs. branch crt check to global stage 2017-04-25 15:24:52 +02:00
Anatol Belski
3dfcb7ccd1 bail out if the active crt is not what the branch tells 2017-04-25 12:34:44 +02:00
Anatol Belski
b79e4ba51b update tag name 2017-04-24 22:33:42 +02:00
Anatol Belski
1ce16ca360 back to dev 2017-04-24 19:43:36 +02:00
Anatol Belski
80e2aec078 prepare version for tag 2017-04-24 19:42:07 +02:00
Anatol Belski
f88e36cc2b implement phpsdk_deps --no-backup 2017-04-24 19:32:13 +02:00
Anatol Belski
524f27bd17 change msg 2017-04-24 19:19:52 +02:00
Anatol Belski
e0d0c67953 implement --force for deps update 2017-04-16 13:59:35 +02:00
Anatol Belski
6c2eee890e missed that 2017-04-15 01:01:48 +02:00
Anatol Belski
1e51c38c22 upgrade bundled php to 7.1.4 2017-04-13 14:37:10 +02:00
Anatol Belski
14c2e7f32e replace custom re2c build by msys2 pkg 2017-04-02 22:36:35 +02:00
Anatol Belski
2329abeefb upgrade bison to 3.0.4 2017-04-02 16:49:36 +02:00
Anatol Belski
0050de4131 wrong link syntax 2017-03-30 17:59:33 +02:00
Anatol Belski
71cf47f6f2 explicitly mention legacy branch 2017-03-30 17:58:44 +02:00
Anatol Belski
4abd44bae4 and back to dev 2017-03-30 17:55:08 +02:00
Anatol Belski
d552f7118b reached first stable, 2.0.0 final 2017-03-30 17:53:34 +02:00
Anatol Belski
f77a7e791a Merge branch 'new_binary_tools'
* new_binary_tools: (141 commits)
  yet more reword
  typo
  rephrase readme
  bump version
  improve crt usability check with multiple choices
  fix condition
  don't check for sdk 8.1 for vc15 and up, only vc14 is relevant
  extend readme with vc15 support
  version++
  add new line
  add dedicated vc15 starter scripts
  vc15 support, more to follow
  add vswhere
  add lemon to the list
  beta2 now
  prepare for beta1
  provide lemon
  upgrade to 7.1.0, seems fine so far
  downgrade the bundled to 7.0.12 for now
  fix graceful exit
  ...
2017-03-30 17:48:38 +02:00
Anatol Belski
024c694807 yet more reword 2017-03-30 01:48:53 +02:00
Anatol Belski
5c7c222e8f typo 2017-03-30 01:42:39 +02:00
Anatol Belski
9fe493edf7 rephrase readme 2017-03-30 01:42:09 +02:00
Anatol Belski
5d51577cd5 bump version 2017-03-20 15:39:32 +01:00
Anatol Belski
cad50539cf improve crt usability check with multiple choices 2017-03-20 15:38:07 +01:00
Anatol Belski
6b50dabf00 fix condition 2017-03-13 18:39:15 +01:00
Anatol Belski
f5f5620c55 don't check for sdk 8.1 for vc15 and up, only vc14 is relevant 2017-03-13 18:22:19 +01:00
Anatol Belski
139ea9a86d extend readme with vc15 support 2017-03-09 15:29:12 +01:00
Anatol Belski
cf054fd362 version++ 2017-03-09 15:28:22 +01:00
Anatol Belski
2635a7936a add new line 2017-03-08 12:12:57 +01:00
Anatol Belski
9414d3a55c add dedicated vc15 starter scripts 2017-03-08 11:58:52 +01:00
Anatol Belski
36f67d7cce vc15 support, more to follow 2017-03-08 02:46:46 +01:00
Anatol Belski
e5b9fb320c add vswhere 2017-03-07 21:57:59 +01:00
Anatol Belski
edb52f1c34 add lemon to the list 2017-01-03 22:31:10 +01:00
Anatol Belski
aeeddd2e34 beta2 now 2017-01-03 20:47:26 +01:00
Anatol Belski
0236c6ec39 prepare for beta1 2017-01-03 20:44:30 +01:00
Anatol Belski
7eaaa4b6e9 provide lemon 2016-12-17 22:19:39 +01:00
Anatol Belski
72c2c103bc upgrade to 7.1.0, seems fine so far 2016-12-09 16:45:28 +01:00
Anatol Belski
71bf098e04 downgrade the bundled to 7.0.12 for now 2016-12-07 12:54:30 +01:00
Anatol Belski
b693b485b7 fix graceful exit 2016-11-28 17:28:42 +01:00
Anatol Belski
a4ab6b98d8 make php verbose 2016-11-28 16:39:14 +01:00
Anatol Belski
833eb864e8 alpha7 now 2016-11-21 18:03:22 +01:00
Anatol Belski
b56aa4c288 don't dump env for task build 2016-11-19 19:20:07 +01:00
Anatol Belski
9dc14d6f1e accept also task arguments 2016-11-19 16:49:39 +01:00
Anatol Belski
9134ee4718 upgrade PHP and add ext/mbstring needed for pickle 2016-11-16 20:19:17 +01:00
Anatol Belski
2849ea89a8 rename var for more clarity 2016-11-16 19:44:02 +01:00
Anatol Belski
c84a5d8303 rework the unattended build example 2016-11-16 19:16:21 +01:00
Anatol Belski
e350e99ba6 task could be also run, when the local setup doesn't exist 2016-11-16 18:58:49 +01:00
Anatol Belski
67bf1f579a add bsdtar 2016-11-16 18:48:27 +01:00
Anatol Belski
8fadf1d33d add deplister 2016-11-16 18:37:05 +01:00
Anatol Belski
f7d859266b add the standard set for tar/gz/bz2, etc. 2016-11-16 18:35:37 +01:00
Anatol Belski
c6c77737aa add tee 2016-11-16 17:49:46 +01:00
Anatol Belski
5ccc58cab5 improve wording 2016-11-16 16:47:20 +01:00
Anatol Belski
9c3d40ab02 extend the task script example 2016-11-15 14:10:26 +01:00
Anatol Belski
c0941efae5 extend on upgrading 2016-11-08 12:48:46 +01:00
Anatol Belski
49217155a3 clarify 2016-11-08 12:46:13 +01:00
Anatol Belski
b0f5cef8bd merge sentences 2016-11-08 12:44:14 +01:00
Anatol Belski
18d0b098ff version count up 2016-11-04 02:25:18 +01:00
123 changed files with 1145 additions and 602 deletions

7
.gitattributes vendored Normal file
View 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
View File

@@ -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
View File

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

228
README.md
View File

@@ -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
- `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`
- either run or click on `phpsdk-vc14-x64.bat` in the PHP SDK root
- `cd` to c:\php-sdk and click on `phpsdk-vc14-x64.bat` in the PHP SDK root
- `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 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 process.
## 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
# 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 and code 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.4, `re2c` 1.0.2, `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, MSYS2 or MinGW flavors are exposed in global PATH, it might cause issues. If it's unavoidable, ensure SDK preceeds it on the PATH.
- When fetching the binary SDK 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.

View File

@@ -1 +1 @@
2.0.0alpha5
2.0.12

BIN
bin/deplister.exe Normal file

Binary file not shown.

BIN
bin/lemon.exe Normal file

Binary file not shown.

View File

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

Binary file not shown.

Binary file not shown.

Binary file not shown.

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

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
bin/php/nghttp2.dll Normal file

Binary file not shown.

Binary file not shown.

View File

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

Binary file not shown.

Binary file not shown.

View File

@@ -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%

View File

@@ -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%

View File

@@ -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;

View File

@@ -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%

View File

@@ -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:

View File

@@ -5,6 +5,10 @@ if "%PHP_SDK_OS_ARCH%"=="" (
exit /b 3
)
cmd /c "exit /b 0"
echo.
call %PHP_SDK_BIN_PATH%\phpsdk_version.bat
echo.
@@ -20,9 +24,9 @@ if "%PHP_SDK_ARCH%"=="x64" (
echo Build architecture: 32-bit
)
echo Visual C++: %PHP_SDK_VC:~2%
echo PHP-SDK path: %PHP_SDK_PATH%
echo Visual C++: %PHP_SDK_VC_NUM%
echo PHP-SDK path: %PHP_SDK_ROOT_PATH%
exit /b
exit /b %errorlevel%

View File

@@ -13,10 +13,34 @@ if "%1"=="-h" goto :help
if "%1"=="--help" goto :help
if "%2"=="" goto :help
if /i not "%1"=="vc14" (
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" (
@@ -25,7 +49,6 @@ if /i not "%2"=="x64" (
)
)
set PHP_SDK_VC=%1
set PHP_SDK_ARCH=%2
rem check OS arch
@@ -43,41 +66,67 @@ if not errorlevel 1 (
set TMPKEY=
rem get vc base dir
if /i "%PHP_SDK_OS_ARCH%"=="x64" (
set TMPKEY=HKLM\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\%PHP_SDK_VC:~2%.0\Setup\VC
) else (
set TMPKEY=HKLM\SOFTWARE\Microsoft\VisualStudio\%PHP_SDK_VC:~2%.0\Setup\VC
)
reg query !TMPKEY! /v ProductDir >nul 2>&1
if errorlevel 1 (
echo Couldn't determine VC%PHP_SDK_VC:~2% directory
goto out_error;
)
for /f "tokens=2*" %%a in ('reg query !TMPKEY! /v ProductDir') do set PHP_SDK_VC_DIR=%%b
set TMPKEY=
rem get sdk dir
if /i "%PHP_SDK_OS_ARCH%"=="x64" (
set TMPKEY=HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Microsoft SDKs\Windows\v8.1
) else (
set TMPKEY=HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v8.1
)
for /f "tokens=2*" %%a in ('reg query "!TMPKEY!" /v InstallationFolder') do (
if exist "%%b\Include\um\Windows.h" (
set PHP_SDK_WIN_SDK_DIR=%%b
if 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 (
set TMPKEY=HKLM\SOFTWARE\Microsoft\VisualStudio\%PHP_SDK_VC:~2%.0\Setup\VC
)
)
if not defined PHP_SDK_WIN_SDK_DIR (
echo Windows SDK not found.
goto out_error;
reg query !TMPKEY! /v ProductDir >nul 2>&1
if errorlevel 1 (
echo Couldn't determine VC%PHP_SDK_VC:~2% directory
goto out_error;
)
for /f "tokens=2*" %%a in ('reg query !TMPKEY! /v ProductDir') do set PHP_SDK_VC_DIR=%%b
) else (
rem vc15 support only for now, could parse out and pass on later
for /f "tokens=1* delims=: " %%a in ('%~dp0\vswhere -nologo -version %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=
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 /i "%PHP_SDK_ARCH%"=="x64" (
set PHP_SDK_VC_SHELL_CMD="!PHP_SDK_VC_DIR!\vcvarsall.bat" amd64
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 (
set PHP_SDK_VC_SHELL_CMD="!PHP_SDK_VC_DIR!\vcvarsall.bat" x86
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
)
)
rem echo Visual Studio path %PHP_SDK_VC_DIR%

View File

@@ -1,19 +1,21 @@
@echo off
cmd /c "exit /b 0"
rem Add necessary dirs to the path
set PHP_SDK_BIN_PATH=%~dp0
rem remove trailing slash
set PHP_SDK_BIN_PATH=%PHP_SDK_BIN_PATH:~0,-1%
for %%a in ("%PHP_SDK_BIN_PATH%") do set PHP_SDK_PATH=%%~dpa
for %%a in ("%PHP_SDK_BIN_PATH%") do set PHP_SDK_ROOT_PATH=%%~dpa
rem remove trailing slash
set PHP_SDK_PATH=%PHP_SDK_PATH:~0,-1%
set PHP_SDK_ROOT_PATH=%PHP_SDK_ROOT_PATH:~0,-1%
set PHP_SDK_MSYS2_PATH=%PHP_SDK_PATH%\msys2\usr\bin
set PHP_SDK_MSYS2_PATH=%PHP_SDK_ROOT_PATH%\msys2\usr\bin
set PHP_SDK_PHP_CMD=%PHP_SDK_BIN_PATH%\php\do_php.bat
set PATH=%PHP_SDK_BIN_PATH%;%PHP_SDK_MSYS2_PATH%;%PATH%
exit /b
exit /b %errorlevel%

View File

@@ -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!"=="" (
@@ -8,7 +10,7 @@ if "%PHP_SDK_PHP_CMD%"=="" (
)
)
%PHP_SDK_PHP_CMD% -r "echo 'PHP SDK ' . file_get_contents(getenv('PHP_SDK_PATH') . '\\VERSION');"
%PHP_SDK_PHP_CMD% -r "echo 'PHP SDK ' . file_get_contents(getenv('PHP_SDK_ROOT_PATH') . '\\VERSION');"
exit /b
exit /b %errorlevel%

Binary file not shown.

BIN
bin/vswhere.exe Normal file

Binary file not shown.

View File

@@ -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

View File

@@ -6,12 +6,19 @@ rem Program/script: C:\php-sdk\bin\task.exe
rem Add arguments: "C:\php-sdk\phpsdk-starter.bat -c vc14 -a x64 -t C:\php-sdk\unattended-build-task.bat"
rem Run the task
set LOG_NAME=%PHP_SDK_VC%-%PHP_SDK_ARCH%-task.log
pushd C:\php-sdk\php70\vc14\x64\php-src
git pull --rebase
git pull --rebase > %LOG_NAME% 2>&1
nmake clean
nmake > vs.log 2>&1
call phpsdk_deps -u -s staging >> %LOG_NAME% 2>&1
call buildconf >> %LOG_NAME% 2>&1
call configure --enable-snapshot-build --enable-debug-pack >> %LOG_NAME% 2>&1
nmake clean >> %LOG_NAME% 2>&1
nmake >> %LOG_NAME% 2>&1
popd

View File

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

View File

@@ -1,11 +1,8 @@
<?php
namespace SDK\Dependency;
namespace SDK\Build\Dependency;
use SDK\Config;
use SDK\Cache;
use SDK\Exception;
use SDK\FileOps;
use SDK\{Config, Cache, Exception, FileOps, 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);
}
}/*}}}*/
}

View File

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

View File

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

View File

@@ -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;
}/*}}}*/
}

View File

@@ -2,7 +2,7 @@
namespace SDK;
use SDK\Dependency\Fetcher;
use SDK\Build\Dependency\Fetcher;
use SDK\Cache;
use SDK\Exception;
@@ -39,33 +39,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,12 +281,12 @@ class Config
return self::$sdkNugetFeedUrl;
}/*}}}*/
public static function getSdkPath()
public static function getSdkPath() : string
{/*{{{*/
$path = getenv("PHP_SDK_PATH");
$path = getenv("PHP_SDK_ROOT_PATH");
if (!$path) {
throw new Exception("PHP_SDK_PATH isn't set!");
throw new Exception("PHP_SDK_ROOT_PATH isn't set!");
}
$path = realpath($path);
@@ -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;
}/*}}}*/

View File

@@ -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
View 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.

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

Binary file not shown.

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

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

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

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

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

Binary file not shown.

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.

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

Binary file not shown.

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

Binary file not shown.

Binary file not shown.

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

Binary file not shown.

View File

@@ -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,

View File

@@ -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.

View File

@@ -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])

View File

@@ -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

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