From 7c83c63d8edd53db4b9048b753e3c927d3d2eacb Mon Sep 17 00:00:00 2001 From: Ouss4 Date: Wed, 2 Sep 2020 19:04:33 +0100 Subject: [PATCH] tools/configure.sh: Add -L option to list all available configurations. Mention this option when Make is run on an unconfiugred project. --- Makefile | 7 +++++-- tools/configure.bat | 9 ++++++++- tools/configure.c | 33 +++++++++++++++++++++++++++------ tools/configure.sh | 30 +++++++++++++++++++----------- 4 files changed, 59 insertions(+), 20 deletions(-) diff --git a/Makefile b/Makefile index cc92b82016..002760277f 100644 --- a/Makefile +++ b/Makefile @@ -22,8 +22,11 @@ ifeq ($(wildcard .config),) .DEFAULT default: - @echo "Nuttx has not been configured:" - @echo " tools/configure.sh " + @echo "NuttX has not been configured!" + @echo "To configure the project:" + @echo " tools/configure.sh " + @echo "For a list of available configurations:" + @echo " tools/configure.sh -L" else include .config diff --git a/tools/configure.bat b/tools/configure.bat index 9d9cd35f08..ac4dba64c7 100755 --- a/tools/configure.bat +++ b/tools/configure.bat @@ -65,6 +65,7 @@ if "%1"=="-l" goto :SetHostOption if "%1"=="-c" goto :SetHostOption if "%1"=="-u" goto :SetHostOption if "%1"=="-n" goto :SetHostOption +if "%1"=="-L" goto :SetList if "%1"=="-a" goto :SetAppDir set config=%1 @@ -82,6 +83,10 @@ goto :NextArg set hostopt=%1 goto :NextArg +:SetList +set list=%1 +goto :EndOfLoop + :SetAppDir shift set appdir=-a %1 @@ -108,7 +113,7 @@ if errorlevel 1 ( :HaveConfigureExe cd .. -tools\configure.exe %debug% %fmt% %hostopt% %appdir% %config% +tools\configure.exe %debug% %fmt% %hostopt% %appdir% %config% %list% if errorlevel 1 echo configure.exe failed goto End @@ -133,6 +138,8 @@ echo select one of the Windows environments. Default: Use host setup echo in the defconfig file echo [-c^|u^|n] selects the Windows host and a Windows environment: Cygwin (c), echo Ubuntu under Windows 10 (u), or Windows native (n). Default Cygwin +echo -L: +echo List all available configurations. echo -a ^: echo Informs the configuration tool where the application build echo directory. This is a relative path from the top-level NuttX diff --git a/tools/configure.c b/tools/configure.c index f7dcc62dd7..cf10f849a0 100644 --- a/tools/configure.c +++ b/tools/configure.c @@ -78,6 +78,7 @@ ****************************************************************************/ static void show_usage(const char *progname, int exitcode); +static void dumpcfgs(void); static void debug(const char *fmt, ...); static void parse_args(int argc, char **argv); static int run_make(const char *arg); @@ -181,7 +182,7 @@ static const char *g_optfiles[] = static void show_usage(const char *progname, int exitcode) { - fprintf(stderr, "\nUSAGE: %s [-d] [-E] [-e] [-b|f] [-l|m|c|u|g|n] " + fprintf(stderr, "\nUSAGE: %s [-d] [-E] [-e] [-b|f] [-L] [-l|m|c|u|g|n] " "[-a ] : [make-opts]\n", progname); fprintf(stderr, "\nUSAGE: %s [-h]\n", progname); @@ -224,6 +225,8 @@ static void show_usage(const char *progname, int exitcode) fprintf(stderr, " -n Selects the Windows native (n) environment.\n"); fprintf(stderr, " Default: Use host setup in the defconfig file.\n"); fprintf(stderr, " Default Windows: Cygwin.\n"); + fprintf(stderr, " -L:\n"); + fprintf(stderr, " Lists all available configurations.\n"); fprintf(stderr, " -a :\n"); fprintf(stderr, " Informs the configuration tool where the\n"); fprintf(stderr, " application build directory. This is a relative\n"); @@ -250,6 +253,17 @@ static void show_usage(const char *progname, int exitcode) exit(exitcode); } +static void dumpcfgs(void) +{ + find_topdir(); + snprintf(g_buffer, BUFFER_SIZE, "%s%cboards", g_topdir, g_delim); + verify_directory(g_buffer); + g_configtop = strdup(g_buffer); + enumerate_configs(); + free(g_configtop); + exit(EXIT_SUCCESS); +} + static void debug(const char *fmt, ...) { va_list ap; @@ -269,7 +283,7 @@ static void parse_args(int argc, char **argv) /* Parse command line options */ - while ((ch = getopt(argc, argv, "a:bcdEefghlmnu")) > 0) + while ((ch = getopt(argc, argv, "a:bcdEefghLlmnu")) > 0) { switch (ch) { @@ -312,6 +326,9 @@ static void parse_args(int argc, char **argv) case 'h' : show_usage(argv[0], EXIT_SUCCESS); + case 'L' : + dumpcfgs(); + case 'l' : g_host = HOST_LINUX; break; @@ -811,7 +828,8 @@ static void check_configdir(void) if (!verify_optiondir(g_buffer)) { fprintf(stderr, "ERROR: No configuration at %s\n", g_buffer); - enumerate_configs(); + fprintf(stderr, "Run tools/configure -L" + " to list available configurations.\n"); exit(EXIT_FAILURE); } @@ -1072,7 +1090,8 @@ static void check_configuration(void) { fprintf(stderr, "ERROR: No configuration in %s\n", g_configpath); fprintf(stderr, " No defconfig file found.\n"); - enumerate_configs(); + fprintf(stderr, "Run tools/configure -L" + " to list available configurations.\n"); exit(EXIT_FAILURE); } @@ -1097,14 +1116,16 @@ static void check_configuration(void) g_configpath); fprintf(stderr, " No Make.defs file in %s\n", g_scriptspath); - enumerate_configs(); + fprintf(stderr, "Run tools/configure -L" + " to list available configurations.\n"); exit(EXIT_FAILURE); } } else { fprintf(stderr, "ERROR: No Make.defs file in %s\n", g_configpath); - enumerate_configs(); + fprintf(stderr, "Run tools/configure -L" + " to list available configurations.\n"); exit(EXIT_FAILURE); } } diff --git a/tools/configure.sh b/tools/configure.sh index bf6702d115..fcfafe70ae 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} [-E] [-e] [-l|m|c|u|g|n] [-a ] : [make-opts] +USAGE: ${0} [-E] [-e] [-l|m|c|u|g|n] [L] [-a ] : [make-opts] Where: -E enforces distclean if already configured. @@ -50,6 +50,7 @@ Where: -n selects the Windows host and Windows native (n) environment. Default: Use host setup in the defconfig file Default Windows: Cygwin + -L Lists all available configurations. -a is the path to the apps/ directory, relative to the nuttx directory is the name of the board in the boards directory @@ -75,6 +76,17 @@ unset host unset enforce_distclean unset distclean +function dumpcfgs +{ + configlist=`find ${TOPDIR}/boards -name defconfig` + for defconfig in ${configlist}; do + config=`dirname ${defconfig} | sed -e "s,${TOPDIR}/boards/,,g"` + boardname=`echo ${config} | cut -d'/' -f3` + configname=`echo ${config} | cut -d'/' -f5` + echo " ${boardname}:${configname}" + done +} + while [ ! -z "$1" ]; do case "$1" in -a ) @@ -99,6 +111,10 @@ while [ ! -z "$1" ]; do echo "$USAGE" exit 0 ;; + -L ) + dumpcfgs + exit 0 + ;; *) boardconfig=$1 shift @@ -131,17 +147,9 @@ if [ ! -d ${configpath} ]; then configpath=${TOPDIR}/${boardconfig} if [ ! -d ${configpath} ]; then - echo "Directory for ${boardconfig} does not exist. Options are:" - echo "" - echo "Select one of the following options for :" - configlist=`find ${TOPDIR}/boards -name defconfig` - for defconfig in ${configlist}; do - config=`dirname ${defconfig} | sed -e "s,${TOPDIR}/boards/,,g"` - boardname=`echo ${config} | cut -d'/' -f3` - configname=`echo ${config} | cut -d'/' -f5` - echo " ${boardname}:${configname}" - done + echo "Directory for ${boardconfig} does not exist." echo "" + echo "Run tools/configure.sh -L to list available configurations." echo "$USAGE" exit 3 fi