]> www.fi.muni.cz Git - tinyboard.git/blobdiff - projects/rgb-led-light/version.pl
Merge branch 'master' of ssh://anxur.fi.muni.cz/~kas/html/git/tinyboard
[tinyboard.git] / projects / rgb-led-light / version.pl
diff --git a/projects/rgb-led-light/version.pl b/projects/rgb-led-light/version.pl
new file mode 100755 (executable)
index 0000000..cb4ecc7
--- /dev/null
@@ -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 <<EOF;
+/* DO NOT EDIT - GENERATED BY $0 */
+
+#include <avr/eeprom.h>
+
+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";
+}
+