You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by gn...@apache.org on 2020/01/23 02:25:45 UTC

[incubator-nuttx] 01/06: tools/refresh.sh: support to refresh all configuration by pseudo config

This is an automated email from the ASF dual-hosted git repository.

gnutt pushed a commit to branch pr149
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git

commit 5e30f1980788344330cc0b1e533534e9224afb9d
Author: Xiang Xiao <xi...@xiaomi.com>
AuthorDate: Thu Jan 23 04:07:43 2020 +0800

    tools/refresh.sh: support to refresh all configuration by pseudo config
    
    Change-Id: I0d7db7f6baeba22d3ea2745b983ed53a0e673180
    Signed-off-by: Xiang Xiao <xi...@xiaomi.com>
---
 tools/refresh.sh | 231 +++++++++++++++++++++++++++++--------------------------
 1 file changed, 120 insertions(+), 111 deletions(-)

diff --git a/tools/refresh.sh b/tools/refresh.sh
index 6f1f495..e08e963 100755
--- a/tools/refresh.sh
+++ b/tools/refresh.sh
@@ -37,7 +37,7 @@ WD=`test -d ${0%/*} && cd ${0%/*}; pwd`
 USAGE="USAGE: $0 [options] <board>:<config>"
 ADVICE="Try '$0 --help' for more information"
 
-unset CONFIG
+unset CONFIGS
 silent=n
 defaults=n
 prompt=y
@@ -80,40 +80,17 @@ while [ ! -z "$1" ]; do
     echo "     The board directory under nuttx/boards"
     echo "  <config>"
     echo "     The board configuration directory under nuttx/boards/<board>/configs"
+    echo "  Note: all configuration is refreshed if <board>:<config> equals all."
     exit 0
     ;;
   * )
-    CONFIG=$1
+    CONFIGS=$1
     break
     ;;
   esac
   shift
 done
 
-# Get the board configuration
-
-if [ -z "${CONFIG}" ]; then
-  echo "ERROR: No configuration provided"
-  echo $USAGE
-  echo $ADVICE
-  exit 1
-fi
-
-CONFIGSUBDIR=`echo ${CONFIG} | cut -s -d':' -f2`
-if [ -z "${CONFIGSUBDIR}" ]; then
-  CONFIGSUBDIR=`echo ${CONFIG} | cut -s -d'/' -f2`
-  if [ -z "${CONFIGSUBDIR}" ]; then
-    echo "ERROR: Malformed configuration: ${CONFIG}"
-    echo $USAGE
-    echo $ADVICE
-    exit 1
-  else
-    BOARDSUBDIR=`echo ${CONFIG} | cut -d'/' -f1`
-  fi
-else
-  BOARDSUBDIR=`echo ${CONFIG} | cut -d':' -f1`
-fi
-
 # Where are we
 
 MYNAME=`basename $0`
@@ -127,15 +104,7 @@ if [ ! -x tools/${MYNAME} ] ; then
   exit 1
 fi
 
-# Set up the environment
-
-BOARDDIR=boards/*/*/$BOARDSUBDIR
-SCRIPTSDIR=$BOARDDIR/scripts
-MAKEDEFS1=$SCRIPTSDIR/Make.defs
-
-CONFIGDIR=$BOARDDIR/configs/$CONFIGSUBDIR
-DEFCONFIG=$CONFIGDIR/defconfig
-MAKEDEFS2=$CONFIGDIR/Make.defs
+# If the cmpconfig executable does not exist, then build it
 
 CMPCONFIG_TARGET=cmpconfig
 CMPCONFIG1=tools/cmpconfig
@@ -143,36 +112,6 @@ CMPCONFIG2=tools/cmpconfig.exe
 CMPCONFIGMAKEFILE=Makefile.host
 CMPCONFIGMAKEDIR=tools
 
-# Check the board configuration directory
-
-if [ ! -d $BOARDDIR ]; then
-  echo "No board directory found at $BOARDDIR"
-  exit 1
-fi
-
-if [ ! -d $CONFIGDIR ]; then
-  echo "No configuration directory found at $CONFIGDIR"
-  exit 1
-fi
-
-if [ ! -r $DEFCONFIG ]; then
-  echo "No readable defconfig file at $DEFCONFIG"
-  exit 1
-fi
-
-if [ -r $MAKEDEFS1 ]; then
-  MAKEDEFS=$MAKEDEFS1
-else
-  if [ -r $MAKEDEFS2 ]; then
-    MAKEDEFS=$MAKEDEFS2
-  else
-    echo "No readable Make.defs file at $MAKEDEFS1 or $MAKEDEFS2"
-    exit 1
-  fi
-fi
-
-# If the cmpconfig executable does not exist, then build it
-
 if [ -x ${CMPCONFIG1} ]; then
   CMPCONFIG=${CMPCONFIG1}
 else
@@ -195,70 +134,140 @@ else
   fi
 fi
 
-# Copy the .config and Make.defs to the toplevel directory
+# Get the board configuration
+
+if [ -z "${CONFIGS}" ]; then
+  echo "ERROR: No configuration provided"
+  echo $USAGE
+  echo $ADVICE
+  exit 1
+fi
 
-rm -f SAVEconfig
-if [ -e .config ]; then
-  mv .config SAVEconfig || \
-    { echo "ERROR: Failed to move .config to SAVEconfig"; exit 1; }
+if [ "X${CONFIGS}" == "Xall" ]; then
+  CONFIGS=`find boards -name defconfig | cut -d'/' -f4,6`
 fi
 
-cp -a $DEFCONFIG .config || \
-  { echo "ERROR: Failed to copy $DEFCONFIG to .config"; exit 1; }
+for CONFIG in ${CONFIGS}; do
+  echo "Refresh ${CONFIG}"
 
-rm -f SAVEMake.defs
-if [ -e Make.defs ]; then
-  mv Make.defs SAVEMake.defs || \
-    { echo "ERROR: Failed to move Make.defs to SAVEMake.defs"; exit 1; }
-fi
+  # Set up the environment
 
-cp -a $MAKEDEFS Make.defs || \
-  { echo "ERROR: Failed to copy $MAKEDEFS to Make.defs"; exit 1; }
+  CONFIGSUBDIR=`echo ${CONFIG} | cut -s -d':' -f2`
+  if [ -z "${CONFIGSUBDIR}" ]; then
+    CONFIGSUBDIR=`echo ${CONFIG} | cut -s -d'/' -f2`
+    if [ -z "${CONFIGSUBDIR}" ]; then
+      echo "ERROR: Malformed configuration: ${CONFIG}"
+      echo $USAGE
+      echo $ADVICE
+      exit 1
+    else
+      BOARDSUBDIR=`echo ${CONFIG} | cut -d'/' -f1`
+    fi
+  else
+    BOARDSUBDIR=`echo ${CONFIG} | cut -d':' -f1`
+  fi
 
-# Then run oldconfig or oldefconfig
+  BOARDDIR=boards/*/*/$BOARDSUBDIR
+  SCRIPTSDIR=$BOARDDIR/scripts
+  MAKEDEFS1=$SCRIPTSDIR/Make.defs
 
-if [ "X${defaults}" == "Xy" ]; then
-  make olddefconfig
-else
-  make oldconfig
-fi
+  CONFIGDIR=$BOARDDIR/configs/$CONFIGSUBDIR
+  DEFCONFIG=$CONFIGDIR/defconfig
+  MAKEDEFS2=$CONFIGDIR/Make.defs
 
-# Run savedefconfig to create the new defconfig file
+  # Check the board configuration directory
 
-make savedefconfig
+  if [ ! -d $BOARDDIR ]; then
+    echo "No board directory found at $BOARDDIR"
+    exit 1
+  fi
 
-# Show differences
+  if [ ! -d $CONFIGDIR ]; then
+    echo "No configuration directory found at $CONFIGDIR"
+    exit 1
+  fi
+
+  if [ ! -r $DEFCONFIG ]; then
+    echo "No readable defconfig file at $DEFCONFIG"
+    exit 1
+  fi
 
-# sed -i -e "s/^CONFIG_APPS_DIR/# CONFIG_APPS_DIR/g" defconfig
-$CMPCONFIG $DEFCONFIG defconfig
+  if [ -r $MAKEDEFS1 ]; then
+    MAKEDEFS=$MAKEDEFS1
+  else
+    if [ -r $MAKEDEFS2 ]; then
+      MAKEDEFS=$MAKEDEFS2
+    else
+      echo "No readable Make.defs file at $MAKEDEFS1 or $MAKEDEFS2"
+      exit 1
+    fi
+  fi
+
+  # Copy the .config and Make.defs to the toplevel directory
+
+  rm -f SAVEconfig
+  if [ -e .config ]; then
+    mv .config SAVEconfig || \
+      { echo "ERROR: Failed to move .config to SAVEconfig"; exit 1; }
+  fi
 
-# Save the refreshed configuration
+  cp -a $DEFCONFIG .config || \
+    { echo "ERROR: Failed to copy $DEFCONFIG to .config"; exit 1; }
 
-if [ "X${prompt}" == "Xy" ]; then
-  read -p "Save the new configuration (y/n)?" -n 1 -r
-  echo
-  if [[ $REPLY =~ ^[Yy]$ ]]
-  then
+  rm -f SAVEMake.defs
+  if [ -e Make.defs ]; then
+    mv Make.defs SAVEMake.defs || \
+      { echo "ERROR: Failed to move Make.defs to SAVEMake.defs"; exit 1; }
+  fi
+
+  cp -a $MAKEDEFS Make.defs || \
+    { echo "ERROR: Failed to copy $MAKEDEFS to Make.defs"; exit 1; }
+
+  # Then run oldconfig or oldefconfig
+
+  if [ "X${defaults}" == "Xy" ]; then
+    make olddefconfig
+  else
+    make oldconfig
+  fi
+
+  # Run savedefconfig to create the new defconfig file
+
+  make savedefconfig
+
+  # Show differences
+
+  # sed -i -e "s/^CONFIG_APPS_DIR/# CONFIG_APPS_DIR/g" defconfig
+  $CMPCONFIG $DEFCONFIG defconfig
+
+  # Save the refreshed configuration
+
+  if [ "X${prompt}" == "Xy" ]; then
+    read -p "Save the new configuration (y/n)?" -n 1 -r
+    echo
+    if [[ $REPLY =~ ^[Yy]$ ]]
+    then
+      echo "Saving the new configuration file"
+      mv defconfig $DEFCONFIG || \
+          { echo "ERROR: Failed to move defconfig to $DEFCONFIG"; exit 1; }
+      chmod 644 $DEFCONFIG
+    fi
+  else
     echo "Saving the new configuration file"
     mv defconfig $DEFCONFIG || \
         { echo "ERROR: Failed to move defconfig to $DEFCONFIG"; exit 1; }
     chmod 644 $DEFCONFIG
   fi
-else
-  echo "Saving the new configuration file"
-  mv defconfig $DEFCONFIG || \
-      { echo "ERROR: Failed to move defconfig to $DEFCONFIG"; exit 1; }
-  chmod 644 $DEFCONFIG
-fi
 
-# Restore any previous .config and Make.defs files
+  # Restore any previous .config and Make.defs files
 
-if [ -e SAVEconfig ]; then
-  mv SAVEconfig .config || \
-    { echo "ERROR: Failed to move SAVEconfig to .config"; exit 1; }
-fi
+  if [ -e SAVEconfig ]; then
+    mv SAVEconfig .config || \
+      { echo "ERROR: Failed to move SAVEconfig to .config"; exit 1; }
+  fi
 
-if [ -e SAVEMake.defs ]; then
-  mv SAVEMake.defs Make.defs || \
-    { echo "ERROR: Failed to move SAVEMake.defs to Make.defs"; exit 1; }
-fi
+  if [ -e SAVEMake.defs ]; then
+    mv SAVEMake.defs Make.defs || \
+      { echo "ERROR: Failed to move SAVEMake.defs to Make.defs"; exit 1; }
+  fi
+done