Skip to content

Commit

Permalink
Improved versioning stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcos Del Sol Vives committed Mar 11, 2017
1 parent d7dd307 commit df1405d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 29 deletions.
4 changes: 2 additions & 2 deletions amiitool.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ static char * self;

void usage() {
fprintf(stderr,
"amiitool v%s (commit %08x)\n"
"amiitool build %i (commit %s-%08x)\n"
"by Marcos Del Sol Vives <[email protected]>\n"
"\n"
"Usage: %s (-e|-d) -k keyfile [-i input] [-o output]\n"
Expand All @@ -29,7 +29,7 @@ void usage() {
" -i input file. If not specified, stdin will be used.\n"
" -o output file. If not specified, stdout will be used.\n"
" -l decrypt files with invalid signatures.\n",
nfc3d_version(), nfc3d_commit_id(), self
nfc3d_version_build(), nfc3d_version_fork(), nfc3d_version_commit(), self
);
}

Expand Down
7 changes: 3 additions & 4 deletions include/nfc3d/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@

#include <stdint.h>

const char * nfc3d_version();
uint32_t nfc3d_version_code();
uint32_t nfc3d_commit_id();
uint32_t nfc3d_commit_count();
const char * nfc3d_version_fork();
uint32_t nfc3d_version_build();
uint32_t nfc3d_version_commit();

#endif
29 changes: 6 additions & 23 deletions version.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/*
* (c) 2015-2017 Marcos Del Sol Vives
* (c) 2016 javiMaD
* (c) 2017 Marcos Del Sol Vives
*
* SPDX-License-Identifier: MIT
*/
Expand All @@ -9,31 +8,15 @@
#include <stdio.h>
#include "gitversion.h"

static char vstr[16] = { 0 };

const char * nfc3d_version() {
if (vstr[0]) {
return vstr;
}

uint32_t version = nfc3d_version_code();
uint32_t major = version >> 24;
uint32_t minor = version >> 12 & 0xFFF;
uint32_t revision = version & 0xFFF;

snprintf(vstr, sizeof(vstr) - 1, "%x.%x.%x", major, minor, revision);
return vstr;
}

uint32_t nfc3d_version_code() {
// TODO: can we get this from Git tags somehow?
return 0x01000000;
const char * nfc3d_version_fork() {
// TODO: maybe this should go in another file?
return "socram";
}

uint32_t nfc3d_commit_id() {
uint32_t nfc3d_version_commit() {
return GIT_COMMIT_ID;
}

uint32_t nfc3d_commit_count() {
uint32_t nfc3d_version_build() {
return GIT_COMMIT_COUNT;
}

0 comments on commit df1405d

Please sign in to comment.