mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-01-29 14:52:12 +01:00
OP-483: include dirty state of repository into the version string
This commit is contained in:
parent
6f5f334818
commit
5c085550cb
@ -82,6 +82,14 @@ class Repo:
|
||||
if m:
|
||||
self._branch = m.group(1)
|
||||
|
||||
def _get_dirty(self):
|
||||
"""Check for dirty state of repository"""
|
||||
self._dirty = False
|
||||
self._exec('update-index --refresh --unmerged')
|
||||
self._exec('diff-index --name-only --exit-code --quiet HEAD')
|
||||
if self._rc:
|
||||
self._dirty = True
|
||||
|
||||
def __init__(self, path = "."):
|
||||
"""Initialize object instance and read repo info"""
|
||||
self._path = path
|
||||
@ -92,12 +100,14 @@ class Repo:
|
||||
self._get_time()
|
||||
self._get_tag()
|
||||
self._get_branch()
|
||||
self._get_dirty()
|
||||
else:
|
||||
self._hash = None
|
||||
self._origin = None
|
||||
self._time = None
|
||||
self._tag = None
|
||||
self._branch = None
|
||||
self._dirty = None
|
||||
|
||||
def path(self):
|
||||
"""Return the repository path"""
|
||||
@ -141,6 +151,13 @@ class Repo:
|
||||
else:
|
||||
return self._branch
|
||||
|
||||
def dirty(self, dirty = "-dirty", clean = ""):
|
||||
"""Return git repository dirty state or empty string"""
|
||||
if self._dirty:
|
||||
return dirty
|
||||
else:
|
||||
return clean
|
||||
|
||||
def info(self):
|
||||
"""Print some repository info"""
|
||||
print "path: ", self.path()
|
||||
@ -151,6 +168,7 @@ class Repo:
|
||||
print "short hash: ", self.hash(8)
|
||||
print "branch: ", self.branch()
|
||||
print "commit tag: ", self.tag()
|
||||
print "dirty: ", self.dirty('yes', 'no')
|
||||
|
||||
def file_from_template(tpl_name, out_name, dict):
|
||||
"""Create or update file from template using dictionary
|
||||
@ -287,6 +305,7 @@ dependent targets.
|
||||
HASH8 = r.hash(8),
|
||||
TAG_OR_BRANCH = r.tag(r.branch('unreleased')),
|
||||
TAG_OR_HASH8 = r.tag(r.hash(8, 'untagged')),
|
||||
DIRTY = r.dirty(),
|
||||
UNIXTIME = r.time(),
|
||||
DATE = r.time('%Y%m%d'),
|
||||
DATETIME = r.time('%Y%m%d %H:%M'),
|
||||
|
@ -38,7 +38,7 @@
|
||||
* 4 bytes: GIT commit tag (short version of SHA1).
|
||||
* 4 bytes: Unix timestamp of compile time.
|
||||
* 2 bytes: target platform. Should follow same rule as BOARD_TYPE and BOARD_REVISION in board define files.
|
||||
* 26 bytes: commit tag if it is there, otherwise branch name. Zero-padded.
|
||||
* 26 bytes: commit tag if it is there, otherwise branch name. '-dirty' may be added if needed. Zero-padded.
|
||||
* ---- 40 bytes limit ---
|
||||
* 20 bytes: SHA1 sum of the firmware.
|
||||
* 40 bytes: free for now.
|
||||
@ -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}",
|
||||
.commit_tag_name = "${TAG_OR_BRANCH}${DIRTY}",
|
||||
.sha1sum = { ${SHA1} },
|
||||
};
|
||||
|
||||
|
@ -14,7 +14,7 @@ ROOT_DIR := $(realpath $(WHEREAMI)/../)
|
||||
# Set up some macros
|
||||
BUILD_DIR := $(ROOT_DIR)/build
|
||||
VERSION_CMD := python $(ROOT_DIR)/make/scripts/version-info.py --path="$(ROOT_DIR)"
|
||||
RELEASE_LBL := $(shell $(VERSION_CMD) --format=\$${DATE}-\$${TAG_OR_HASH8})
|
||||
RELEASE_LBL := $(shell $(VERSION_CMD) --format=\$${DATE}-\$${TAG_OR_HASH8}\$${DIRTY})
|
||||
RELEASE_DIR := $(BUILD_DIR)/release-$(RELEASE_LBL)
|
||||
FW_DIR := $(RELEASE_DIR)/firmware-$(RELEASE_LBL)
|
||||
BL_DIR := $(FW_DIR)/bootloaders
|
||||
|
@ -14,12 +14,12 @@ $(NSIS_HEADER): $(NSIS_TEMPLATE)
|
||||
$(V1) mkdir -p "$(dir $@)"
|
||||
$(V1) $(VERSION_CMD) --template="$<" --outfile="$@"
|
||||
|
||||
nsis: gcs release_flight $(NSIS_HEADER)
|
||||
package: gcs release_flight $(NSIS_HEADER)
|
||||
$(NSIS_CMD) $(NSIS_OPTS) $(NSIS_SCRIPT)
|
||||
|
||||
gcs: uavobjects
|
||||
$(V1) $(MAKE) -C $(ROOT_DIR) GCS_BUILD_CONF=release $@
|
||||
|
||||
ground_package: | nsis
|
||||
ground_package: | package
|
||||
|
||||
.PHONY: nsis gcs ground_package
|
||||
.PHONY: gcs ground_package package
|
||||
|
@ -12,12 +12,12 @@
|
||||
#
|
||||
|
||||
; Some names, paths and constants
|
||||
!define RELEASE_LBL "${DATE}-${TAG_OR_HASH8}"
|
||||
!define RELEASE_LBL "${DATE}-${TAG_OR_HASH8}${DIRTY}"
|
||||
!define RELEASE_DIR "..\..\build\release-$${RELEASE_LBL}"
|
||||
!define OUT_FILE "OpenPilotGCS-$${RELEASE_LBL}-install.exe"
|
||||
!define OUT_FILE "OpenPilot-$${RELEASE_LBL}-install.exe"
|
||||
!define FIRMWARE_DIR "firmware-$${RELEASE_LBL}"
|
||||
|
||||
; Installer version info
|
||||
!define PRODUCT_VERSION "0.0.0.0"
|
||||
!define FILE_VERSION "${TAG_OR_BRANCH}:${HASH8} ${DATETIME}"
|
||||
!define BUILD_DESCRIPTION "${TAG_OR_BRANCH}:${HASH8} built using ${ORIGIN} as origin, committed ${DATETIME} as ${HASH}"
|
||||
!define FILE_VERSION "${TAG_OR_BRANCH}:${HASH8}${DIRTY} ${DATETIME}"
|
||||
!define BUILD_DESCRIPTION "${TAG_OR_BRANCH}:${HASH8}${DIRTY} built using ${ORIGIN} as origin, committed ${DATETIME} as ${HASH}"
|
||||
|
Loading…
x
Reference in New Issue
Block a user