[PATCH modular] Process a user-supplied list of module/components.

Trevor Woerner twoerner at gmail.com
Tue Oct 5 14:35:58 PDT 2010


From: Trevor Woerner <twoerner at gmail.com>

New feature.

Using the new "--modlist <file>" option, the user can specify a file which
contains a list of the module/component items to process. The file can contain
blank lines and comment lines which start with a hash mark (#).

The list can be in any arbitrary order, the script will process them in the
correct dependency order. The script can't figure out what the dependencies
are, it expects the list to contain the necessary module/component items.

The script attempts to process any unknown items at the end of the known list.

Suggested usage:
    1. run script go generate the list of known items, redirecting to a file
	$ util/modular/build.sh -L > modulefile
    2. edit file, commenting or deleting out unnecessary items
    3. run the build off the list:
	$ util/modular/build.sh $PREFIX --modfile modulefile ...

Signed-off-by: Trevor Woerner <twoerner at gmail.com>
---
 build.sh |  158 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 141 insertions(+), 17 deletions(-)

diff --git a/build.sh b/build.sh
index 1e31c2a..b904c97 100755
--- a/build.sh
+++ b/build.sh
@@ -1,5 +1,7 @@
 #!/bin/sh
 
+APP=$0
+
 envoptions() {
 cat << EOF
 global environment variables you may set:
@@ -864,6 +866,113 @@ build_doc() {
     build doc xorg-docs
 }
 
+# just process the modules supplied in the given file ($MODFILE)
+# in their correct order, attempt to process unknown modules at the end
+# globals used:
+#   $MODFILE - readable file containing list of modules to process
+# arguments:
+#   (none)
+# returns:
+#   0 - good
+#   1 - bad
+process_module_file() {
+    local line
+    local modlist=""
+    local inorder
+    local noorder
+    local module
+    local component
+    local processed=""
+    local mc
+    local found
+    local notprocessed=""
+
+    # preconds
+    if [ X"$MODFILE" = X ]; then
+	echo "internal process_module_file() error, \$MODFILE is empty"
+	return 1
+    fi
+    if [ ! -r "$MODFILE" ]; then
+	echo "module file '$MODFILE' is not readable or does not exist"
+	return 1
+    fi
+
+    # read from input file, skipping blank and comment lines
+    echo "reading module file '$MODFILE'..."
+    while read line; do
+	# skip blank lines
+	if [ X"$line" = X ]; then
+	    continue
+	fi
+
+	# skip comment lines
+	echo "$line" | grep "^#" > /dev/null
+	if [ $? -eq 0 ]; then
+	    continue
+	fi
+
+	echo "- adding $line"
+	modlist="$modlist $line"
+    done <"$MODFILE"
+    echo "=> done!"
+
+    # process module/components in-order
+    for inorder in `$APP -L`; do
+	# handle the resume case whereby a module was in the list,
+	# a failure occurs, a resume is requested, and the module
+	# is now missing from the list
+	if [ X"$RESUME" = X"$inorder" ]; then
+	    unset RESUME
+	fi
+
+	for noorder in $modlist; do
+	    if [ X"$inorder" = X"$noorder" ]; then
+		module=`echo $noorder | cut -d'/' -f1`
+		component=`echo $noorder | cut -d'/' -f2`
+		build $module $component
+		processed="$processed $noorder"
+	    fi
+	done
+    done
+
+    # check user-supplied list for extras which weren't processed
+    for noorder in $modlist; do
+	found=0
+	for mc in $processed; do
+	    if [ X"$noorder" = X"$mc" ]; then
+		found=1
+		break
+	    fi
+	done
+	if [ $found -eq 0 ]; then
+	    notprocessed="$notprocessed $noorder"
+	fi
+    done
+
+    # warn the user of any module/component items in the user-supplied list
+    # that don't appear in the known list
+    if [ X"$notprocessed" != X ]; then
+	echo ""
+	echo "***** WARNING: the following user-supplied module/components"
+	echo "               are not in the known list but will be attempted:"
+	for mc in $notprocessed; do
+	    echo "    $mc"
+	done
+    fi
+
+    # if any modules from the user-list are not processed
+    # attempt to process them now at the end
+    if [ X"$notprocessed" != X ]; then
+	for mc in $notprocessed; do
+	    module=`echo $mc | cut -d'/' -f1`
+	    component=`echo $mc | cut -d'/' -f2`
+	    build $module $component
+	done
+    fi
+
+    return 0
+}
+
 usage() {
     echo "Usage: $0 [options] prefix"
     echo "  where options are:"
@@ -886,6 +995,7 @@ usage() {
     echo "  --check : run make check in addition to others"
     echo "  --clone : clone non-existing repositories (uses \$GITROOT if set)"
     echo "  --cmd cmd : execute arbitrary git or make command 'cmd'"
+    echo "  --modfile file : only process the module/components specified in 'file'"
     echo ""
     echo "Usage: $0 -L"
     echo "  -L : just list modules to build"
@@ -1022,6 +1132,16 @@ do
 	    exit 1
 	fi
 	;;
+    --modfile)
+	required_arg $1 $2
+	shift
+	CLONE=1
+	if [ ! -r "$1" ]; then
+	    echo "can't find/read file '$1'"
+	    exit 1
+	fi
+	MODFILE=$1
+	;;
     *)
 	if [ X"$PREFIX" != X ]; then
 	    echo "unrecognized and/or too many command-line arguments"
@@ -1064,23 +1184,27 @@ if [ X"$LISTONLY" = X ]; then
     date
 fi
 
-# We must install the global macros before anything else
-build util macros
-build font util
-
-build_proto
-build_lib
-build_mesa
-
-if [ $LIB_ONLY -eq 0 ]; then
-    build_doc
-    build data bitmaps
-    build_app
-    build_xserver
-    build_driver
-    build_data
-    build_font
-    build_util
+if [ X"$MODFILE" = X ]; then
+    # We must install the global macros before anything else
+    build util macros
+    build font util
+
+    build_proto
+    build_lib
+    build_mesa
+
+    if [ $LIB_ONLY -eq 0 ]; then
+	build_doc
+	build data bitmaps
+	build_app
+	build_xserver
+	build_driver
+	build_data
+	build_font
+	build_util
+    fi
+else
+    process_module_file
 fi
 
 if [ X"$LISTONLY" != X ]; then
-- 
1.7.3.1.50.g1e633



More information about the xorg-devel mailing list