changeset 1680:543bee60af4c

Build standalone commands where "depends on" config entries need to be switched on.
author Rob Landley <rob@landley.net>
date Sat, 07 Feb 2015 17:20:23 -0600
parents ce1d240b8ec8
children 4bcfe4cf3e50
files scripts/make.sh scripts/single.sh
diffstat 2 files changed, 18 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/make.sh	Sat Feb 07 17:19:38 2015 -0600
+++ b/scripts/make.sh	Sat Feb 07 17:20:23 2015 -0600
@@ -56,7 +56,10 @@
 [ ! -z "$V" ] && echo "Which C files to build..."
 
 # Extract a list of toys/*/*.c files to compile from the data in $KCONFIG_CONFIG
-TOYFILES="$(egrep -l "TOY[(]($(sed -n 's/^CONFIG_\([^=]*\)=.*/\1/p' "$KCONFIG_CONFIG" | xargs | tr ' [A-Z]' '|[a-z]'))[ ,]" toys/*/*.c)"
+# (First command names, then filenames with relevant {NEW,OLD}TOY() macro.)
+
+TOYFILES="$(sed -n 's/^CONFIG_\([^=]*\)=.*/\1/p' "$KCONFIG_CONFIG" | xargs | tr ' [A-Z]' '|[a-z]')"
+TOYFILES="$(egrep -l "TOY[(]($TOYFILES)[ ,]" toys/*/*.c)"
 BUILD="$(echo ${CROSS_COMPILE}${CC} $CFLAGS -I . $OPTIMIZE)"
 FILES="$(echo lib/*.c main.c $TOYFILES)"
 
--- a/scripts/single.sh	Sat Feb 07 17:19:38 2015 -0600
+++ b/scripts/single.sh	Sat Feb 07 17:20:23 2015 -0600
@@ -10,18 +10,24 @@
 
 for i in "$@"
 do
+
+  TOYFILE="$(egrep -l "TOY[(]($i)[ ,]" toys/*/*.c)"
+
+  if [ -z "$TOYFILE" ]
+  then
+    echo "Unknown command '$i'" >&2
+    exit 1
+  fi
+
+  DEPENDS="$(sed -n 's/^[ \t]*depends on //;T;s/[!][A-Z0-9_]*//g;s/ *&& */|/g;p' $TOYFILE | xargs | tr ' ' '|')"
+
   NAME=$(echo $i | tr a-z- A-Z_)
   export KCONFIG_CONFIG=.singleconfig
-  USET="is not set"
 
   make allnoconfig > /dev/null &&
-  sed -i -e "s/\(CONFIG_TOYBOX\)=y/# \1 $USET/" \
-         -e "s/# \(CONFIG_$NAME\) $USET/\1=y/"  \
-         -e "s/# \(CONFIG_${NAME}_.*\) $USET/\1=y/" \
-         -e "s/# \(CONFIG_TOYBOX_HELP.*\) $USET/\1=y/" \
-         -e "s/# \(CONFIG_TOYBOX_I18N\) $USET/\1=y/" \
-         -e "s/# \(CONFIG_TOYBOX_FLOAT\) $USET/\1=y/" \
-         "$KCONFIG_CONFIG" &&
+  sed -ri -e "s/CONFIG_TOYBOX=y/# CONFIG_TOYBOX is not set/;t" \
+    -e "s/# (CONFIG_(TOYBOX(|_HELP|_I18N|_FLOAT)|$NAME|${NAME}_.*${DEPENDS:+|$DEPENDS})) is not set/\1=y/" \
+    "$KCONFIG_CONFIG" &&
   make &&
   mv toybox $PREFIX$i || exit 1
 done