Skip to content

Commit fb14b59

Browse files
committed
chore: wip
1 parent d9a7d2d commit fb14b59

File tree

1 file changed

+86
-5
lines changed

1 file changed

+86
-5
lines changed

scripts/build-php.ts

Lines changed: 86 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2232,15 +2232,33 @@ exec ./configure "$@"
22322232
})
22332233
log('🔧 ✅ Build-time PHP binary is working correctly')
22342234
} catch (error) {
2235-
log('🔧 ❌ Build-time PHP binary still has issues, attempting additional fixes...')
2235+
log('💥 ❌ CRITICAL: Build-time PHP binary validation failed')
2236+
log('💥 This indicates a fundamental compilation issue that cannot be resolved with fallbacks')
22362237

22372238
// Try additional comprehensive fixing
22382239
const otoolOutput = execSync(`otool -L "${buildTimePhpBinary}"`, { encoding: 'utf8' })
22392240
log('🔧 Current dependencies after first fix:')
22402241
log(otoolOutput)
22412242

22422243
// Apply fixes again in case some were missed
2243-
fixMacOSLibraryPaths(buildTimePhpBinary, homeDir)
2244+
try {
2245+
fixMacOSLibraryPaths(buildTimePhpBinary, homeDir)
2246+
2247+
// Test the binary one more time after fixes
2248+
execSync(`"${buildTimePhpBinary}" --version`, {
2249+
stdio: 'pipe',
2250+
env: {
2251+
...process.env,
2252+
DYLD_LIBRARY_PATH: libPaths.join(':'),
2253+
DYLD_FALLBACK_LIBRARY_PATH: libPaths.join(':')
2254+
}
2255+
})
2256+
log('🔧 ✅ Build-time PHP binary fixed successfully')
2257+
} catch (retryError) {
2258+
log('💥 ❌ CRITICAL: Build-time PHP binary cannot be fixed')
2259+
log('💥 This indicates a fundamental compilation failure')
2260+
throw new Error('Build failed: PHP binary compilation produced non-functional binary despite fixes')
2261+
}
22442262
}
22452263
}
22462264

@@ -2307,12 +2325,27 @@ exec ./configure "$@"
23072325
timeout: 15 * 60 * 1000, // 15 minutes timeout for install
23082326
})
23092327

2310-
// Fallback: if make install didn't create the binary, manually copy it
2328+
// Verify make install succeeded - it should have created the PHP binary
23112329
const phpBinaryPath = join(installPrefix, 'bin', 'php')
23122330
const buildTimePhpBinary = join(phpSourceDir, 'sapi', 'cli', 'php')
23132331

2314-
if (!existsSync(phpBinaryPath) && existsSync(buildTimePhpBinary)) {
2315-
log('🔧 ⚠️ make install did not create PHP binary, manually copying...')
2332+
if (!existsSync(phpBinaryPath)) {
2333+
log('💥 ❌ CRITICAL: make install failed to create PHP binary')
2334+
log(`💥 Expected PHP binary at: ${phpBinaryPath}`)
2335+
log(`💥 Build-time binary exists: ${existsSync(buildTimePhpBinary)}`)
2336+
2337+
if (existsSync(buildTimePhpBinary)) {
2338+
log('💥 This indicates make install failed during the installation phase')
2339+
log('💥 Check the make install logs above for errors')
2340+
} else {
2341+
log('💥 This indicates make compilation failed to produce a working binary')
2342+
log('💥 Check the make logs above for compilation errors')
2343+
}
2344+
2345+
throw new Error('Build failed: make install did not create PHP binary. This is a critical build failure.')
2346+
}
2347+
2348+
log('✅ make install successfully created PHP binary')
23162349

23172350
// Copy the main PHP binary
23182351
copyFileSync(buildTimePhpBinary, phpBinaryPath)
@@ -2414,6 +2447,54 @@ exec ./configure "$@"
24142447
}
24152448
}
24162449

2450+
// Additional post-build validation
2451+
log('🔍 Performing post-build validation...')
2452+
2453+
// Verify final PHP binary works correctly
2454+
try {
2455+
const phpBinaryPath = join(installPrefix, 'bin', 'php')
2456+
const versionOutput = execSync(`"${phpBinaryPath}" --version`, {
2457+
encoding: 'utf8',
2458+
env: {
2459+
...process.env,
2460+
DYLD_LIBRARY_PATH: libPaths.join(':'),
2461+
DYLD_FALLBACK_LIBRARY_PATH: libPaths.join(':')
2462+
}
2463+
})
2464+
2465+
log('✅ Final PHP binary validation successful')
2466+
log(`📋 PHP Version: ${versionOutput.split('\n')[0]}`)
2467+
2468+
// Check for required extensions
2469+
const extensionsOutput = execSync(`"${phpBinaryPath}" -m`, {
2470+
encoding: 'utf8',
2471+
env: {
2472+
...process.env,
2473+
DYLD_LIBRARY_PATH: libPaths.join(':'),
2474+
DYLD_FALLBACK_LIBRARY_PATH: libPaths.join(':')
2475+
}
2476+
})
2477+
2478+
const extensions = extensionsOutput.split('\n').filter(ext => ext.trim())
2479+
log(`📦 Available extensions (${extensions.length}): ${extensions.slice(0, 10).join(', ')}${extensions.length > 10 ? '...' : ''}`)
2480+
2481+
// Check for critical extensions required for Laravel/Composer
2482+
const criticalExtensions = ['Core', 'json', 'mbstring', 'iconv', 'openssl', 'curl']
2483+
const missingCritical = criticalExtensions.filter(ext => !extensions.includes(ext))
2484+
2485+
if (missingCritical.length > 0) {
2486+
log(`💥 ❌ CRITICAL: Missing required extensions: ${missingCritical.join(', ')}`)
2487+
throw new Error(`Build failed: Critical extensions missing: ${missingCritical.join(', ')}`)
2488+
}
2489+
2490+
log('✅ All critical extensions present')
2491+
2492+
} catch (error) {
2493+
log('💥 ❌ CRITICAL: Final PHP binary validation failed')
2494+
log(`💥 Error: ${error}`)
2495+
throw new Error('Build failed: Final PHP binary is not functional')
2496+
}
2497+
24172498
// Fix library paths on macOS after installation
24182499
if (config.platform === 'darwin') {
24192500
log('🔧 Fixing library paths for installed PHP binary...')

0 commit comments

Comments
 (0)