11dnl config.m4 for extension arrow (Rust-based via ext-php-rs)
2- dnl This is a best-effort PIE compatibility shim delegating to cargo
32
43PHP_ARG_ENABLE([ arrow] ,
54 [ whether to enable arrow support] ,
@@ -8,41 +7,37 @@ PHP_ARG_ENABLE([arrow],
87
98if test "$PHP_ARROW" != "no"; then
109 AC_MSG_CHECKING ( [ for cargo (Rust build tool)] )
11- AC_PATH_PROG ( CARGO , cargo , no )
12- if test "$CARGO" = "no"; then
10+ AC_PATH_PROG ( CARGO , cargo )
11+ if test -z "$CARGO"; then
12+ RUSTUP_CARGO=$(rustup which cargo 2>/dev/null)
13+ if test -n "$RUSTUP_CARGO"; then
14+ CARGO=$RUSTUP_CARGO
15+ fi
16+ fi
17+ if test -z "$CARGO"; then
1318 AC_MSG_ERROR ( [ cargo is required to build the arrow extension. Install Rust from https://rustup.rs/] )
1419 fi
1520 AC_MSG_RESULT ( [ $CARGO] )
1621
17- dnl Build via cargo in the parent directory (where Cargo.toml lives)
18- EXT_DIR=$(pwd)
19- ARROW_SRC_DIR=$(dirname "$EXT_DIR")
20-
21- AC_MSG_NOTICE ( [ Building arrow extension via cargo...] )
22- (cd "$ARROW_SRC_DIR" && $CARGO build --release) || AC_MSG_ERROR ( [ cargo build failed] )
23-
24- dnl Detect the built library
25- case $host_os in
26- darwin*)
27- ARROW_LIB="$ARROW_SRC_DIR/target/release/libarrow.dylib"
28- ;;
29- *)
30- ARROW_LIB="$ARROW_SRC_DIR/target/release/libarrow.so"
31- ;;
32- esac
33-
34- if test ! -f "$ARROW_LIB"; then
35- AC_MSG_ERROR ( [ Built library not found at $ARROW_LIB] )
22+ AC_MSG_CHECKING ( [ for rustc (Rust compiler)] )
23+ AC_PATH_PROG ( RUSTC , rustc )
24+ if test -z "$RUSTC"; then
25+ RUSTUP_RUSTC=$(rustup which rustc 2>/dev/null)
26+ if test -n "$RUSTUP_RUSTC"; then
27+ RUSTC=$RUSTUP_RUSTC
28+ fi
3629 fi
37-
38- dnl Copy built library to expected location
39- mkdir -p "$EXT_DIR/modules"
40- cp "$ARROW_LIB" "$EXT_DIR/modules/arrow.so"
30+ if test -z "$RUSTC"; then
31+ AC_MSG_ERROR ( [ rustc is required to build the arrow extension. Install Rust from https://rustup.rs/ ] )
32+ fi
33+ AC_MSG_RESULT ( [ $RUSTC ] )
4134
4235 dnl Create a dummy C file so phpize/configure infrastructure does not complain
43- if test ! -f "$EXT_DIR/arrow.c"; then
44- echo "/* Dummy - actual extension built by Rust/cargo */" > "$EXT_DIR/arrow.c"
36+ ARROW_EXT_DIR=$(pwd)
37+ if test ! -f "$ARROW_EXT_DIR/arrow.c"; then
38+ echo "/* Dummy - actual extension built by Rust/cargo */" > "$ARROW_EXT_DIR/arrow.c"
4539 fi
4640
4741 PHP_NEW_EXTENSION(arrow, arrow.c, $ext_shared)
42+ PHP_ADD_MAKEFILE_FRAGMENT
4843fi
0 commit comments