From 49420b56b31e113f4c40128c530f2e585a9f8061 Mon Sep 17 00:00:00 2001 From: "Jan \"Yenya\" Kasprzak" Date: Sun, 12 May 2013 01:12:27 +0200 Subject: [PATCH] Include git revision and date in the eeprom variable --- projects/step-up/Makefile | 9 ++++++--- projects/step-up/version.pl | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 3 deletions(-) create mode 100755 projects/step-up/version.pl diff --git a/projects/step-up/Makefile b/projects/step-up/Makefile index 07bb151..55422fc 100644 --- a/projects/step-up/Makefile +++ b/projects/step-up/Makefile @@ -1,7 +1,7 @@ PROGRAM=lights -SRC=main.c logging.c pwm.c adc.c pwmled.c pattern.c buttons.c control.c \ - battery.c wdt.c +SRC=version.c main.c logging.c pwm.c adc.c pwmled.c pattern.c buttons.c \ + control.c battery.c wdt.c OBJ=$(SRC:.c=.o) @@ -62,5 +62,8 @@ objdump: $(PROGRAM).elf clean: rm -f $(PROGRAM).hex $(PROGRAM).eep $(PROGRAM).elf *.o *.s eeprom.raw -.PHONY: all clean dump_eeprom program program_flash program_eeprom objdump +version.c: + ./version.pl > version.c + +.PHONY: all clean dump_eeprom program program_flash program_eeprom objdump version.c diff --git a/projects/step-up/version.pl b/projects/step-up/version.pl new file mode 100755 index 0000000..cb4ecc7 --- /dev/null +++ b/projects/step-up/version.pl @@ -0,0 +1,32 @@ +#!/usr/bin/perl -w + +use strict; +use POSIX qw(strftime); + +my $git = `git rev-parse --short HEAD`; +chomp $git; + +my $now = strftime('%Y%m%d', localtime(time)); + +print < + +unsigned char version[] EEMEM = { +EOF + +print hex2c($git, "git revision"); +print hex2c($now, "date"); + +print "};\n\n/* EOF - this file has not been truncated */\n\n"; + +sub hex2c { + my ($data, $comment) = @_; + + my $data1 = $data; + $data1 .= '0' if (length($data1) & 1 == 1); + $data1 =~ s/(..)/0x$1, /g; + return "\t$data1 /* $comment $data */\n"; +} + -- 2.43.5