]> git.zerfleddert.de Git - proxmark3-svn/blame - tools/mkversion.pl
ADD: some more keys
[proxmark3-svn] / tools / mkversion.pl
CommitLineData
8a6aec16 1#!/usr/bin/perl
2# Output a version.c file that includes information about the current build
3# Normally a couple of lines of bash would be enough (see openpcd project, original firmware by Harald Welte and Milosch Meriac)
4# but this will, at least in theory, also work on Windows with our current compile environment.
5# -- Henryk Plötz <henryk@ploetzli.ch> 2009-09-28
e3ac0d70
MHS
6# Modified april 2014 because of the move to github.
7# --- Martin Holst Swende <martin@swende.se>
43d3f769 8# Modified january 2016 to work with Travis-CI
9# --- iceman <iceman@iuse.se>
8a6aec16 10
9c683716 11# Clear environment locale so that git will not use localized strings
8a6aec16 12$ENV{'LC_ALL'} = "C";
13$ENV{'LANG'} = "C";
14
43d3f769 15my $githistory = `git fetch --all`;
e3ac0d70
MHS
16my $gitversion = `git describe --dirty`;
17my $gitbranch = `git rev-parse --abbrev-ref HEAD`;
dbbc8296 18my $clean = $gitversion =~ '-dirty' ? 0 : 1;
c3b6fdfa 19my @compiletime = localtime();
8a6aec16 20
d515e7a3 21my $fullgitinfo = 'iceman';
22
23if ( defined $gitbranch and defined $gitversion ) {
c3b6fdfa 24 $fullgitinfo = $fullgitinfo.'/'. $gitbranch . '/' . $gitversion;
d515e7a3 25} else {
c3b6fdfa 26 $fullgitinfo = $fullgitinfo.'/master/release-build (no_git)';
d515e7a3 27}
49b35ff9 28
9c683716 29$fullgitinfo =~ s/(\s)//g;
49b35ff9 30
e3ac0d70
MHS
31# Crop so it fits within 50 characters
32$fullgitinfo =~ s/.{50}\K.*//s;
8a6aec16 33
34$compiletime[4] += 1;
35$compiletime[5] += 1900;
36my $ctime = sprintf("%6\$04i-%5\$02i-%4\$02i %3\$02i:%2\$02i:%1\$02i", @compiletime);
e3ac0d70 37
8a6aec16 38
39print <<EOF
49b35ff9 40#include "proxmark3.h"
8a6aec16 41/* Generated file, do not edit */
b7913d8f 42const struct version_information __attribute__((section(".version_information"))) version_information = {
8a6aec16 43 VERSION_INFORMATION_MAGIC,
44 1,
69135e1c 45 1,
8a6aec16 46 $clean,
e3ac0d70 47 "$fullgitinfo",
8a6aec16 48 "$ctime",
49};
50EOF
Impressum, Datenschutz