Patchwork [U-Boot] tools: Fix mingw tools build

login
register
mail settings
Submitter Vladimir Yakovlev
Date July 7, 2012, 8:05 p.m.
Message ID <1341691506-17106-1-git-send-email-nagos@inbox.ru>
Download mbox | patch
Permalink /patch/169612/
State Accepted
Commit 8b6a4952e6064dc558cb7d5d375990b17491f26f
Headers show

Comments

Vladimir Yakovlev - July 7, 2012, 8:05 p.m.
mkenvimage does not build due to missed os_support.o and unsupported
file modes S_IRGRP S_IWGRP.
Tested with mingw 4.2.1 on ubuntu 12.04.

Signed-off-by: Vladimir Yakovlev <nagos@inbox.ru>
---
 tools/Makefile     |    3 ++-
 tools/mkenvimage.c |   10 ++++++++--
 2 files changed, 10 insertions(+), 3 deletions(-)
Wolfgang Denk - July 8, 2012, 8:41 p.m.
Dear Vladimir Yakovlev,

In message <1341691506-17106-1-git-send-email-nagos@inbox.ru> you wrote:
> mkenvimage does not build due to missed os_support.o and unsupported
> file modes S_IRGRP S_IWGRP.
> Tested with mingw 4.2.1 on ubuntu 12.04.
> 
> Signed-off-by: Vladimir Yakovlev <nagos@inbox.ru>
> ---
>  tools/Makefile     |    3 ++-
>  tools/mkenvimage.c |   10 ++++++++--
>  2 files changed, 10 insertions(+), 3 deletions(-)

Applied, thanks.

Best regards,

Wolfgang Denk
Mike Frysinger - July 18, 2012, 10:51 p.m.
On Saturday 07 July 2012 16:05:06 Vladimir Yakovlev wrote:
> --- a/tools/mkenvimage.c
> +++ b/tools/mkenvimage.c
> @@ -45,6 +45,13 @@
> 
>  #define CRC_SIZE sizeof(uint32_t)
> 
> +#ifdef __MINGW32__
> +#define FILE_PERM		(S_IRUSR | S_IWUSR)
> +#else
> +#define FILE_PERM		(S_IRUSR | S_IWUSR | S_IRGRP |\
> +					     S_IWGRP)
> +#endif

err, i'd rather you didn't do this.  we've tried very hard to avoid sprinkling 
arch-specific crap (like __MINGW32__) in random files. instead, i'd like to see 
in (either in os_support.h or mingw_support.h):
#ifndef S_IRGRP
# define S_IRGRP 0
#endif
#indef S_IWGRP
# define S_IWGRP 0
#endif

then no one has to care about mingw, and we don't have to add complicated 
defines that disconnect the locations of the code (the define and the open()).
-mike

Patch

diff --git a/tools/Makefile b/tools/Makefile
index 8993fdd..8fa6f85 100644
--- a/tools/Makefile
+++ b/tools/Makefile
@@ -194,7 +194,8 @@  $(obj)xway-swap-bytes$(SFX):	$(obj)xway-swap-bytes.o
 	$(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
 	$(HOSTSTRIP) $@
 
-$(obj)mkenvimage$(SFX):	$(obj)crc32.o $(obj)mkenvimage.o
+$(obj)mkenvimage$(SFX):	$(obj)crc32.o $(obj)mkenvimage.o \
+	$(obj)os_support.o
 	$(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
 	$(HOSTSTRIP) $@
 
diff --git a/tools/mkenvimage.c b/tools/mkenvimage.c
index bfc4eb6..c879e5d 100644
--- a/tools/mkenvimage.c
+++ b/tools/mkenvimage.c
@@ -45,6 +45,13 @@ 
 
 #define CRC_SIZE sizeof(uint32_t)
 
+#ifdef __MINGW32__
+#define FILE_PERM		(S_IRUSR | S_IWUSR)
+#else
+#define FILE_PERM		(S_IRUSR | S_IWUSR | S_IRGRP |\
+					     S_IWGRP)
+#endif
+
 static void usage(const char *exec_name)
 {
 	fprintf(stderr, "%s [-h] [-r] [-b] [-p <byte>] -s <environment partition size> -o <output> <input file>\n"
@@ -292,8 +299,7 @@  int main(int argc, char **argv)
 	if (!bin_filename || strcmp(bin_filename, "-") == 0) {
 		bin_fd = STDOUT_FILENO;
 	} else {
-		bin_fd = creat(bin_filename, S_IRUSR | S_IWUSR | S_IRGRP |
-					     S_IWGRP);
+		bin_fd = creat(bin_filename, FILE_PERM);
 		if (bin_fd == -1) {
 			fprintf(stderr, "Can't open output file \"%s\": %s\n",
 					bin_filename, strerror(errno));