diff --git a/tools/configure.c b/tools/configure.c index 2029a7e2ea..d4101b0474 100644 --- a/tools/configure.c +++ b/tools/configure.c @@ -79,14 +79,23 @@ static void show_usage(const char *progname, int exitcode); static void debug(const char *fmt, ...); -static int find_archname(const char *boardname, const char *configname); static void parse_args(int argc, char **argv); static bool check_directory(const char *directory); static void verify_directory(const char *directory); static bool verify_optiondir(const char *directory); static bool verify_file(const char *path); static void find_topdir(void); -static void config_search(const char *boarddir); +typedef void (*config_callback)(const char *boarddir, const char *archname, + const char *chipname, const char *boardname, + const char *configname, void *data); +static void config_search(const char *boarddir, config_callback callback, void *data); +static void find_archname_callback(const char *boarddir, const char *archname, + const char *chipname, const char *boardname, + const char *configname, void *data); +static void find_archname(void); +static void enumerate_callback(const char *boarddir, const char *archname, + const char *chipname, const char *boardname, + const char *configname, void *data); static void enumerate_configs(void); static void check_configdir(void); static void check_configured(void); @@ -148,92 +157,6 @@ static char g_buffer[BUFFER_SIZE]; /* Scratch buffer for forming full p static struct variable_s *g_configvars = NULL; static struct variable_s *g_versionvars = NULL; -/* Recognized architectures */ - -static const char *g_archnames[] = -{ - "arm", - "avr", - "hc", - "mips", - "misoc", - "or1k", - "renesas", - "risc-v", - "sim", - "x86", - "xtensa", - "z16", - "z80", - NULL -}; - -/* Recognized chip names */ - -static const char *g_chipnames[] = -{ - "a1x", - "am335x", - "c5471", - "cxd56xx", - "dm320", - "efm32", - "imx6", - "imxrt", - "kinetis", - "kl", - "lc823450", - "lpc17xx_40xx", - "lpc214x", - "lpc2378", - "lpc31xx", - "lpc43xx", - "lpc54xx", - "max326xx", - "moxart", - "nrf52", - "nuc1xx", - "rx65n" - "s32k1xx", - "sam34", - "sama5", - "samd2l2", - "samd5e5", - "samv7", - "stm32", - "stm32f0l0g0", - "stm32f7", - "stm32h7", - "stm32l4", - "str71x", - "tiva", - "tms570", - "xmc4", - "at32uc3", - "at90usb", - "atmega", - "mcs92s12ne64", - "pic32mx", - "pic32mz", - "lm32", - "mor1kx", - "m32262f8", - "sh7032", - "fe310", - "gap8", - "k210", - "nr5m100", - "sim", - "qemu", - "esp32", - "z16f2811", - "ez80", - "z180", - "z8", - "z80", - NULL -}; - /* Optional configuration files */ static const char *g_optfiles[] = @@ -318,49 +241,10 @@ static void debug(const char *fmt, ...) } } -static int find_archname(const char *boardname, const char *configname) -{ - const char **archname; - const char **chipname; - struct stat statbuf; - int ret; - - /* Try each combination of board and chip names */ - - for (archname = g_archnames; *archname != NULL; archname++) - { - for (chipname = g_chipnames; *chipname != NULL; chipname++) - { - /* Get the architecture directory under boards. Path format: - * board////configs/ - */ - - snprintf(g_buffer, BUFFER_SIZE, "boards%c%s%c%s%c%s%cconfigs%c%s", - g_delim, *archname, g_delim, *chipname, g_delim, boardname, - g_delim, g_delim, configname); - - /* Check if there is a directory at this path */ - - ret = stat(g_buffer, &statbuf); - if (ret == 0 && S_ISDIR(statbuf.st_mode)) - { - g_archdir = *archname; - g_chipdir = *chipname; - return 0; - } - } - } - - g_archdir = "unknown"; - g_chipdir = "unknown"; - return -1; -} - static void parse_args(int argc, char **argv) { char *ptr; int ch; - int ret; /* Parse command line options */ @@ -477,13 +361,6 @@ static void parse_args(int argc, char **argv) fprintf(stderr, "ERROR: Unexpected garbage at the end of the line\n"); show_usage(argv[0], EXIT_FAILURE); } - - ret = find_archname(g_boarddir, g_configdir); - if (ret != 0) - { - fprintf(stderr, "ERROR: Architecture for board %s not found\n", - g_boarddir); - } } static bool check_directory(const char *directory) @@ -633,7 +510,7 @@ static void find_topdir(void) } } -static void config_search(const char *boarddir) +static void config_search(const char *boarddir, config_callback callback, void *data) { DIR *dir; struct dirent *dp; @@ -667,7 +544,7 @@ static void config_search(const char *boarddir) /* Visit each entry in the directory */ - while ((dp = readdir (dir)) != NULL) + while ((dp = readdir(dir)) != NULL) { /* Ignore directory entries that start with '.' */ @@ -700,7 +577,7 @@ static void config_search(const char *boarddir) char *tmppath; snprintf(g_buffer, BUFFER_SIZE, "%s%c%s", boarddir, g_delim, child); tmppath = strdup(g_buffer); - config_search(tmppath); + config_search(tmppath, callback, data); free(tmppath); } @@ -712,10 +589,11 @@ static void config_search(const char *boarddir) else if (S_ISREG(buf.st_mode) && strcmp("defconfig", child) == 0) { + char *archname; + char *chipname; char *boardname; char *configname; char *delim; - char *tmp; /* Get the board directory near the beginning of the 'boarddir' path: * ///configs/ @@ -725,7 +603,9 @@ static void config_search(const char *boarddir) strncpy(g_buffer, boarddir, BUFFER_SIZE); - /* Skip over */ + /* Save the */ + + archname = g_buffer; delim = strchr(g_buffer, g_delim); if (delim == NULL) @@ -734,13 +614,15 @@ static void config_search(const char *boarddir) } else { - /* Skip over */ + /* Save the */ - tmp = delim + 1; - delim = strchr(tmp, g_delim); + *delim = '\0'; + chipname = delim + 1; + + delim = strchr(chipname, g_delim); if (delim == NULL) { - debug("ERROR: delimiter not found in path: %s\n", tmp); + debug("ERROR: delimiter not found in path: %s\n", chipname); } else { @@ -768,7 +650,7 @@ static void config_search(const char *boarddir) else { configname = delim + 1; - fprintf(stderr, " %s:%s\n", boardname, configname); + callback(boarddir, archname, chipname, boardname, configname, data); } } } @@ -782,10 +664,39 @@ static void config_search(const char *boarddir) closedir(dir); } +static void find_archname_callback(const char *boarddir, const char *archname, + const char *chipname, const char *boardname, + const char *configname, void *data) +{ + if (strcmp(g_boarddir, boardname) == 0 && + strcmp(g_configdir, configname) == 0) + { + g_archdir = strdup(archname); + g_chipdir = strdup(chipname); + } +} + +static void find_archname(void) +{ + config_search("", find_archname_callback, NULL); + if (g_archdir == NULL || g_chipdir == NULL) + { + g_archdir = "unknown"; + g_chipdir = "unknown"; + } +} + +static void enumerate_callback(const char *boarddir, const char *archname, + const char *chipname, const char *boardname, + const char *configname, void *data) +{ + fprintf(stderr, " %s:%s\n", boardname, configname); +} + static void enumerate_configs(void) { fprintf(stderr, "Options for : include:\n\n"); - config_search(""); + config_search("", enumerate_callback, NULL); } static void check_configdir(void) @@ -802,6 +713,8 @@ static void check_configdir(void) * boards////configs/ */ + find_archname(); + snprintf(g_buffer, BUFFER_SIZE, "%s%cboards%c%s%c%s%c%s%cconfigs%c%s", g_topdir, g_delim, g_delim, g_archdir, g_delim, g_chipdir, g_delim, g_boarddir, g_delim, g_delim, g_configdir); diff --git a/tools/configure.sh b/tools/configure.sh index b91b3915cb..1194b763d6 100755 --- a/tools/configure.sh +++ b/tools/configure.sh @@ -142,33 +142,12 @@ else boarddir=`echo ${boardconfig} | cut -d':' -f1` fi -# Detect the architecture of this board. - -archs="arm avr hc mips misoc or1k renesas risc-v sim x86 xtensa z16 z80" -chips="a1x am335x c5471 cxd56xx dm320 efm32 imx6 imxrt kinetis kl lc823450 - lpc17xx_40xx lpc214x lpc2378 lpc31xx lpc43xx lpc54xx max326xx moxart nrf52 - nuc1xx rx65n s32k1xx sam34 sama5 samd2l2 samd5e5 samv7 stm32 stm32f0l0g0 stm32f7 stm32h7 - stm32l4 str71x tiva tms570 xmc4 at32uc3 at90usb atmega mcs92s12ne64 pic32mx - pic32mz lm32 mor1kx m32262f8 sh7032 fe310 k210 gap8 nr5m100 sim qemu esp32 z16f2811 - ez80 z180 z8 z80" - -for arc in ${archs}; do -for chip in ${chips}; do - if [ -f ${TOPDIR}/boards/${arc}/${chip}/${boarddir}/Kconfig ]; then - archdir=${arc} - chipdir=${chip} - echo " Detected ${archdir} Architecture" - echo " Detected ${chipdir} Chip" - fi -done -done - -configpath=${TOPDIR}/boards/${archdir}/${chipdir}/${boarddir}/configs/${configdir} -if [ ! -d "${configpath}" ]; then +configpath=${TOPDIR}/boards/*/*/${boarddir}/configs/${configdir} +if [ ! -d ${configpath} ]; then # Try direct path used with custom configurations. configpath=${TOPDIR}/${boardconfig} - if [ ! -d "${configpath}" ]; then + if [ ! -d ${configpath} ]; then echo "Directory for ${boardconfig} does not exist. Options are:" echo "" echo "Select one of the following options for :" @@ -185,26 +164,26 @@ if [ ! -d "${configpath}" ]; then fi fi -src_makedefs="${TOPDIR}/boards/${archdir}/${chipdir}/${boarddir}/configs/${configdir}/Make.defs" +src_makedefs=${TOPDIR}/boards/*/*/${boarddir}/configs/${configdir}/Make.defs dest_makedefs="${TOPDIR}/Make.defs" -if [ ! -r "${src_makedefs}" ]; then - src_makedefs="${TOPDIR}/boards/${archdir}/${chipdir}/${boarddir}/scripts/Make.defs" +if [ ! -r ${src_makedefs} ]; then + src_makedefs=${TOPDIR}/boards/*/*/${boarddir}/scripts/Make.defs - if [ ! -r "${src_makedefs}" ]; then - src_makedefs="${TOPDIR}/${boardconfig}/Make.defs" - if [ ! -r "${src_makedefs}" ]; then + if [ ! -r ${src_makedefs} ]; then + src_makedefs=${TOPDIR}/${boardconfig}/Make.defs + if [ ! -r ${src_makedefs} ]; then echo "File Make.defs could not be found" exit 4 fi fi fi -src_config="${configpath}/defconfig" +src_config=${configpath}/defconfig dest_config="${TOPDIR}/.config" -if [ ! -r "${src_config}" ]; then - echo "File \"${src_config}\" does not exist" +if [ ! -r ${src_config} ]; then + echo "File ${src_config} does not exist" exit 5 fi @@ -223,7 +202,7 @@ fi # If we are going to some host other then windows native or to a windows # native host, then don't even check what is in the defconfig file. -oldnative=`grep CONFIG_WINDOWS_NATIVE= "${src_config}" | cut -d'=' -f2` +oldnative=`grep CONFIG_WINDOWS_NATIVE= ${src_config} | cut -d'=' -f2` if [ "X$host" != "Xwindows" -o "X$wenv" != "Xnative" ]; then unset winnative else @@ -241,7 +220,7 @@ fi defappdir=y if [ -z "${appdir}" -a "X$oldnative" = "$winnative" ]; then - quoted=`grep "^CONFIG_APPS_DIR=" "${src_config}" | cut -d'=' -f2` + quoted=`grep "^CONFIG_APPS_DIR=" ${src_config} | cut -d'=' -f2` if [ ! -z "${quoted}" ]; then appdir=`echo ${quoted} | sed -e "s/\"//g"` defappdir=n @@ -288,15 +267,15 @@ fi # Okay... Everything looks good. Setup the configuration echo " Copy files" -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_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 any optional files for opt in ${OPTFILES}; do - test -f "${configpath}/${opt}" && install "${configpath}/${opt}" "${TOPDIR}/" + test -f ${configpath}/${opt} && install ${configpath}/${opt} "${TOPDIR}/" done # If we did not use the CONFIG_APPS_DIR that was in the defconfig config file, diff --git a/tools/refresh.sh b/tools/refresh.sh index 3e7c7af2c7..914a52e8a4 100755 --- a/tools/refresh.sh +++ b/tools/refresh.sh @@ -33,7 +33,6 @@ # WD=`test -d ${0%/*} && cd ${0%/*}; pwd` -TOPDIR="${WD}/.." USAGE="USAGE: $0 [options] :" ADVICE="Try '$0 --help' for more information" @@ -115,39 +114,6 @@ else BOARDSUBDIR=`echo ${CONFIG} | cut -d':' -f1` fi -# Detect the architecture of this board. - -ARCHLIST="arm avr hc mips misoc or1k renesas risc-v sim x86 xtensa z16 z80" -ARCHLIST="arm avr hc mips misoc or1k renesas risc-v sim x86 xtensa z16 z80" -CHIPLIST="a1x am335x c5471 cxd56xx dm320 efm32 imx6 imxrt kinetis kl lc823450 - lpc17xx_40xx lpc214x lpc2378 lpc31xx lpc43xx lpc54xx max326xx moxart nrf52 - nuc1xx rx65n s32k1xx sam34 sama5 samd2l2 samd5e5 samv7 stm32 stm32f0l0g0 stm32f7 stm32h7 - stm32l4 str71x tiva tms570 xmc4 at32uc3 at90usb atmega mcs92s12ne64 pic32mx - pic32mz lm32 mor1kx m32262f8 sh7032 fe310 k210 gap8 nr5m100 sim qemu esp32 z16f2811 - ez80 z180 z8 z80" - -for ARCH in ${ARCHLIST}; do - for CHIP in ${CHIPLIST}; do - if [ -f ${TOPDIR}/boards/${ARCH}/${CHIP}/${BOARDSUBDIR}/Kconfig ]; then - ARCHSUBDIR=${ARCH} - CHIPSUBDIR=${CHIP} - echo " Detected ${ARCHSUBDIR} Architecture" - echo " Detected ${CHIPSUBDIR} Chip" - fi - done -done - -for ARCH in ${ARCHLIST}; do - if [ -f boards/${ARCH}/${BOARDSUBDIR}/Kconfig ]; then - ARCHSUBDIR=${ARCH} - fi -done - -if [ -z "${ARCHSUBDIR}" ]; then - echo "ERROR: Architecture of ${BOARDSUBDIR} not found" - exit 1 -fi - # Where are we MYNAME=`basename $0` @@ -163,7 +129,7 @@ fi # Set up the environment -BOARDDIR=boards/$ARCHSUBDIR/$CHIPSUBDIR/$BOARDSUBDIR +BOARDDIR=boards/*/*/$BOARDSUBDIR SCRIPTSDIR=$BOARDDIR/scripts MAKEDEFS1=$SCRIPTSDIR/Make.defs @@ -179,25 +145,25 @@ CMPCONFIGMAKEDIR=tools # Check the board configuration directory -if [ ! -d "$BOARDDIR" ]; then +if [ ! -d $BOARDDIR ]; then echo "No board directory found at $BOARDDIR" exit 1 fi -if [ ! -d "$CONFIGDIR" ]; then +if [ ! -d $CONFIGDIR ]; then echo "No configuration directory found at $CONFIGDIR" exit 1 fi -if [ ! -r "$DEFCONFIG" ]; then +if [ ! -r $DEFCONFIG ]; then echo "No readable defconfig file at $DEFCONFIG" exit 1 fi -if [ -r "$MAKEDEFS1" ]; then +if [ -r $MAKEDEFS1 ]; then MAKEDEFS=$MAKEDEFS1 else - if [ -r "$MAKEDEFS2" ]; then + if [ -r $MAKEDEFS2 ]; then MAKEDEFS=$MAKEDEFS2 else echo "No readable Make.defs file at $MAKEDEFS1 or $MAKEDEFS2" diff --git a/tools/testbuild.sh b/tools/testbuild.sh index 3925fdffdc..d23ca89ebf 100755 --- a/tools/testbuild.sh +++ b/tools/testbuild.sh @@ -296,32 +296,8 @@ for line in $testlist; do boarddir=`echo $config | cut -d':' -f1` fi - # Detect the architecture of this board. - - ARCHLIST="arm avr hc mips misoc or1k renesas risc-v sim x86 xtensa z16 z80" - CHIPLIST="a1x am335x c5471 cxd56xx dm320 efm32 imx6 imxrt kinetis kl lc823450 - lpc17xx_40xx lpc214x lpc2378 lpc31xx lpc43xx lpc54xx max326xx moxart nrf52 - nuc1xx rx65n s32k1xx sam34 sama5 samd2l2 samd5e5 samv7 stm32 stm32f0l0g0 stm32f7 stm32h7 - stm32l4 str71x tiva tms570 xmc4 at32uc3 at90usb atmega mcs92s12ne64 pic32mx - pic32mz lm32 mor1kx m32262f8 sh7032 fe310 k210 gap8 nr5m100 sim qemu esp32 z16f2811 - ez80 z180 z8 z80" - - for arch in ${ARCHLIST}; do - for chip in ${CHIPLIST}; do - if [ -f ${nuttx}/boards/${arch}/${chip}/${boarddir}/Kconfig ]; then - archdir=${arch} - chipdir=${chip} - fi - done - done - - if [ -z "${archdir}" ]; then - echo "ERROR: Architecture of ${boarddir} not found" - exit 1 - fi - - path=$nuttx/boards/$archdir/$chipdir/$boarddir/configs/$configdir - if [ ! -r "$path/defconfig" ]; then + path=$nuttx/boards/*/*/$boarddir/configs/$configdir + if [ ! -r $path/defconfig ]; then echo "ERROR: no configuration found at $path" showusage fi