Skip to content

Commit e44efb2

Browse files
committed
use go mod to bypass github rate limiting
1 parent 598f6d5 commit e44efb2

File tree

2 files changed

+15
-22
lines changed

2 files changed

+15
-22
lines changed

src/SPC/builder/unix/UnixBuilderBase.php

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -143,11 +143,13 @@ protected function sanityCheck(int $build_target): void
143143
if (getenv('SPC_CMD_VAR_PHP_EMBED_TYPE') === 'shared') {
144144
if (PHP_OS_FAMILY === 'Darwin') {
145145
$ext_path = 'DYLD_LIBRARY_PATH=' . BUILD_LIB_PATH . ':$DYLD_LIBRARY_PATH ';
146-
} else {
146+
}
147+
else {
147148
$ext_path = 'LD_LIBRARY_PATH=' . BUILD_LIB_PATH . ':$LD_LIBRARY_PATH ';
148149
}
149150
FileSystem::removeFileIfExists(BUILD_LIB_PATH . '/libphp.a');
150-
} else {
151+
}
152+
else {
151153
$ext_path = '';
152154
$suffix = PHP_OS_FAMILY === 'Darwin' ? 'dylib' : 'so';
153155
foreach (glob(BUILD_LIB_PATH . "/libphp*.{$suffix}") as $file) {
@@ -268,25 +270,14 @@ protected function buildFrankenphp(): void
268270
logger()->warning('caddy-cbrotli module is enabled, but brotli library is not built. Disabling caddy-cbrotli.');
269271
$xcaddyModules = str_replace('--with github.com/dunglas/caddy-cbrotli', '', $xcaddyModules);
270272
}
271-
$releaseInfo = false;
272-
$retries = 5;
273-
while (!$releaseInfo && --$retries >= 0) {
274-
try {
275-
$releaseInfo = json_decode(Downloader::curlExec(
276-
'https://api.github.com/repos/php/frankenphp/releases/latest',
277-
hooks: [[CurlHook::class, 'setupGithubToken']],
278-
retries: 3,
279-
), true, 512, JSON_THROW_ON_ERROR);
280-
} catch (\Exception) {
281-
sleep(1);
282-
}
283-
}
284-
$frankenPhpVersion = $releaseInfo['tag_name'];
273+
[, $out] = shell()->execWithResult('go list -m github.com/dunglas/frankenphp@latest');
274+
$frankenPhpVersion = str_replace('github.com/dunglas/frankenphp v', '', $out[0]);
285275
$libphpVersion = $this->getPHPVersion();
286276
$dynamic_exports = '';
287277
if (getenv('SPC_CMD_VAR_PHP_EMBED_TYPE') === 'shared') {
288278
$libphpVersion = preg_replace('/\.\d+$/', '', $libphpVersion);
289-
} else {
279+
}
280+
else {
290281
if ($dynamicSymbolsArgument = LinuxSystemUtil::getDynamicExportedSymbols(BUILD_LIB_PATH . '/libphp.a')) {
291282
$dynamic_exports = ' ' . $dynamicSymbolsArgument;
292283
}
@@ -306,8 +297,8 @@ protected function buildFrankenphp(): void
306297
$libs = $config['libs'];
307298
$libs .= PHP_OS_FAMILY === 'Linux' ? ' -lrt' : '';
308299
// Go's gcc driver doesn't automatically link against -lgcov or -lrt. Ugly, but necessary fix.
309-
if ((str_contains((string) getenv('SPC_DEFAULT_C_FLAGS'), '-fprofile') ||
310-
str_contains((string) getenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS'), '-fprofile')) &&
300+
if ((str_contains((string)getenv('SPC_DEFAULT_C_FLAGS'), '-fprofile') ||
301+
str_contains((string)getenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS'), '-fprofile')) &&
311302
ToolchainManager::getToolchainClass() === GccNativeToolchain::class) {
312303
$cflags .= ' -Wno-error=missing-profile';
313304
$libs .= ' -lgcov';
@@ -326,7 +317,8 @@ protected function buildFrankenphp(): void
326317
foreach (GoXcaddy::getEnvironment() as $key => $value) {
327318
if ($key === 'PATH') {
328319
GlobalEnvManager::addPathIfNotExists($value);
329-
} else {
320+
}
321+
else {
330322
$env[$key] = $value;
331323
}
332324
}
@@ -337,7 +329,8 @@ protected function buildFrankenphp(): void
337329
if (!$this->getOption('no-strip', false) && file_exists(BUILD_BIN_PATH . '/frankenphp')) {
338330
if (PHP_OS_FAMILY === 'Linux') {
339331
shell()->cd(BUILD_BIN_PATH)->exec('strip --strip-unneeded frankenphp');
340-
} else { // macOS doesn't understand strip-unneeded
332+
}
333+
else { // macOS doesn't understand strip-unneeded
341334
shell()->cd(BUILD_BIN_PATH)->exec('strip -S frankenphp');
342335
}
343336
}

src/globals/test-extensions.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
$upx = false;
4444

4545
// whether to test frankenphp build, only available for macos and linux
46-
$frankenphp = false;
46+
$frankenphp = true;
4747

4848
// prefer downloading pre-built packages to speed up the build process
4949
$prefer_pre_built = false;

0 commit comments

Comments
 (0)