- Use meson when meson.build is present

- Protect souring when inside existing pg-env VENV
This commit is contained in:
Yogesh Sharma 2024-01-24 13:44:55 -05:00
parent a6c857bcb4
commit a82a004366

117
pg-env
View file

@ -52,48 +52,68 @@ fi
if [ -z "$PGV" ]; then if [ -z "$PGV" ]; then
echo "Missing PGV, export PGV=HEAD or export PGV=15" echo "Missing PGV, export PGV=HEAD or export PGV=15"
else else
PG_DEV_SRC=${GIT_DIR}/${PG_DEV_NAME} if [ -z "$PG_ENV_VENV" ]; then
PG_DEV_INST=${GIT_DIR}/${PG_INST_NAME} PG_DEV_SRC=${GIT_DIR}/${PG_DEV_NAME}
if [ ! -d ${PG_DEV_SRC} ] || [ ! -d ${PG_DEV_INST_DIR} ]; then PG_DEV_INST=${GIT_DIR}/${PG_INST_NAME}
echo "Missing source worktree/clone in ${PG_DEV_SRC} or ${PG_DEV_INST}" if [ ! -d ${PG_DEV_SRC} ] || [ ! -d ${PG_DEV_INST_DIR} ]; then
echo "git worktree add --track -b <local branch> ../<local dir> origin/<Branch/TAG>\ngit clone ...\n\n" echo "Missing source worktree/clone in ${PG_DEV_SRC} or ${PG_DEV_INST}"
echo "git worktree add --track -b REL_${PGV}_STABLE ../${PG_DEV_NAME} origin/REL_${PGV}_STABLE" echo "git worktree add --track -b <local branch> ../<local dir> origin/<Branch/TAG>\ngit clone ...\n\n"
echo "mkdir -p ${PG_DEV_INST}" echo "git worktree add --track -b REL_${PGV}_STABLE ../${PG_DEV_NAME} origin/REL_${PGV}_STABLE"
else echo "mkdir -p ${PG_DEV_INST}"
export SAVED_LD_LIBRARY_PATH=${LD_LIBRARY_PATH}
export SAVED_PGDATA=${PGDATA}
export SAVED_PGPORT=${PGPORT}
export SAVED_PGDATABASE=${PGDATABASE}
export PS1="(PG:${PGV}) ${SAVED_PS1}"
export VIRTUAL_ENV="PG:${PGV}"
export PG_DEV_SRC
export PG_DEV_INST
export PG_BIN=${PG_DEV_INST}/bin
export PGDATA=${PG_DEV_INST}/data
export PGDATABASE=postgres
export LD_LIBRARY_PATH=${PG_DEV_INST}/lib
export PATH=${PG_BIN}:${SAVED_PATH}
if [[ "$PGV" =~ '^[0-9]+$' ]]; then
export PGPORT=54${PGV}
else else
export PGPORT=5432 if [ -f ${PG_DEV_SRC}/meson.build ]; then
export MESON_BUILD_PRESENT=1
fi
export PG_ENV_VENV=1
export SAVED_LD_LIBRARY_PATH=${LD_LIBRARY_PATH}
export SAVED_PGDATA=${PGDATA}
export SAVED_PGPORT=${PGPORT}
export SAVED_PGDATABASE=${PGDATABASE}
export PS1="(PG:${PGV}) ${SAVED_PS1}"
export VIRTUAL_ENV="PG:${PGV}"
export PG_DEV_SRC
export PG_DEV_INST
export PG_BIN=${PG_DEV_INST}/bin
export PGDATA=${PG_DEV_INST}/data
export PGDATABASE=postgres
export LD_LIBRARY_PATH=${PG_DEV_INST}/lib
export PATH=${PG_BIN}:${SAVED_PATH}
if [[ "$PGV" =~ '^[0-9]+$' ]]; then
export PGPORT=54${PGV}
else
export PGPORT=5432
fi
fi fi
fi
distclean() { distclean() {
pushd ${PG_DEV_SRC} pushd ${PG_DEV_SRC}
make distclean make distclean
if [ -z ${MESON_BUILD_PRESENT} ]; then
(cd build; ninja clean)
fi
popd popd
} }
compile() { compile() {
pushd ${PG_DEV_SRC} pushd ${PG_DEV_SRC}
./configure --prefix=${PG_DEV_INST} --enable-debug --with-pgport=${PGPORT} --with-lz4 --with-ssl=openssl --with-python --with-perl --enable-debug --enable-cassert --enable-tap-tests CFLAGS="-ggdb -O0 -g3 -ggdb3 -fno-omit-frame-pointer ${PG_ENV_CFLAGS}" if [ -z ${MESON_BUILD_PRESENT} ]; then
if [ $? -gt 0 ]; then ./configure --prefix=${PG_DEV_INST} --enable-debug --with-pgport=${PGPORT} --with-lz4 --with-ssl=openssl --with-python --with-perl --enable-debug --enable-cassert --enable-tap-tests CFLAGS="-ggdb -O0 -g3 -ggdb3 -fno-omit-frame-pointer ${PG_ENV_CFLAGS}"
echo "Configure failed"
else else
make install meson setup build --prefix=${PG_DEV_INST} -Dpgport=${PGPORT} -Dlz4=enabled -Dssl=openssl -Dplpython=enabled -Dplperl=enabled -Ddebug=true -Dcassert=true -Dtap_tests=enabled -Dc_args="-ggdb -O0 -g3 -ggdb3 -fno-omit-frame-pointer ${PG_ENV_CFLAGS}"
fi
if [ $? -gt 0 ]; then
if [ -z ${MESON_BUILD_PRESENT} ]; then
echo "Configure failed"
else
echo "meson setup failed"
fi
else
if [ -z ${MESON_BUILD_PRESENT} ]; then
make install
else
(cd build; ninja -v install)
fi
if [ $? -gt 0 ]; then if [ $? -gt 0 ]; then
echo "make install failed" echo "make install failed"
fi fi
@ -102,12 +122,14 @@ compile() {
} }
compile_contrib() { compile_contrib() {
pushd ${PG_DEV_SRC}/contrib if [ -z ${MESON_BUILD_PRESENT} ]; then
make install pushd ${PG_DEV_SRC}/contrib
if [ $? -gt 0 ]; then make install
echo "make install failed" if [ $? -gt 0 ]; then
echo "make install failed"
fi
popd
fi fi
popd
} }
startdb(){ startdb(){
@ -206,16 +228,6 @@ deactivate() {
else else
unset PGDATABASE unset PGDATABASE
fi fi
unset PG_DEV_SRC
unset PG_DEV_INST
unset PG_BIN
unset SAVED_LD_LIBRARY_PATH
unset SAVED_PGDATA
unset SAVED_PGPORT
unset SAVED_PGDATABASE
unset SAVED_PATH
unset SAVED_PS1
unset SAVED_VIRTUAL_ENV
unset -f distclean unset -f distclean
unset -f compile unset -f compile
unset -f compile_contrib unset -f compile_contrib
@ -227,6 +239,21 @@ deactivate() {
unset -f resetdb unset -f resetdb
unset -f resetall unset -f resetall
unset -f deactivate unset -f deactivate
unset MESON_BUILD_PRESENT
unset PG_DEV_SRC
unset PG_DEV_INST
unset PG_BIN
unset SAVED_LD_LIBRARY_PATH
unset SAVED_PGDATA
unset SAVED_PGPORT
unset SAVED_PGDATABASE
unset SAVED_PATH
unset SAVED_PS1
unset SAVED_VIRTUAL_ENV
unset PG_ENV_VENV
} }
else
echo "Already in pg-env VENV"
fi
fi fi