2018-04-27 05:02:53 +08:00
|
|
|
#!/usr/bin/perl -w
|
|
|
|
|
2009-08-28 14:40:44 +08:00
|
|
|
# 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
|
2019-03-12 07:12:26 +08:00
|
|
|
# Modified april 2014 because of the move to github.
|
2014-04-02 02:52:45 +08:00
|
|
|
# --- 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";
|
|
|
|
|
2017-08-20 09:52:06 +08:00
|
|
|
# if you are making your own fork, change this line to reflect your fork-name
|
2019-04-28 23:06:07 +08:00
|
|
|
my $fullgitinfo = 'RRG/Iceman';
|
2018-04-27 05:07:50 +08:00
|
|
|
my $ctime;
|
2018-04-27 05:02:53 +08:00
|
|
|
# GIT status 0 = dirty, 1 = clean , 2 = undecided
|
|
|
|
my $clean = 2;
|
2018-09-06 11:24:50 +08:00
|
|
|
|
2019-03-12 07:12:26 +08:00
|
|
|
# Do we have acces to git command?
|
2018-09-06 11:24:50 +08:00
|
|
|
#######
|
2019-03-12 07:12:26 +08:00
|
|
|
# solves some bug on macos i.e:
|
2018-09-06 11:24:50 +08:00
|
|
|
##
|
|
|
|
# perl ../tools/mkversion.pl .. > version.c || cp ../common/default_version.c version.c
|
|
|
|
# /usr/bin/which: /usr/bin/which: cannot execute binary file
|
|
|
|
# fatal: No names found, cannot describe anything.
|
|
|
|
##
|
|
|
|
# anyway forcing any kind of shell is at least useless, at worst fatal.
|
2019-02-18 17:18:55 +08:00
|
|
|
my $commandGIT = "env which git";
|
2016-09-01 22:11:31 +08:00
|
|
|
|
2018-04-27 05:02:53 +08:00
|
|
|
if ( defined($commandGIT) ) {
|
2017-08-20 09:52:06 +08:00
|
|
|
|
2019-04-27 16:41:10 +08:00
|
|
|
# this goes on Internet and cause major slowdowns on poor connections or intranets, let's comment it
|
|
|
|
#my $githistory = `git fetch --all`;
|
2019-03-09 17:52:45 +08:00
|
|
|
# now avoiding the "fatal: No names found, cannot describe anything." error by fallbacking to abbrev hash in such case
|
|
|
|
my $gitversion = `git describe --dirty --always`;
|
|
|
|
my $gitbranch = `git rev-parse --abbrev-ref HEAD`;
|
|
|
|
$clean = $gitversion =~ '-dirty' ? 0 : 1;
|
2018-04-27 05:02:53 +08:00
|
|
|
|
2019-03-09 17:52:45 +08:00
|
|
|
if ( defined($gitbranch) and defined($gitversion) ) {
|
|
|
|
$fullgitinfo = $fullgitinfo.'/'. $gitbranch . '/' . $gitversion;
|
2017-08-20 09:52:06 +08:00
|
|
|
|
2019-03-09 17:52:45 +08:00
|
|
|
my @compiletime = localtime();
|
|
|
|
$compiletime[4] += 1;
|
|
|
|
$compiletime[5] += 1900;
|
|
|
|
$ctime = sprintf("%6\$04i-%5\$02i-%4\$02i %3\$02i:%2\$02i:%1\$02i", @compiletime);
|
|
|
|
} else {
|
|
|
|
$fullgitinfo = $fullgitinfo.'/master/release (git)';
|
|
|
|
}
|
2018-04-27 05:02:53 +08:00
|
|
|
} else {
|
2019-03-09 17:52:45 +08:00
|
|
|
$fullgitinfo = $fullgitinfo.'/master/release (no_git)';
|
|
|
|
my @dl_time = localtime( (stat('../README.md'))[10] );
|
|
|
|
$dl_time[4] += 1;
|
|
|
|
$dl_time[5] += 1900;
|
|
|
|
$ctime = sprintf("%6\$04i-%5\$02i-%4\$02i %3\$02i:%2\$02i:%1\$02i", @dl_time);
|
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
|
2018-04-27 05:02:53 +08:00
|
|
|
#$fullgitinfo =~ s/.{50}\K.*//s;
|
|
|
|
$fullgitinfo = substr $fullgitinfo, 0, 49;
|
2009-08-28 14:40:44 +08:00
|
|
|
|
|
|
|
print <<EOF
|
2019-08-08 22:57:33 +08:00
|
|
|
#include "proxmark3_arm.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 = {
|
2019-03-09 17:52:45 +08:00
|
|
|
VERSION_INFORMATION_MAGIC,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
$clean,
|
|
|
|
"$fullgitinfo",
|
|
|
|
"$ctime",
|
2009-08-28 14:40:44 +08:00
|
|
|
};
|
2017-08-21 23:29:47 +08:00
|
|
|
EOF
|