Skip to content

Commit

Permalink
[GLUTEN-6537][BUILD] Support more shell environments beyond Bash in b…
Browse files Browse the repository at this point in the history
…uild scripts
  • Loading branch information
wecharyu committed Jul 20, 2024
1 parent 318df24 commit 9058f64
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 12 deletions.
4 changes: 2 additions & 2 deletions cpp/compile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,12 @@ for arg in "$@"; do
done

CURRENT_DIR=$(
cd "$(dirname "$BASH_SOURCE")"
cd "$(dirname $0)"
pwd
)

#gluten cpp will find velox lib from VELOX_HOME
if [ "$VELOX_HOME" == "" ]; then
if [[ "$VELOX_HOME" == "" ]]; then
VELOX_HOME="$CURRENT_DIR/../ep/build-velox/build/velox_ep"
fi

Expand Down
2 changes: 1 addition & 1 deletion dev/build_arrow.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

CURRENT_DIR=$(cd "$(dirname "$BASH_SOURCE")"; pwd)
CURRENT_DIR=$(cd "$(dirname $0)"; pwd)
export SUDO=sudo
source ${CURRENT_DIR}/build_helper_functions.sh
VELOX_ARROW_BUILD_VERSION=15.0.0
Expand Down
2 changes: 1 addition & 1 deletion dev/builddeps-veloxbe.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
####################################################################################################
set -exu

CURRENT_DIR=$(cd "$(dirname "$BASH_SOURCE")"; pwd)
CURRENT_DIR=$(cd "$(dirname $0)"; pwd)
GLUTEN_DIR="$CURRENT_DIR/.."
BUILD_TYPE=Release
BUILD_TESTS=OFF
Expand Down
2 changes: 1 addition & 1 deletion dev/package-vcpkg.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

set -ex

CURRENT_DIR=$(cd "$(dirname "$BASH_SOURCE")"; pwd)
CURRENT_DIR=$(cd "$(dirname $0)"; pwd)
GLUTEN_DIR="$CURRENT_DIR/.."

cd "$GLUTEN_DIR"
Expand Down
2 changes: 1 addition & 1 deletion dev/package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

set -eux

CURRENT_DIR=$(cd "$(dirname "$BASH_SOURCE")"; pwd)
CURRENT_DIR=$(cd "$(dirname $0)"; pwd)
GLUTEN_DIR="$CURRENT_DIR/.."
THIRDPARTY_LIB="$GLUTEN_DIR/package/target/thirdparty-lib"
LINUX_OS=$(. /etc/os-release && echo ${ID})
Expand Down
17 changes: 13 additions & 4 deletions dev/vcpkg/env.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
#! /bin/bash
#!/bin/sh

if [ -z "${BASH_SOURCE[0]}" ] || [ "$0" == "${BASH_SOURCE[0]}" ]; then
echo "env.sh should only be sourced in bash" >&2
if [ -n "$BASH_VERSION" ]; then
# Replace `$0` with `BASH_SOURCE[0]` in Bash because it returns the shell when using `source`.
SCRIPT_PATH=${BASH_SOURCE[0]}
else
SCRIPT_PATH="$0"
fi

# source command does not start a new process, so the cmdline would not contains current script name.
CMD=$(cat /proc/$$/cmdline)
if [[ ${CMD} == *"$SCRIPT_PATH"* ]]; then
echo "env.sh should only be sourced" >&2
exit 1
fi

SCRIPT_ROOT="$(realpath "$(dirname "${BASH_SOURCE[0]}")")"
SCRIPT_ROOT="$(realpath "$(dirname "$SCRIPT_PATH")")"
init_vcpkg_env=$("${SCRIPT_ROOT}/init.sh")
eval "$init_vcpkg_env"
2 changes: 1 addition & 1 deletion ep/build-velox/src/build_velox.sh
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ function check_commit {
}

CURRENT_DIR=$(
cd "$(dirname "$BASH_SOURCE")"
cd "$(dirname $0)"
pwd
)

Expand Down
2 changes: 1 addition & 1 deletion ep/build-velox/src/get_velox.sh
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ echo "Preparing Velox source code..."
echo "ENABLE_HDFS=${ENABLE_HDFS}"

CURRENT_DIR=$(
cd "$(dirname "$BASH_SOURCE")"
cd "$(dirname $0)"
pwd
)

Expand Down

0 comments on commit 9058f64

Please sign in to comment.