From 82af0f40a4933c701b7d7993477b35035889905e Mon Sep 17 00:00:00 2001 From: Asish Kumar Date: Thu, 9 Apr 2026 18:53:20 +0000 Subject: [PATCH] [GLUTEN-11885][VL] Respect custom VELOX_HOME in build info generation --- dev/builddeps-veloxbe.sh | 9 ++++++--- dev/gluten-build-info.sh | 42 ++++++++++++++++++++++++++++++++++++---- 2 files changed, 44 insertions(+), 7 deletions(-) diff --git a/dev/builddeps-veloxbe.sh b/dev/builddeps-veloxbe.sh index 7018df478cf1..6ce2c6d08315 100755 --- a/dev/builddeps-veloxbe.sh +++ b/dev/builddeps-veloxbe.sh @@ -120,15 +120,15 @@ do shift # Remove argument name from processing ;; --velox_repo=*) - VELOX_REPO=("${arg#*=}") + VELOX_REPO="${arg#*=}" shift # Remove argument name from processing ;; --velox_branch=*) - VELOX_BRANCH=("${arg#*=}") + VELOX_BRANCH="${arg#*=}" shift # Remove argument name from processing ;; --velox_home=*) - VELOX_HOME=("${arg#*=}") + VELOX_HOME="${arg#*=}" shift # Remove argument name from processing ;; --build_velox_tests=*) @@ -208,6 +208,9 @@ fi concat_velox_param +# Keep VELOX_HOME visible to child processes such as Maven's build-info generation step. +export VELOX_HOME + function build_arrow { if [ ! -d "$VELOX_HOME" ]; then get_velox diff --git a/dev/gluten-build-info.sh b/dev/gluten-build-info.sh index 61d7693f9e61..c22b100898e1 100755 --- a/dev/gluten-build-info.sh +++ b/dev/gluten-build-info.sh @@ -21,6 +21,7 @@ GLUTEN_ROOT=$(cd $(dirname -- $0)/..; pwd -P) EXTRA_RESOURCE_DIR=$GLUTEN_ROOT/gluten-core/target/generated-resources BUILD_INFO="$EXTRA_RESOURCE_DIR"/gluten-build-info.properties +BACKEND_HOME="" # Delete old build-info file before regenerating rm -f "$BUILD_INFO" @@ -38,9 +39,9 @@ function echo_revision_info() { function echo_velox_revision_info() { BACKEND_HOME=$1 echo gcc_version=$(strings $GLUTEN_ROOT/cpp/build/releases/libgluten.so | grep "GCC:" | head -n 1) - echo velox_branch=$(git -C $BACKEND_HOME rev-parse --abbrev-ref HEAD) - echo velox_revision=$(git -C $BACKEND_HOME rev-parse HEAD) - echo velox_revision_time=$(git -C $BACKEND_HOME show -s --format=%ci HEAD) + echo velox_branch=$(git -C "$BACKEND_HOME" rev-parse --abbrev-ref HEAD) + echo velox_revision=$(git -C "$BACKEND_HOME" rev-parse HEAD) + echo velox_revision_time=$(git -C "$BACKEND_HOME" show -s --format=%ci HEAD) } function echo_clickhouse_revision_info() { @@ -49,6 +50,34 @@ function echo_clickhouse_revision_info() { echo ch_commit=$(cat $GLUTEN_ROOT/cpp-ch/clickhouse.version | grep -oP '(?<=^CH_COMMIT=).*') } +function read_cmake_cache_path() { + CACHE_FILE="$GLUTEN_ROOT/cpp/build/CMakeCache.txt" + CACHE_KEY="$1" + if [ -f "$CACHE_FILE" ]; then + grep "^${CACHE_KEY}:PATH=" "$CACHE_FILE" | cut -d= -f2- | head -n 1 + fi +} + +function resolve_velox_home() { + if [ -n "$BACKEND_HOME" ]; then + echo "$BACKEND_HOME" + return + fi + + if [ -n "${VELOX_HOME:-}" ]; then + echo "$VELOX_HOME" + return + fi + + CACHED_VELOX_HOME=$(read_cmake_cache_path VELOX_HOME) + if [ -n "$CACHED_VELOX_HOME" ]; then + echo "$CACHED_VELOX_HOME" + return + fi + + echo "$GLUTEN_ROOT/ep/build-velox/build/velox_ep" +} + while (( "$#" )); do echo "$1" case $1 in @@ -60,12 +89,17 @@ while (( "$#" )); do echo backend_type="$BACKEND_TYPE" >> "$BUILD_INFO" # Compute backend home path based on type if [ "velox" = "$BACKEND_TYPE" ]; then - BACKEND_HOME="$GLUTEN_ROOT/ep/build-velox/build/velox_ep" + BACKEND_HOME=$(resolve_velox_home) echo_velox_revision_info "$BACKEND_HOME" >> "$BUILD_INFO" elif [ "ch" = "$BACKEND_TYPE" ] || [ "clickhouse" = "$BACKEND_TYPE" ]; then echo_clickhouse_revision_info >> "$BUILD_INFO" fi ;; + --backend_home|--velox_home) + if [ -n "$2" ]; then + BACKEND_HOME="$2" + fi + ;; --java) echo java_version="$2" >> "$BUILD_INFO" ;;