[PATCH build] Add -L command-line option to list build components.

Peter Hutterer peter.hutterer at who-t.net
Thu Aug 26 15:50:06 PDT 2010


On Tue, Aug 10, 2010 at 10:29:09PM -0400, Trevor Woerner wrote:
> From: Trevor Woerner <twoerner at gmail.com>
> 
> I don't know if others have a better way of doing this, but sometimes it
> would be nice to sit in the top-most directory and perform arbitrary git
> commands in all modules which are being built. E.g.:
> 
> for module in `util/modular/build.sh -L`; do
>     pushd $module
>     git status
>     popd
> done
> 
> Reviewed-by: Patrick E. Kane <pekane52 at gmail.com>
> Signed-off-by: Trevor Woerner <twoerner at gmail.com>
> ---
>  build.sh |   68 ++++++++++++++++++++++++++++++++++++++-----------------------
>  1 files changed, 42 insertions(+), 26 deletions(-)
> 
> diff --git a/build.sh b/build.sh
> index 0bc366b..aef5641 100755
> --- a/build.sh
> +++ b/build.sh
> @@ -145,6 +145,10 @@ clone() {
>  }
>  
>  build() {
> +    if [ -n "$LISTONLY" ]; then
> +	echo "$1/$2"
> +	return 0
> +    fi
>      if [ -n "$RESUME" ]; then
>  	if [ "$RESUME" = "$1/$2" ]; then
>  	    unset RESUME
> @@ -701,6 +705,9 @@ usage() {
>      echo "  --autoresume file : autoresume from file"
>      echo "  --check : run make check in addition to others"
>      echo ""
> +    echo "Usage: $0 -L"
> +    echo "  -L : just list modules to build"
> +    echo ""

why not just add this to the normal list? it doesn't need the prefix but
then again ppl will likely figure that bit out anyway :)

>      envoptions
>  }
>  
> @@ -779,6 +786,9 @@ do
>  	shift
>  	SUDO=$1
>  	;;
> +    -L)
> +	LISTONLY=1
> +	;;
>      *)
>  	PREFIX=$1
>  	;;
> @@ -787,7 +797,7 @@ do
>      shift
>  done
>  
> -if test x"${PREFIX}" = x ; then
> +if test x"${PREFIX}" = x -a -z "$LISTONLY" ; then

nitpick: the rest of the script uses test foo && test foo instead of -a

>      usage
>      exit
>  fi
> @@ -803,11 +813,13 @@ export HOST_OS
>  export HOST_CPU
>  export LIBDIR
>  
> -echo "Building to run $HOST_OS / $HOST_CPU ($HOST)"
> +if [ -z "$LISTONLY" ]; then
> +    echo "Building to run $HOST_OS / $HOST_CPU ($HOST)"

test or []?

>  
> -# Must create local aclocal dir or aclocal fails
> -ACLOCAL_LOCALDIR="${DESTDIR}${PREFIX}/share/aclocal"
> -$SUDO mkdir -p ${ACLOCAL_LOCALDIR}
> +    # Must create local aclocal dir or aclocal fails
> +    ACLOCAL_LOCALDIR="${DESTDIR}${PREFIX}/share/aclocal"
> +    $SUDO mkdir -p ${ACLOCAL_LOCALDIR}
> +fi
>  
>  # The following is required to make aclocal find our .m4 macros
>  if test x"$ACLOCAL" = x; then
> @@ -840,10 +852,12 @@ if test x"$FONTPATH" = x; then
>      export FONTPATH
>  fi
>  
> -# Create the log file directory
> -$SUDO mkdir -p ${DESTDIR}${PREFIX}/var/log
> +if [ -z "$LISTONLY" ]; then
> +    # Create the log file directory
> +    $SUDO mkdir -p ${DESTDIR}${PREFIX}/var/log
>  
> -date
> +    date
> +fi

these few strike me as odd. you escape some of the env settings but not
others. might be better to define a setup_buildenv() that sets environment
variables and initialized the prefix and just skip the call to
setup_buildenv() if listonly is set.
>  
>  # We must install the global macros before anything else
>  build util macros
> @@ -864,26 +878,28 @@ if test $LIB_ONLY -eq 0; then
>      build_util
>  fi
>  
> -date
> +if [ -z "$LISTONLY" ]; then
> +    date
>  
> -if test "x$nonexistent_components" != x ; then
> -    echo ""
> -    echo "***** Skipped components (not available) *****"
> -    echo "$nonexistent_components"
> -    echo ""
> -fi
> +    if test "x$nonexistent_components" != x ; then
> +	echo ""
> +	echo "***** Skipped components (not available) *****"
> +	echo "$nonexistent_components"
> +	echo ""
> +    fi
>  
> -if test "x$failed_components" != x ; then
> -    echo ""
> -    echo "***** Failed components *****"
> -    echo "$failed_components"
> -    echo ""
> -fi
> +    if test "x$failed_components" != x ; then
> +	echo ""
> +	echo "***** Failed components *****"
> +	echo "$failed_components"
> +	echo ""
> +    fi
>  
> -if test "x$CLONE" != x && test "x$clonefailed_components" != x ;  then
> -    echo ""
> -    echo "***** Components failed to clone *****"
> -    echo "$clonefailed_components"
> -    echo ""
> +    if test "x$CLONE" != x && test "x$clonefailed_components" != x ;  then
> +	echo ""
> +	echo "***** Components failed to clone *****"
> +	echo "$clonefailed_components"
> +	echo ""
> +    fi
>  fi

not needed, the $failed_components, etc arent' modified if you exit that
early from build().

Cheers,
  Peter


More information about the xorg-devel mailing list