[RFC util-modular] build.sh: add --stop-at to skip some stages of each module

Gaetan Nadon memsize at videotron.ca
Fri Jul 27 13:19:35 PDT 2012


On 12-07-27 12:05 AM, Peter Hutterer wrote:
> Add a new command to stop each module after the given stage.
>
> Main use-case:
>   build.sh --clone --stop-at clone
> to quickly clone the source tree without building.
>
> Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
> ---
> There's an argument to be made for --start-at as well to quickly force a
> rebuild of all modules as well, without the autogen/configure stage.
> Likewise, once the NOCONFIGURE work hits, we could split autotools and
> configure as well, but that's all future work. Meanwhile, I just wanted
> build.sh to give me a full source tree without having to wait.
>
>  build.sh |   59 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 59 insertions(+)
>
> diff --git a/build.sh b/build.sh
> index 4d0efb5..ed4a195 100755
> --- a/build.sh
> +++ b/build.sh
> @@ -390,6 +390,11 @@ process() {
>          return 0
>      fi
>  
> +    stop_here "clone"
> +    if [ $? -ne 0 ]; then
> +        return 0
> +    fi
> +
Ok for this. This will clone any missing modules and not git-pull
existing modules.
>      old_pwd=`pwd`
>      cd $SRCDIR
>      if [ $? -ne 0 ]; then
> @@ -424,6 +429,11 @@ process() {
>          fi
>      fi
>  
> +    stop_here "update"
> +    if [ $? -ne 0 ]; then
> +        return 0
> +    fi
> +

Ok, this will clone missing modules and git-pull others such that you
have a complete up-to-date source tree.
>      # Build outside source directory
>      if [ X"$DIR_ARCH" != X ] ; then
>  	mkdir -p "$DIR_ARCH"
> @@ -464,6 +474,11 @@ process() {
>  	fi
>      fi
>  
> +    stop_here "configure"
> +    if [ $? -ne 0 ]; then
> +        return 0
> +    fi
> +
Limited usefulness. When autogen.sh is not run, dependant modules will
fail in the config step as the .pc files are not installed. Is it worth
the confusion? It can always be added later given the open design.

>      # A custom 'make' target list was supplied through --cmd option
>      if [ X"$MAKECMD" != X ]; then
>  	${MAKE} $MAKEFLAGS $MAKECMD
> @@ -490,6 +505,11 @@ process() {
>  	return 1
>      fi
>  
> +    stop_here "build"
> +    if [ $? -ne 0 ]; then
> +        return 0
> +    fi
> +
Limited usefulness. When make is not run, dependant modules will fail in
the config step as the .pc files are not installed. Is it worth the
confusion?

This is the wrong place to bail out. A user might have specified
--check. I don't think you meant the stop_at to be an override for
running the tests.


>      if [ X"$CHECK" != X ]; then
>  	${MAKE} $MAKEFLAGS check
>  	if [ $? -ne 0 ]; then
> @@ -524,6 +544,11 @@ process() {
>  	return 1
>      fi
>  
> +    stop_here "install"
> +    if [ $? -ne 0 ]; then
> +        return 0
> +    fi
> +

Same idea here, a user may have specified -c, -d or -D. Once fixed, I
can't see how stopping after install is any different from a normal
termination.
>      if [ X"$CLEAN" != X ]; then
>  	${MAKE} $MAKEFLAGS clean
>  	if [ $? -ne 0 ]; then
> @@ -1041,6 +1066,8 @@ process_module_file() {
>      return 0
>  }
>  
> +stages="clone update configure build install"
> +
>  usage() {
>      basename="`expr "//$0" : '.*/\([^/]*\)'`"
>      echo "Usage: $basename [options] [prefix]"
> @@ -1070,6 +1097,10 @@ usage() {
>      echo "              is assumed to be configuration options for the configuration"
>      echo "              of each module/component specifically"
>      echo "  --retry-v1  Remake 'all' on failure with Automake silent rules disabled"
> +    echo "  --stop-at <stage>"
> +    echo "              Stop module processing after <stage> and continue "
> +    echo "              with success. Allowed stages are:"
> +    echo "               $stages"
>      echo ""
>      echo "Usage: $basename -L"
>      echo "  -L          Just list modules to build"
> @@ -1077,6 +1108,17 @@ usage() {
>      envoptions
>  }
>  
> +stop_here() {
> +    current_stage=$1
> +
> +    if [ x$current_stage = x$STOP_STAGE ]; then
> +        echo "Stopping at stage $STOP_STAGE as requested"
> +        return 1
> +    fi
> +
> +    return 0
> +}
> +
>  # Ensure the named variable value contains a full path name
>  # arguments:
>  #   $1 - the variable value (the path to examine)
> @@ -1282,6 +1324,23 @@ do
>      --retry-v1)
>  	RETRY_VERBOSE=1
>  	;;
> +    --stop-at)
> +        shift
> +        STOP_STAGE=$1
> +        found=0
> +        for stage in $stages; do
> +            if [ "$stage" =  "$STOP_STAGE" ]; then
> +                found=1
> +                break
> +            fi
> +        done
> +        if [ $found -ne 1 ]; then
> +            echo "Invalid stage '$STOP_STAGE'. Allowed stages are: "
> +            echo "    $stages"
> +            usage
> +            exit 1
> +        fi
> +        ;;
>      *)
>  	if [ X"$too_many" = Xyes ]; then
>  	    echo "unrecognized and/or too many command-line arguments"

It looks like 'clone' and 'update' are the only stages that would be
useful. In terms of naming the stages, consider using 'git-pull' as
opposed to 'update' as this is very generic and mean different things to
different people.

For testing, verify 'auto-resume' and 'single component build' features
are not affected. Also check the log.
Will the patch affect the '--cmd' or 'retry-v1'?
What should happen if a user enters 'build.sh --stop-at clone' without
using --clone? Noop, error message?



More information about the xorg-devel mailing list