aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCyril Bur <cyril.bur@au1.ibm.com>2015-11-11 15:40:02 +1100
committerStewart Smith <stewart@linux.vnet.ibm.com>2015-11-16 13:08:29 +1100
commite23b2485de0ec6b0962b983a688d1fb4b8a8d112 (patch)
treef0f2af761e6050709a74ec2a9b75417552c261e5
parentfc8a7e30dd27360514ea145d19bcc6a5820a6e3f (diff)
downloadskiboot-e23b2485de0ec6b0962b983a688d1fb4b8a8d112.zip
skiboot-e23b2485de0ec6b0962b983a688d1fb4b8a8d112.tar.gz
skiboot-e23b2485de0ec6b0962b983a688d1fb4b8a8d112.tar.bz2
external/gard: Add version information
Method for recording version is identical to pflash. Uses the current skiboot version and any current repository state. Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
-rw-r--r--external/gard/Makefile20
-rw-r--r--external/gard/gard.c9
-rw-r--r--external/gard/rules.mk11
-rw-r--r--external/gard/test/results/02-usage.out1
-rw-r--r--external/gard/test/tests/02-usage2
5 files changed, 37 insertions, 6 deletions
diff --git a/external/gard/Makefile b/external/gard/Makefile
index c3dc6fb..2f21607 100644
--- a/external/gard/Makefile
+++ b/external/gard/Makefile
@@ -6,7 +6,7 @@ include ../../external/common/rules.mk
all: $(EXE)
.PHONY: links
-links: libflash ccan common
+links: libflash ccan common make_version.sh
libflash:
ln -sf ../../libflash .
@@ -17,17 +17,27 @@ ccan:
common:
ln -sf ../common .
-check: all
+make_version.sh:
+ ln -sf ../../make_version.sh
+
+#Rebuild version.o so that the the version always matches
+#what the test suite will get from ./make_version.sh
+check: version.o all
@ln -sf ../../test/test.sh test/test.sh
@test/test-gard
$(OBJS): | links arch_links
+.PHONY: VERSION-always
+.version: VERSION-always
+ @echo $(GARD_VERSION) > $@.tmp
+ @cmp -s $@ $@.tmp || cp $@.tmp $@
+ @rm -f $@.tmp
+
clean: arch_clean
- rm -f $(OBJS) $(EXE) *.o *.d
+ rm -f $(OBJS) $(EXE) *.o *.d .version .version.tmp
distclean: clean
rm -f *.c~ *.h~ *.sh~ Makefile~ config.mk~ libflash/*.c~ libflash/*.h~
- rm -f libflash ccan .version .version.tmp
- rm -f common io.h make_version.sh
+ rm -f libflash ccan common io.h make_version.sh
diff --git a/external/gard/gard.c b/external/gard/gard.c
index b656f40..e41047f 100644
--- a/external/gard/gard.c
+++ b/external/gard/gard.c
@@ -44,6 +44,9 @@
#define SYSFS_MTD_PATH "/sys/class/mtd/"
#define FLASH_GARD_PART "GUARD"
+/* Full gard version number (possibly includes gitid). */
+extern const char version[];
+
struct gard_ctx {
bool ecc;
uint32_t f_size;
@@ -637,10 +640,16 @@ struct {
{ "clear", "Clear GARD records", do_clear },
};
+static void print_version(void)
+{
+ printf("Open-Power GARD tool %s\n", version);
+}
+
static void usage(const char *progname)
{
unsigned int i;
+ print_version();
fprintf(stderr, "Usage: %s [-a -e -f <file> -p] <command> [<args>]\n\n",
progname);
fprintf(stderr, "-e --ecc\n\tForce reading/writing with ECC bytes.\n\n");
diff --git a/external/gard/rules.mk b/external/gard/rules.mk
index bef8fbb..a78a401 100644
--- a/external/gard/rules.mk
+++ b/external/gard/rules.mk
@@ -1,7 +1,7 @@
.DEFAULT_GOAL := all
override CFLAGS += -O2 -Wall -Werror -I.
-OBJS = gard.o
+OBJS = version.o gard.o
OBJS += libflash/file.o libflash/libflash.o libflash/libffs.o libflash/ecc.o libflash/blocklevel.o
OBJS += common/arch_flash.o
EXE = gard
@@ -13,6 +13,15 @@ sbindir = $(prefix)/sbin
datadir = $(prefix)/share
mandir = $(datadir)/man
+GARD_VERSION ?= $(shell ./make_version.sh $(EXE))
+
+version.c: make_version.sh .version
+ @(if [ "a$(GARD_VERSION)" = "a" ]; then \
+ echo "#error You need to set GARD_VERSION environment variable" > $@ ;\
+ else \
+ echo "const char version[] = \"$(GARD_VERSION)\";" ;\
+ fi) > $@
+
%.o : %.c
$(CC) $(CFLAGS) -c $< -o $@
diff --git a/external/gard/test/results/02-usage.out b/external/gard/test/results/02-usage.out
index e69de29..c862167 100644
--- a/external/gard/test/results/02-usage.out
+++ b/external/gard/test/results/02-usage.out
@@ -0,0 +1 @@
+Open-Power GARD tool VERSION
diff --git a/external/gard/test/tests/02-usage b/external/gard/test/tests/02-usage
index 768f5d0..45e5e02 100644
--- a/external/gard/test/tests/02-usage
+++ b/external/gard/test/tests/02-usage
@@ -5,6 +5,8 @@ if [ "$?" -ne 1 ] ; then
fail_test
fi
+strip_version_from_result "gard"
+
diff_with_result
pass_test