1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2024-12-01 09:24:10 +01:00

Packaging: now should work for all 3 platforms

This commit is contained in:
Oleg Semyonov 2013-03-21 23:11:30 +02:00
parent 096d0d7442
commit 105e7d95c9
9 changed files with 80 additions and 212 deletions

View File

@ -28,11 +28,11 @@ export OPENPILOT_IS_COOL := Fuck Yeah!
.DEFAULT_GOAL := help
# Set up some macros for common directories within the tree
export ROOT_DIR := $(realpath $(dir $(lastword $(MAKEFILE_LIST))))
export TOOLS_DIR := $(ROOT_DIR)/tools
export BUILD_DIR := $(ROOT_DIR)/build
export DL_DIR := $(ROOT_DIR)/downloads
export PKG_DIR := $(ROOT_DIR)/build/package
export ROOT_DIR := $(realpath $(dir $(lastword $(MAKEFILE_LIST))))
export TOOLS_DIR := $(ROOT_DIR)/tools
export BUILD_DIR := $(ROOT_DIR)/build
export DL_DIR := $(ROOT_DIR)/downloads
export PACKAGE_DIR := $(ROOT_DIR)/build/package
# Set up default build configurations (debug | release)
GCS_BUILD_CONF := release
@ -784,61 +784,61 @@ $(OPFW_RESOURCE): $(FW_TARGETS)
$(V1) $(MKDIR) -p $(dir $@)
$(V1) $(ECHO) $(QUOTE)$(OPFW_CONTENTS)$(QUOTE) > $@
# If opfw_resource is requested, GCS should depend on it
ifneq ($(strip $(filter opfw_resource,$(MAKECMDGOALS))),)
$(eval openpilotgcs: | opfw_resource)
endif
# Packaging targets: package, clean_package
# - removes build directory (clean_package only)
# - builds all firmware, opfw_resource, gcs
# - copies firmware into a package directory
# - calls paltform-specific packaging script
export PKG_LABEL := $(shell $(VERSION_INFO) --format=\$${LABEL})
export PKG_NAME := OpenPilot
export PKG_SEP := -
# Do some checks and define some values if package is requested
ifneq ($(strip $(filter package clean_package,$(MAKECMDGOALS))),)
# Define some variables
export PACKAGE_LBL := $(shell $(VERSION_INFO) --format=\$${LABEL})
export PACKAGE_NAME := OpenPilot
export PACKAGE_SEP := -
# Clean the build directory if clean_package is requested
ifneq ($(strip $(filter clean_package,$(MAKECMDGOALS))),)
$(info Cleaning build directory before packaging...)
ifneq ($(shell $(MAKE) all_clean >/dev/null 2>&1 && $(ECHO) "clean"), clean)
$(error Cannot clean build directory)
# We can only package release builds
ifneq ($(GCS_BUILD_CONF),release)
$(error Packaging is currently supported for release builds only)
endif
.PHONY: clean_package
clean_package: package
endif
# Packaged GCS should depend on opfw_resource
ifneq ($(strip $(filter package clean_package,$(MAKECMDGOALS))),)
$(eval openpilotgcs: | opfw_resource)
endif
# Make sure we package release build of GCS
ifneq ($(GCS_BUILD_CONF),release)
$(error Packaging is currently supported for release builds only)
endif
# Clean the build directory if clean_package is requested
ifneq ($(strip $(filter clean_package,$(MAKECMDGOALS))),)
$(info Cleaning build directory before packaging...)
ifneq ($(shell $(MAKE) all_clean >/dev/null 2>&1 && $(ECHO) "clean"), clean)
$(error Cannot clean build directory)
endif
# Build GCS with embedded firmware if package or opfw_resource is requested
ifneq ($(strip $(filter package clean_package opfw_resource,$(MAKECMDGOALS))),)
$(eval openpilotgcs: | opfw_resource)
.PHONY: clean_package
clean_package: package
endif
endif
# Copy file template. Empty line before the endef is required, do not remove
define COPY_FW_FILES
$(V1) $(CP) "$(BUILD_DIR)/$(1)/$(1).opfw" "$(PKG_DIR)/firmware/$(1)$(PKG_SEP)$(PKG_LABEL).opfw"
$(V1) $(CP) "$(BUILD_DIR)/$(1)/$(1).opfw" "$(PACKAGE_DIR)/firmware/$(1)$(PACKAGE_SEP)$(PACKAGE_LBL).opfw"
endef
# Build and copy package files into the package directory
# and call platform-specific packaging script
.PHONY: package
package: all_fw all_ground
$(V1) $(ECHO) "Packaging for $(UNAME) $(ARCH) into $(call toprel, $(PKG_DIR)) directory"
$(V1) [ ! -d "$(PKG_DIR)" ] || $(RM) -rf "$(PKG_DIR)"
$(V1) $(MKDIR) -p "$(PKG_DIR)/firmware"
package: all_fw all_ground uavobjects_matlab
$(V1) $(ECHO) "Packaging for $(UNAME) $(ARCH) into $(call toprel, $(PACKAGE_DIR)) directory"
$(V1) [ ! -d "$(PACKAGE_DIR)" ] || $(RM) -rf "$(PACKAGE_DIR)"
$(V1) $(MKDIR) -p "$(PACKAGE_DIR)/firmware"
$(foreach fw_targ, $(FW_TARGETS), $(call COPY_FW_FILES,$(fw_targ)))
# Call platform-specific packaging script
$(MAKE) --no-print-directory -C $(ROOT_DIR)/package --file=$(UNAME).mk $@
##############################
#

View File

@ -1,8 +1,15 @@
#
# MacOSX-specific packaging
# MacOSX-specific packaging script
#
osx_package: gcs package_flight
ifndef OPENPILOT_IS_COOL
$(error Top level Makefile must be used to build this target)
endif
FW_DIR := $(PACKAGE_DIR)/firmware
.PHONY: package
package:
( \
ROOT_DIR="$(ROOT_DIR)" \
BUILD_DIR="$(BUILD_DIR)" \
@ -13,10 +20,3 @@ osx_package: gcs package_flight
FW_DIR="$(FW_DIR)" \
"$(ROOT_DIR)/package/osx/package" \
)
gcs: uavobjects
$(V1) $(MAKE) -C $(ROOT_DIR) GCS_BUILD_CONF=release $@
ground_package: | osx_package
.PHONY: gcs ground_package osx_package

View File

@ -1,18 +1,24 @@
#
# Linux-specific packaging
# Linux-specific packaging script
#
ifndef OPENPILOT_IS_COOL
$(error Top level Makefile must be used to build this target)
endif
FW_DIR := $(PACKAGE_DIR)/firmware
# Update this number for every formal release. The Deb packaging system relies on this to know to update a
# package or not. Otherwise, the user has to uninstall first.
# Until we do that, package name does NOT include $(VERNUM) and uses $(PACKAGE_LBL) only
VERNUM := 0.1.0
VERNUM := 0.1.0
VERSION_FULL := $(VERNUM)-$(PACKAGE_LBL)
DEB_BUILD_DIR := $(ROOT_DIR)/debian
SED_DATE_STRG = $(shell date -R)
SED_SCRIPT = s/<VERSION>/$(VERNUM)/;s/<DATE>/$(SED_DATE_STRG)/
DEB_CFG_CMN := $(ROOT_DIR)/package/linux/deb_common
DEB_CFG_CMN := $(ROOT_DIR)/package/linux/deb_common
DEB_CFG_I386_DIR := $(ROOT_DIR)/package/linux/deb_i386
DEB_CFG_AMD64_DIR := $(ROOT_DIR)/package/linux/deb_amd64
DEB_CFG_CMN_FILES := $(shell ls $(DEB_CFG_CMN))
@ -34,7 +40,8 @@ FULL_PACKAGE_NAME := $(PACKAGE_NAME)$(PACKAGE_SEP)$(PACKAGE_LBL)$(PACKAGE_SEP)$(
ALL_DEB_FILES = $(foreach f, $(DEB_CFG_CMN_FILES), $(DEB_BUILD_DIR)/$(f))
ALL_DEB_FILES += $(foreach f, $(DEB_MACHINE_FILES), $(DEB_BUILD_DIR)/$(f))
linux_deb_package: $(ALL_DEB_FILES) gcs package_flight
.PHONY: package
package: $(ALL_DEB_FILES)
$(V1) echo "Building Linux package, please wait..."
$(V1) mkdir -p $(DEB_BUILD_DIR)
$(V1)$(shell echo $(FW_DIR) > $(BUILD_DIR)/package_dir)
@ -44,8 +51,6 @@ linux_deb_package: $(ALL_DEB_FILES) gcs package_flight
$(V1) mv $(ROOT_DIR)/../$(DEB_PACKAGE_NAME).changes $(BUILD_DIR)/$(FULL_PACKAGE_NAME).changes
$(V1) rm -rf $(DEB_BUILD_DIR)
$(ALL_DEB_FILES): | uavobjects
define CP_DEB_FILES_TEMPLATE
.PHONY: $(2)/$(1)
$(2)/$(1): $(3)/$(1)
@ -55,10 +60,3 @@ endef
$(foreach cpfile, $(DEB_CFG_CMN_FILES), $(eval $(call CP_DEB_FILES_TEMPLATE,$(cpfile),$(DEB_BUILD_DIR),$(DEB_CFG_CMN))))
$(foreach cpfile, $(DEB_MACHINE_FILES), $(eval $(call CP_DEB_FILES_TEMPLATE,$(cpfile),$(DEB_BUILD_DIR),$(DEB_MACHINE_DIR))))
gcs: uavobjects
$(V1) $(MAKE) -C $(ROOT_DIR) GCS_BUILD_CONF=release $@
ground_package: | linux_deb_package
.PHONY: gcs ground_package linux_deb_package

View File

@ -1,127 +0,0 @@
# Set up a default goal
.DEFAULT_GOAL := help
# Tried the best to support parallel (-j) builds. But since this Makefile
# uses other Makefiles to build few targets which in turn have similar
# dependencies on uavobjects and other generated files, it is difficult
# to support parallel builds perfectly. But at least it was tested with
# -j (unlimited job number) on Windows and Linux.
# Locate the root of the tree
WHEREAMI := $(dir $(lastword $(MAKEFILE_LIST)))
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)"
PACKAGE_LBL := $(shell $(VERSION_CMD) --format=\$${LABEL})
PACKAGE_DIR := $(BUILD_DIR)/package-$(PACKAGE_LBL)
PACKAGE_NAME := OpenPilot
PACKAGE_SEP := -
FW_DIR := $(PACKAGE_DIR)/firmware-$(PACKAGE_LBL)
BL_DIR := $(FW_DIR)/bootloaders
BU_DIR := $(FW_DIR)/bootloader-updaters
# Clean build options (recommended for package testing only)
ifeq ($(CLEAN_BUILD), NO)
CLEAN_GROUND := NO
CLEAN_FLIGHT := NO
else
CLEAN_GROUND := YES
CLEAN_FLIGHT := YES
endif
# Set up targets
ALL_BOARDS := coptercontrol pipxtreme revolution revomini osd
ALL_BOARDS_BU := coptercontrol pipxtreme
FW_TARGETS := $(addprefix fw_, $(ALL_BOARDS))
FW_TARGETS_TOOLS := $(addprefix fw_, $(ALL_BOARDS))
BL_TARGETS := $(addprefix bl_, $(ALL_BOARDS))
BU_TARGETS := $(addprefix bu_, $(ALL_BOARDS_BU))
help:
$(V1) $(MAKE) -C $(ROOT_DIR) $@
# Clean and build uavobjects since all parts depend on them
uavobjects: all_clean
$(V1) $(MAKE) -C $(ROOT_DIR) $@
all_clean:
ifneq ($(CLEAN_GROUND), NO)
$(V1) $(MAKE) -C $(ROOT_DIR) $@
endif
# Install template:
# $1 = target
# $2 = dependencies
# $3 = install directory (must be defined)
# $4 = installed file name prefix (optional)
# $5 = installed file name suffix (optional)
# $6 = extra make options (for instance, USE_SPEKTRUM=YES)
# $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)
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)
endef
# Firmware
$(eval $(call INSTALL_TEMPLATE,all_fw,uavobjects,$(FW_DIR),,-$(PACKAGE_LBL),,,$(FW_TARGETS),install))
# Bootloaders (change 'install' to 'bin' if you don't want to install bootloaders)
$(eval $(call INSTALL_TEMPLATE,all_bl,uavobjects,$(BL_DIR),,-$(PACKAGE_LBL),,,$(BL_TARGETS),install))
# Bootloader updaters
$(eval $(call INSTALL_TEMPLATE,all_bu,all_bl,$(BU_DIR),,-$(PACKAGE_LBL),,,$(BU_TARGETS),install))
# Order-only dependencies
package_flight: | all_fw all_bu
package_ground: | ground_package
package: | package_flight package_ground
.PHONY: help uavobjects all_clean package_flight package_ground package
# opfw_resource must be generated before the ground package,
# and it depends on flight firmware images
ground_package: | opfw_resource
.PHONY: opfw_resource
opfw_resource: all_fw
$(V1) $(MAKE) -C $(ROOT_DIR) $@
# Decide on a verbosity level based on the V= parameter
export AT := @
ifndef V
export V0 :=
export V1 := $(AT)
else ifeq ($(V), 0)
export V0 := $(AT)
export V1 := $(AT)
else ifeq ($(V), 1)
endif
ifneq ($(V),1)
MAKEFLAGS += --no-print-directory
endif
# Platform-dependent stuff
PLATFORM := winx86
UNAME := $(shell uname)
ifeq ($(UNAME), Linux)
PLATFORM := linux
endif
ifeq ($(UNAME), Darwin)
PLATFORM := osx
endif
include $(WHEREAMI)/Makefile.$(PLATFORM)

View File

@ -1,7 +1,14 @@
#
# Windows-specific packaging
# Windows-specific packaging script
#
ifndef OPENPILOT_IS_COOL
$(error Top level Makefile must be used to build this target)
endif
VERSION_CMD := $(VERSION_INFO)
FW_DIR := $(PACKAGE_DIR)/firmware
NSIS_CMD := makensis.exe
NSIS_OPTS := /V3
NSIS_DIR := $(ROOT_DIR)/package/winx86
@ -9,7 +16,8 @@ NSIS_SCRIPT := $(NSIS_DIR)/openpilotgcs.nsi
NSIS_TEMPLATE := $(NSIS_DIR)/openpilotgcs.tpl
NSIS_HEADER := $(BUILD_DIR)/ground/openpilotgcs/openpilotgcs.nsh
win_package: gcs package_flight
.PHONY: package
package:
$(V1) mkdir -p "$(dir $(NSIS_HEADER))"
$(VERSION_CMD) \
--template="$(NSIS_TEMPLATE)" \
@ -21,10 +29,3 @@ win_package: gcs package_flight
$(V1) echo "If you have a script error in line 1 - use Unicode NSIS 2.46+"
$(V1) echo " http://www.scratchpaper.com"
$(NSIS_CMD) $(NSIS_OPTS) $(NSIS_SCRIPT)
gcs: uavobjects
$(V1) $(MAKE) -C $(ROOT_DIR) GCS_BUILD_CONF=release $@
ground_package: | win_package
.PHONY: gcs ground_package win_package

View File

@ -33,10 +33,10 @@ install:
dh_installdirs
dh_installudev --priority=45
# Add here commands to install the package into debian/<packagename>
cp -arp build/ground/openpilotgcs/bin debian/openpilot/usr/local/OpenPilot
cp -arp build/ground/openpilotgcs/lib debian/openpilot/usr/local/OpenPilot
cp -arp build/ground/openpilotgcs/share debian/openpilot/usr/local/OpenPilot
cp -arp build/ground/openpilotgcs/.obj debian/openpilot/usr/local/OpenPilot
cp -arp build/ground/openpilotgcs/release/bin debian/openpilot/usr/local/OpenPilot
cp -arp build/ground/openpilotgcs/release/lib debian/openpilot/usr/local/OpenPilot
cp -arp build/ground/openpilotgcs/release/share debian/openpilot/usr/local/OpenPilot
cp -arp build/ground/openpilotgcs/release/.obj debian/openpilot/usr/local/OpenPilot
cp -arp build/ground/openpilotgcs/gcsversioninfo.h debian/openpilot/usr/local/OpenPilot
cp -arp package/linux/openpilot.desktop debian/openpilot/usr/share/applications
cp -arp package/linux/openpilot.png debian/openpilot/usr/share/pixmaps

View File

@ -4,7 +4,7 @@
: ${ROOT_DIR?} ${BUILD_DIR?} ${PACKAGE_LBL?} ${PACKAGE_DIR?} ${FW_DIR?} ${PACKAGE_NAME?} ${PACKAGE_SEP?}
# more variables
APP_PATH="${BUILD_DIR}/ground/openpilotgcs/bin/OpenPilot GCS.app"
APP_PATH="${BUILD_DIR}/ground/openpilotgcs/release/bin/OpenPilot GCS.app"
TEMP_FILE="${PACKAGE_DIR}/OpenPilot-temp.dmg"
OUT_FILE="${PACKAGE_DIR}/../${PACKAGE_NAME}${PACKAGE_SEP}${PACKAGE_LBL}${PACKAGE_SEP}osx.dmg"
VOL_NAME="OpenPilot"

View File

@ -36,9 +36,9 @@
; Tree root locations (relative to this script location)
!define PROJECT_ROOT "..\.."
!define NSIS_DATA_TREE "."
!define GCS_BUILD_TREE "..\..\build\ground\openpilotgcs"
!define GCS_BUILD_TREE "..\..\build\ground\openpilotgcs\release"
!define UAVO_SYNTH_TREE "..\..\build\uavobject-synthetics"
!define AEROSIMRC_TREE "..\..\build\ground\AeroSIM-RC"
!define AEROSIMRC_TREE "${GCS_BUILD_TREE}\misc\AeroSIM-RC"
; Default installation folder
InstallDir "$PROGRAMFILES\OpenPilot"
@ -61,7 +61,7 @@
; !define PRODUCT_VERSION "0.0.0.0"
; !define FILE_VERSION "${TAG_OR_BRANCH}:${HASH8} ${DATETIME}"
; !define BUILD_DESCRIPTION "${TAG_OR_BRANCH}:${HASH8} built from ${ORIGIN}, committed ${DATETIME} as ${HASH}"
!include "${GCS_BUILD_TREE}\openpilotgcs.nsh"
!include "${GCS_BUILD_TREE}\..\openpilotgcs.nsh"
Name "${PRODUCT_NAME}"
OutFile "${PACKAGE_DIR}\..\${OUT_FILE}"
@ -203,12 +203,8 @@ SectionEnd
; Copy firmware files
Section "Firmware" InSecFirmware
; SetOutPath "$INSTDIR\firmware\${FIRMWARE_DIR}"
; File /r "${PACKAGE_DIR}\${FIRMWARE_DIR}\*"
SetOutPath "$INSTDIR\firmware"
File "${PACKAGE_DIR}\${FIRMWARE_DIR}\fw_coptercontrol-${PACKAGE_LBL}.opfw"
File "${PACKAGE_DIR}\${FIRMWARE_DIR}\fw_pipxtreme-${PACKAGE_LBL}.opfw"
File "${PACKAGE_DIR}\${FIRMWARE_DIR}\fw_revomini-${PACKAGE_LBL}.opfw"
File /r "${PACKAGE_DIR}\${FIRMWARE_DIR}\*"
SectionEnd
; Copy utility files

View File

@ -15,8 +15,8 @@
!define PACKAGE_LBL "${PACKAGE_LBL}"
!define PACKAGE_NAME "${PACKAGE_NAME}"
!define PACKAGE_SEP "${PACKAGE_SEP}"
!define PACKAGE_DIR "..\..\build\package-$${PACKAGE_LBL}"
!define FIRMWARE_DIR "firmware-$${PACKAGE_LBL}"
!define PACKAGE_DIR "..\..\build\package"
!define FIRMWARE_DIR "firmware"
!define OUT_FILE "$${PACKAGE_NAME}$${PACKAGE_SEP}$${PACKAGE_LBL}$${PACKAGE_SEP}win32.exe"
; Installer version info