This is an automated email from the ASF dual-hosted git repository. xiaoxiang pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git
commit 2bbb1f28d52746b5b6f0411069b40af2e29f04f5 Author: liuhaitao <liuhai...@xiaomi.com> AuthorDate: Mon Nov 30 20:47:57 2020 +0800 configure.c: add custom board path build support too Signed-off-by: liuhaitao <liuhai...@xiaomi.com> --- tools/configure.c | 114 +++++++++++++++++++++++++++++++++--------------------- 1 file changed, 69 insertions(+), 45 deletions(-) diff --git a/tools/configure.c b/tools/configure.c index 2270c8a..fd65b0a 100644 --- a/tools/configure.c +++ b/tools/configure.c @@ -365,30 +365,40 @@ static void parse_args(int argc, char **argv) /* The required option should be the board directory name and the * configuration directory name separated by ':', '/' or '\'. Any are - * acceptable in this context. + * acceptable in this context. Or using the custom board relative or + * absolute path directly here. */ g_boarddir = argv[optind]; optind++; - ptr = strchr(g_boarddir, ':'); - if (ptr == NULL) + if (!verify_optiondir(g_boarddir)) { - ptr = strchr(g_boarddir, '/'); - if (!ptr) + ptr = strchr(g_boarddir, ':'); + if (ptr == NULL) { - ptr = strchr(g_boarddir, '\\'); + ptr = strchr(g_boarddir, '/'); + if (!ptr) + { + ptr = strchr(g_boarddir, '\\'); + } } - } - if (ptr == NULL) - { - fprintf(stderr, "ERROR: Invalid <board-name>:<config-name>\n"); - show_usage(argv[0], EXIT_FAILURE); + if (ptr == NULL) + { + fprintf(stderr, "ERROR: Invalid <board-name>:<config-name>\n"); + show_usage(argv[0], EXIT_FAILURE); + } + + *ptr++ = '\0'; + g_configdir = ptr; } + else + { + /* custom board case with relative or absolute path */ - *ptr++ = '\0'; - g_configdir = ptr; + g_configpath = strdup(g_boarddir); + } /* The left arguments will pass to make */ @@ -799,48 +809,62 @@ static void enumerate_configs(void) static void check_configdir(void) { - /* Get the path to the top level configuration directory: boards/ */ + if (verify_optiondir(g_configpath)) + { + /* Get the path to the custom board scripts directory */ - snprintf(g_buffer, BUFFER_SIZE, "%s%cboards", g_topdir, g_delim); - debug("check_configdir: Checking configtop=%s\n", g_buffer); + snprintf(g_buffer, BUFFER_SIZE, "%s%c..%c..%cscripts", + g_configpath, g_delim, g_delim, g_delim); + if (verify_optiondir(g_buffer)) + { + g_scriptspath = strdup(g_buffer); + } + } + else + { + /* Get the path to the top level configuration directory: boards/ */ - verify_directory(g_buffer); - g_configtop = strdup(g_buffer); + snprintf(g_buffer, BUFFER_SIZE, "%s%cboards", g_topdir, g_delim); + debug("check_configdir: Checking configtop=%s\n", g_buffer); - /* Get and verify the path to the selected configuration: - * boards/<archdir>/<chipdir>/<boarddir>/configs/<configdir> - */ + verify_directory(g_buffer); + g_configtop = strdup(g_buffer); - find_archname(); + /* Get and verify the path to the selected configuration: + * boards/<archdir>/<chipdir>/<boarddir>/configs/<configdir> + */ - 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); - debug("check_configdir: Checking configpath=%s\n", g_buffer); + find_archname(); - if (!verify_optiondir(g_buffer)) - { - fprintf(stderr, "ERROR: No configuration at %s\n", g_buffer); - fprintf(stderr, "Run tools/configure -L" - " to list available configurations.\n"); - exit(EXIT_FAILURE); - } + 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); + debug("check_configdir: Checking configpath=%s\n", g_buffer); - g_configpath = strdup(g_buffer); + if (!verify_optiondir(g_buffer)) + { + fprintf(stderr, "ERROR: No configuration at %s\n", g_buffer); + fprintf(stderr, "Run tools/configure -L" + " to list available configurations.\n"); + exit(EXIT_FAILURE); + } - /* Get and verify the path to the scripts directory: - * boards/<archdir>/<chipdir>/<boarddir>/scripts - */ + g_configpath = strdup(g_buffer); - snprintf(g_buffer, BUFFER_SIZE, "%s%cboards%c%s%c%s%c%s%cscripts", - g_topdir, g_delim, g_delim, g_archdir, g_delim, - g_chipdir, g_delim, g_boarddir, g_delim); - debug("check_configdir: Checking scriptspath=%s\n", g_buffer); + /* Get and verify the path to the scripts directory: + * boards/<archdir>/<chipdir>/<boarddir>/scripts + */ - g_scriptspath = NULL; - if (verify_optiondir(g_buffer)) - { - g_scriptspath = strdup(g_buffer); + snprintf(g_buffer, BUFFER_SIZE, "%s%cboards%c%s%c%s%c%s%cscripts", + g_topdir, g_delim, g_delim, g_archdir, g_delim, + g_chipdir, g_delim, g_boarddir, g_delim); + debug("check_configdir: Checking scriptspath=%s\n", g_buffer); + + g_scriptspath = NULL; + if (verify_optiondir(g_buffer)) + { + g_scriptspath = strdup(g_buffer); + } } }