tools/configure.sh: Add -e option to invoke distclean if already configured

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: I19eddc3d4e6650eace2482c3cce8fbb07aadc04b
This commit is contained in:
Xiang Xiao 2020-03-20 02:09:45 +08:00 committed by David Sidrane
parent 1653b29542
commit c4ea4e976d
4 changed files with 58 additions and 28 deletions

View file

@ -648,6 +648,7 @@ endif
$(call DELFILE, include/nuttx/config.h)
$(call DELFILE, include/nuttx/version.h)
$(call DELFILE, Make.defs)
$(call DELFILE, defconfig)
$(call DELFILE, .config)
$(call DELFILE, .config.old)
$(call DELFILE, .gdbinit)

View file

@ -626,6 +626,7 @@ ifeq ($(CONFIG_BUILD_2PASS),y)
$(Q) $(MAKE) -C $(CONFIG_PASS1_BUILDIR) TOPDIR="$(TOPDIR)" distclean
endif
$(call DELFILE, Make.defs)
$(call DELFILE, defconfig)
$(call DELFILE, .config)
$(call DELFILE, .config.old)
$(call DELDIR, include\arch\board)

View file

@ -127,6 +127,7 @@ static char g_delim = '/'; /* Delimiter to use when forming pat
static bool g_winpaths = false; /* False: POSIX style paths */
#endif
static bool g_debug = false; /* Enable debug output */
static bool g_enforce = false; /* Enfore distclean */
static const char *g_appdir = NULL; /* Relative path to the application directory */
static const char *g_archdir = NULL; /* Name of architecture subdirectory */
@ -173,11 +174,13 @@ static const char *g_optfiles[] =
static void show_usage(const char *progname, int exitcode)
{
fprintf(stderr, "\nUSAGE: %s [-d] [-b] [-f] [-l|m|c|u|g|n] [-a <app-dir>] <board-name>:<config-name>\n", progname);
fprintf(stderr, "\nUSAGE: %s [-d] [-e] [-b|f] [-l|m|c|u|g|n] [-a <app-dir>] <board-name>:<config-name>\n", progname);
fprintf(stderr, "\nUSAGE: %s [-h]\n", progname);
fprintf(stderr, "\nWhere:\n");
fprintf(stderr, " -d:\n");
fprintf(stderr, " Enables debug output\n");
fprintf(stderr, " -e:\n");
fprintf(stderr, " Enforce distclean if already configured\n");
fprintf(stderr, " -b:\n");
#ifdef CONFIG_WINDOWS_NATIVE
fprintf(stderr, " Informs the tool that it should use Windows style paths like C:\\Program Files\n");
@ -246,7 +249,7 @@ static void parse_args(int argc, char **argv)
g_debug = false;
while ((ch = getopt(argc, argv, "a:bcdfghlmnu")) > 0)
while ((ch = getopt(argc, argv, "a:bcdefghlmnu")) > 0)
{
switch (ch)
{
@ -268,6 +271,10 @@ static void parse_args(int argc, char **argv)
g_debug = true;
break;
case 'e' :
g_enforce = true;
break;
case 'f' :
g_delim = '/';
g_winpaths = true;
@ -499,6 +506,11 @@ static void find_topdir(void)
/* Yes, we are probably in the tools/ sub-directory */
free(currdir);
if (chdir(g_topdir) < 0)
{
fprintf(stderr, "ERROR: Failed to ch to %s\n", g_topdir);
exit(EXIT_FAILURE);
}
}
}
@ -747,20 +759,27 @@ static void check_configured(void)
debug("check_configured: Checking %s\n", g_buffer);
if (verify_file(g_buffer))
{
fprintf(stderr, "ERROR: Found %s... Already configured\n", g_buffer);
fprintf(stderr, " Please 'make distclean' and try again\n");
exit(EXIT_FAILURE);
}
/* Try the Make.defs file */
snprintf(g_buffer, BUFFER_SIZE, "%s%cMake.defs", g_topdir, g_delim);
debug("check_configuration: Checking %s\n", g_buffer);
if (verify_file(g_buffer))
{
fprintf(stderr, "ERROR: Found %s... Already configured\n", g_buffer);
fprintf(stderr, " Please 'make distclean' and try again\n");
exit(EXIT_FAILURE);
if (g_enforce)
{
if (g_debug)
{
system("make distclean V=1");
}
else
{
#ifdef WIN32
system("make distclean");
#else
system("make distclean 1>/dev/null");
#endif
}
}
else
{
fprintf(stderr, "ERROR: Found %s... Already configured\n", g_buffer);
fprintf(stderr, " Please 'make distclean' and try again\n");
exit(EXIT_FAILURE);
}
}
}
@ -1397,13 +1416,6 @@ static void refresh(void)
{
int ret;
ret = chdir(g_topdir);
if (ret < 0)
{
fprintf(stderr, "ERROR: Failed to ch to %s\n", g_topdir);
exit(EXIT_FAILURE);
}
printf(" Refreshing...\n");
fflush(stdout);

View file

@ -37,10 +37,11 @@ WD=`test -d ${0%/*} && cd ${0%/*}; pwd`
TOPDIR="${WD}/.."
USAGE="
USAGE: ${0} [-d] [-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>
Where:
-d enables script debug output
-e enforce distclean if already configured
-l selects the Linux (l) host environment.
-m selects the macOS (m) host environment.
-c selects the Windows host and Cygwin (c) environment.
@ -71,6 +72,7 @@ unset winnative
unset appdir
unset host
unset debug
unset enforce
while [ ! -z "$1" ]; do
case "$1" in
@ -88,7 +90,9 @@ while [ ! -z "$1" ]; do
;;
-d )
debug=-d
set -x
;;
-e )
enforce=y
;;
-h )
echo "$USAGE"
@ -163,6 +167,7 @@ fi
src_config=${configpath}/defconfig
dest_config="${TOPDIR}/.config"
backup_config="${TOPDIR}/defconfig"
if [ ! -r ${src_config} ]; then
echo "File ${src_config} does not exist"
@ -170,9 +175,18 @@ if [ ! -r ${src_config} ]; then
fi
if [ -r ${dest_config} ]; then
echo "Already configured!"
echo "Do 'make distclean' and try again."
exit 6
if cmp -s ${src_config} ${backup_config}; then
echo "No configuration change."
exit 0
fi
if [ "X${enforce}" = "Xy" ]; then
make -C ${TOPDIR} distclean
else
echo "Already configured!"
echo "Do 'make distclean' and try again."
exit 6
fi
fi
# Extract values needed from the defconfig file. We need:
@ -250,6 +264,8 @@ install -m 644 ${src_makedefs} "${dest_makedefs}" || \
{ echo "Failed to copy ${src_makedefs}" ; exit 8 ; }
install -m 644 ${src_config} "${dest_config}" || \
{ echo "Failed to copy ${src_config}" ; exit 9 ; }
install -m 644 ${src_config} "${backup_config}" || \
{ echo "Failed to backup ${src_config}" ; exit 10 ; }
# Install any optional files