From c861e4cab67bffacd1b85bd19861304f8cc7acf5 Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Thu, 27 Sep 2012 10:18:40 +0200 Subject: scripts/bareboxenv: Only print information if -v is given Signed-off-by: Sascha Hauer --- scripts/bareboxenv.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'scripts') diff --git a/scripts/bareboxenv.c b/scripts/bareboxenv.c index f7f5351ca6..91f5bc29d8 100644 --- a/scripts/bareboxenv.c +++ b/scripts/bareboxenv.c @@ -133,7 +133,8 @@ void usage(char *prgname) "options:\n" " -s save (directory -> environment sector)\n" " -l load (environment sector -> directory)\n" - " -p pad output file to given size\n", + " -p pad output file to given size\n" + " -v verbose\n", prgname); } @@ -142,8 +143,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; @@ -154,6 +156,9 @@ int main(int argc, char *argv[]) case 'p': pad = strtoul(optarg, NULL, 0); break; + case 'v': + verbose = 1; + break; } } @@ -187,11 +192,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); -- cgit v1.2.3 From c8c49c14aef009a86f238c4bdaf78b1d01b7bdcf Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Thu, 27 Sep 2012 10:29:48 +0200 Subject: environment generation: Fix dependencies 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 --- Makefile | 2 +- common/Makefile | 28 ++++++++++++++++++++-------- scripts/genenv | 17 +++++++++++------ 3 files changed, 32 insertions(+), 15 deletions(-) (limited to 'scripts') diff --git a/Makefile b/Makefile index c6264d3404..4e50c9f766 100644 --- a/Makefile +++ b/Makefile @@ -1007,7 +1007,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 88580a235d..c091b7350c 100644 --- a/common/Makefile +++ b/common/Makefile @@ -38,6 +38,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 @@ -62,8 +63,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) @@ -76,18 +88,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 c84af0c015..834ea594dd 100755 --- a/scripts/genenv +++ b/scripts/genenv @@ -1,22 +1,27 @@ #!/bin/bash # Generate the default environment file from a list of directories -# usage: genenv ... +# usage: genenv ... # where is the base directory for relative pathes in # where is the base directory for relative pathes for result +# and is the resulting binary environment objtree=$2 -cd $1 || exit 1 -shift 2 +basedir=$1 +target=$3 +shift 3 -tempdir=$(mktemp -d tmp.XXXXXX) +tempdir="$objtree/.barebox_default_env" +mkdir -p "$tempdir" + +(cd $basedir for i in $*; do cp -r $i/* $tempdir 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 - -- cgit v1.2.3