Skip to content

Commit f30f095

Browse files
authored
Merge branch 'main' into tiff
2 parents d91a66e + e492108 commit f30f095

File tree

7 files changed

+37
-9
lines changed

7 files changed

+37
-9
lines changed

config/env.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ PHP_SDK_PATH="${WORKING_DIR}\php-sdk-binary-tools"
6363
UPX_EXEC="${PKG_ROOT_PATH}\bin\upx.exe"
6464
; phpmicro patches, for more info, see: https://github.com/easysoft/phpmicro/tree/master/patches
6565
SPC_MICRO_PATCHES=static_extensions_win32,cli_checks,disable_huge_page,vcruntime140,win32,zend_stream,cli_static
66+
; Windows static linking system libs
67+
SPC_EXTRA_LIBS=""
6668

6769
[linux]
6870
; Linux can use different build toolchain, but the toolchain can not be changed in this file:

config/source.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
"license": {
55
"type": "file",
66
"path": "LICENSE"
7-
}
7+
},
8+
"alt": false
89
},
910
"amqp": {
1011
"type": "url",

src/SPC/builder/extension/curl.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use SPC\builder\Extension;
88
use SPC\builder\linux\LinuxBuilder;
99
use SPC\builder\macos\MacOSBuilder;
10+
use SPC\builder\windows\WindowsBuilder;
1011
use SPC\exception\FileSystemException;
1112
use SPC\exception\WrongUsageException;
1213
use SPC\store\FileSystem;
@@ -57,6 +58,17 @@ public function patchBeforeConfigure(): bool
5758
return true;
5859
}
5960

61+
public function patchBeforeMake(): bool
62+
{
63+
$extra_libs = getenv('SPC_EXTRA_LIBS');
64+
if ($this->builder instanceof WindowsBuilder && !str_contains($extra_libs, 'secur32.lib')) {
65+
$extra_libs .= ' secur32.lib';
66+
putenv('SPC_EXTRA_LIBS=' . trim($extra_libs));
67+
return true;
68+
}
69+
return false;
70+
}
71+
6072
public function patchBeforeSharedConfigure(): bool
6173
{
6274
$file = $this->source_dir . '/config.m4';

src/SPC/builder/windows/WindowsBuilder.php

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,6 @@ public function __construct(array $options = [])
6161
*/
6262
public function buildPHP(int $build_target = BUILD_TARGET_NONE): void
6363
{
64-
// ---------- Update extra-libs ----------
65-
$extra_libs = getenv('SPC_EXTRA_LIBS') ?: '';
66-
$extra_libs .= (empty($extra_libs) ? '' : ' ') . implode(' ', $this->getAllStaticLibFiles());
67-
f_putenv('SPC_EXTRA_LIBS=' . $extra_libs);
68-
6964
$enableCli = ($build_target & BUILD_TARGET_CLI) === BUILD_TARGET_CLI;
7065
$enableFpm = ($build_target & BUILD_TARGET_FPM) === BUILD_TARGET_FPM;
7166
$enableMicro = ($build_target & BUILD_TARGET_MICRO) === BUILD_TARGET_MICRO;
@@ -162,8 +157,10 @@ public function buildCli(): void
162157
{
163158
SourcePatcher::patchWindowsCLITarget();
164159

160+
$extra_libs = getenv('SPC_EXTRA_LIBS') ?: '';
161+
165162
// add nmake wrapper
166-
FileSystem::writeFile(SOURCE_PATH . '\php-src\nmake_cli_wrapper.bat', "nmake /nologo LIBS_CLI=\"{$this->getOption('extra-libs')} ws2_32.lib shell32.lib\" EXTRA_LD_FLAGS_PROGRAM= %*");
163+
FileSystem::writeFile(SOURCE_PATH . '\php-src\nmake_cli_wrapper.bat', "nmake /nologo LIBS_CLI=\"ws2_32.lib shell32.lib {$extra_libs}\" EXTRA_LD_FLAGS_PROGRAM= %*");
167164

168165
cmd()->cd(SOURCE_PATH . '\php-src')->exec("{$this->sdk_prefix} nmake_cli_wrapper.bat --task-args php.exe");
169166

@@ -197,9 +194,11 @@ public function buildMicro(): void
197194
}
198195
FileSystem::writeFile(SOURCE_PATH . '\php-src\Makefile', $makefile);
199196

197+
$extra_libs = getenv('SPC_EXTRA_LIBS') ?: '';
198+
200199
// add nmake wrapper
201200
$fake_cli = $this->getOption('with-micro-fake-cli', false) ? ' /DPHP_MICRO_FAKE_CLI" ' : '';
202-
$wrapper = "nmake /nologo LIBS_MICRO=\"{$this->getOption('extra-libs')} ws2_32.lib shell32.lib\" CFLAGS_MICRO=\"/DZEND_ENABLE_STATIC_TSRMLS_CACHE=1{$fake_cli}\" %*";
201+
$wrapper = "nmake /nologo LIBS_MICRO=\"ws2_32.lib shell32.lib {$extra_libs}\" CFLAGS_MICRO=\"/DZEND_ENABLE_STATIC_TSRMLS_CACHE=1{$fake_cli}\" %*";
203202
FileSystem::writeFile(SOURCE_PATH . '\php-src\nmake_micro_wrapper.bat', $wrapper);
204203

205204
// phar patch for micro

src/SPC/builder/windows/library/curl.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ protected function build(): void
3737
'-DBUILD_EXAMPLES=OFF ' . // disable examples
3838
'-DUSE_LIBIDN2=OFF ' . // disable libidn2
3939
'-DCURL_USE_LIBPSL=OFF ' . // disable libpsl
40+
'-DUSE_WINDOWS_SSPI=ON ' . // use Schannel instead of OpenSSL
4041
'-DCURL_USE_SCHANNEL=ON ' . // use Schannel instead of OpenSSL
4142
'-DCURL_USE_OPENSSL=OFF ' . // disable openssl due to certificate issue
4243
'-DCURL_ENABLE_SSL=ON ' .

src/SPC/command/DownloadCommand.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,11 +245,15 @@ public function handle(): int
245245
}
246246
// if download failed, we will try to download alternative sources
247247
logger()->warning("Download failed: {$e->getMessage()}");
248-
logger()->notice("Trying to download alternative sources for {$source}");
249248
$alt_sources = Config::getSource($source)['alt'] ?? null;
250249
if ($alt_sources === null) {
250+
logger()->warning("No alternative sources found for {$source}, using default alternative source");
251251
$alt_config = array_merge($config, $this->getDefaultAlternativeSource($source));
252+
} elseif ($alt_sources === false) {
253+
logger()->warning("No alternative sources found for {$source}, skipping alternative download");
254+
throw $e;
252255
} else {
256+
logger()->notice("Trying to download alternative sources for {$source}");
253257
$alt_config = array_merge($config, $alt_sources);
254258
}
255259
Downloader::downloadSource($source, $alt_config, $force_all || in_array($source, $force_list));

src/SPC/command/dev/PackLibCommand.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,15 @@ public function handle(): int
4242

4343
$builder->proveLibs($libraries);
4444
$builder->validateLibsAndExts();
45+
46+
// before pack, check if the dependency tree contains lib-suggests
47+
foreach ($libraries as $lib) {
48+
if (Config::getLib($lib, 'lib-suggests', []) !== []) {
49+
logger()->critical("The library {$lib} has lib-suggests, packing [{$lib_name}] is not safe, abort !");
50+
return static::FAILURE;
51+
}
52+
}
53+
4554
foreach ($builder->getLibs() as $lib) {
4655
if ($lib->getName() !== $lib_name) {
4756
// other dependencies: install or build, both ok

0 commit comments

Comments
 (0)