diff --git a/configs/Makefile b/configs/Makefile index 31de5604e0..cee8bdafed 100644 --- a/configs/Makefile +++ b/configs/Makefile @@ -116,7 +116,7 @@ depend: .depend $(DUMMY_KCONFIG): $(BOARD_KCONFIG) $(call DELFILE, $(DUMMY_KCONFIG)) - $(Q) cp -f $(BOARD_KCONFIG) $(DUMMY_KCONFIG) + $(call COPYFILE, $(BOARD_KCONFIG), $(DUMMY_KCONFIG)) dirlinks: $(DUMMY_KCONFIG) diff --git a/tools/Config.mk b/tools/Config.mk index b059bbabe3..eb95551f5f 100644 --- a/tools/Config.mk +++ b/tools/Config.mk @@ -268,6 +268,18 @@ define MOVEFILE endef endif +# COPYFILE - Copy one file + +ifeq ($(CONFIG_WINDOWS_NATIVE),y) +define COPYFILE + $(Q) if exist $1 (copy /y /b $1 $2) +endef +else +define COPYFILE + $(Q) cp -f $1 $2 +endef +endif + # CATFILE - Cat and append a list of files # # USAGE: $(call CATFILE,dest,src1,src2,src3,...) diff --git a/tools/configure.c b/tools/configure.c index ba7f1d5600..629157b529 100644 --- a/tools/configure.c +++ b/tools/configure.c @@ -202,7 +202,7 @@ static void parse_args(int argc, char **argv) g_debug = false; - while ((ch = getopt(argc, argv, ":a:bcdfhlmnu")) > 0) + while ((ch = getopt(argc, argv, "a:bcdfghlmnu")) > 0) { switch (ch) { @@ -917,6 +917,59 @@ static void substitute(char *str, int ch1, int ch2) } } +static char *double_appdir_backslashes(char *old_appdir) +{ + char *new_appdir = NULL; + char *p_old = NULL; + char *p_new = NULL; + int oldlen = 0; + int occurrences = 0; + int alloclen = 0; + + p_old = old_appdir; + while ((p_old = strchr(p_old, '\\')) != NULL) + { + occurrences++; + p_old++; + } + + if (occurrences != 0) + { + oldlen = strlen(old_appdir); + alloclen = oldlen + occurrences + sizeof((char) '\0'); + new_appdir = malloc(alloclen); + + if (new_appdir != NULL) + { + p_old = old_appdir; + p_new = new_appdir; + while (oldlen) + { + if (*p_old != '\\') + { + *p_new++ = *p_old; + } + else + { + *p_new++ = '\\'; + *p_new++ = '\\'; + } + + ++p_old; + --oldlen; + } + + *p_new = '\0'; + } + } + else + { + new_appdir = strdup(old_appdir); + } + + return new_appdir; +} + static void copy_optional(void) { int i; @@ -1155,6 +1208,24 @@ static void configure(void) } } + /* Looks like prebuilt winnative kconfig-conf interprets "..\apps" as + * "..apps" (possibly '\a' as escape-sequence) so expand winnative path + * to double-backslashed variant "..\\apps". + */ + + if (g_winnative) + { + char *tmp_appdir = double_appdir_backslashes(appdir); + if (NULL == tmp_appdir) + { + fprintf(stderr, "ERROR: Failed to double appdir backslashes\n"); + exit(EXIT_FAILURE); + } + + free(appdir); + appdir = tmp_appdir; + } + /* Open the file for appending */ stream = fopen(destconfig, "a"); @@ -1185,7 +1256,7 @@ static void refresh(void) exit(EXIT_FAILURE); } - printf(" Refreshing..."); + printf(" Refreshing...\n"); fflush(stdout); #ifdef WIN32 diff --git a/tools/configure.sh b/tools/configure.sh index 030d52340c..d51d73201f 100755 --- a/tools/configure.sh +++ b/tools/configure.sh @@ -235,7 +235,7 @@ fi # For checking the apps dir path, we need a POSIX version of the relative path. posappdir=`echo "${appdir}" | sed -e 's/\\\\/\\//g'` -winappdir=`echo "${appdir}" | sed -e 's/\\//\\\\/g'` +winappdir=`echo "${appdir}" | sed -e 's/\\//\\\\\\\/g'` # If appsdir was provided (or discovered) then make sure that the apps/ # directory exists diff --git a/tools/link.bat b/tools/link.bat index 22ddaf14b1..21baa6c03e 100755 --- a/tools/link.bat +++ b/tools/link.bat @@ -89,7 +89,7 @@ goto :End ) xcopy %src% %link% /c /q /s /e /y /i -echo FAKELNK > include\apps\.fakelnk +echo FAKELNK > %link%\.fakelnk goto :End :ShowUsage diff --git a/tools/mkdeps.c b/tools/mkdeps.c index 01db9c4e0c..3daae91f66 100644 --- a/tools/mkdeps.c +++ b/tools/mkdeps.c @@ -219,7 +219,7 @@ static void append(char **base, char *str) } else { - alloclen = strlen(oldbase) + strlen(str) + 2; + alloclen = strlen(oldbase) + strlen(str) + sizeof((char) ' ') + sizeof((char) '\0'); newbase = (char *)malloc(alloclen); if (!newbase) { @@ -227,7 +227,7 @@ static void append(char **base, char *str) exit(EXIT_FAILURE); } - snprintf(newbase, alloclen, "%s %s\n", oldbase, str); + snprintf(newbase, alloclen, "%s %s", oldbase, str); free(oldbase); }