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

Merge branch 'master' into osx_distributable

This commit is contained in:
James Cotton 2011-05-22 12:27:14 -05:00
commit af59cbfd2f
7 changed files with 91 additions and 38 deletions

View File

@ -11,7 +11,7 @@ from subprocess import Popen, PIPE
from re import search, MULTILINE
from datetime import datetime
from string import Template
import argparse
import optparse
import hashlib
import sys
@ -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
@ -240,29 +258,39 @@ dependent targets.
"""
# Parse command line.
parser = argparse.ArgumentParser(
formatter_class=argparse.RawDescriptionHelpFormatter,
class RawDescriptionHelpFormatter(optparse.IndentedHelpFormatter):
"""optparse formatter function to pretty print raw epilog"""
def format_epilog(self, epilog):
if epilog:
return "\n" + epilog + "\n"
else:
return ""
parser = optparse.OptionParser(
formatter=RawDescriptionHelpFormatter(),
description = "Performs variable substitution in template file or string.",
epilog = main.__doc__);
parser.add_argument('--path', default='.',
parser.add_option('--path', default='.',
help='path to the git repository');
parser.add_argument('--info', action='store_true',
parser.add_option('--info', action='store_true',
help='print repository info to stdout');
parser.add_argument('--format',
parser.add_option('--format',
help='format string to print to stdout');
parser.add_argument('--template',
parser.add_option('--template',
help='name of template file');
parser.add_argument('--outfile',
parser.add_option('--outfile',
help='name of output file');
parser.add_argument('--image',
parser.add_option('--image',
help='name of image file for sha1 calculation');
parser.add_argument('--type', default="",
parser.add_option('--type', default="",
help='board type, for example, 0x04 for CopterControl');
parser.add_argument('--revision', default = "",
parser.add_option('--revision', default = "",
help='board revision, for example, 0x01');
args = parser.parse_args()
(args, positional_args) = parser.parse_args()
if len(positional_args) != 0:
parser.error("incorrect number of arguments, try --help for help")
# Process arguments. No advanced error handling is here.
# Any error will raise an exception and terminate process
@ -277,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

@ -33,8 +33,8 @@ It is expected that you have the following tools installed into the listed
locations (but any other locations are fine as well):
- Python in C:\Python27
- CodeSourcery G++ in C:\CodeSourcery
- QtSDK in C:\Qt\2010.05
- CodeSourcery G++ in %ProgramFiles%\CodeSourcery\Sourcery G++ Lite
- msysGit in %ProgramFiles%\Git
- Unicode NSIS in %ProgramFiles%\NSIS\Unicode
- OpenOCD in C:\OpenOCD\0.4.0\bin
@ -55,6 +55,10 @@ accordingly. Also if you have tools installed into different directories and
they are not in the PATH, then you may want to update paths in the sh.cmd
script too (it is self-documented).
Note for Windows 64-bit users: 64-bit systems use %ProgramFiles(x86)% folder
as default for program files instead of %ProgramFiles%. You have to check where
your tools are installed and update paths above accordingly.
3. How to use it?
-----------------

View File

@ -53,7 +53,7 @@ set PATH_DIRS=
call :which MSYSGIT "%ProgramFiles%\Git\bin" git.exe
call :which QTMINGW "C:\Qt\2010.05\mingw\bin" mingw32-make.exe
call :which QTSDK "C:\Qt\2010.05\qt\bin" qmake.exe
call :which CODESOURCERY "C:\CodeSourcery\bin" cs-make.exe
call :which CODESOURCERY "%ProgramFiles%\CodeSourcery\Sourcery G++ Lite\bin" cs-make.exe
call :which PYTHON "C:\Python27" python.exe
call :which UNSIS "%ProgramFiles%\NSIS\Unicode" makensis.exe
call :which OPENOCDBIN "C:\OpenOCD\0.4.0\bin" openocd.exe

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