Skip to content

Commit 79d00fb

Browse files
committed
chore: wip
1 parent f0de567 commit 79d00fb

File tree

7 files changed

+79
-31
lines changed

7 files changed

+79
-31
lines changed

packages/launchpad/src/commands/dev.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ const cmd: Command = {
2828
skipGlobal: env.NODE_ENV === 'test' || env.LAUNCHPAD_SKIP_GLOBAL_AUTO_SCAN === 'true',
2929
})
3030

31+
// In shell mode, force exit to prevent hanging on async operations
32+
if (isShellIntegration) {
33+
process.exit(0)
34+
}
35+
3136
return 0
3237
},
3338
}

packages/launchpad/src/dev/dump.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1769,6 +1769,13 @@ function outputShellCode(dir: string, envBinPath: string, envSbinPath: string, p
17691769
pathComponents.push(envSbinPath)
17701770
}
17711771

1772+
// Add bun global bin directory for this environment (high priority for global installs)
1773+
const envRoot = fs.existsSync(envBinPath) ? path.dirname(envBinPath) : ''
1774+
const bunGlobalBinPath = path.join(envRoot, '.bun', 'bin')
1775+
if (envRoot && fs.existsSync(bunGlobalBinPath)) {
1776+
pathComponents.push(bunGlobalBinPath)
1777+
}
1778+
17721779
// Add global paths second (fallback for tools not in project environment)
17731780
if (globalBinPath && fs.existsSync(globalBinPath)) {
17741781
pathComponents.push(globalBinPath)

packages/launchpad/src/dev/shellcode.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,12 @@ __launchpad_switch_environment() {
254254
# Remove project-specific paths from PATH if they exist
255255
if [[ -n "$LAUNCHPAD_ENV_BIN_PATH" ]]; then
256256
export PATH=$(echo "$PATH" | sed "s|$LAUNCHPAD_ENV_BIN_PATH:||g" | sed "s|:$LAUNCHPAD_ENV_BIN_PATH||g" | sed "s|^$LAUNCHPAD_ENV_BIN_PATH$||g")
257+
258+
# Also remove bun global bin directory (derive from env path)
259+
local old_env_dir=$(dirname "$LAUNCHPAD_ENV_BIN_PATH")
260+
if [[ -n "$old_env_dir" ]]; then
261+
export PATH=$(echo "$PATH" | sed "s|$old_env_dir/.bun/bin:||g" | sed "s|:$old_env_dir/.bun/bin||g" | sed "s|^$old_env_dir/.bun/bin$||g")
262+
fi
257263
fi
258264
259265
# Show deactivation message if enabled
@@ -313,6 +319,12 @@ __launchpad_switch_environment() {
313319
# Remove old project paths from PATH
314320
if [[ -n "$LAUNCHPAD_ENV_BIN_PATH" ]]; then
315321
export PATH=$(echo "$PATH" | sed "s|$LAUNCHPAD_ENV_BIN_PATH:||g" | sed "s|:$LAUNCHPAD_ENV_BIN_PATH||g" | sed "s|^$LAUNCHPAD_ENV_BIN_PATH$||g")
322+
323+
# Also remove old bun global bin directory (derive from old env path)
324+
local old_env_dir=$(dirname "$LAUNCHPAD_ENV_BIN_PATH")
325+
if [[ -n "$old_env_dir" ]]; then
326+
export PATH=$(echo "$PATH" | sed "s|$old_env_dir/.bun/bin:||g" | sed "s|:$old_env_dir/.bun/bin||g" | sed "s|^$old_env_dir/.bun/bin$||g")
327+
fi
316328
317329
# Show deactivation message for old project if enabled
318330
if [[ "${showMessages}" == "true" ]]; then
@@ -340,6 +352,14 @@ __launchpad_switch_environment() {
340352
# Add project-specific path first (highest priority)
341353
export PATH="$env_dir/bin:$PATH"
342354
355+
# Add bun global bin directory for this environment (high priority for global installs)
356+
if [[ -d "$env_dir/.bun/bin" ]]; then
357+
# Remove bun global bin path if it was already in PATH
358+
export PATH=$(echo "$PATH" | sed "s|$env_dir/.bun/bin:||g" | sed "s|:$env_dir/.bun/bin||g" | sed "s|^$env_dir/.bun/bin$||g")
359+
# Add it with high priority (after project bin but before system paths)
360+
export PATH="$PATH:$env_dir/.bun/bin"
361+
fi
362+
343363
# Now ensure global paths are available but with lower priority
344364
# Add ~/.local/bin to PATH if not already there (after project paths)
345365
if [[ -d "$local_bin" && ":$PATH:" != *":$local_bin:"* ]]; then

packages/launchpad/src/php/precompiler.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,10 @@ export class PhpPrecompiler {
478478
// Platform-specific library paths
479479
if (this.config.platform === 'darwin') {
480480
// macOS: Set up proper environment for Launchpad dependencies
481-
const homeDir = process.env.HOME || '/Users/runner'
481+
const homeDir = process.env.HOME
482+
if (!homeDir) {
483+
throw new Error('HOME environment variable must be set for macOS builds')
484+
}
482485
const launchpadLibs = `${homeDir}/.local`
483486

484487
// Use existing environment variables from Launchpad

packages/launchpad/test-envs/test-shell-integration.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
1111
LAUNCHPAD_BIN=""
1212
if command -v launchpad >/dev/null 2>&1; then
1313
LAUNCHPAD_BIN="launchpad"
14-
elif [[ -f "/Users/chrisbreuer/.bun/bin/launchpad" ]]; then
15-
LAUNCHPAD_BIN="/Users/chrisbreuer/.bun/bin/launchpad"
14+
elif [[ -f "$HOME/.bun/bin/launchpad" ]]; then
15+
LAUNCHPAD_BIN="$HOME/.bun/bin/launchpad"
1616
elif [[ -f "/usr/local/bin/launchpad" ]]; then
1717
LAUNCHPAD_BIN="/usr/local/bin/launchpad"
1818
elif [[ -f "$SCRIPT_DIR/../bin/launchpad" ]]; then

scripts/build-php.ts

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -234,9 +234,6 @@ echo This is not a real PHP binary. The download of the Windows PHP binary faile
234234
}
235235

236236
function generateConfigureArgs(config: BuildConfig, installPrefix: string): string[] {
237-
const homeDir = process.env.HOME || process.env.USERPROFILE
238-
const launchpadPath = `${homeDir}/.local`
239-
240237
// Base configure arguments for all platforms
241238
const baseArgs = [
242239
`--prefix=${installPrefix}`,
@@ -271,23 +268,23 @@ function generateConfigureArgs(config: BuildConfig, installPrefix: string): stri
271268
'--without-gdbm'
272269
]
273270

274-
// Add Launchpad dependency paths
271+
// Use Launchpad libraries without hardcoded paths - rely on PKG_CONFIG_PATH and environment
275272
const dependencyArgs = [
276-
`--with-curl=${launchpadPath}/curl.se/v8.15.0`,
277-
`--with-ffi=${launchpadPath}/sourceware.org/libffi/v3.5.2`,
278-
`--with-gettext=${launchpadPath}/gnu.org/gettext/v0.22.5`,
279-
`--with-gmp=${launchpadPath}/gnu.org/gmp/v6.3.0`,
280-
`--with-openssl=${launchpadPath}/openssl.org/v1.1.1w`,
281-
`--with-sodium=${launchpadPath}/libsodium.org/v1.0.18`,
282-
`--with-xsl=${launchpadPath}/gnome.org/libxslt/v1.1.43`,
283-
`--with-zlib=${launchpadPath}/zlib.net/v1.3.1`,
284-
`--with-bz2=${launchpadPath}/sourceware.org/bzip2/v1.0.8`
273+
'--with-curl', // Will use PKG_CONFIG_PATH to find curl
274+
'--with-ffi', // Will use PKG_CONFIG_PATH to find libffi
275+
'--with-gettext', // Will use PKG_CONFIG_PATH to find gettext
276+
'--with-gmp', // Will use PKG_CONFIG_PATH to find gmp
277+
'--with-openssl', // Will use PKG_CONFIG_PATH to find openssl
278+
'--with-sodium', // Will use PKG_CONFIG_PATH to find sodium
279+
'--with-xsl', // Will use PKG_CONFIG_PATH to find xsl
280+
'--with-zlib', // Will use PKG_CONFIG_PATH to find zlib
281+
'--with-bz2' // Will use PKG_CONFIG_PATH to find bz2
285282
]
286283

287284
// Platform-specific dependency paths
288285
const platformDependencyArgs = []
289286
if (config.platform === 'darwin') {
290-
platformDependencyArgs.push(`--with-iconv=${launchpadPath}/gnu.org/libiconv/v1.18.0`)
287+
platformDependencyArgs.push('--with-iconv') // Will use PKG_CONFIG_PATH to find iconv
291288
}
292289

293290
// Platform-specific arguments
@@ -796,7 +793,10 @@ async function buildPhp(config: BuildConfig): Promise<string> {
796793

797794
// Set up build environment with selective Launchpad dependencies
798795
let buildEnv = { ...process.env }
799-
const homeDir = process.env.HOME || process.env.USERPROFILE || '/Users/chrisbreuer'
796+
const homeDir = process.env.HOME || process.env.USERPROFILE
797+
if (!homeDir) {
798+
throw new Error('HOME or USERPROFILE environment variable must be set')
799+
}
800800
const launchpadRoot = `${homeDir}/.local`
801801

802802
// Add essential Launchpad paths to PATH
@@ -825,7 +825,8 @@ async function buildPhp(config: BuildConfig): Promise<string> {
825825
`${launchpadRoot}/sourceware.org/libffi/v3.5.2/lib/pkgconfig`,
826826
`${launchpadRoot}/gnome.org/libxslt/v1.1.43/lib/pkgconfig`,
827827
`${launchpadRoot}/sqlite.org/v3.47.2/lib/pkgconfig`,
828-
`${launchpadRoot}/libzip.org/v1.11.4/lib/pkgconfig`
828+
`${launchpadRoot}/libzip.org/v1.11.4/lib/pkgconfig`,
829+
`${launchpadRoot}/invisible-island.net/ncurses/v6.5.0/lib/pkgconfig`
829830
]
830831

831832
// Completely exclude libstdcxx and gcc paths on Linux
@@ -854,7 +855,8 @@ async function buildPhp(config: BuildConfig): Promise<string> {
854855
`${launchpadRoot}/sourceware.org/libffi/v3.5.2/lib`,
855856
`${launchpadRoot}/gnome.org/libxslt/v1.1.43/lib`,
856857
`${launchpadRoot}/sqlite.org/v3.47.2/lib`,
857-
`${launchpadRoot}/libzip.org/v1.11.4/lib`
858+
`${launchpadRoot}/libzip.org/v1.11.4/lib`,
859+
`${launchpadRoot}/invisible-island.net/ncurses/v6.5.0/lib`
858860
]
859861

860862
// Completely exclude libstdcxx and gcc paths on Linux
@@ -880,7 +882,8 @@ async function buildPhp(config: BuildConfig): Promise<string> {
880882
`${launchpadRoot}/sourceware.org/libffi/v3.5.2/include`,
881883
`${launchpadRoot}/gnome.org/libxslt/v1.1.43/include`,
882884
`${launchpadRoot}/sqlite.org/v3.47.2/include`,
883-
`${launchpadRoot}/libzip.org/v1.11.4/include`
885+
`${launchpadRoot}/libzip.org/v1.11.4/include`,
886+
`${launchpadRoot}/invisible-island.net/ncurses/v6.5.0/include`
884887
]
885888

886889
// Add iconv paths for macOS only (Linux uses system iconv)
@@ -895,14 +898,16 @@ async function buildPhp(config: BuildConfig): Promise<string> {
895898
buildEnv.LDFLAGS = libPaths.map(path => `-L${path}`).join(' ')
896899
buildEnv.CPPFLAGS = includePaths.map(path => `-I${path}`).join(' ')
897900

898-
// Add macOS-specific linker flags for DNS resolver functions
901+
// Add platform-specific linker flags without hardcoded rpaths
899902
if (config.platform === 'darwin') {
900-
buildEnv.LDFLAGS += ` -lresolv -Wl,-rpath,${launchpadRoot},-headerpad_max_install_names`
901-
// Set up runtime library path for macOS
903+
// macOS: Use standard system paths only, rely on shim scripts for dynamic library loading
904+
buildEnv.LDFLAGS += ` -lresolv -Wl,-rpath,/usr/local/lib,-rpath,/opt/homebrew/lib,-headerpad_max_install_names`
905+
// Set up runtime library path for macOS (build-time only)
902906
buildEnv.DYLD_LIBRARY_PATH = libPaths.join(':')
903907
buildEnv.LD = '/usr/bin/ld'
904908
} else {
905-
buildEnv.LDFLAGS += ` -Wl,-rpath,${launchpadRoot}`
909+
// Linux: Use standard system paths only, rely on shim scripts for dynamic library loading
910+
buildEnv.LDFLAGS += ` -Wl,-rpath,/usr/local/lib,-rpath,/usr/lib`
906911
}
907912

908913
log('✅ Configured targeted Launchpad dependencies')

test.sh

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
echo "🧪 Testing PHP Build - Simplified Approach..."
44

5-
cd /Users/chrisbreuer/Code/launchpad
5+
cd "$(dirname "$0")"
66

77
echo "1. Testing basic compilation with libintl..."
88
mkdir -p /tmp/simple-test
@@ -12,10 +12,17 @@ echo '#include <libintl.h>' > test.c
1212
echo 'int main() { bindtextdomain("test", "."); return 0; }' >> test.c
1313

1414
echo "2. Testing libintl compilation..."
15-
clang -I/Users/chrisbreuer/.local/gnu.org/gettext/v0.22.5/include \
16-
-L/Users/chrisbreuer/.local/gnu.org/gettext/v0.22.5/lib \
17-
-Wl,-rpath,/Users/chrisbreuer/.local/gnu.org/gettext/v0.22.5/lib \
18-
-lintl test.c -o test
15+
# Use dynamic paths instead of hardcoded ones
16+
GETTEXT_DIR="$HOME/.local/gnu.org/gettext/v0.22.5"
17+
if [ ! -d "$GETTEXT_DIR" ]; then
18+
echo "⚠️ Gettext not found at $GETTEXT_DIR, using system libraries"
19+
clang -lintl test.c -o test
20+
else
21+
clang -I"$GETTEXT_DIR/include" \
22+
-L"$GETTEXT_DIR/lib" \
23+
-Wl,-rpath,"$GETTEXT_DIR/lib" \
24+
-lintl test.c -o test
25+
fi
1926

2027
if [ $? -eq 0 ]; then
2128
echo "✅ libintl compilation successful"
@@ -29,7 +36,8 @@ mkdir -p /tmp/minimal-php
2936
cd /tmp/minimal-php
3037

3138
echo "4. Downloading PHP source..."
32-
/Users/chrisbreuer/.local/gnu.org/wget/v1.25.0/bin/wget --no-check-certificate -O php-8.3.13.tar.gz https://www.php.net/distributions/php-8.3.13.tar.gz
39+
# Use curl instead of hardcoded wget path
40+
curl -L -k -o php-8.3.13.tar.gz https://www.php.net/distributions/php-8.3.13.tar.gz
3341

3442
echo "5. Extracting and configuring..."
3543
tar -xzf php-8.3.13.tar.gz

0 commit comments

Comments
 (0)