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 0a3e43d
Showing 1 changed file with 32 additions and 19 deletions.
51 changes: 32 additions & 19 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,15 +27,21 @@ function usage ()
INSTALL_DIR=
# linux distribution name
DISTRO=
PICK_PIC=ON
if [[ $(uname -s) == 'Darwin' ]]; then
PICK_PIC=OFF
fi

while getopts ":hi:d:" opt
while getopts ":hi:d:p:" opt
do
case $opt in

h ) usage; exit 0 ;;

d ) DISTRO=$OPTARG ;;

p ) PICK_PIC=$OPTARG ;;

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

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

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

Expand All @@ -68,7 +81,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 [[ "$PICK_PIC" == 'ON' ]]; then
libname=$(echo "$libname" | sed -e 's/\.pic\.a$/.a/')
fi

if [[ "$OSTYPE" == "linux-gnu"* ]]
then
Expand All @@ -85,20 +101,17 @@ 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/')
libname=$(basename "$file")
if [[ "$PICK_PIC" == 'ON' ]]; then
libname=$(echo "$libname" | sed -e 's/\.pic\.a$/.a/')
fi
if [[ "$OSTYPE" == "linux-gnu"* ]]
then
INSTALL_BIN="install"
Expand All @@ -121,38 +134,38 @@ 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"
find re2 -iname "*.h" -exec ${INSTALL_BIN} -D {} "$PREFIX"/include/{} \;
find re2 -iname "*.h" -exec ${INSTALL_BIN} -Dv {} "$PREFIX"/include/{} \;
popd

pushd "$(realpath .)/../../../../../external/com_googleapis_googleapis"
find google -iname "*.h" -exec ${INSTALL_BIN} -D {} "$PREFIX"/include/{} \;
find google -iname "*.h" -exec ${INSTALL_BIN} -Dv {} "$PREFIX"/include/{} \;
popd

pushd "$(realpath .)/../../../../../external/com_google_file_based_test_driver"
find file_based_test_driver -iname "*.h" -exec ${INSTALL_BIN} -D {} "$PREFIX"/include/{} \;
find file_based_test_driver -iname "*.h" -exec ${INSTALL_BIN} -Dv {} "$PREFIX"/include/{} \;
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

# zetasql generated files: protobuf & template generated files
find zetasql -type f -iname "*.h" -exec ${INSTALL_BIN} -D {} "$PREFIX"/include/{} \;
find zetasql -type f -iname "*.h" -exec ${INSTALL_BIN} -Dv {} "$PREFIX"/include/{} \;
find zetasql -iregex ".*/_virtual_includes/.*\.h\$" -exec bash -c 'install_gen_include_file $0' {} \;
popd # bazel-bin

# header files from source
find zetasql -type f -iname "*.h" -exec ${INSTALL_BIN} -D {} "$PREFIX"/include/{} \;
find zetasql -type f -iname "*.h" -exec ${INSTALL_BIN} -Dv {} "$PREFIX"/include/{} \;


if [[ "$OSTYPE" == "linux-gnu"* ]]
Expand Down

0 comments on commit 0a3e43d

Please sign in to comment.