You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by da...@apache.org on 2020/03/21 16:49:11 UTC
[incubator-nuttx] 05/08: tools/configure.sh: Support passing
options to make
This is an automated email from the ASF dual-hosted git repository.
davids5 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git
commit a54a492dd217ac49b6bc90a411db5f62aad512b8
Author: Xiang Xiao <xi...@xiaomi.com>
AuthorDate: Fri Mar 20 12:08:27 2020 +0800
tools/configure.sh: Support passing options to make
Signed-off-by: Xiang Xiao <xi...@xiaomi.com>
Change-Id: I6c928ac4574721aacb87be27c979ca8ae146a4ce
---
tools/README.txt | 3 ++-
tools/configure.c | 38 ++++++++++++++++++++++++++++----------
tools/configure.sh | 15 ++++++---------
tools/sethost.sh | 29 ++++++++++++-----------------
4 files changed, 48 insertions(+), 37 deletions(-)
diff --git a/tools/README.txt b/tools/README.txt
index fcf4b75..dfee90f 100644
--- a/tools/README.txt
+++ b/tools/README.txt
@@ -940,13 +940,14 @@ sethost.sh
$ ./sethost.sh -h
- USAGE: ./sethost.sh [-l|m|c|u|g|n]
+ USAGE: ./sethost.sh [-l|m|c|u|g|n] [make-opts]
./sethost.sh -h
Where:
-l|m|c|u|g|n selects Linux (l), macOS (m), Cygwin (c),
Ubuntu under Windows 10 (u), MSYS/MSYS2 (g)
or Windows native (n). Default Linux
+ make-opts directly pass to make
-h will show this help test and terminate
simhostroute.sh
diff --git a/tools/configure.c b/tools/configure.c
index d35b84b..c66f493 100644
--- a/tools/configure.c
+++ b/tools/configure.c
@@ -80,6 +80,7 @@
static void show_usage(const char *progname, int exitcode);
static void debug(const char *fmt, ...);
static void parse_args(int argc, char **argv);
+static int run_make(const char *arg);
static bool check_directory(const char *directory);
static void verify_directory(const char *directory);
static bool verify_optiondir(const char *directory);
@@ -147,6 +148,8 @@ static char *g_verstring = "0.0"; /* Version String */
static char *g_srcdefconfig = NULL; /* Source defconfig file */
static char *g_srcmakedefs = NULL; /* Source Make.defs file */
+static char **g_makeargv = NULL; /* Arguments pass to make */
+
static bool g_winnative = false; /* True: Windows native configuration */
static bool g_oldnative = false; /* True: Was Windows native configuration */
static bool g_needapppath = true; /* Need to add app path to the .config file */
@@ -177,7 +180,8 @@ static const char *g_optfiles[] =
static void show_usage(const char *progname, int exitcode)
{
fprintf(stderr, "\nUSAGE: %s [-d] [-e] [-b|f] [-l|m|c|u|g|n] "
- "[-a <app-dir>] <board-name>:<config-name>\n", progname);
+ "[-a <app-dir>] <board-name>:<config-name> [make-opts]\n",
+ progname);
fprintf(stderr, "\nUSAGE: %s [-h]\n", progname);
fprintf(stderr, "\nWhere:\n");
fprintf(stderr, " -d:\n");
@@ -235,6 +239,8 @@ static void show_usage(const char *progname, int exitcode)
fprintf(stderr, " a sub-directory under the board directory at\n");
fprintf(stderr, " under nuttx%cboards%c<board-name>%cconfigs%c.\n",
g_delim, g_delim, g_delim, g_delim);
+ fprintf(stderr, " [make-opts]:\n");
+ fprintf(stderr, " Options directly pass to make\n");
fprintf(stderr, " -h:\n");
fprintf(stderr, " Prints this message and exits.\n");
exit(exitcode);
@@ -368,11 +374,23 @@ static void parse_args(int argc, char **argv)
*ptr++ = '\0';
g_configdir = ptr;
- if (optind < argc)
+ /* The left arguments will pass to make */
+
+ g_makeargv = &argv[optind];
+}
+
+static int run_make(const char *arg)
+{
+ char **argv;
+
+ snprintf(g_buffer, BUFFER_SIZE, "make %s", arg);
+ for (argv = g_makeargv; *argv; argv++)
{
- fprintf(stderr, "ERROR: Unexpected garbage at the end of the line\n");
- show_usage(argv[0], EXIT_FAILURE);
+ strncat(g_buffer, " ", BUFFER_SIZE);
+ strncat(g_buffer, *argv, BUFFER_SIZE);
}
+
+ return system(g_buffer);
}
static bool check_directory(const char *directory)
@@ -789,14 +807,14 @@ static void check_configured(void)
{
if (g_debug)
{
- system("make distclean V=1");
+ run_make("distclean V=1");
}
else
{
#ifdef WIN32
- system("make distclean");
+ run_make("distclean");
#else
- system("make distclean 1>/dev/null");
+ run_make("distclean 1>/dev/null");
#endif
}
}
@@ -1456,14 +1474,14 @@ static void refresh(void)
if (g_debug)
{
- ret = system("make olddefconfig V=1");
+ ret = run_make("olddefconfig V=1");
}
else
{
#ifdef WIN32
- ret = system("make olddefconfig");
+ ret = run_make("olddefconfig");
#else
- ret = system("make olddefconfig 1>/dev/null");
+ ret = run_make("olddefconfig 1>/dev/null");
#endif
}
diff --git a/tools/configure.sh b/tools/configure.sh
index 5a653d8..aa01677 100755
--- a/tools/configure.sh
+++ b/tools/configure.sh
@@ -37,7 +37,7 @@ WD=`test -d ${0%/*} && cd ${0%/*}; pwd`
TOPDIR="${WD}/.."
USAGE="
-USAGE: ${0} [-d] [-e] [-l|m|c|u|g|n] [-a <app-dir>] <board-name>:<config-name>
+USAGE: ${0} [-d] [-e] [-l|m|c|u|g|n] [-a <app-dir>] <board-name>:<config-name> [make-opts]
Where:
-d enables script debug output
@@ -54,6 +54,7 @@ Where:
directory
<board-name> is the name of the board in the boards directory
configs/<config-name> is the name of the board configuration sub-directory
+ make-opts directly pass to make
"
@@ -99,13 +100,9 @@ while [ ! -z "$1" ]; do
exit 0
;;
*)
- if [ ! -z "${boardconfig}" ]; then
- echo ""
- echo "<board/config> defined twice"
- echo "$USAGE"
- exit 1
- fi
boardconfig=$1
+ shift
+ break
;;
esac
shift
@@ -181,7 +178,7 @@ if [ -r ${dest_config} ]; then
fi
if [ "X${enforce}" = "Xy" ]; then
- make -C ${TOPDIR} distclean
+ make -C ${TOPDIR} distclean $*
else
echo "Already configured!"
echo "Do 'make distclean' and try again."
@@ -293,4 +290,4 @@ fi
# The saved defconfig files are all in compressed format and must be
# reconstitued before they can be used.
-${TOPDIR}/tools/sethost.sh $debug $host
+${TOPDIR}/tools/sethost.sh $debug $host $*
diff --git a/tools/sethost.sh b/tools/sethost.sh
index 2d2bd18..af4aa4c 100755
--- a/tools/sethost.sh
+++ b/tools/sethost.sh
@@ -39,7 +39,7 @@ wenv=
function showusage {
echo ""
- echo "USAGE: $progname -d [-l|m|c|u|g|n]"
+ echo "USAGE: $progname -d [-l|m|c|u|g|n] [make-opts]"
echo " $progname -h"
echo ""
echo "Where:"
@@ -47,6 +47,7 @@ function showusage {
echo " -l|m|c|u|g|n selects Linux (l), macOS (m), Cygwin (c),"
echo " Ubuntu under Windows 10 (u), MSYS/MSYS2 (g)"
echo " or Windows native (n). Default Linux"
+ echo " make-opts directly pass to make"
echo " -h will show this help test and terminate"
exit 1
}
@@ -84,7 +85,7 @@ while [ ! -z "$1" ]; do
showusage
;;
* )
- break;
+ break
;;
esac
shift
@@ -116,23 +117,18 @@ if [ -z "$host" ]; then
esac
fi
-if [ ! -z "$1" ]; then
- echo "ERROR: Garbage at the end of line"
- showusage
-fi
-
WD=`test -d ${0%/*} && cd ${0%/*}; pwd`
cd $WD
if [ -x sethost.sh ]; then
- nuttx=$PWD/..
+ cd ..
+fi
+
+if [ -x tools/sethost.sh ]; then
+ nuttx=$PWD
else
- if [ -x tools/sethost.sh ]; then
- nuttx=$PWD
- else
- echo "This script must be execute in nuttx/ or nutts/tools directories"
- exit 1
- fi
+ echo "This script must be execute in nuttx/ or nutts/tools directories"
+ exit 1
fi
if [ ! -r $nuttx/.config ]; then
@@ -220,9 +216,8 @@ fi
sed -i -e "/CONFIG_HOST_OTHER/d" $nuttx/.config
echo " Refreshing..."
-cd $nuttx || { echo "ERROR: failed to cd to $nuttx"; exit 1; }
if [ "X${debug}" = "Xy" ]; then
- make olddefconfig V=1 || { echo "ERROR: failed to refresh"; exit 1; }
+ make olddefconfig $* V=1 || { echo "ERROR: failed to refresh"; exit 1; }
else
- make olddefconfig 1>/dev/null || { echo "ERROR: failed to refresh"; exit 1; }
+ make olddefconfig $* 1>/dev/null || { echo "ERROR: failed to refresh"; exit 1; }
fi