Skip to content

Commit 5c924e4

Browse files
committed
chore: wip
1 parent d84ebad commit 5c924e4

File tree

1 file changed

+69
-9
lines changed

1 file changed

+69
-9
lines changed

scripts/build-php.ts

Lines changed: 69 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1206,6 +1206,14 @@ function buildPhpWithSystemLibraries(config: BuildConfig, installPrefix: string)
12061206
const phpSourceDir = downloadPhpSource(config)
12071207
mkdirSync(installPrefix, { recursive: true })
12081208

1209+
// Install required system packages for extensions
1210+
log('Installing required system packages...')
1211+
try {
1212+
execSync('apt-get update && apt-get install -y libbz2-dev libzip-dev gettext libgettextpo-dev', { stdio: 'inherit' })
1213+
} catch (e) {
1214+
log('Warning: Could not install system packages, continuing with available libraries')
1215+
}
1216+
12091217
// Use clean system environment without any Launchpad paths
12101218
const buildEnv = {
12111219
...process.env,
@@ -1237,7 +1245,7 @@ function buildPhpWithSystemLibraries(config: BuildConfig, installPrefix: string)
12371245
})
12381246

12391247
log('Configuring PHP with system libraries...')
1240-
const configureArgs = [
1248+
const baseConfigureArgs = [
12411249
`--prefix=${installPrefix}`,
12421250
'--enable-bcmath',
12431251
'--enable-calendar',
@@ -1273,18 +1281,70 @@ function buildPhpWithSystemLibraries(config: BuildConfig, installPrefix: string)
12731281
'--with-zlib',
12741282
'--enable-opcache=shared',
12751283
'--with-readline',
1276-
'--without-zip',
1277-
'--without-iconv',
12781284
'--without-ldap-sasl'
12791285
]
12801286

1281-
execSync(`./configure ${configureArgs.join(' ')}`, {
1282-
cwd: phpSourceDir,
1283-
env: buildEnv,
1284-
stdio: 'inherit'
1285-
})
1287+
// Try to configure with all critical extensions first
1288+
const fullConfigureArgs = [
1289+
...baseConfigureArgs,
1290+
'--enable-zip',
1291+
'--with-iconv',
1292+
'--with-bz2',
1293+
'--with-gettext'
1294+
]
12861295

1287-
log('Building PHP...')
1296+
let configureSuccess = false
1297+
try {
1298+
log('Attempting full configure with all extensions...')
1299+
execSync(`./configure ${fullConfigureArgs.join(' ')}`, {
1300+
cwd: phpSourceDir,
1301+
env: buildEnv,
1302+
stdio: 'inherit'
1303+
})
1304+
configureSuccess = true
1305+
} catch (error) {
1306+
log('Full configure failed, trying individual extensions...')
1307+
1308+
// Try with individual extensions to see which ones work
1309+
const workingArgs = [...baseConfigureArgs]
1310+
1311+
// Test each extension individually
1312+
const extensionsToTest = [
1313+
{ flag: '--enable-zip', name: 'zip' },
1314+
{ flag: '--with-iconv', name: 'iconv' },
1315+
{ flag: '--with-bz2', name: 'bz2' },
1316+
{ flag: '--with-gettext', name: 'gettext' }
1317+
]
1318+
1319+
for (const ext of extensionsToTest) {
1320+
try {
1321+
const testArgs = [...baseConfigureArgs, ext.flag]
1322+
execSync(`./configure ${testArgs.join(' ')}`, {
1323+
cwd: phpSourceDir,
1324+
env: buildEnv,
1325+
stdio: 'pipe'
1326+
})
1327+
workingArgs.push(ext.flag)
1328+
log(`✅ ${ext.name} extension: Available`)
1329+
} catch (e) {
1330+
log(`❌ ${ext.name} extension: Not available, skipping`)
1331+
}
1332+
}
1333+
1334+
// Final configure with working extensions
1335+
execSync(`./configure ${workingArgs.join(' ')}`, {
1336+
cwd: phpSourceDir,
1337+
env: buildEnv,
1338+
stdio: 'inherit'
1339+
})
1340+
configureSuccess = true
1341+
}
1342+
1343+
if (!configureSuccess) {
1344+
throw new Error('Configure failed even with minimal extensions')
1345+
}
1346+
1347+
log('Configure completed successfully, building PHP...')
12881348
const jobs = execSync('nproc 2>/dev/null || echo 2', { encoding: 'utf8' }).trim()
12891349
execSync(`make -j${jobs}`, {
12901350
cwd: phpSourceDir,

0 commit comments

Comments
 (0)