nuttx/tools: Fixes for some Windows native build issues from Max Holtzberg

This commit is contained in:
Gregory Nutt 2014-01-04 09:08:14 -06:00
parent 84596e8473
commit b9a38cea22
3 changed files with 22 additions and 12 deletions

View File

@ -6358,4 +6358,6 @@
yet work (2014-1-1). yet work (2014-1-1).
* arch/arm/src/stm32/stm32_serial.c: Single-wire UART support from * arch/arm/src/stm32/stm32_serial.c: Single-wire UART support from
Thomas Grubler (2014-1-2). Thomas Grubler (2014-1-2).
* tools/configure.c and mkdeps.c: Fixes for Windows build issues
from Max Holtzberg (2014-1-4).

View File

@ -58,6 +58,10 @@
#define BUFFER_SIZE 1024 #define BUFFER_SIZE 1024
#ifdef WIN32
# define strndup(x, y) strdup(x)
#endif
/**************************************************************************** /****************************************************************************
* Private Data * Private Data
****************************************************************************/ ****************************************************************************/
@ -630,7 +634,7 @@ static void check_configuration(void)
} }
g_srcdefconfig = strdup(g_buffer); g_srcdefconfig = strdup(g_buffer);
snprintf(g_buffer, BUFFER_SIZE, "%s%cMake.defs", g_configpath, g_delim); snprintf(g_buffer, BUFFER_SIZE, "%s%cMake.defs", g_configpath, g_delim);
debug("check_configuration: Checking %s\n", g_buffer); debug("check_configuration: Checking %s\n", g_buffer);
if (!verify_file(g_buffer)) if (!verify_file(g_buffer))
@ -789,7 +793,7 @@ static void configure(void)
debug("configure: Copying from %s to %s\n", g_srcsetenvsh, g_buffer); debug("configure: Copying from %s to %s\n", g_srcsetenvsh, g_buffer);
copy_file(g_srcsetenvsh, g_buffer, 0755); copy_file(g_srcsetenvsh, g_buffer, 0755);
} }
/* Copy the setenv.bat file if have one and need one */ /* Copy the setenv.bat file if have one and need one */
if (g_srcsetenvbat) if (g_srcsetenvbat)
@ -841,7 +845,7 @@ static void configure(void)
} }
/* Open the file for appending */ /* Open the file for appending */
stream = fopen(destconfig, "a"); stream = fopen(destconfig, "a");
if (!stream) if (!stream)
{ {

View File

@ -54,6 +54,10 @@
#define MAX_BUFFER (4096) #define MAX_BUFFER (4096)
#ifdef WIN32
# define NAME_MAX FILENAME_MAX
#endif
/**************************************************************************** /****************************************************************************
* Private Types * Private Types
****************************************************************************/ ****************************************************************************/
@ -171,7 +175,7 @@ static void append(char **base, char *str)
oldbase = *base; oldbase = *base;
if (!oldbase) if (!oldbase)
{ {
newbase = strdup(str); newbase = strdup(str);
if (!newbase) if (!newbase)
{ {
fprintf(stderr, "ERROR: Failed to strdup %s\n", str); fprintf(stderr, "ERROR: Failed to strdup %s\n", str);
@ -187,7 +191,7 @@ static void append(char **base, char *str)
fprintf(stderr, "ERROR: Failed to allocate %d bytes\n", alloclen); fprintf(stderr, "ERROR: Failed to allocate %d bytes\n", alloclen);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
snprintf(newbase, alloclen, "%s %s\n", oldbase, str); snprintf(newbase, alloclen, "%s %s\n", oldbase, str);
free(oldbase); free(oldbase);
} }
@ -277,7 +281,7 @@ static void parse_args(int argc, char **argv)
} }
else else
{ {
append(&g_altpath, argv[argidx]); append(&g_altpath, argv[argidx]);
} }
} }
else if (strcmp(argv[argidx], "--obj-path") == 0) else if (strcmp(argv[argidx], "--obj-path") == 0)
@ -359,7 +363,7 @@ static void parse_args(int argc, char **argv)
{ {
fprintf(stderr, " OBJDIR : (None)\n"); fprintf(stderr, " OBJDIR : (None)\n");
} }
#ifdef HAVE_WINPATH #ifdef HAVE_WINPATH
fprintf(stderr, " Windows Paths : [%s]\n", g_winpath ? "TRUE" : "FALSE"); fprintf(stderr, " Windows Paths : [%s]\n", g_winpath ? "TRUE" : "FALSE");
if (g_winpath) if (g_winpath)
@ -544,7 +548,7 @@ static void do_dependency(const char *file, char separator)
totallen, MAX_BUFFER); totallen, MAX_BUFFER);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
strcat(g_command, file); strcat(g_command, file);
/* Check that a file actually exists at this path */ /* Check that a file actually exists at this path */
@ -573,7 +577,7 @@ static void do_dependency(const char *file, char separator)
* compiler, system() will return -1; Otherwise, the returned value * compiler, system() will return -1; Otherwise, the returned value
* from the compiler is in WEXITSTATUS(ret). * from the compiler is in WEXITSTATUS(ret).
*/ */
ret = system(g_command); ret = system(g_command);
#ifdef WEXITSTATUS #ifdef WEXITSTATUS
if (ret < 0 || WEXITSTATUS(ret) != 0) if (ret < 0 || WEXITSTATUS(ret) != 0)
@ -598,9 +602,9 @@ static void do_dependency(const char *file, char separator)
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
#endif #endif
/* We don't really know that the command succeeded... Let's assume that it did */ /* We don't really know that the command succeeded... Let's assume that it did */
free(alloc); free(alloc);
return; return;
} }
@ -632,7 +636,7 @@ static char *cywin2windows(const char *str, const char *append, enum slashmode_e
if (append) if (append)
{ {
char *tmp; char *tmp;
alloclen = sizeof(str) + sizeof(append) + 1; alloclen = sizeof(str) + sizeof(append) + 1;
allocpath = (char *)malloc(alloclen); allocpath = (char *)malloc(alloclen);
if (!allocpath) if (!allocpath)