mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] Fix environment generation dependencies
@ 2012-09-27 17:13 Sascha Hauer
  2012-09-27 17:14 ` [PATCH 1/3] scripts/bareboxenv: Only print information if -v is given Sascha Hauer
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Sascha Hauer @ 2012-09-27 17:13 UTC (permalink / raw)
  To: barebox

barebox has an annoying longstanding bug in checking the defaultenv
generation dependencies. Often the defaultenv is not regenerated when
it should be. This series fixes this.

Sascha

----------------------------------------------------------------
Sascha Hauer (3):
      scripts/bareboxenv: Only print information if -v is given
      environment generation: remove unused CLEAN_FILES
      environment generation: Fix dependencies

 Makefile             |    2 +-
 common/Makefile      |   32 ++++++++++++++++++++------------
 scripts/bareboxenv.c |   15 +++++++++++----
 scripts/genenv       |    8 +++++---
 4 files changed, 37 insertions(+), 20 deletions(-)

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/3] scripts/bareboxenv: Only print information if -v is given
  2012-09-27 17:13 [PATCH] Fix environment generation dependencies Sascha Hauer
@ 2012-09-27 17:14 ` Sascha Hauer
  2012-09-27 17:14 ` [PATCH 2/3] environment generation: remove unused CLEAN_FILES Sascha Hauer
  2012-09-27 17:14 ` [PATCH 3/3] environment generation: Fix dependencies Sascha Hauer
  2 siblings, 0 replies; 5+ messages in thread
From: Sascha Hauer @ 2012-09-27 17:14 UTC (permalink / raw)
  To: barebox

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 scripts/bareboxenv.c |   15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/scripts/bareboxenv.c b/scripts/bareboxenv.c
index a4aec94..f44a1f8 100644
--- a/scripts/bareboxenv.c
+++ b/scripts/bareboxenv.c
@@ -130,7 +130,8 @@ void usage(char *prgname)
 		"options:\n"
 		"  -s        save (directory -> environment sector)\n"
 		"  -l        load (environment sector -> directory)\n"
-		"  -p <size> pad output file to given size\n",
+		"  -p <size> pad output file to given size\n"
+		"  -v        verbose\n",
 		prgname);
 }
 
@@ -139,8 +140,9 @@ int main(int argc, char *argv[])
 	int opt;
 	int save = 0, load = 0, pad = 0, fd;
 	char *filename = NULL, *dirname = NULL;
+	int verbose = 0;
 
-	while((opt = getopt(argc, argv, "slp:")) != -1) {
+	while((opt = getopt(argc, argv, "slp:v")) != -1) {
 		switch (opt) {
 		case 's':
 			save = 1;
@@ -151,6 +153,9 @@ int main(int argc, char *argv[])
 		case 'p':
 			pad = strtoul(optarg, NULL, 0);
 			break;
+		case 'v':
+			verbose = 1;
+			break;
 		}
 	}
 
@@ -184,11 +189,13 @@ int main(int argc, char *argv[])
 	}
 
 	if (load) {
-		printf("loading env from file %s to %s\n", filename, dirname);
+		if (verbose)
+			printf("loading env from file %s to %s\n", filename, dirname);
 		envfs_load(filename, dirname);
 	}
 	if (save) {
-		printf("saving contents of %s to file %s\n", dirname, filename);
+		if (verbose)
+			printf("saving contents of %s to file %s\n", dirname, filename);
 		envfs_save(filename, dirname);
 	}
 	exit(0);
-- 
1.7.10.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 2/3] environment generation: remove unused CLEAN_FILES
  2012-09-27 17:13 [PATCH] Fix environment generation dependencies Sascha Hauer
  2012-09-27 17:14 ` [PATCH 1/3] scripts/bareboxenv: Only print information if -v is given Sascha Hauer
@ 2012-09-27 17:14 ` Sascha Hauer
  2012-09-27 17:14 ` [PATCH 3/3] environment generation: Fix dependencies Sascha Hauer
  2 siblings, 0 replies; 5+ messages in thread
From: Sascha Hauer @ 2012-09-27 17:14 UTC (permalink / raw)
  To: barebox

The CLEAN_FILES in common/Makefile are unused. All generated files
are removed from the toplevel Makefile.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 common/Makefile |    4 ----
 1 file changed, 4 deletions(-)

diff --git a/common/Makefile b/common/Makefile
index 68582b7..9eda98c 100644
--- a/common/Makefile
+++ b/common/Makefile
@@ -90,10 +90,6 @@ include/generated/barebox_default_env.h: barebox_default_env$(barebox_default_en
 	$(Q)cat $< | $(objtree)/scripts/bin2c default_environment > $@
 	$(Q)echo "const int default_environment_uncompress_size=`stat -c%s barebox_default_env`;" >> $@
 
-CLEAN_FILES += include/generated/barebox_default_env.h barebox_default_env
-CLEAN_FILES += barebox_default_env.gz barebox_default_env.bz2
-CLEAN_FILES += barebox_default_env.lzo
-
 # dependencies on generated files need to be listed explicitly
 $(obj)/version.o: include/generated/compile.h
 
-- 
1.7.10.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 3/3] environment generation: Fix dependencies
  2012-09-27 17:13 [PATCH] Fix environment generation dependencies Sascha Hauer
  2012-09-27 17:14 ` [PATCH 1/3] scripts/bareboxenv: Only print information if -v is given Sascha Hauer
  2012-09-27 17:14 ` [PATCH 2/3] environment generation: remove unused CLEAN_FILES Sascha Hauer
@ 2012-09-27 17:14 ` Sascha Hauer
  2012-09-27 18:42   ` Jean-Christophe PLAGNIOL-VILLARD
  2 siblings, 1 reply; 5+ messages in thread
From: Sascha Hauer @ 2012-09-27 17:14 UTC (permalink / raw)
  To: barebox

The dependencies for generating the environment do not work properly:

- If files are removed from the defaultenv, a subsequent make will not
  update the default environment.
- If CONFIG_DEFAULT_ENVIRONMENT_PATH changes, the default environment
  also will not be regenerated.

This patch fixes this by introducing a cmd_env which has the content of
$(ENV_FILES) in the command so that the if_changed mechanism recognizes
a change when $(ENV_FILE) changes. This also results in a nice "  ENV "
string in the build process.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 Makefile        |    2 +-
 common/Makefile |   28 ++++++++++++++++++++--------
 scripts/genenv  |    8 +++++---
 3 files changed, 26 insertions(+), 12 deletions(-)

diff --git a/Makefile b/Makefile
index 0f1a319..af5c036 100644
--- a/Makefile
+++ b/Makefile
@@ -1013,7 +1013,7 @@ endif # CONFIG_MODULES
 CLEAN_DIRS  += $(MODVERDIR)
 CLEAN_FILES +=	barebox System.map include/generated/barebox_default_env.h \
                 .tmp_version .tmp_barebox* barebox.bin barebox.map barebox.S \
-		.tmp_kallsyms* barebox_default_env* barebox.ldr \
+		.tmp_kallsyms* common/barebox_default_env* barebox.ldr \
 		scripts/bareboxenv-target barebox-flash-image \
 		Doxyfile.version barebox.srec barebox.s5p
 
diff --git a/common/Makefile b/common/Makefile
index 9eda98c..b74c76b 100644
--- a/common/Makefile
+++ b/common/Makefile
@@ -39,6 +39,7 @@ obj-$(CONFIG_PASSWORD) += password.o
 obj-$(CONFIG_MODULES) += module.o
 obj-$(CONFIG_FLEXIBLE_BOOTARGS) += bootargs.o
 extra-$(CONFIG_MODULES) += module.lds
+extra-y += barebox_default_env
 
 ifdef CONFIG_DEFAULT_ENVIRONMENT
 $(obj)/startup.o: include/generated/barebox_default_env.h
@@ -63,8 +64,19 @@ ENV_FILES := $(shell cd $(srctree); for i in $(DEFAULT_ENVIRONMENT_PATH); do fin
 
 endif # ifdef CONFIG_DEFAULT_ENVIRONMENT
 
-barebox_default_env: $(ENV_FILES)
-	$(Q)$(srctree)/scripts/genenv $(srctree) $(objtree) $(DEFAULT_ENVIRONMENT_PATH)
+#
+# Generate a barebox envfs image.
+#
+# echo $(ENV_FILES) > /dev/null is just for letting if_changed
+# recognize that something has changed when the environment has
+# other files,
+#
+quiet_cmd_env = ENV     $@
+cmd_env = ($(srctree)/scripts/genenv $(srctree) $(objtree) $@ $(DEFAULT_ENVIRONMENT_PATH)) || \
+	(echo $(ENV_FILES) > /dev/null; rm -f $@ ; false)
+
+$(obj)/barebox_default_env: $(ENV_FILES) FORCE
+	$(call if_changed,env)
 
 barebox_default_env_comp =
 ifeq ($(CONFIG_DEFAULT_ENVIRONMENT_COMPRESSED_GZIP),y)
@@ -77,18 +89,18 @@ ifeq ($(CONFIG_DEFAULT_ENVIRONMENT_COMPRESSED_LZO),y)
 barebox_default_env_comp = .lzo
 endif
 
-barebox_default_env.gz: barebox_default_env
+$(obj)/barebox_default_env.gz: $(obj)/barebox_default_env
 	$(call if_changed,gzip)
 
-barebox_default_env.bz2: barebox_default_env
+$(obj)/barebox_default_env.bz2: $(obj)/barebox_default_env
 	$(call if_changed,bzip2)
 
-barebox_default_env.lzo: barebox_default_env
+$(obj)/barebox_default_env.lzo: $(obj)/barebox_default_env
 	$(call if_changed,lzo)
 
-include/generated/barebox_default_env.h: barebox_default_env$(barebox_default_env_comp)
-	$(Q)cat $< | $(objtree)/scripts/bin2c default_environment > $@
-	$(Q)echo "const int default_environment_uncompress_size=`stat -c%s barebox_default_env`;" >> $@
+include/generated/barebox_default_env.h: $(obj)/barebox_default_env$(barebox_default_env_comp)
+	$(Q)cat $< | (cd $(obj) && $(objtree)/scripts/bin2c default_environment) > $@
+	$(Q)echo "const int default_environment_uncompress_size=`stat -c%s $(obj)/barebox_default_env`;" >> $@
 
 # dependencies on generated files need to be listed explicitly
 $(obj)/version.o: include/generated/compile.h
diff --git a/scripts/genenv b/scripts/genenv
index ff7972b..08c0c10 100755
--- a/scripts/genenv
+++ b/scripts/genenv
@@ -1,12 +1,14 @@
 #!/bin/bash
 
 # Generate the default environment file from a list of directories
-# usage: genenv <basedir> <objdir> <dir>...
+# usage: genenv <basedir> <objdir> <target> <dir>...
 # where <basedir> is the base directory for relative pathes in <dir>
 # where <objdir> is the base directory for relative pathes for result
+# and <target> is the resulting binary environment
 objtree=$2
 cd $1 || exit 1
-shift 2
+target=$3
+shift 3
 
 tempdir=$(mktemp -d tmp.XXXXXX)
 
@@ -20,7 +22,7 @@ done
 
 find $tempdir -name '.svn' -o -name '*~' | xargs --no-run-if-empty rm -r
 
-$objtree/scripts/bareboxenv -s $tempdir $objtree/barebox_default_env
+$objtree/scripts/bareboxenv -s $tempdir $target
 
 rm -r $tempdir
 
-- 
1.7.10.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 3/3] environment generation: Fix dependencies
  2012-09-27 17:14 ` [PATCH 3/3] environment generation: Fix dependencies Sascha Hauer
@ 2012-09-27 18:42   ` Jean-Christophe PLAGNIOL-VILLARD
  0 siblings, 0 replies; 5+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-09-27 18:42 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: barebox

On 19:14 Thu 27 Sep     , Sascha Hauer wrote:
> The dependencies for generating the environment do not work properly:
> 
> - If files are removed from the defaultenv, a subsequent make will not
>   update the default environment.
> - If CONFIG_DEFAULT_ENVIRONMENT_PATH changes, the default environment
>   also will not be regenerated.
> 
> This patch fixes this by introducing a cmd_env which has the content of
> $(ENV_FILES) in the command so that the if_changed mechanism recognizes
> a change when $(ENV_FILE) changes. This also results in a nice "  ENV "
> string in the build process.
> 

we still have an toehr annoying bug generte the temporary env in srctree
instead of objtree

Best Regrards,
J.

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2012-09-27 18:44 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-09-27 17:13 [PATCH] Fix environment generation dependencies Sascha Hauer
2012-09-27 17:14 ` [PATCH 1/3] scripts/bareboxenv: Only print information if -v is given Sascha Hauer
2012-09-27 17:14 ` [PATCH 2/3] environment generation: remove unused CLEAN_FILES Sascha Hauer
2012-09-27 17:14 ` [PATCH 3/3] environment generation: Fix dependencies Sascha Hauer
2012-09-27 18:42   ` Jean-Christophe PLAGNIOL-VILLARD

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox