Skip to content

Commit

Permalink
fix pack_zetasql.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
aceforeverd committed Sep 16, 2024
1 parent 30a04b6 commit 91d1889
Showing 1 changed file with 28 additions and 18 deletions.
46 changes: 28 additions & 18 deletions pack_zetasql.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ function usage ()
Options:
-h Display this message
-d Linux distribution name, e.g centos, ubuntu, default empty
-p Pick PIC libraries only, by default ON on linux, OFF on darwin
-i Request install to given directory after pack"

} # ---------- end of function usage ----------
Expand All @@ -26,6 +27,13 @@ function usage ()
INSTALL_DIR=
# linux distribution name
DISTRO=
PICK_PIC=ON
if [[ $(uname -s) == 'Darwin' ]]; then
PICK_PIC=
INSTALL_BIN="ginstall"
else
INSTALL_BIN="install"
fi

while getopts ":hi:d:" opt
do
Expand All @@ -35,6 +43,8 @@ do

d ) DISTRO=$OPTARG ;;

p ) PICK_PIC=ON ;;

i )
INSTALL_DIR=$OPTARG
mkdir -p "$INSTALL_DIR"
Expand All @@ -48,6 +58,12 @@ do
done
shift $((OPTIND-1))

if [[ -n "$PICK_PIC" ]] ; then
LIB_PATTERN='*.pic.a'
else
LIB_PATTERN='*.a'
fi

pushd "$(dirname "$0")"
pushd "$(git rev-parse --show-toplevel)"

Expand All @@ -68,7 +84,10 @@ install_lib() {
local file
file=$1
local libname
libname=lib$(echo "$file" | tr '/' '_' | sed -e 's/lib//' | sed -e 's/\.pic\.a$/.a/')
libname=lib$(echo "$file" | tr '/' '_' | sed -e 's/lib//' )
if [[ -n "$PICK_PIC" ]]; then
libname=$(echo "$libname" | sed -e 's/\.pic\.a$/.a/')
fi

if [[ "$OSTYPE" == "linux-gnu"* ]]
then
Expand All @@ -85,25 +104,16 @@ install_gen_include_file() {
local outfile
outfile=$(echo "$file" | sed -e 's/^.*proto\///')

if [[ "$OSTYPE" == "linux-gnu"* ]]
then
INSTALL_BIN="install"
else
INSTALL_BIN="ginstall"
fi
${INSTALL_BIN} -Dv "$file" "$PREFIX/include/$outfile"
}

install_external_lib() {
local file
file=$1
local libname
libname=$(basename "$file" | sed -e 's/\.pic\.a$/.a/')
if [[ "$OSTYPE" == "linux-gnu"* ]]
then
INSTALL_BIN="install"
else
INSTALL_BIN="ginstall"
libname=$(basename "$file")
if [[ -n "$PICK_PIC" ]]; then
libname=$(echo "$libname" | sed -e 's/\.pic\.a$/.a/')
fi
${INSTALL_BIN} -Dv "$file" "$PREFIX/lib/$libname"
}
Expand All @@ -121,7 +131,7 @@ else
fi

pushd bazel-bin/
find zetasql -type f -iname '*.pic.a' -exec bash -c 'install_lib $0' {} \;
find zetasql -type f -iname "$LIB_PATTERN" -exec bash -c 'install_lib $0' {} \;

# external lib headers
pushd "$(realpath .)/../../../../../external/com_googlesource_code_re2"
Expand All @@ -139,10 +149,10 @@ popd
# external lib
pushd external

find icu -type f -iname '*.pic.a' -exec bash -c 'install_external_lib $0' {} \;
find com_googlesource_code_re2 -type f -iname '*.pic.a' -exec bash -c 'install_external_lib $0' {} \;
find com_googleapis_googleapis -type f -iname '*.pic.a' -exec bash -c 'install_external_lib $0' {} \;
find com_google_file_based_test_driver -type f -iname '*.pic.a' -exec bash -c 'install_external_lib $0' {} \;
find icu -type f -iname "$LIB_PATTERN" -exec bash -c 'install_external_lib $0' {} \;
find com_googlesource_code_re2 -type f -iname "$LIB_PATTERN" -exec bash -c 'install_external_lib $0' {} \;
find com_googleapis_googleapis -type f -iname "$LIB_PATTERN" -exec bash -c 'install_external_lib $0' {} \;
find com_google_file_based_test_driver -type f -iname "$LIB_PATTERN" -exec bash -c 'install_external_lib $0' {} \;

popd

Expand Down

0 comments on commit 91d1889

Please sign in to comment.