1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-02-20 10:54:14 +01:00

Merge branch 'master' of ssh://git.openpilot.org/OpenPilot

This commit is contained in:
dankers 2011-05-25 04:14:21 +10:00
commit b4c5f3e0fe
5 changed files with 63 additions and 24 deletions

View File

@ -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'),

View File

@ -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} },
};

View File

@ -14,12 +14,24 @@ 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
BLUPD_DIR := $(FW_DIR)/bootloader_updaters
# Clean build options (recommended for package testing only)
ifeq ($(CLEAN_BUILD), NO)
CLEAN_GROUND := NO
CLEAN_FLIGHT := YES
else ifeq ($(CLEAN_BUILD), NEVER)
CLEAN_GROUND := NO
CLEAN_FLIGHT := NO
else
CLEAN_GROUND := YES
CLEAN_FLIGHT := YES
endif
# Setup targets
FW_TARGETS_COMMON := ahrs pipxtreme
FW_TARGETS_INPUT := coptercontrol openpilot
@ -35,14 +47,23 @@ help:
@echo
@echo " Here is a summary of the available targets:"
@echo
@echo " [Release build and packaging]"
@echo " release - Build and package the OpenPilot release"
@echo " release_flight - Build and package the OpenPilot flight firmware"
@echo " [Packaging]"
@echo " release - Build and package the OpenPilot distributable"
@echo " release_flight - Build and package the OpenPilot flight firmware only"
@echo
@echo " Notes:"
@echo " - the build directory will be removed first on every run"
@echo " unless CLEAN_BUILD=NO is defined (recommended for testing only)"
@echo " - release packages will be placed in $(RELEASE_DIR)"
@echo " - package will be placed in $(RELEASE_DIR)"
@echo
@echo " - the build directory will be removed first on every run unless one"
@echo " of CLEAN_BUILD=NO or CLEAN_BUILD=NEVER options is defined."
@echo
@echo " CLEAN_BUILD=NO means no clean before build except for multi-input"
@echo " firmware binaries like CopterControl or OpenPilot. This usually is"
@echo " safe."
@echo
@echo " CLEAN_BUILD=NEVER means no clean will be done at all. This will,"
@echo " probably, give invalid multi-input firmware and is recommended"
@echo " for package testing only. Do not use for release builds."
@echo
# Clean and build uavobjects since all parts depend on them
@ -50,7 +71,7 @@ uavobjects: all_clean
$(V1) $(MAKE) -C $(ROOT_DIR) $@
all_clean:
ifneq ($(CLEAN_BUILD), NO)
ifneq ($(CLEAN_GROUND), NO)
$(V1) $(MAKE) -C $(ROOT_DIR) $@
endif
@ -61,13 +82,15 @@ endif
# $4 = installed file name prefix (optional)
# $5 = installed file name suffix (optional)
# $6 = extra make options (for instance, USE_SPEKTRUM=YES)
# $7 = optional target suffix (for instance, clean, if target must be cleaned first)
# $7 = optional 'clean' string to clean target before rebuild
# $8 = list of targets to install (without _install suffix)
# $9 = inner make target (usually install, but can be other to just build)
define INSTALL_TEMPLATE
$(1): $(2)
ifneq ($(7),)
ifeq ($(7),clean)
ifneq ($$(CLEAN_FLIGHT), NO)
$$(V1) +$(MAKE) -C $(ROOT_DIR) $(6) $(addsuffix _$(7), $(8))
endif
endif
$$(V1) +$(MAKE) -C $(ROOT_DIR) INSTALL_DIR=$(3) INSTALL_PFX=$(4) INSTALL_SFX=$(5) $(6) $(addsuffix _$(9), $(8))
.PHONY: $(1)

View File

@ -9,17 +9,14 @@ NSIS_SCRIPT := $(NSIS_DIR)/openpilotgcs.nsi
NSIS_TEMPLATE := $(NSIS_DIR)/openpilotgcs.tpl
NSIS_HEADER := $(BUILD_DIR)/ground/openpilotgcs/openpilotgcs.nsh
$(NSIS_HEADER): $(NSIS_TEMPLATE)
$(V0) @echo " PY $@"
$(V1) mkdir -p "$(dir $@)"
$(V1) $(VERSION_CMD) --template="$<" --outfile="$@"
nsis: gcs release_flight $(NSIS_HEADER)
package: gcs release_flight
mkdir -p "$(dir $(NSIS_HEADER))"
$(VERSION_CMD) --template="$(NSIS_TEMPLATE)" --outfile="$(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

View File

@ -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}"