2009-08-28 14:40:44 +08:00
|
|
|
#!/usr/bin/perl
|
|
|
|
# Output a version.c file that includes information about the current build
|
|
|
|
# Normally a couple of lines of bash would be enough (see openpcd project, original firmware by Harald Welte and Milosch Meriac)
|
|
|
|
# but this will, at least in theory, also work on Windows with our current compile environment.
|
|
|
|
# -- Henryk Plötz <henryk@ploetzli.ch> 2009-09-28
|
2014-04-02 02:52:45 +08:00
|
|
|
# Modified april 2014 because of the move to github.
|
|
|
|
# --- Martin Holst Swende <martin@swende.se>
|
2016-01-15 19:43:29 +08:00
|
|
|
# Modified january 2016 to work with Travis-CI
|
|
|
|
# --- iceman <iceman@iuse.se>
|
2009-08-28 14:40:44 +08:00
|
|
|
|
2014-04-03 03:46:25 +08:00
|
|
|
# Clear environment locale so that git will not use localized strings
|
2009-08-28 14:40:44 +08:00
|
|
|
$ENV{'LC_ALL'} = "C";
|
|
|
|
$ENV{'LANG'} = "C";
|
|
|
|
|
2016-01-15 19:43:29 +08:00
|
|
|
my $githistory = `git fetch --all`;
|
2014-04-02 02:52:45 +08:00
|
|
|
my $gitversion = `git describe --dirty`;
|
|
|
|
my $gitbranch = `git rev-parse --abbrev-ref HEAD`;
|
2016-12-08 00:06:15 +08:00
|
|
|
my $clean = $gitversion =~ '-dirty' ? 0 : 1;
|
2016-09-26 18:28:35 +08:00
|
|
|
my @compiletime = localtime();
|
2009-08-28 14:40:44 +08:00
|
|
|
|
2016-09-01 22:11:31 +08:00
|
|
|
my $fullgitinfo = 'iceman';
|
|
|
|
|
|
|
|
if ( defined $gitbranch and defined $gitversion ) {
|
2016-09-26 18:28:35 +08:00
|
|
|
$fullgitinfo = $fullgitinfo.'/'. $gitbranch . '/' . $gitversion;
|
2016-09-01 22:11:31 +08:00
|
|
|
} else {
|
2016-09-26 18:28:35 +08:00
|
|
|
$fullgitinfo = $fullgitinfo.'/master/release-build (no_git)';
|
2016-09-01 22:11:31 +08:00
|
|
|
}
|
2010-02-21 05:56:46 +08:00
|
|
|
|
2014-04-03 03:46:25 +08:00
|
|
|
$fullgitinfo =~ s/(\s)//g;
|
2010-02-21 05:56:46 +08:00
|
|
|
|
2014-04-02 02:52:45 +08:00
|
|
|
# Crop so it fits within 50 characters
|
|
|
|
$fullgitinfo =~ s/.{50}\K.*//s;
|
2009-08-28 14:40:44 +08:00
|
|
|
|
|
|
|
$compiletime[4] += 1;
|
|
|
|
$compiletime[5] += 1900;
|
|
|
|
my $ctime = sprintf("%6\$04i-%5\$02i-%4\$02i %3\$02i:%2\$02i:%1\$02i", @compiletime);
|
2014-04-02 02:52:45 +08:00
|
|
|
|
2009-08-28 14:40:44 +08:00
|
|
|
|
|
|
|
print <<EOF
|
2010-02-21 05:56:46 +08:00
|
|
|
#include "proxmark3.h"
|
2009-08-28 14:40:44 +08:00
|
|
|
/* Generated file, do not edit */
|
2010-02-26 22:02:27 +08:00
|
|
|
const struct version_information __attribute__((section(".version_information"))) version_information = {
|
2009-08-28 14:40:44 +08:00
|
|
|
VERSION_INFORMATION_MAGIC,
|
|
|
|
1,
|
2013-03-27 18:27:14 +08:00
|
|
|
1,
|
2009-08-28 14:40:44 +08:00
|
|
|
$clean,
|
2014-04-02 02:52:45 +08:00
|
|
|
"$fullgitinfo",
|
2009-08-28 14:40:44 +08:00
|
|
|
"$ctime",
|
|
|
|
};
|
|
|
|
EOF
|