Compare commits

...

209 Commits

Author SHA1 Message Date
Jean-Baptiste Nahan
53afca7edb Add header if API_TOKEN is present 2024-11-12 22:59:25 +01:00
Jean-Baptiste Nahan
96d8b2f49a change hostname and url to download in Config.php 2024-11-12 21:56:35 +01:00
Shivam Mathur
53d62894b7 Fix reading vs16 and newer dependencies in phpsdk_dllmap.php 2024-10-12 19:58:10 +00:00
Christoph M. Becker
f0b6aacb6a Update Nginx to 1.26.2 (GH-28)
That is the latest stable version, and certainly progress over Nginx
1.17.6 which has been released almost five years ago.
2024-09-04 12:37:31 +02:00
Christoph M. Becker
1cd2c55d47 Update vswhere to 3.1.7 (GH-18) 2024-09-04 12:35:22 +02:00
Christoph M. Becker
afa44a8ac6 Update php.ini for PGO for PHP >= 8.2 (GH-26)
ext/zip is no longer statically compiled as of PHP 8.2.0, but is needed
for several setup tasks; thus we load the shared extension.
2024-09-03 23:02:16 +02:00
Christoph M. Becker
dc48bef3a6 Upgrade bundled PHP to 8.3.9 (GH-20)
As of PHP 8.2.0, ext/zip is no longer statically available, but since
it is needed by the PHP SDK (e.g. too unpack the fetched dependencies),
we include the DLL, and load it in php.ini.
2024-08-28 20:39:40 +02:00
Christoph M. Becker
449a2092e0 Remove out-dated fixme comment
The composer version requirement has long been fixed[1], so we can drop
the respective comment also.

[1] <8583bb4f00>
2024-08-28 19:33:31 +02:00
Christoph M. Becker
4b1dbb58de Add type hints
Some are not as specific as they should be, and some may even be wrong,
but since these are only type hints (not type declarations) they won't
affect code execution, but rather provide some help to better understand
the code – for developers as well as tooling.
2024-08-25 20:12:43 +02:00
Christoph M. Becker
a047c663b9 Code clean-up (GH-22)
* Declare methods and instance variables in abstract classes

While PHP doesn't require this, it is good style, and makes the code
easier to reason about.

* Declare class variable

While `Config::getSdkNugetFeedUrl()` is not used from within the
project, and probably just was some experimental stuff, the method is
public, so we better keep it for now, but avoid reading an undeclared
class variable.

* Dodge from covariance warnings regarding Iterator for now

* Don't pass unnecessary arguments

These are retrieved from within the called functions, what *might* not
be the best idea, but it's what we have for now.

* Assert that $cb is actually a string before string conversion

In practice, it's either "copy" or "rename".

* Declare missing `Server::getPhp()`

* Remove unreachable code

* Ensure that `$crt` is defined

From looking at the code, it seems so, but let's make sure before
reading an undefined variable.

* Config::getDepsPort() returns an int

While that is changing the signature of a public method, it makes no
sense to return a string, and later to convert to int again.

* The abstract class TrainingCase is an Interfaces\TrainingCase

There shouldn't be the need for even having an interface (an abstract
class should be sufficient), but we keep the interface for now.
2024-08-25 18:03:45 +02:00
Christoph M. Becker
20d13baab2 Fix #23: Windows permissions incorrect after cloning (#24)
We set executable permissions for all .bat and .exe files.  This is
required for running in Cygwin shells, but generally considered good
style.
2024-08-21 20:53:15 +02:00
Christoph M. Becker
78c9f7b6d7 Fix reading series from cache if fetching fails
`Fetcher::getByUri()` returns a string (and since it is a public method
we don't want to change that for now), but we check for `false`; so we
change that.

We also use `file_exists()` instead of `Cache::isFileCached()` because
the method is actually called `Cache::fileIsCached()` but appears to be
broken due to applying `::getCacheablePath()` again.  Furthermore the
other methods of `Cache` also use `file_exists()` directly.  Since
`Cache::fileIsCached()` is public, we do not remove the otherwise
unused method yet.
2024-08-18 15:34:59 +02:00
Christoph M. Becker
8a4ca6589c Back to dev 2024-07-16 16:36:52 +02:00
Christoph M. Becker
8ae549bbbe Prepare 2.3.0 2024-07-16 16:35:46 +02:00
Christoph M. Becker
d683a0977f Add info about the release cycle to README.md (#17) 2024-07-16 18:40:07 +05:30
Shivam Mathur
b1e2870343 Add PHP 8.4 configs for PGO (#16) 2024-07-04 02:44:00 +05:30
Shivam Mathur
d1036b5b3d Add support for toolset (#15) 2024-05-25 17:29:56 +05:30
Jakub Zelenka
19c8ccbf07 Migrate sdk files to http://downloads.php.net/~windows/php-sdk (#5)
* Migrate sdk files to http://downloads.php.net/~windows/php-sdk

* Add some debugging

* Allow multiline package match
2024-03-27 17:09:19 +05:30
Christoph M. Becker
abe66fdf5b Add PHP 8.3 configs for PGO 2023-06-06 20:19:55 +02:00
Christoph M. Becker
775cf0dbfa Upgrade bundled PHP to 8.0.20 2022-08-09 15:54:38 +02:00
Christoph M. Becker
6ee0f9557b Fix x86 PGO builds wrt. 3a4163b0fa
PGO builds are not supported when cross-compiling, but our 32bit
production builds are supposed to be optimized.  We fix this by doing
native builds of x86 on amd64 architectures, what is supported due to
the WOW64 subsystem, and is what we did before anyway.
2022-04-03 13:49:03 +02:00
dixyes
3a4163b0fa Initial support for arm64 cross compilation
Closes GH-1.
2022-03-29 12:37:55 +02:00
Christoph M. Becker
cc7c11adad Support Visual Studio 2022 aka. VS17 2022-01-09 17:25:45 +01:00
Christoph M. Becker
d929b4aa7f Add PHP 8.2 configs for PGO 2022-01-09 13:25:14 +01:00
Christoph M. Becker
c56dfe3e27 Patch pgo01org training initialization
Cf. <https://github.com/intel/php_pgo_training_scripts/pull/5>.
2021-12-05 13:41:39 +01:00
Christoph M. Becker
33bbf07e51 php_gd2.dll is renamed to php_gd.dll as of PHP 8.0.0 2021-12-05 13:41:39 +01:00
Christoph M. Becker
f29db9b574 Add 8.1 configs for PGO 2021-12-05 13:41:38 +01:00
Christoph M. Becker
e88df96780 Disable JIT for now
Almost all requests fail with JIT enabled.
2021-12-05 13:41:38 +01:00
Christoph M. Becker
75fdf46b45 Deactivate unsupported PHP 8 PGO training cases 2021-12-05 13:41:37 +01:00
Christoph M. Becker
e93a98a22b Update repo links 2021-12-05 13:40:14 +01:00
Christoph M. Becker
a00a4ff668 Remove reference to MSFT Code of Conduct
Of course, people are still supposed to behave!
2021-12-05 13:37:23 +01:00
Christoph M. Becker
1bb6a4adb5 Update msys certs (#76) 2021-06-18 08:03:36 -07:00
Christoph M. Becker
7893436c79 Deactivate symfony_demo (#74)
Apparently, the phar based installation via get.symfony.com/symfony.phar
has finally been shut down.  So for now, we deactivate this training
case.

See also issue #73.
2021-02-02 09:06:13 -08:00
Christoph M. Becker
f6d81cff66 Fix syntax error in example batch script 2020-08-03 10:16:39 +02:00
Christoph M. Becker
571063120d Upgrade to PHP 7.4.4 (closes #67) 2020-04-06 16:55:59 +02:00
Christoph M. Becker
3562ee4586 Work around issue #69
For now we enforce HTTP/1.1, which *works*.
2020-04-06 16:55:07 +02:00
Christoph M. Becker
9d638cbb32 Upgrade to MariaDB 10.3.22 2020-04-06 10:45:54 +02:00
Christoph M. Becker
73c01dfa10 Add note regarding composer memory requirements 2020-04-06 10:43:46 +02:00
Christoph M. Becker
677fe52847 Fix typo in error message 2020-03-20 13:17:47 +01:00
Christoph M. Becker
2aef6dbdf2 Upgrade to Symfony Demo 1.5.1
Symfony 4 triggers functionality which is deprecated as of PHP 7.4.0.
2020-03-20 12:08:25 +01:00
Christoph M. Becker
37e9248d0f Upgrade bundled PHP to 7.3.13 2020-01-08 08:58:46 +01:00
Christoph M. Becker
b3f507b55f Link to Code of Conduct
Cf. <https://opensource.microsoft.com/codeofconduct/faq/#howadopt>.
2019-12-25 14:54:08 +01:00
Christoph M. Becker
743aedd52c Patch pgo01org training case
See intel/php_pgo_training_scripts#4.
2019-11-22 15:10:53 +01:00
Christoph M. Becker
1bb2ac6540 Upgrade PGO tools and apps 2019-11-21 16:25:17 +01:00
Christoph M. Becker
050caa59e5 Fix typo 2019-09-06 15:56:56 +02:00
Christoph M. Becker
27ea9be829 Back to dev 2019-08-27 13:29:56 +02:00
Christoph M. Becker
cb51b8f716 Prepare 2.2.0 2019-08-27 13:29:06 +02:00
Christoph M. Becker
77ae352d49 Update :create_all part of phpsdk_buildtree.bat 2019-06-05 16:25:38 +02:00
Anatol Belski
647f367c55 Sync year 2019-06-01 13:37:33 +02:00
Anatol Belski
3040efb46f Back to dev 2019-06-01 13:35:07 +02:00
Anatol Belski
d584b2f1c5 Prepare 2.2.0beta6 2019-06-01 13:34:07 +02:00
Anatol Belski
5c7a304e77 Reorder list 2019-06-01 13:32:45 +02:00
Anatol Belski
b3fffba01c Rework more, especially requirements 2019-06-01 13:31:45 +02:00
Anatol Belski
58a7bdcfa7 Missed comma 2019-06-01 13:27:34 +02:00
Anatol Belski
81aaa702b2 Rework the overview part 2019-06-01 13:26:06 +02:00
Anatol Belski
ccfc816560 Add vs2019 note 2019-06-01 13:04:05 +02:00
Anatol Belski
cf6ded7cec Update README 2019-06-01 13:01:12 +02:00
Anatol Belski
c73ab2dc76 Switch also to 64-bit PHP build for internal purposes 2019-06-01 12:57:49 +02:00
Anatol Belski
06e32545f5 Don't tell the name used is CRT 2019-05-23 17:51:21 +02:00
Christoph M. Becker
b8bf87b831 Get info from Config, which may get info from environment
There is no need to implement the detection logic in the PHP class;
instead we can get it from the Config object, where we try to get the
respective information from the environment, if not already set.
2019-05-22 19:18:50 +02:00
Christoph M. Becker
70ed1c2418 Fix phpsdk_pgo for multiple CRT support
If dependencies for multiple CRTs are available, phpsdk_pgo didn't know
which one to use, since Config::$currentCrtName is not initialized.
Instead of adding an argument to phpsdk_pgo, we simply get the CRT to
use from the environment.
2019-05-21 13:01:03 +02:00
Christoph M. Becker
8d1df4af8c Fix known branches detection
If there were vs16 packages listed in the series folder, the first
regex didn't parse these correctly, and if any vc packages were there,
the second regex was never executed.  We fix this by merging the two
regexs into one.
2019-05-19 16:08:14 +02:00
Anatol Belski
7050077f31 Add jq 2019-05-11 16:56:34 +02:00
Theodore Brown
94c9d6c97d Fix typos in readme 2019-05-10 08:50:42 +02:00
Christoph M. Becker
2dab4068aa Update download URLs
This saves a redirect, and might prevent download issues.
2019-04-30 10:33:48 +02:00
Christoph M. Becker
bbdc8dd597 Back to dev 2019-04-18 16:27:55 +02:00
Christoph M. Becker
e28c5e9b96 Prepare 2.2.0beta5 2019-04-18 16:24:57 +02:00
Christoph M. Becker
b359404509 Fix #58: Missing msys-crypto-1.1.dll
After discussion with @weltling, this time we only fix what is
definitely known to be broken, i.e. wget relying on OpenSSL 1.1 (which
does not work yet in msys2), the OpenSSL DLLs which have been x86
binaries, and finally we remove the gcc_s DLL which was also a x86
binary.
2019-04-16 23:38:44 +02:00
Christoph M. Becker
912853c55f Revert "Fix #58: Missing msys-crypto-1.1.dll"
This reverts commit 806f743f3c.
2019-04-16 23:31:05 +02:00
Christoph M. Becker
806f743f3c Fix #58: Missing msys-crypto-1.1.dll
While we're at it, we also bring all packages up to date.

Since wget 1.20.1-1 - 1.20.3-1 has issues with SSL, we're downgrading
to the latest working version, i.e. wget 1.19.5-1.
2019-04-16 19:35:37 +02:00
Christoph M. Becker
d13ff857f0 Back to dev 2019-04-08 12:44:33 +02:00
Christoph M. Becker
217ab7b4ca Prepare 2.2.0beta4 2019-04-08 12:42:25 +02:00
Anatol Belski
f740aface6 Remove unmatching sentence 2019-04-04 16:18:54 +02:00
Anatol Belski
f160e68fbc Update readme 2019-04-04 16:17:39 +02:00
Christoph M. Becker
9e3fcfdd77 Update phpsdk_rebase_msys2.cmd for x64 2019-04-04 15:06:29 +02:00
Christoph M. Becker
51d2eaa463 Upgrade msys2 to 64-bit
We update all existing packages right away.
2019-04-04 14:38:49 +02:00
Christoph M. Becker
15cc20920a Be more strict when looking for the desired VS (#56)
* Be more strict when looking for the desired VS

On systems where VS 2017 and VS 2019 are available, the starter script
may choose VS 2019 if vc15 is requested.  The documentation on vswhere
isn't particularly clear regarding the -version parameter, but it
states that a version range is expected.  Therefore we change the
shell setup script accordingly.

* Remove break constructs

These had been introduced to cater to multiple found VS installations,
to only use the first one.  Since the ranges are supposed to find only
a single installation, and since apparently the order of multiple
findings is not guaranteed, we remove the break constructs for better
readability of the source code.
2019-04-03 16:03:42 +02:00
Christoph M. Becker
df2eb74fee Fix phpsdk_deps
Rename `PHP_SDK_VC` to `PHP_SDK_VS` according to commit 76ede8f900.
2019-04-03 01:32:20 +02:00
Christoph M. Becker
f59fd45ee5 Don't repeat yourself
`Config::getCurrentStabilityName()` already retrieves the current
stability name, so there is no need to explicitly set it.
2019-03-31 14:37:17 +02:00
Christoph M. Becker
43107058f8 Work around old-style constructors in PGO training case
class.php of the pgo01org training case still uses PHP 4 style
constructors, which trigger deprecation notices and as such may
negatively affect the optimization.  Until this will be fixed upstream,
we're employing the workaround to modify the file during the PGO
initialization step.
2019-03-31 14:36:55 +02:00
Anatol Belski
b53316585a Fix var name 2019-03-31 13:19:05 +02:00
Anatol Belski
8b957129bd Fix loops 2019-03-31 13:05:27 +02:00
Anatol Belski
76ede8f900 Renames VC => VS
Rename starter scripts for 16
2019-03-31 12:51:55 +02:00
Anatol Belski
60cfe587d5 Show exact VC++ version 2019-03-11 16:30:07 +01:00
Anatol Belski
e6b4a0d34d Involve JIT in PGO training for master 2019-03-10 18:33:42 +01:00
Anatol Belski
dac0e43fec Add VS2019 command prompt starters 2019-02-24 20:08:23 +01:00
Anatol Belski
1d69f089ca Improve error handling on erroneous branch data 2019-02-21 19:33:12 +01:00
Anatol Belski
99112657d2 Update vswhere 2019-02-21 17:14:21 +01:00
Anatol Belski
7eaeba9e73 Back to dev 2019-02-11 22:24:57 -08:00
Anatol Belski
ad95ee0c7b Prepare 2.2.0beta3 2019-02-11 22:23:32 -08:00
Anatol Belski
55cdd86d3a Add missing bison files 2019-02-11 22:22:07 -08:00
Anatol Belski
1045633875 Back to dev 2019-02-11 22:10:05 -08:00
Anatol Belski
c6a2644a57 Prepare 2.2.0beta2 2019-02-11 22:09:08 -08:00
Anatol Belski
9ffa736cbc Update bison to 3.3.2 2019-02-11 21:59:18 -08:00
Anatol Belski
79fbcfee08 Upgrade bundled PHP to 7.3.2 2019-02-11 09:51:30 -08:00
Anatol Belski
f84b056d1c Make the major number optional and care about 8 2019-02-04 23:31:01 -08:00
Anatol Belski
0ab9b8ddc6 Add error check 2019-02-04 20:00:05 -08:00
Anatol Belski
794ef96470 Add 8.0 configs for PGO 2019-02-04 15:33:26 -08:00
Anatol Belski
cecf3df7f3 Back to dev 2019-01-12 22:05:55 +01:00
Anatol Belski
1e6ee7afaa Prepare 2.2.0beta1 2019-01-12 22:04:56 +01:00
Anatol Belski
05af1a3b06 Upgrade bundled PHP to 7.3.1 2019-01-12 18:41:21 +01:00
Anatol Belski
c748916f5c Back to dev
Also raise the version to 2.2.0 as some essential tool upgrades are to expect.
2019-01-12 16:17:01 +01:00
Anatol Belski
bebb84afd7 Prepare 2.1.10 2019-01-12 16:08:52 +01:00
Anatol Belski
841065efd4 One more version update 2019-01-08 17:57:31 +01:00
Anatol Belski
c726890170 Update versions in README 2019-01-08 17:55:26 +01:00
Anatol Belski
b2e52e36d8 Back to dev 2018-12-26 13:51:10 +01:00
Anatol Belski
b8713d8543 Prepare 2.1.10beta1 2018-12-26 13:49:56 +01:00
Anatol Belski
025290f6d3 Upgrade to re2c 1.1.1 2018-12-26 13:31:49 +01:00
Anatol Belski
1ed89bbba2 Upgrade to bison 3.2.4 2018-12-26 13:30:28 +01:00
Anatol Belski
1d4f4966af Convert eol 2018-09-29 21:01:31 +02:00
Anatol Belski
a5b1137938 Back to dev 2018-09-19 21:20:37 +02:00
Anatol Belski
908f5eeea7 Prepare 2.1.9 2018-09-19 21:19:41 +02:00
Anatol Belski
a7cc2823bf Back to dev 2018-09-12 12:04:30 +02:00
Anatol Belski
ff6a7245a3 Prepare 2.1.9beta1 2018-09-12 12:01:23 +02:00
Anatol Belski
9bb1377d59 Extend README 2018-09-10 17:26:47 +02:00
Anatol Belski
95d712bde7 Rebase MSYS2 DLLs 2018-09-10 17:22:44 +02:00
Anatol Belski
446f4272fe Add tool to rebase MSYS2 DLLs 2018-09-10 17:13:53 +02:00
Anatol Belski
f6b6bd96e0 Upgrade msys2 tools 2018-09-10 13:21:24 +02:00
Anatol Belski
94b3d07034 Upgrade grep 2018-09-10 12:12:14 +02:00
Anatol Belski
6797238516 Extend for MingW, too 2018-09-07 10:00:56 +02:00
Anatol Belski
02f2f372b6 Add note on child process debugging 2018-09-07 09:58:11 +02:00
Anatol Belski
04832718bb Extend debug notes 2018-09-07 09:47:03 +02:00
Anatol Belski
b52a0c281a Add note on debugging 2018-09-07 09:35:24 +02:00
Anatol Belski
bc3606fbaf Back to dev 2018-08-17 15:41:17 +02:00
Anatol Belski
41a63dc0b4 Prepare 2.1.8 2018-08-17 15:39:45 +02:00
Anatol Belski
99ae3ca016 Update MariaDB version 2018-08-17 12:35:35 +02:00
Anatol Belski
777542838c Update Nginx version 2018-08-17 12:35:01 +02:00
Anatol Belski
82987940a0 Update bundled PHP 2018-08-16 06:26:07 +02:00
Anatol Belski
45344d7691 Update wp-cli version 2018-08-16 06:21:57 +02:00
Anatol Belski
02a726256a Update Joomla version 2018-08-16 06:20:01 +02:00
Anatol Belski
0a7732ba09 Update Symfony demo version 2018-08-14 09:31:26 +02:00
Anatol Belski
8583bb4f00 Remove explicit composer requirement 2018-08-14 00:14:59 +02:00
Anatol Belski
d6fc46edfd Convert EOL 2018-08-08 16:16:38 +02:00
Anatol Belski
75740674e5 Extend the requirements note 2018-08-07 20:22:44 +02:00
Anatol Belski
e81199f9af Fix command 2018-08-07 17:55:42 +02:00
Anatol Belski
134556d419 Stick to a specific composer version
For now only, until Symfony demo app has fixed issues.
2018-08-07 17:22:18 +02:00
Anatol Belski
6121772665 Upgrade 7zip 2018-08-07 17:12:53 +02:00
Anatol Belski
61dff2296a Retry downloads 2018-08-07 15:46:00 +02:00
Gemorroj
1b8473489f some minor improvements drop unused imports, unused variables, dirname(__FILE__) -> __DIR__, cs fixes, ...
revert some non-obvious getters, explicit specification of abstract classes

null -> NULL

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

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

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

View File

@@ -1,4 +1,4 @@
Copyright 2017-2018 Anatol Belski
Copyright 2017-2019 Anatol Belski
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

108
README.md
View File

@@ -8,19 +8,26 @@ The PHP SDK itself and the SDK own tools and code are licensed under the BSD 2-C
# 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/Microsoft/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.
The toolset consists on a mix of the hand written scripts, selected MSYS2 parts and standalone programs. It supports any workflows, be it a custom, local or a CI build whatsoever.
The PHP SDK 2.2+ is compatible with PHP 7.2 and above.
The PHP SDK 2.1 is required to build PHP 7.1 or 7.0.
The legacy binary tools SDK is available from the [legacy branch](https://github.com/php/php-sdk-binary-tools/tree/legacy) and is suitable to build PHP 5.
# 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
- A 64-bit build host
- Windows 7 or later
- `Visual C++ 2017` or `Visual C++ 2019` must be installed prior SDK usage. Required components
- C++ dev
- Windows SDK
- .NET dev
- if `Cygwin`, `MingW` or any other cross solution is installed, please read notes in the pitfalls section
# 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-&lt;crt&gt;-&lt;arch&gt;.bat
@@ -33,8 +40,8 @@ All the tools included are either scripts or 32-bit binaries. They are therefore
## Other tools
- `bison` 3.0.4, `re2c` 1.0.3, `lemon`
- `awk`, `gawk`, `sed`, `grep`
- `bison` 3.3.2, `re2c` 1.1.1, `lemon`
- `awk`, `gawk`, `sed`, `grep`, `jq`
- `diff`, `diff3`, `patch`
- `md5sum`, `sha1sum`, `sha224sum`, `sha256sum`, `sha384sum`, `sha512sum`
- `7za`, `zip`, `unzip`, `unzipsfx`
@@ -52,7 +59,7 @@ These are not included with the PHP SDK, but might be useful. While Visual C++ i
# Usage
The PHP SDK should be unzipped into the shortest possible path, preferrably somewhere near the drive root.
The PHP SDK should be unzipped into the shortest possible path, preferably 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.
@@ -60,9 +67,9 @@ It is not required to hold the source in the PHP SDK directory. It could be usef
## Basic usage example
- `git clone https://github.com/Microsoft/php-sdk-binary-tools.git c:\php-sdk`
- `git clone https://github.com/php/php-sdk-binary-tools.git c:\php-sdk`
- `cd c:\php-sdk`
- `git checkout php-sdk-2.0.12` or later
- `git checkout php-sdk-2.1.9` or later
- invoke `phpsdk-vc15-x64.bat`
- `phpsdk_buildtree phpmaster`
- `git clone https://github.com/php/php-src.git && cd php-src`, or fetch a zipball
@@ -73,7 +80,7 @@ More extensive documentation can be found on the [wiki](https://wiki.php.net/int
## The old way
- `git clone https://github.com/Microsoft/php-sdk-binary-tools.git c:\php-sdk`
- `git clone https://github.com/php/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
@@ -115,7 +122,9 @@ As of the version 2.1.0, the SDK includes a tool for the [PGO](https://docs.micr
## Preparing PGO training environment
- the pgo folder in the SDK root dir contains templates and scenarios for PGO training
- adjust and execute [doc/phpsdk_pgo_prep_elevated.bat.example](doc/phpsdk_pgo_prep_elevated.bat.example) to open ports required for PHP SDK training servers
- run `phpsdk_pgo --init`
- run `phpsdk_pgo --init`. Note that composer requires huge amounts of memory, so
it may be necessary to set the environment variable `COMPOSER_MEMORY_LIMIT=-1`.
The PGO initialization may not succeed in x86 enviroments.
## Creating PGO build
- compile PHP configured using `--enable-pgi`
@@ -138,6 +147,51 @@ After a training case is implemented and put under `pgo/cases`, the work environ
To skip a training case, add a file named `inactive` into the case folder.
# Debugging PHP
This part covers debugging possibilities for the builds produced by the native VS compilers.
For the cross compiled builds produced with toolsets other than VC++, please check the
documentation for the corresponding toolsets. In any case, general principles on debugging
native programs apply.
Either a debug build of PHP or enabled debug symbols are required to be able to debug PHP.
A debug build is usually more suitable for the development process and can be produced by
adding `--enable-debug` to the configure options. A release build with debug symbols can
be produced by adding `--enable-debug-pack`. These options are mutually exclusive.
## Debugging with Visual Studio
- Configure with either `--enable-debug` or `--enable-debug-pack`.
- A debug build might bring better experience for dev, but sometimes you want to debug a release build.
- `nmake run ARGS=yourscript.php DEBUGGER=1`, that will open a Visual Studio window.
- Any additional runtime options for PHP or the script executed go to ARGS, too.
- Select `Debug -> New Breakpoint -> Function Breakpoint` and add a function where the debugger should break.
- Click `Start`.
Adding a breakpoint before starting debugging might be not necessary, if a crash is debugged. When such a script runs
under the debugger, the debugger will stop at the crashing point. In that case, a breakpoint can be added
around the crashed code directly.
## Debugging test suite with Visual Studio
The [Microsoft Child Process Debugging Power Tool](https://marketplace.visualstudio.com/items?itemName=vsdbgplat.MicrosoftChildProcessDebuggingPowerTool)
plugin for Visual Studio is required. After installing it, following these steps
- `nmake test TESTS=ext/myext/tests/sometest.phpt DEBUGGER=1`
- Select `Debug -> Other Debug Targets -> Child Process Debugging Settings` and enable child process debugging.
- If necessary, add a breakpoint and start debugging as described in the previous section.
## Debugging with WinDbg
PHP can also be debugged with the tools from the WinDbg package. There is currently no way
implemented in the Makefile to start the WinDbg integrated, so it needs to de done manually.
Either a debug build or a release build with debug symbols is still required, as described
previously.
# Support
- Join `#winphp-dev` on Freenode to discuss any ideas or questions
- File an issue on GitHub
# Pitfalls
@@ -147,8 +201,30 @@ To skip a training case, add a file named `inactive` into the case folder.
- 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.
- The VC++ toolset is still required, even if another compiler, fe. clang, is intended to be used.
- `task.exe` is not a console application, some systems might not propagate exit code except the batch is explicitly run from `cmd /c`, etc.
- `7za` should be prefered over `unzip` and `zip` for compatibility reasons.
- `7za` should be preferred over `unzip` and `zip` for compatibility reasons.
- If you experience some strange crashes on MSYS2 tools, try the phpsdk_rebase_msys2 tool. MSYS2 tools might be have unstable
on ASLR enabled systems.
# Internal notes
## Releases
Users of the PHP SDK are supposed to use tagged versions for stability and
reproducability. This requires the maintainers of the PHP SDK to create such
tags for *all* *relevant* *changes*. The tag format should be `php-sdk-X.Y.Z`,
with the common major, minor and revision numbers.
Comprehensive changes, which would be hard to test extensively, such as updates
to the bundled PHP or the MinGW tools, should walk through a QA (aka. pre-release)
process, typically with beta versions (e.g. `php-sdk-X.Y.Zbeta1`). Only after
these have been thoroughly tested, and all relevant issues have been resolved,
a GA release should be tagged.
After each tag, a couple of other repositories should be informed about the
available update, ideally in form of a pull request. These repositories are:
* https://github.com/php/php-src (for Windows CI)
* https://github.com/php/php-windows-builder
* https://github.com/php/setup-php-sdk

View File

@@ -1 +1 @@
2.1.3beta1
2.3.1-dev

Binary file not shown.

BIN
bin/7za.exe Normal file → Executable file

Binary file not shown.

Binary file not shown.

0
bin/deplister.exe Normal file → Executable file
View File

BIN
bin/jq.exe Executable file

Binary file not shown.

0
bin/lemon.exe Normal file → Executable file
View File

0
bin/php/do_php.bat Normal file → Executable file
View 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.

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

Binary file not shown.

BIN
bin/php/libcrypto-3-x64.dll Normal file

Binary file not shown.

Binary file not shown.

BIN
bin/php/libsqlite3.dll Normal file

Binary file not shown.

Binary file not shown.

BIN
bin/php/libssl-3-x64.dll Normal file

Binary file not shown.

Binary file not shown.

BIN
bin/php/php.exe Normal file → Executable file

Binary file not shown.

View File

@@ -5,7 +5,8 @@ extension=php_sqlite3.dll
extension=php_openssl.dll
extension=php_mbstring.dll
extension=php_mysqli.dll
memory_limit=1G
extension=php_zip.dll
memory_limit=4G
error_reporting=-1
display_errors=1

Binary file not shown.

BIN
bin/php/php8.dll Normal file

Binary file not shown.

Binary file not shown.

27
bin/phpsdk_buildtree.bat Normal file → Executable file
View File

@@ -10,22 +10,27 @@ rem otherwise - retain the old behavior, create structs for all the known build
cmd /c "exit /b 0"
if "%PHP_SDK_ARCH%" NEQ "" (
if "%PHP_SDK_VC%" NEQ "" (
MD %_%\%PHP_SDK_VC%\%PHP_SDK_ARCH%\deps\bin
MD %_%\%PHP_SDK_VC%\%PHP_SDK_ARCH%\deps\lib
MD %_%\%PHP_SDK_VC%\%PHP_SDK_ARCH%\deps\include
cd %_%\%PHP_SDK_VC%\%PHP_SDK_ARCH%
if "%PHP_SDK_VS%" NEQ "" (
MD %_%\%PHP_SDK_VS%\%PHP_SDK_ARCH%\deps\bin
MD %_%\%PHP_SDK_VS%\%PHP_SDK_ARCH%\deps\lib
MD %_%\%PHP_SDK_VS%\%PHP_SDK_ARCH%\deps\include
cd %_%\%PHP_SDK_VS%\%PHP_SDK_ARCH%
goto exit
)
goto create_all
) else (
:create_all
MD %_%\vc14\x86\deps\bin
MD %_%\vc14\x86\deps\lib
MD %_%\vc14\x86\deps\include
MD %_%\vc14\x64\deps\bin
MD %_%\vc14\x64\deps\lib
MD %_%\vc14\x64\deps\include
for %%i in (vc14 vc15 vs16 vs17) do (
MD %_%\%%i\x86\deps\bin
MD %_%\%%i\x86\deps\lib
MD %_%\%%i\x86\deps\include
MD %_%\%%i\x64\deps\bin
MD %_%\%%i\x64\deps\lib
MD %_%\%%i\x64\deps\include
MD %_%\%%i\arm64\deps\bin
MD %_%\%%i\arm64\deps\lib
MD %_%\%%i\arm64\deps\include
)
)
set _=

0
bin/phpsdk_deps.bat Normal file → Executable file
View File

View File

@@ -1,6 +1,6 @@
<?php
include dirname(__FILE__) . "/../lib/php/autoload.php";
include __DIR__ . "/../lib/php/autoload.php";
use SDK\{Config, Exception};
@@ -36,7 +36,7 @@ try {
switch ($name) {
default:
throw new Exception("Unknown switch '$name'");
break;
break;
case "h":
case "help":
@@ -126,17 +126,9 @@ try {
usage(3);
}
/* The current CRT needs to match the config one. */
$active_crt = getenv("PHP_SDK_VC");
$active_crt = getenv("PHP_SDK_VS");
if (Config::getCurrentCrtName() != $active_crt && !$force) {
throw new Exception("Active CRT '$active_crt' differs from the branch CRT '" . Config::getCurrentCrtName() . "'.");
}
if (NULL === Config::getCurrentStabilityName()) {
if ("master" == Config::getCurrentBranchName()) {
Config::setCurrentStabilityName("staging");
} else {
Config::setCurrentStabilityName("stable");
}
throw new Exception("Active CRT name '$active_crt' differs from the branch CRT name '" . Config::getCurrentCrtName() . "'.");
}
$branch_data = Config::getCurrentBranchData();
@@ -188,7 +180,7 @@ function usage(int $code = -1)
echo "Usage: ", PHP_EOL, PHP_EOL;
echo "Configuration:", 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 " -a --arch Architecture, x86 or x64 or arm64. 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;

0
bin/phpsdk_dllmap.bat Normal file → Executable file
View File

View File

@@ -29,10 +29,10 @@ $flags = 0;
$opt = getopt($sopt, $lopt);
foreach ($opt as $name => $val) {
switch ($name) {
case "p":
case "pretty":
$flags = JSON_PRETTY_PRINT;
break;
case "p":
case "pretty":
$flags = JSON_PRETTY_PRINT;
break;
}
}
@@ -65,7 +65,7 @@ foreach ($dirs as $path) {
continue;
}
if (!preg_match(",.*-(vc\d+)-(x\d\d)\.zip,", $filename, $m)) {
if (!preg_match(",.*-(v[c|s]\d+)-(x\d\d)\.zip,", $filename, $m)) {
continue;
}
@@ -85,16 +85,16 @@ foreach ($dirs as $path) {
$dlls = array();
for( $i = 0; $i < $zip->numFiles; $i++ ){
$stat = $zip->statIndex( $i );
for ($i = 0; $i < $zip->numFiles; $i++) {
$stat = $zip->statIndex($i);
if (substr($stat['name'], -3) != "dll") {
continue;
}
$dlls[] = basename($stat['name']);
}
$zip->close();
unset($zip);

16
bin/phpsdk_dumpenv.bat Normal file → Executable file
View File

@@ -12,19 +12,9 @@ echo.
call %PHP_SDK_BIN_PATH%\phpsdk_version.bat
echo.
if "%PHP_SDK_OS_ARCH%"=="x64" (
echo OS architecture: 64-bit
) else (
echo OS architecture: 32-bit
)
if "%PHP_SDK_ARCH%"=="x64" (
echo Build architecture: 64-bit
) else (
echo Build architecture: 32-bit
)
echo Visual C++: %PHP_SDK_VC_NUM%
echo OS architecture: %PHP_SDK_OS_ARCH%
echo Build architecture: %PHP_SDK_ARCH%
echo Visual C++: %PHP_SDK_VC_TOOLSET_VER%
echo PHP-SDK path: %PHP_SDK_ROOT_PATH%

28
bin/phpsdk_pgo.bat Normal file → Executable file
View File

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

View File

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

View File

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

176
bin/phpsdk_setshell.bat Normal file → Executable file
View File

@@ -15,91 +15,144 @@ if "%2"=="" goto :help
cmd /c "exit /b 0"
set PHP_SDK_VC=%1
if /i not "%PHP_SDK_VC:~0,2%"=="vc" (
set PHP_SDK_VS=%1
if /i not "%PHP_SDK_VS:~0,2%"=="vc" (
if /i not "%PHP_SDK_VS:~0,2%"=="vs" (
:malformed_vc_string
echo Malformed CRT string "%1"
set PHP_SDK_VC=
goto out_error
echo Malformed CRT string "%1"
set PHP_SDK_VS=
goto out_error
)
)
if ""=="%PHP_SDK_VC:~2%" (
if ""=="%PHP_SDK_VS:~2%" (
goto malformed_vc_string
)
set /a TMP_CHK=%PHP_SDK_VC:~2%
set /a TMP_CHK=%PHP_SDK_VS:~2%
if 14 gtr %TMP_CHK% (
if "0"=="%TMP_CHK%" (
if not "0"=="%PHP_SDK_VC:~2%" (
if not "0"=="%PHP_SDK_VS:~2%" (
set TMP_CHK=
goto malformed_vc_string
)
)
echo At least vc14 is required
set PHP_SDK_VC=
set PHP_SDK_VS=
set TMP_CHK=
goto out_error
)
set PHP_SDK_VC_NUM=%TMP_CHK%
set PHP_SDK_VS_NUM=%TMP_CHK%
set TMP_CHK=
if /i not "%2"=="x64" (
if /i not "%2"=="x86" (
echo Unsupported arch "%2"
goto out_error
)
rem check target arch
if "%2"=="x86" set PHP_SDK_ARCH=%2
if "%2"=="x64" set PHP_SDK_ARCH=%2
if "%2"=="x86_64" set PHP_SDK_ARCH=x64
if "%2"=="amd64" set PHP_SDK_ARCH=x64
if "%2"=="arm64" set PHP_SDK_ARCH=%2
if "%PHP_SDK_ARCH%"=="" (
echo Unsupported target arch %2 >&2
goto out_error
)
set PHP_SDK_ARCH=%2
set TOOLSET=
if NOT "%3"=="" SET TOOLSET=%3
rem check OS arch
set TMPKEY=HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion
reg query "%TMPKEY%" /v "ProgramFilesDir (x86)" >nul 2>nul
if not errorlevel 1 (
set PHP_SDK_OS_ARCH=x64
) else (
if /i "%PHP_SDK_ARCH%"=="x64" (
echo 32-bit OS detected, native 64-bit toolchain is unavailable.
goto out_error
)
set PHP_SDK_OS_ARCH=x86
rem todo: allow user choose host sdk arch (i.e. x64 target can be compiled at x64(native) or x86(cross))
for /f "usebackq tokens=1*" %%i in (`wmic cpu get Architecture /value /format:table ^| findstr /r "[1234567890][1234567890]*"`) do (
set PHP_SDK_OS_ARCH_NUM=%%i
)
set TMPKEY=
goto os_arch_cases
:os_arch_error
echo Unsupported OS arch %PHP_SDK_OS_ARCH% >&2
goto out_error
:os_arch_cases
if "%PHP_SDK_OS_ARCH_NUM%"=="0" set PHP_SDK_OS_ARCH=x86
if "%PHP_SDK_OS_ARCH_NUM%"=="1" (set PHP_SDK_OS_ARCH=mips && goto os_arch_error)
if "%PHP_SDK_OS_ARCH_NUM%"=="2" (set PHP_SDK_OS_ARCH=alpha && goto os_arch_error)
if "%PHP_SDK_OS_ARCH_NUM%"=="3" (set PHP_SDK_OS_ARCH=ppc && goto os_arch_error)
if "%PHP_SDK_OS_ARCH_NUM%"=="4" (set PHP_SDK_OS_ARCH=shx && goto os_arch_error)
if "%PHP_SDK_OS_ARCH_NUM%"=="5" (set PHP_SDK_OS_ARCH=arm32 && goto os_arch_error)
if "%PHP_SDK_OS_ARCH_NUM%"=="6" (set PHP_SDK_OS_ARCH=ia64 && goto os_arch_error)
if "%PHP_SDK_OS_ARCH_NUM%"=="7" (set PHP_SDK_OS_ARCH=alpha64 && goto os_arch_error)
if "%PHP_SDK_OS_ARCH_NUM%"=="8" (set PHP_SDK_OS_ARCH=msil && goto os_arch_error)
if "%PHP_SDK_OS_ARCH_NUM%"=="9" set PHP_SDK_OS_ARCH=x64
rem wow64
if "%PHP_SDK_OS_ARCH_NUM%"=="10" set PHP_SDK_OS_ARCH=x86
if "%PHP_SDK_OS_ARCH_NUM%"=="11" (set PHP_SDK_OS_ARCH=neutral && goto os_arch_error)
if "%PHP_SDK_OS_ARCH_NUM%"=="12" set PHP_SDK_OS_ARCH=arm64
if "%PHP_SDK_OS_ARCH_NUM%"=="13" (set PHP_SDK_OS_ARCH=arm32 && goto os_arch_error)
rem woa64
if "%PHP_SDK_OS_ARCH_NUM%"=="14" set PHP_SDK_OS_ARCH=x86
if "%PHP_SDK_OS_ARCH%"=="" (
goto os_arch_error
)
set PHP_SDK_OS_ARCH_NUM=
rem cross compile is ok, so we donot need this
rem if not /i "%PHP_SDK_ARCH%"=="PHP_SDK_OS_ARCH" (
rem echo 32-bit OS detected, native 64-bit toolchain is unavailable.
rem goto out_error
rem )
rem get vc base dir
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
if 15 gtr %PHP_SDK_VS_NUM% (
rem for arch other than x86, use WOW6432
if /i not "%PHP_SDK_OS_ARCH%"=="x86" (
set TMPKEY=HKLM\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\%PHP_SDK_VS:~2%.0\Setup\VC
) else (
set TMPKEY=HKLM\SOFTWARE\Microsoft\VisualStudio\%PHP_SDK_VC:~2%.0\Setup\VC
set TMPKEY=HKLM\SOFTWARE\Microsoft\VisualStudio\%PHP_SDK_VS:~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
echo Couldn't determine VC%PHP_SDK_VS:~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
rem build the version range, e.g. "[15,16)"
set /a PHP_SDK_VS_RANGE=PHP_SDK_VS_NUM + 1
set PHP_SDK_VS_RANGE="[%PHP_SDK_VS_NUM%,!PHP_SDK_VS_RANGE%!)"
set APPEND=x86.x64
if /i "%PHP_SDK_OS_ARCH%"=="arm64" (
set APPEND=ARM64
)
set VS_VERSION_ARGS="-latest"
if "%TOOLSET%"=="" set VS_VERSION_ARGS=-version !PHP_SDK_VS_RANGE!
for /f "tokens=1* delims=: " %%a in ('%~dp0\vswhere -nologo !VS_VERSION_ARGS! -requires Microsoft.VisualStudio.Component.VC.Tools.!APPEND! -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
for /f "tokens=1* delims=: " %%a in ('%~dp0\vswhere -nologo !VS_VERSION_ARGS! -products Microsoft.VisualStudio.Product.BuildTools -requires Microsoft.VisualStudio.Component.VC.Tools.!APPEND! -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
for /f "tokens=1* delims=: " %%a in ('%~dp0\vswhere -nologo !VS_VERSION_ARGS! -prerelease -requires Microsoft.VisualStudio.Component.VC.Tools.!APPEND! -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
echo Could not determine '%PHP_SDK_VS%' directory
goto out_error;
)
)
)
set VSCMD_ARG_no_logo=nologo
)
set APPEND=
set TMPKEY=
set PHP_SDK_VS_RANGE=
if 15 gtr %PHP_SDK_VC_NUM% (
if 15 gtr %PHP_SDK_VS_NUM% (
rem get sdk dir
rem if 10.0 is available, it's ok
if /i "%PHP_SDK_OS_ARCH%"=="x64" (
rem for arch other than x86, use WOW6432
if /i not "%PHP_SDK_OS_ARCH%"=="x86" (
set TMPKEY=HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Microsoft SDKs\Windows\v10.0
) else (
set TMPKEY=HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v10.0
@@ -113,7 +166,8 @@ if 15 gtr %PHP_SDK_VC_NUM% (
)
rem Otherwise 8.1 should be available anyway
if /i "%PHP_SDK_OS_ARCH%"=="x64" (
rem for arch other than x86, use WOW6432
if /i not "%PHP_SDK_OS_ARCH%"=="x86" (
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
@@ -131,20 +185,40 @@ if 15 gtr %PHP_SDK_VC_NUM% (
)
if /i "%PHP_SDK_ARCH%"=="x64" (
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
)
set TARGET_ARCH_NAME=amd64
) else (
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
)
set TARGET_ARCH_NAME=%PHP_SDK_ARCH%
)
rem echo Visual Studio path %PHP_SDK_VC_DIR%
if /i "%PHP_SDK_OS_ARCH%"=="x64" (
set HOST_ARCH_NAME=amd64
) else (
set HOST_ARCH_NAME=%PHP_SDK_ARCH%
)
if "%HOST_ARCH_NAME%"=="%TARGET_ARCH_NAME%" (
set VCVARSALL_ARCH_NAME=%HOST_ARCH_NAME%
) else if "%HOST_ARCH_NAME%_%TARGET_ARCH_NAME%"=="amd64_x86" (
set VCVARSALL_ARCH_NAME=%TARGET_ARCH_NAME%
) else (
set VCVARSALL_ARCH_NAME=%HOST_ARCH_NAME%_%TARGET_ARCH_NAME%
)
if 15 gtr %PHP_SDK_VS_NUM% (
if NOT "%TOOLSET%"=="" (
set PHP_SDK_VS_SHELL_CMD="!PHP_SDK_VC_DIR!\vcvarsall.bat" !VCVARSALL_ARCH_NAME! -vcvars_ver=%TOOLSET%
) else (
set PHP_SDK_VS_SHELL_CMD="!PHP_SDK_VC_DIR!\vcvarsall.bat" !VCVARSALL_ARCH_NAME!
)
) else (
if NOT "%TOOLSET%"=="" (
set PHP_SDK_VS_SHELL_CMD="!PHP_SDK_VC_DIR!\Auxiliary\Build\vcvarsall.bat" !VCVARSALL_ARCH_NAME! -vcvars_ver=%TOOLSET%
) else (
set PHP_SDK_VS_SHELL_CMD="!PHP_SDK_VC_DIR!\Auxiliary\Build\vcvarsall.bat" !VCVARSALL_ARCH_NAME!
)
)
set VCVARSALL_ARCH_NAME=
rem echo Visual Studio VC path %PHP_SDK_VC_DIR%
rem echo Windows SDK path %PHP_SDK_WIN_SDK_DIR%

7
bin/phpsdk_setvars.bat Normal file → Executable file
View File

@@ -17,5 +17,12 @@ set PHP_SDK_PHP_CMD=%PHP_SDK_BIN_PATH%\php\do_php.bat
set PATH=%PHP_SDK_BIN_PATH%;%PHP_SDK_MSYS2_PATH%;%PATH%
for /f "tokens=1* delims=: " %%a in ('link /?') do (
set PHP_SDK_VC_TOOLSET_VER=%%b
goto break0
)
:break0
set PHP_SDK_VC_TOOLSET_VER=%PHP_SDK_VC_TOOLSET_VER:~-13%
exit /b %errorlevel%

0
bin/phpsdk_version.bat Normal file → Executable file
View File

BIN
bin/sqlite3.exe Executable file

Binary file not shown.

0
bin/task.exe Normal file → Executable file
View File

BIN
bin/vswhere.exe Normal file → Executable file

Binary file not shown.

View File

@@ -18,7 +18,7 @@ rem netsh advfirewall set allprofiles state off
rem NGINX
netsh advfirewall firewall add rule name="NGINX for PGO" dir=in action=allow program="C:\php-snap-build\php-sdk\pgo\work\server\nginx\nginx.exe" profile=private
for \l %%p in (8081, 1, 8091) do (
for /l %%p in (8081, 1, 8091) do (
netsh advfirewall firewall add rule name="Open Port %%p for PHP PGO" dir=in action=allow protocol=TCP localport=%%p profile=private
netsh advfirewall firewall add rule name="Open Port %%p for PHP PGO" dir=in action=allow protocol=UDP localport=%%p profile=private
)

View File

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

View File

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

View File

@@ -2,18 +2,29 @@
namespace SDK\Build\Dependency;
use SDK\{Config, Exception, FileOps};
use SDK\{Exception, FileOps};
class Fetcher
{
use FileOps;
/** @var string */
protected $host;
/** @var int */
protected $port;
/** @var ?string */
protected $stability;
/** @var ?string */
protected $arch;
/** @var Series */
protected $series;
/** @var string */
protected $scheme;
public function __construct(string $host, int $port, string $scheme = "https", string $arch = NULL, string $stability = NULL, Series $series = NULL)
{/*{{{*/
@@ -22,6 +33,7 @@ class Fetcher
$this->host = $host;
$this->port = $port;
$this->scheme = $scheme;
$this->series = $series;
}/*}}}*/
public function getSeries() : Series

View File

@@ -8,11 +8,25 @@ class Manager
{
use FileOps;
/** @var string */
protected $stability;
/** @var string */
protected $arch;
/** @var string */
protected $path;
/** @var Cache */
protected $cache;
/** @var Series */
protected $series;
/** @var Fetcher */
protected $fetcher;
/** @var ?bool */
protected $updatesFlag = NULL;
public function __construct(string $path, string $stability, string $arch)
@@ -41,7 +55,7 @@ class Manager
public function updatesAvailable() : bool
{/*{{{*/
if (!is_null($this->updatesFlag)) {
if (NULL !== $this->updatesFlag) {
return $this->updatesFlag;
}

View File

@@ -8,9 +8,16 @@ class Package
{
use FileOps;
/** @var string */
protected $name;
/** @var Series */
protected $series;
/** @var Fetcher */
protected $fetcher;
/** @var string */
protected $filepath;
public function __construct(string $name, Series $series, Fetcher $fetcher)

View File

@@ -8,10 +8,19 @@ use SDK\Exception;
class Series
{
/** @var ?Fetcher */
protected $fetcher;
/** @var string */
protected $stability;
/** @var string */
protected $arch;
/** @var string */
protected $rawData;
/** @var Cache */
protected $cache;
public function __construct(string $stability, string $arch, Cache $cache, Fetcher $fetcher = NULL)
@@ -44,7 +53,6 @@ class Series
public function getName() : string
{/*{{{*/
$base = Config::getDepsBaseUri();
$branch_data = Config::getCurrentBranchData();
$file = "packages-" . Config::getCurrentBranchName() . "-{$branch_data['crt']}-{$this->arch}-{$this->stability}.txt";
@@ -60,6 +68,7 @@ class Series
return "$base/series/$file";
}/*}}}*/
/** @return array<string>|string */
public function getData(bool $raw = false, bool $cache = true)
{/*{{{*/
if ($cache && $this->rawData) {

View File

@@ -2,16 +2,30 @@
namespace SDK\Build\PGO\Abstracts;
use SDK\Build\PGO\Interfaces\Server;
use SDK\Build\PGO\PHP\CLI;
use SDK\Build\PGO\Config as PGOConfig;
use SDK\{Config as SDKConfig, Exception, FileOps};
use SDK\{Config as SDKConfig, Exception};
abstract class PHP
{
/** @var string */
protected $php_root;
/** @var string */
protected $php_ext_root;
/** @var string */
protected $opcache_file_cache;
/** @var string */
protected $id;
/** @var string */
protected $scenario;
/** @var \SDK\Build\PGO\Config */
protected $conf;
/** @return void */
protected function setupPaths()
{
$this->php_root = $this->getRootDir();
@@ -23,14 +37,20 @@ abstract class PHP
} else {
$this->php_ext_root = $this->php_root;
}
if ("cache" == $this->scenario) {
$this->opcache_file_cache = SDKConfig::getTmpDir() . DIRECTORY_SEPARATOR . $this->id;
}
}
abstract public function getExeFilename() : string;
/* TODO Might be improved. */
public function isDist() : bool
{
return !file_exists("Makefile") && file_exists("php.exe");
}
/** @return array<string,string> */
protected function createEnv() : array
{
$env = getenv();
@@ -39,12 +59,22 @@ abstract class PHP
$deps_root = SDKConfig::getDepsLocalPath();
foreach ($env as $k => $v) {
if (strtoupper($k) == "PATH") {
$env[$k] = "$deps_root" . DIRECTORY_SEPARATOR . "bin;" . $env[$k];
$env[$k] = $deps_root . DIRECTORY_SEPARATOR . "bin;" . $env[$k];
break;
}
}
}
$drive = getenv("HOMEDRIVE");
$path = getenv("HOMEPATH");
if (!$drive || !$path) {
$p = SDKConfig::getTmpDir();
$drive = substr($p, 0, 2);
$path = substr($p, 2);
putenv("HOMEDRIVE=$drive");
putenv("HOMEPATH=$path");
}
return $env;
}
@@ -81,7 +111,7 @@ abstract class PHP
public function getVersion(bool $short = false) : string
{
$ret = NULL;
$cli = new CLI($this->conf, $this->scenario);
$cli = new CLI($this->conf);
$out = shell_exec($cli->getExeFilename() . " -n -v");
@@ -95,7 +125,7 @@ abstract class PHP
}
}
if (is_null($ret)) {
if (NULL === $ret) {
throw new Exception("Failed to determine the test PHP version.");
}
@@ -104,7 +134,7 @@ abstract class PHP
public function isThreadSafe() : bool
{
$cli = new CLI($this->conf, $this->scenario);
$cli = new CLI($this->conf);
$out = shell_exec($cli->getExeFilename() . " -n -v");
@@ -115,20 +145,8 @@ abstract class PHP
return true;
}
public function is64bit() : bool
{
$cli = new CLI($this->conf, $this->scenario);
$out = shell_exec($cli->getExeFilename() . " -n -v");
if (preg_match(",x64,", $out, $m) > 0) {
return true;
}
return false;
}
/* Need to cleanup it somewhere. */
/** @return string */
public function getIniFilename()
{
$ret = tempnam(sys_get_temp_dir(), "ini");
@@ -138,7 +156,7 @@ abstract class PHP
$this->conf->buildTplVarName("php", "error_log") => $this->getRootDir() . DIRECTORY_SEPARATOR . "pgo_run_error.log",
);
$k = $this->is64bit() ? "x64" : "x86";
$k = SDKConfig::getCurrentArchName();
$scenario_vars = (array)$this->conf->getSectionItem("php", "scenario", $this->scenario, "ini", $k);
if ($scenario_vars) {
foreach ($scenario_vars as $k => $v) {
@@ -147,6 +165,11 @@ abstract class PHP
}
}
/* Special handling, otherwise it'll need functionality to extrapolate ini values. */
if ("cache" == $this->scenario) {
$tpl_vars[$this->conf->buildTplVarName("php", "opcache", "file_cache")] = $this->opcache_file_cache;
}
$this->conf->processTplFile(
$this->getIniTplFilename(),
$ret,
@@ -156,6 +179,7 @@ abstract class PHP
return $ret;
}
/** @return string */
protected function getIniTplFilename()
{
$tpl_path = $this->conf->getTplDir("php");
@@ -171,11 +195,12 @@ abstract class PHP
return $construct;
}
/** @param array<string,string> $extra_env */
public function exec(string $php_cmd, string $args = NULL, array $extra_env = array()) : int
{
$env = $this->createEnv();
$exe = $this->getExeFilename();
$ini = $this->getIniFilename();
$exe = $this->getExeFilename();
$ini = $this->getIniFilename();
$cert_path = getenv("PHP_SDK_ROOT_PATH") . "\\msys2\\usr\\ssl\\cert.pem";
$ini .= " -d curl.cainfo=$cert_path";
@@ -203,7 +228,7 @@ abstract class PHP
$env[$k] = $v;
}
$cmd = "$exe -n -c $ini " . ($args ? "$args " : "") . "$php_cmd";
$cmd = "$exe -n -c $ini " . ($args ? "$args " : "") . $php_cmd;
$desc = array(
0 => array("file", "php://stdin", "r"),
@@ -214,5 +239,13 @@ abstract class PHP
return proc_close($p);
}
}
public function getIdString(): string
{
return $this->getVersion() . "-"
. SDKConfig::getCurrentCrtName() . "-"
. ($this->isThreadSafe() ? "ts" : "nts") . "-"
. SDKConfig::getCurrentArchName()
. "-" . substr(md5(uniqid()), 0, 8);
}
}

View File

@@ -4,8 +4,14 @@ namespace SDK\Build\PGO\Abstracts;
use SDK\Build\PGO\Interfaces;
class Server
abstract class Server
{
/** @var string */
protected $name;
/** @var Interfaces\PHP */
protected $php;
public function getName() : string
{
return $this->name;
@@ -17,6 +23,3 @@ class Server
}
}

View File

@@ -2,19 +2,28 @@
namespace SDK\Build\PGO\Abstracts;
use SDK\Build\PGO\Config as PGOConfig;
use SDK\{Config as SDKConfig, Exception, FileOps};
use SDK\FileOps;
use SDK\Build\PGO\Interfaces;
use SDK\Build\PGO\Tool;
class TrainingCase
abstract class TrainingCase implements Interfaces\TrainingCase
{
use FileOps;
const TYPE_WEB = "web";
const TYPE_CLI = "cli";
/** @var array<mixed> */
protected $stat = array();
/** @var \SDK\Build\PGO\Config */
protected $conf;
/** @var mixed */
protected $php;
abstract public function getName() : string;
public function getType() : string
{
$type = $this->conf->getSectionItem($this->getName(), "type");
@@ -148,4 +157,3 @@ class TrainingCase
return $ret;
}
}

View File

@@ -2,7 +2,7 @@
namespace SDK\Build\PGO;
use SDK\{Config as SDKConfig, Exception};
use SDK\Exception;
class Config
{
@@ -11,14 +11,25 @@ class Config
const MODE_REINIT = 2; /* currently unused */
const MODE_CHECK_INIT = 3;
/** @var int */
protected $mode;
/** @var int */
protected $last_port = 8081;
/** @var array<string,mixed> */
protected $sections = array();
/** @var string */
protected $scenario = "default";
/** @var array<mixed> */
protected $tpl_vars = array();
/** @var array<mixed> */
protected $srv = array();
public function __construct(int $mode = MODE_RUN)
public function __construct(int $mode = self::MODE_RUN)
{
if (self::MODE_CHECK_INIT == $mode) {
// XXX The check is simple right now, so this is sufficient.
@@ -40,7 +51,6 @@ class Config
$this->mode = $mode;
$base = getenv("PHP_SDK_ROOT_PATH");
if (self::MODE_INIT == $mode) {
foreach (array("nginx", "mariadb", "postgresql", "php") as $i) {
$this->importSectionFromDir($i, $this->getTplDir() . DIRECTORY_SEPARATOR . $i);
@@ -68,6 +78,7 @@ class Config
}
}
/** @return bool */
public function isInitialized()
{
/* XXX Could be some better check. */
@@ -162,6 +173,7 @@ class Config
return $ret;
}
/** @param string ...$args */
public function sectionItemExists(...$args) : bool
{
$i = 0;
@@ -179,6 +191,10 @@ class Config
return $i == count($args);
}
/**
* @param string ...$args
* @return mixed
*/
public function getSectionItem(...$args)
{
$i = 0;
@@ -200,6 +216,7 @@ class Config
return $it;
}
/** @param string|int ...$args */
public function setSectionItem(...$args) : void
{
$val = array_pop($args);
@@ -239,6 +256,7 @@ class Config
}
}
/** @param string ...$args */
public function buildTplVarName(...$args) : string
{
$tpl_k = array("PHP_SDK_PGO");
@@ -250,6 +268,7 @@ class Config
return implode("_", $tpl_k);
}
/** @param array<string,mixed> $section */
protected function importTplVars(string $section_name, array $section) : void
{
foreach($section as $k0 => $v0) {
@@ -267,6 +286,7 @@ class Config
}
}
/** @param array<mixed> $additional_vars */
public function processTpl(string $s, array $additional_vars = array()) : string
{
$vars = array_merge($this->tpl_vars, $additional_vars);
@@ -276,10 +296,11 @@ class Config
return $s;
}
/** @param array<mixed> $additional_vars */
public function processTplFile(string $tpl_fn, string $dst_fn, array $additional_vars = array()) : void
{
if (!file_exists($tpl_fn)) {
throw new Exception("Template file '$fn' doesn't exist.");
throw new Exception("Template file '$tpl_fn' doesn't exist.");
}
$s = file_get_contents($tpl_fn);
@@ -294,6 +315,7 @@ class Config
}
}
/** @return string */
public function getWorkSectionsFilename()
{
return $this->getWorkDir() . DIRECTORY_SEPARATOR . "phpsdk_pgo.json";
@@ -339,6 +361,10 @@ class Config
return getenv("PHP_SDK_PHP_CMD");
}
/**
* @param Interfaces\Server $item
* @return void
*/
public function addSrv($item) : void
{
$name = strtolower($item->getName());
@@ -351,6 +377,7 @@ class Config
$this->srv[$name] = $item;
}
/** @return array<string,Interfaces\Server>|Interfaces\Server|null */
public function getSrv(?string $name = NULL)
{
$ret = NULL;
@@ -368,4 +395,3 @@ class Config
return $ret;
}
}

View File

@@ -2,23 +2,31 @@
namespace SDK\Build\PGO;
use SDK\{Config as SDKConfig, Exception, Lock};
use SDK\{Exception, Lock};
use SDK\Build\PGO\Config as PGOConfig;
use SDK\Build\PGO\Server\{MariaDB, NGINX, PostgreSQL};
use SDK\Build\PGO\PHP;
use SDK\Build\PGO\Tool\{PGO, PackageWorkman};
use SDK\Build\PGO\Interfaces\TrainingCase;
use SDK\Build\PGO\TrainingCaseIterator;
/* TODO add bench action */
class Controller
{
/** @var string */
protected $cmd;
/** @var ?string */
protected $scenario;
/** @var PGOConfig */
protected $conf;
public function __construct(string $cmd, ?string $scenario)
/** @var array<string>|null */
protected $cases;
/** @param array<string>|null $cases */
public function __construct(string $cmd, ?string $scenario, ?array $cases)
{
$this->cmd = $cmd;
@@ -26,8 +34,10 @@ class Controller
$scenario = "default";
}
$this->scenario = $scenario;
$this->cases = $cases;
}
/** @return mixed */
protected function vitalizeSrv()
{
$all = $this->conf->getSrv("all");
@@ -46,12 +56,15 @@ class Controller
return $all;
}
/**
* @param string $cmd
* @return PGOConfig
*/
protected function setupConfig($cmd)
{
switch ($cmd) {
default:
throw new Exception("Unknown action '{$cmd}'.");
break;
case "check_init":
$cnf = new PGOConfig(PGOConfig::MODE_CHECK_INIT);
break;
@@ -68,6 +81,10 @@ class Controller
return $cnf;
}
/**
* @param bool $force
* @return void
*/
public function handle($force)
{
/*$mode = (int)("init" !== $this->cmd);
@@ -77,38 +94,37 @@ class Controller
$this->conf = $this->setupConfig($this->cmd);
switch ($this->cmd) {
default:
throw new Exception("Unknown action '{$this->cmd}'.");
break;
case "init":
$lk = new Lock("pgo_init");
if (!$lk->locked()) {
echo "Another process runs initialization right now, waiting.", PHP_EOL;
$lk->exclusive(true);
echo "Another process finished running initialization, I quit as well.", PHP_EOL;
return;
}
$this->init($force);
break;
case "train":
$lk = new Lock("pgo_train");
if (!$lk->locked()) {
echo "Another process runs training right now, I have to wait.", PHP_EOL;
$lk->exclusive(true);
echo "Another process finished training, I may continue.", PHP_EOL;
}
$this->train();
break;
case "up":
$this->up();
break;
default:
throw new Exception("Unknown action '{$this->cmd}'.");
case "init":
$lk = new Lock("pgo_init");
if (!$lk->locked()) {
echo "Another process runs initialization right now, waiting.", PHP_EOL;
$lk->exclusive(true);
echo "Another process finished running initialization, I quit as well.", PHP_EOL;
return;
}
$this->init($force);
break;
case "train":
$lk = new Lock("pgo_train");
if (!$lk->locked()) {
echo "Another process runs training right now, I have to wait.", PHP_EOL;
$lk->exclusive(true);
echo "Another process finished training, I may continue.", PHP_EOL;
}
$this->train();
break;
case "up":
$this->up();
break;
case "down":
$this->down($force);
break;
case "check_init":
// pass
break;
case "down":
$this->down($force);
break;
case "check_init":
// pass
break;
}
}
@@ -146,6 +162,7 @@ class Controller
}
}
/** @return void */
public function init(bool $force = false)
{
echo "\nInitializing PGO training environment.\n\n";
@@ -179,11 +196,13 @@ class Controller
echo "PGO training environment Initialization complete.\n";
}
/** @return bool */
public function isInitialized()
{
return $this->conf->isinitialized();
}
/** @return void */
public function train()
{
if (!$this->isInitialized()) {
@@ -204,10 +223,24 @@ class Controller
$pgo->clean();
unset($pgo);
$cases = $this->cases;
foreach (new TrainingCaseIterator($this->conf) as $handler) {
$name = $handler->getName();
/* Just a white list handling for now. */
if (is_array($cases)) {
if (!in_array($name, $cases)) {
continue;
}
$key = array_search($name, $cases);
unset($cases[$key]);
}
echo "\n";
$handler->run();
}
if (is_array($cases) && !empty($cases)) {
echo "\n\033[31m WARNING: The cases " . implode(",", $cases) . " don't exist and was ignored!\033[0m\n\n";
}
/* All the PGC files are merged, simply clean them out. */
$pgo = new PGO($this->conf, $php);
@@ -218,6 +251,7 @@ class Controller
echo "PGO training complete.\n";
}
/** @return void */
public function up()
{
@@ -226,7 +260,7 @@ class Controller
}
echo "\nStarting up PGO environment.\n\n";
foreach ($this->vitalizeSrv("all") as $srv) {
foreach ($this->vitalizeSrv() as $srv) {
$srv->up();
echo "\n";
}
@@ -236,6 +270,7 @@ class Controller
echo "The PGO environment is up.\n";
}
/** @return void */
public function down(bool $force = false)
{
if (!$this->isInitialized()) {
@@ -244,7 +279,7 @@ class Controller
/* XXX check it was started of course. */
echo "\nShutting down PGO environment.\n\n";
foreach ($this->vitalizeSrv("all") as $srv) {
foreach ($this->vitalizeSrv() as $srv) {
$srv->down($force);
echo "\n";
}

View File

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

View File

@@ -2,7 +2,6 @@
namespace SDK\Build\PGO\Interfaces;
use SDK\Build\PGO\Config;
use SDK\Build\PGO\Tool\PackageWorkman;
interface Server
@@ -13,5 +12,7 @@ interface Server
public function up() : void;
public function down(bool $force = false) : void;
public function getName() : string;
}
/** @return \SDK\Build\PGO\Interfaces\PHP */
public function getPhp();
}

View File

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

View File

@@ -9,6 +9,10 @@ interface HTTP extends Interfaces\Server
{
public function __construct(Config $conf, Interfaces\PHP $php);
public function getPhp() : Interfaces\PHP;
/**
* @param array<mixed> $tpl_vars
* @return void
*/
public function addServer(string $part_tpl_fn, array $tpl_vars = array());
}

View File

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

View File

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

View File

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

View File

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

View File

@@ -5,16 +5,23 @@ namespace SDK\Build\PGO\Server;
use SDK\Build\PGO\Interfaces;
use SDK\Build\PGO\Abstracts;
use SDK\Build\PGO\{Config as PGOConfig};
use SDK\{Config as SDKConfig, Exception, FileOps};
use SDK\{Exception, FileOps};
use SDK\Build\PGO\Tool\PackageWorkman;
class NGINX extends Abstracts\Server implements Interfaces\Server\HTTP
{
use FileOps;
/** @var string */
protected $name = "NGINX";
/** @var PGOConfig */
protected $conf;
/** @var string */
protected $base;
/** @var Interfaces\PHP */
protected $php;
public function __construct(PGOConfig $conf, Interfaces\PHP $php)
@@ -29,7 +36,6 @@ class NGINX extends Abstracts\Server implements Interfaces\Server\HTTP
$nginx_conf_in = $this->conf->getTplDir($this->name) . DIRECTORY_SEPARATOR . "nginx.conf";
$conf_fn = $this->base . DIRECTORY_SEPARATOR . "conf" . DIRECTORY_SEPARATOR . "nginx.conf";
$vars = array();
$port = $this->conf->getSectionItem($this->name, "port");
if (!$port) {
$port = $this->conf->getNextPort();
@@ -77,7 +83,7 @@ class NGINX extends Abstracts\Server implements Interfaces\Server\HTTP
$h = popen("start /b .\\nginx.exe 2>&1", "r");
if (!is_resource($h)) {
chdir($cwd);
throw new Exception("Failed to start MariaDB.");
throw new Exception("Failed to start NGINX.");
}
sleep(3);
@@ -126,6 +132,10 @@ class NGINX extends Abstracts\Server implements Interfaces\Server\HTTP
}
/* Use only for init phase! */
/**
* @param array<mixed> $tpl_vars
* @return void
*/
public function addServer(string $part_tpl_fn, array $tpl_vars = array())
{
if (!file_exists($part_tpl_fn)) {
@@ -148,4 +158,3 @@ class NGINX extends Abstracts\Server implements Interfaces\Server\HTTP
}
}
}

View File

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

View File

@@ -2,14 +2,19 @@
namespace SDK\Build\PGO\Tool;
use SDK\{Config as SDKConfig, Exception};
use SDK\Exception;
use SDK\Build\PGO\Config as PGOConfig;
use SDK\Build\PGO\Interfaces;
class PGO
{
/** @var Interfaces\PHP */
protected $php;
/** @var PGOConfig */
protected $conf;
/** @var int */
protected $idx = 0;
public function __construct(PGOConfig $conf, Interfaces\PHP $php)
@@ -34,6 +39,7 @@ class PGO
return $dn . DIRECTORY_SEPARATOR . $bn . ".pgd";
}
/** @return array<string> */
protected function getWorkItems() : array
{
$exe = glob($this->php->getRootDir() . DIRECTORY_SEPARATOR . "*.exe");
@@ -41,7 +47,7 @@ class PGO
$dll = array_merge($dll, glob($this->php->getExtRootDir() . DIRECTORY_SEPARATOR . "php*.dll"));
/* find out next index */
$tpl = glob($this->php->getRootDir() . DIRECTORY_SEPARATOR . "php7{ts,}.dll", GLOB_BRACE)[0];
$tpl = glob($this->php->getRootDir() . DIRECTORY_SEPARATOR . "php{7,8,}{ts,}.dll", GLOB_BRACE)[0];
if (!$tpl) {
throw new Exception("Couldn't find php7[ts].dll in the PHP root dir.");
}
@@ -63,11 +69,11 @@ class PGO
$pgc = $this->getPgcName($base);
$pgd = $this->getPgdName($base);
`pgosweep $base $pgc`;
shell_exec("pgosweep $base $pgc");
//passthru("pgosweep $base $pgc");
if ($merge) {
`pgomgr /merge:1000 $pgc $pgd`;
shell_exec("pgomgr /merge:1000 $pgc $pgd");
//passthru("pgomgr /merge:1000 $pgc $pgd");
/* File is already spent, no need to keep it.
If seeing linker warnings about no pgc
@@ -98,10 +104,9 @@ class PGO
$its = glob($this->php->getRootDir() . DIRECTORY_SEPARATOR . "*.pgd");
$its = array_merge($its, glob($this->php->getExtRootDir() . DIRECTORY_SEPARATOR . "*" . DIRECTORY_SEPARATOR . "*.pgd"));
foreach (array_unique($its) as $pgd) {
`pgomgr /clear $pgd`;
shell_exec("pgomgr /clear $pgd");
//passthru("pgomgr /clear $pgd");
}
}
}
}

View File

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

View File

@@ -4,19 +4,23 @@ namespace SDK\Build\PGO\Tool;
use SDK\{Config as SDKConfig, Exception};
use SDK\Build\PGO\Config as PGOConfig;
use SDK\Build\PGO\Interfaces\{TrainingCase, Server, Server\DB, PHP};
use SDK\Build\PGO\Interfaces\TrainingCase;
class Training
{
/** @var PGOConfig */
protected $conf;
/** @var TrainingCase */
protected $t_case;
public function __construct(PGOConfig $conf, TrainingCase $t_case)
{
$this->conf = $conf;
$this->t_case = $t_case;
if (!in_array($this->t_case->getType(), array("web", "cli"))) {
$type = $this->t_case->getType();
if (!in_array($type, array("web", "cli"))) {
throw new Exception("Unknown training type '$type'.");
}
}
@@ -26,6 +30,7 @@ class Training
return $this->t_case;
}
/** @param array<string,mixed> $stat */
public function runWeb(int $max_runs, ?array &$stat = array()) : void
{
$url_list_fn = $this->t_case->getJobFilename();
@@ -104,11 +109,11 @@ class Training
}
/* TODO Extend with number runs. */
/** @param array<string,mixed> $stat */
public function run(int $max_runs = 1, ?array &$stat = array()) : void
{
$type = $this->t_case->getType();
switch ($type)
{
switch ($type) {
case "web":
$this->runWeb($max_runs, $stat);
break;

View File

@@ -2,15 +2,23 @@
namespace SDK\Build\PGO;
use SDK\{Config as SDKConfig, Exception, FileOps};
use SDK\Build\PGO\Config as PGOConfig;
/**
* @implements \Iterator<?string,Interfaces\TrainingCase>
*/
class TrainingCaseIterator implements \Iterator
{
/** @var PGOConfig */
protected $conf;
/** @var array<string> */
protected $items = array();
/** @var int */
protected $idx;
/** @var object */
protected $el;
public function __construct(PGOConfig $conf)
@@ -21,7 +29,7 @@ class TrainingCaseIterator implements \Iterator
$items = glob($this->conf->getCasesTplDir() . DIRECTORY_SEPARATOR . "*");
foreach ($items as $it) {
if(!is_dir($it)) {
if (!is_dir($it)) {
continue;
}
@@ -51,9 +59,10 @@ class TrainingCaseIterator implements \Iterator
return $base . DIRECTORY_SEPARATOR . "TrainingCaseHandler.php";
}
#[\ReturnTypeWillChange]
public function current()
{
$base = $this->items[$this->idx];
$base = $this->items[$this->idx];
$ns = basename($base);
/* Don't overwrite generated config. */
@@ -74,21 +83,25 @@ class TrainingCaseIterator implements \Iterator
return $this->el;
}
#[\ReturnTypeWillChange]
public function next()
{
$this->idx++;
}
#[\ReturnTypeWillChange]
public function rewind()
{
$this->idx = 0;
}
#[\ReturnTypeWillChange]
public function valid()
{
return $this->idx < count($this->items);
}
#[\ReturnTypeWillChange]
public function key()
{
if (!is_object($this->el)) {
@@ -97,6 +110,4 @@ class TrainingCaseIterator implements \Iterator
return $this->el->getName();
}
}

View File

@@ -2,13 +2,12 @@
namespace SDK;
use SDK\Config;
use SDK\Cache;
use SDK\Exception;
class Cache
{
/** @var string */
protected $id;
/** @var string */
protected $hash;
public function __construct(string $id)
@@ -48,7 +47,7 @@ class Cache
$old_sum = md5_file($p);
$new_sum = md5($content);
return $old_sum != $new_sum;
return $old_sum !== $new_sum;
}/*}}}*/
public function cacheContent(string $path, string $content, bool $relative = false) : void
@@ -64,7 +63,7 @@ class Cache
do {
$got = fwrite($fd, substr($content, $wrote));
if (false == $got) {
if (false === $got) {
break;
}
$wrote += $got;
@@ -83,7 +82,7 @@ class Cache
{/*{{{*/
$p = $this->getCacheablePath($path, $relative);
if ($this->isFileCached($p)) {
if (file_exists($p)) {
return file_get_contents($p);
}

View File

@@ -3,26 +3,44 @@
namespace SDK;
use SDK\Build\Dependency\Fetcher;
use SDK\Cache;
use SDK\Exception;
class Config
{
/* Config variables. */
protected static $depsHost = 'windows.php.net';
/** @var string */
protected static $depsHost = 'phpext.phptools.online';
/** @var int */
protected static $depsPort = 443;
/** @var string */
protected static $depsUriScheme = "https";
protected static $depsBaseUri = "/downloads/php-sdk/deps";
/* protected static $sdkNugetFeedUrl = "http://127.0.0.1/sdk/nuget"; */
/** @var string */
protected static $depsBaseUri = "/api/downloadable/download";
/** @var string */
protected static $sdkNugetFeedUrl = "http://127.0.0.1/sdk/nuget"; // experimental?
/** @var array<mixed> */
protected static $knownBranches = array ();
/* Helper props and methods. */
/** @var ?string */
protected static $currentBranchName = NULL;
/** @var ?string */
protected static $currentArchName = NULL;
/** @var ?string */
protected static $currentCrtName = NULL;
/** @var ?string */
protected static $currentStabilityName = NULL;
/** @var ?string */
protected static $depsLocalPath = NULL;
public static function getDepsHost() : string
@@ -30,7 +48,7 @@ class Config
return self::$depsHost;
}/*}}}*/
public static function getDepsPort() : string
public static function getDepsPort() : int
{/*{{{*/
return self::$depsPort;
}/*}}}*/
@@ -49,8 +67,8 @@ class Config
{/*{{{*/
$arch = strtolower($arch);
if ("x64" != $arch && "x86" != $arch) {
throw new Exception("Unknown arch keyword, either x86 or x64 is accepted");
if ("x64" != $arch && "x86" != $arch && "arm64" != $arch) {
throw new Exception("Unknown arch keyword, x86 or x64 or arm64 is accepted");
}
self::$currentArchName = $arch;
@@ -59,20 +77,26 @@ class Config
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");
if (FALSE !== ($env = getenv('PHP_SDK_ARCH'))) {
self::setCurrentArchName($env);
} else {
throw new Exception("Couldn't determine Arch.");
/* 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");
} elseif (preg_match(",arm64,", $out[0])) {
self::setCurrentArchName("arm64");
} else {
throw new Exception("Couldn't determine Arch.");
}
}
}
@@ -87,18 +111,22 @@ class Config
public static function getCurrentCrtName() : ?string
{/*{{{*/
if (NULL === self::$currentCrtName) {
$all_branches = Config::getKnownBranches();
if (FALSE !== ($env = getenv('PHP_SDK_VS'))) {
self::setCurrentCrtName($env);
} else {
$all_branches = Config::getKnownBranches();
if (!isset($all_branches[Config::getCurrentBranchName()])) {
throw new Exception("Couldn't find any configuration for branch '" . Config::getCurrentBranchName() . "'");
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]);
}
$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;
@@ -126,17 +154,22 @@ class Config
return self::$currentStabilityName;
} /*}}}*/
/** @return array<mixed> */
public static function getKnownBranches() : array
{/*{{{*/
if (empty(self::$knownBranches)) {
$cache_file = "known_branches.txt";
$cache = new Cache(self::getDepsLocalPath());
$deps_path = self::getDepsLocalPath();
if (!$deps_path) {
throw new Exception("Couldn't determine dependencies path. Please either switch to the PHP source root or use -d option.");
}
$cache = new Cache($deps_path);
$fetcher = new Fetcher(self::$depsHost, self::$depsPort, self::$depsUriScheme);
$tmp = $fetcher->getByUri(self::$depsBaseUri . "/series/");
if (false !== $tmp) {
if ("" !== $tmp) {
$data = array();
if (preg_match_all(",/packages-(.+)-(vc\d+)-(x86|x64)-(stable|staging)\.txt,U", $tmp, $m, PREG_SET_ORDER)) {
if (preg_match_all(",packages-(.+)-(v[cs]\d+)-(x86|x64|arm64)-(stable|staging)\.txt,Us", $tmp, $m, PREG_SET_ORDER)) {
foreach ($m as $b) {
if (!isset($data[$b[1]])) {
$data[$b[1]] = array();
@@ -179,6 +212,11 @@ class Config
$branch = NULL;
$found = false;
$rmtools_branch = getenv("PHP_RMTOOLS_PHP_BUILD_BRANCH");
if ("master" == $rmtools_branch) {
return "master";
}
/* Try to figure out the branch. The worky scenarios are
- CWD is in php-src
- phpize is on the path
@@ -209,6 +247,19 @@ class Config
if (is_numeric($major) && is_numeric($minor)) {
$branch = "$major.$minor";
}
/* Verify that we use an available branch name. Master has some
version, but no dedicated series. For master, it rather
makes sense to use master as branch name. */
$git = trim(shell_exec("where git.exe"));
if ($git && is_dir(".git")) {
$cmd = "\"$git\" branch";
$ret = trim(shell_exec($cmd));
if (preg_match_all(",\*\s+master,", $ret) > 0) {
$branch = "master";
}
}
}
return $branch;
@@ -224,6 +275,7 @@ class Config
return self::$currentBranchName;
}/*}}}*/
/** @return array<mixed> */
public static function getCurrentBranchData() : array
{/*{{{*/
$ret = array();
@@ -234,6 +286,7 @@ class Config
throw new Exception("Unknown branch '$current_branch_name'");
}
$crt = null;
$cur_crt = Config::getCurrentCrtName();
if (count($branches[$current_branch_name]) > 1) {
if (NULL === $cur_crt) {
@@ -248,7 +301,7 @@ class Config
}
}
if (!$cur_crt_usable) {
throw new Exception("The passed CRT '$cur_crt' doesn't match any availbale for branch '$current_branch_name'");
throw new Exception("The passed CRT '$cur_crt' doesn't match any available for branch '$current_branch_name'");
}
$data = $branches[$current_branch_name][$cur_crt];
} else {
@@ -256,7 +309,7 @@ class Config
$crt = key($branches[$current_branch_name]);
$data = $branches[$current_branch_name][$crt];
if ($crt != $cur_crt) {
throw new Exception("The passed CRT '$cur_crt' doesn't match any availbale for branch '$current_branch_name'");
throw new Exception("The passed CRT '$cur_crt' doesn't match any available for branch '$current_branch_name'");
}
}
@@ -273,10 +326,13 @@ class Config
}
}
if (!$ret["stability"]) {
if (!isset($ret["arch"]) || !$ret["arch"]) {
throw new Exception("Failed to find config with arch '" . self::getCurrentArchName() . "'");
}
if (!isset($ret["stability"]) || !$ret["stability"]) {
throw new Exception("Failed to find config with stability '" . self::getCurrentStabilityName() . "'");
}
if (!$ret["crt"]) {
if (!isset($ret["crt"]) || !$ret["crt"]) {
throw new Exception("Failed to find config with arch '" . self::getCurrentArchName() . "'");
}

View File

@@ -2,9 +2,6 @@
namespace SDK;
use SDK\Config;
use SDK\Exception;
trait FileOps
{
protected function md(string $name = "", bool $tmp = false) : string
@@ -93,6 +90,7 @@ trait FileOps
if ($item->isFile()) {
if (!call_user_func($cb, $src_path, $dst_path)) {
assert(is_string($cb));
throw new Exception("Unable to $cb '$src_path' to '$dst_path'");
}
}
@@ -119,6 +117,9 @@ trait FileOps
protected function download(string $url, string $dest_fn = NULL) : ?string
{/*{{{*/
$fd = NULL;
$retry = 0;
retry:
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
@@ -137,6 +138,14 @@ trait FileOps
curl_setopt($ch, CURLOPT_USERAGENT, Config::getSdkUserAgentName());
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
$token = getenv('API_TOKEN');
if (!empty($token)) {
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Authorization: Bearer '.$token]);
}
// workaround for <https://github.com/microsoft/php-sdk-binary-tools/issues/69>
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
$ret = curl_exec($ch);
$code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
@@ -146,6 +155,9 @@ trait FileOps
if ($dest_fn) {
fclose($fd);
}
if ($retry++ < 3) {
goto retry;
}
throw new Exception($err);
}
@@ -193,7 +205,7 @@ trait FileOps
$name = substr($name, 0, -1);*/
$name = rtrim($stat["name"], "/");
while (strchr($name, '/') !== false) {
while (strstr($name, '/') !== false) {
$name = dirname($name);
}

View File

@@ -2,14 +2,21 @@
namespace SDK;
use SDK\{Config, Exception};
class Lock
{
/** @var ?resource */
protected $fd;
/** @var string */
protected $fn;
/** @var bool */
protected $locked = false;
/** @var bool|int */
protected $wouldBlock = false;
/** @var bool|int */
protected $shared = false;
public function __construct(string $tag, bool $auto = true, bool $autoShared = false)
@@ -68,6 +75,9 @@ class Lock
} else {
$this->fd = fopen($this->fn, "wb");
}
if (false === $this->fd) {
throw new Exception("Failed to open lock under '$this->fn'");
}
$this->locked = flock($this->fd, $flags, $this->wouldBlock);
return $this->locked;
}/*}}}*/

BIN
msys2/usr/bin/awk.exe Normal file → Executable file

Binary file not shown.

BIN
msys2/usr/bin/bison.exe Normal file → Executable file

Binary file not shown.

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

Binary file not shown.

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

Binary file not shown.

BIN
msys2/usr/bin/diff.exe Normal file → Executable file

Binary file not shown.

BIN
msys2/usr/bin/diff3.exe Normal file → Executable file

Binary file not shown.

BIN
msys2/usr/bin/gawk.exe Normal file → Executable file

Binary file not shown.

BIN
msys2/usr/bin/grep.exe Normal file → Executable file

Binary file not shown.

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

Binary file not shown.

BIN
msys2/usr/bin/m4.exe Normal file → Executable file

Binary file not shown.

BIN
msys2/usr/bin/md5sum.exe Normal file → Executable 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.

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