tools/configure.sh: Support passing options to make

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: I6c928ac4574721aacb87be27c979ca8ae146a4ce
This commit is contained in:
Xiang Xiao 2020-03-20 12:08:27 +08:00 committed by David Sidrane
parent 024024f468
commit a54a492dd2
4 changed files with 48 additions and 37 deletions

View File

@ -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

View File

@ -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
}

View File

@ -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 $*

View File

@ -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