From 75d4f19d300363a38c52eb55c31e6d4002366d03 Mon Sep 17 00:00:00 2001 From: Oleg Semyonov Date: Wed, 25 May 2011 10:59:35 +0300 Subject: [PATCH] build: add FWTAG variable to the version-info.py --- make/scripts/version-info.py | 8 ++++++++ make/templates/firmwareinfotemplate.c | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/make/scripts/version-info.py b/make/scripts/version-info.py index 5e9fa5916..740836574 100644 --- a/make/scripts/version-info.py +++ b/make/scripts/version-info.py @@ -235,6 +235,13 @@ def sha1(file): hex_stream = lambda s:",".join(['0x'+hex(ord(c))[2:].zfill(2) for c in s]) return hex_stream(sha1.digest()) +def xtrim(string, length): + """Trim string up to length bytes, adding '+' if truncated""" + if len(string) <= length: + return string + else: + return string[:length-1] + '+' + def main(): """This utility uses git repository in the current working directory or from the given path to extract some info about it and HEAD commit. @@ -306,6 +313,7 @@ dependent targets. TAG_OR_BRANCH = r.tag(r.branch('unreleased')), TAG_OR_HASH8 = r.tag(r.hash(8, 'untagged')), DIRTY = r.dirty(), + FWTAG = xtrim(r.tag(r.branch('unreleased')) + r.dirty(), 25), UNIXTIME = r.time(), DATE = r.time('%Y%m%d'), DATETIME = r.time('%Y%m%d %H:%M'), diff --git a/make/templates/firmwareinfotemplate.c b/make/templates/firmwareinfotemplate.c index 3f3829cc6..b9297273e 100644 --- a/make/templates/firmwareinfotemplate.c +++ b/make/templates/firmwareinfotemplate.c @@ -62,7 +62,7 @@ const struct fw_version_info fw_version_blob __attribute__((used)) __attribute__ .timestamp = ${UNIXTIME}, .board_type = ${BOARD_TYPE}, .board_revision = ${BOARD_REVISION}, - .commit_tag_name = "${TAG_OR_BRANCH}${DIRTY}", + .commit_tag_name = "${FWTAG}", .sha1sum = { ${SHA1} }, };