From 7d406d7ecf1d23f27eacffeb6cfd315bd22c9214 Mon Sep 17 00:00:00 2001 From: "Steven R. Loomis" Date: Wed, 9 Nov 2011 02:28:05 +0000 Subject: [PATCH] ICU-8931 make icurun work with in-source and out-of-source builds, not just installed ICU. X-SVN-Rev: 30942 --- tools/scripts/icurun | 78 +++++++++++++++++++++++++++++++++++++------- 1 file changed, 67 insertions(+), 11 deletions(-) diff --git a/tools/scripts/icurun b/tools/scripts/icurun index 3556086015..7a399c9291 100755 --- a/tools/scripts/icurun +++ b/tools/scripts/icurun @@ -20,6 +20,15 @@ # -i /opt/local # -i /opt/local/bin # -i /opt/local/bin/icu-config +# +# Additionally, /icu/source is a built ICU source directory, either of the following will work: +# +# -i /icu +# -i /icu/source +# +# Also, if /build is an out-of-source build, this will work: +# +# -i /build # # 2) If there is an executable ~/.icurunrc script, it can set the variable "ICU_CONFIG" to point # directly to the icu-config file. @@ -72,6 +81,13 @@ then shift fi +if [ $1 == "-O" ]; +then + shift + XTRA_OPTS=$1 + shift +fi + if [ ! -x "${ICU_CONFIG}" ]; then ICU_CONFIG=`which icu-config 2>/dev/null || echo` @@ -84,6 +100,9 @@ then . ~/.icurunrc fi +IN_SOURCE= +ICU_CONFIG_OPTS= + if [ "x${ICU_OVERRIDE}" != "x" ]; then if [ -f "${ICU_OVERRIDE}" -a -x "${ICU_OVERRIDE}" ]; @@ -95,8 +114,16 @@ then elif [ -x "${ICU_OVERRIDE}/bin/icu-config" ]; then ICU_CONFIG="${ICU_OVERRIDE}/bin/icu-config" + elif [ -x "${ICU_OVERRIDE}/source/config/icu-config" ]; + then + ICU_CONFIG="${ICU_OVERRIDE}/source/config/icu-config" + IN_SOURCE="${ICU_OVERRIDE}/source" + elif [ -x "${ICU_OVERRIDE}/config/icu-config" ]; + then + ICU_CONFIG="${ICU_OVERRIDE}/config/icu-config" + IN_SOURCE="${ICU_OVERRIDE}" else - echo "$0: Don't know what to do with $ICU_OVERRIDE - not an executable or a directory" >&2 + echo "$0: Don't know what to do with $ICU_OVERRIDE - not an executable or a directory containing ICU source or install" >&2 exit 1 fi fi @@ -107,7 +134,41 @@ then exit 1 fi -echo 'ICU ' `${ICU_CONFIG} --version` `${ICU_CONFIG} --prefix` +if [ -d "${IN_SOURCE}" ]; +then + echo "ICU workspace dir:" "${IN_SOURCE}" + # revisit + if [ -f "${IN_SOURCE}/common/unicode/utypes.h" ]; + then + top_srcdir="${IN_SOURCE}" + else + top_srcdir=`sed -n -e 's%^top_srcdir = \(.*\)%\1%p' < "${IN_SOURCE}/Makefile"` + if [ ! -d "${top_srcdir}" ]; + then + echo "Sorry: cannot find top_srcdir from ${IN_SOURCE}/Makefile" + exit 1 + fi + fi + if [ ! -f "${top_srcdir}/common/unicode/utypes.h" ]; + then + echo Sorry: cannot find "${top_srcdir}/common/unicode/utypes.h" + exit 1 + fi + echo "ICU top level source dir:" "${top_srcdir}" + + ICU_CONFIG_OPTS=--noverify + LINKOPTS="--ldflags-libsonly --ldflags-system --ldflags-icuio" + OURLIBPATH=${IN_SOURCE}/lib:${IN_SOURCE}/stubdata:${IN_SOURCE}/tools/ctestfw + SRC_OPTS="-I${top_srcdir}/common -I${top_srcdir}/i18n -I${top_srcdir}/tools/ctestfw -I${top_srcdir}/tools/toolutil -I${IN_SOURCE}/common -L${IN_SOURCE}/lib -L${IN_SOURCE}/stubdata -L${IN_SOURCE}/tools/ctestfw" + INVOKE=`${ICU_CONFIG} ${ICU_CONFIG_OPTS} --invoke`:"${OURLIBPATH}" +else + # no cppflags for in-source + CPPOPTS="--cppflags" + LINKOPTS="--ldflags --ldflags-icuio" + INVOKE=`${ICU_CONFIG} ${ICU_CONFIG_OPTS} --invoke` +fi + +echo 'ICU ' version: `${ICU_CONFIG} ${ICU_CONFIG_OPTS} --version` prefix: `${ICU_CONFIG} ${ICU_CONFIG_OPTS} --prefix` FILE=$1 shift @@ -119,18 +180,16 @@ then exit 1 fi -CPPOPTS="--cppflags" -LINKOPTS="--ldflags --ldflags-icuio" case "${FILE}" in *.cpp) - COMP=`${ICU_CONFIG} --cxx --cxxflags ${CPPOPTS} ${LINKOPTS}` + COMP=`${ICU_CONFIG} ${ICU_CONFIG_OPTS} --cxx --cxxflags ${CPPOPTS} ${LINKOPTS}` OUT=`basename ${FILE} .cpp` ;; *.c) - COMP=`${ICU_CONFIG} --cc --cflags ${CPPOPTS} ${LINKOPTS}` + COMP=`${ICU_CONFIG} ${ICU_CONFIG_OPTS} --cc --cflags ${CPPOPTS} ${LINKOPTS}` OUT=`basename ${FILE} .c` ;; @@ -140,9 +199,6 @@ case "${FILE}" in ;; esac -echo "# ${COMP}" -o "${OUT}" "${FILE}" -${COMP} -o "${OUT}" "${FILE}" || (rm -f "${OUT}" ; exit 1) -INVOKE=`${ICU_CONFIG} --invoke=./${OUT}` -echo "# ${INVOKE}" -"${SHELL}" -c "${INVOKE}" "$@" +echo "# ${COMP}" -o "${OUT}" "${FILE}" "${XTRA_OPTS}" +( ${COMP} ${SRC_OPTS} -o "${OUT}" "${FILE}" "${XTRA_OPTS}" || (rm -f "${OUT}" ; exit 1) ) && ( echo "# ${INVOKE} ./${OUT}" ; "${SHELL}" -c "${INVOKE} ./${OUT}" "$@")