forked from Archive/PX4-Autopilot
Back Port of Git Versioning - without side effects Part 1
This commit is contained in:
parent
bcc49268ca
commit
17fddb1556
38
Makefile
38
Makefile
|
@ -58,12 +58,6 @@ endif
|
||||||
|
|
||||||
GIT_DESC_SHORT := $(shell echo $(GIT_DESC) | cut -c1-16)
|
GIT_DESC_SHORT := $(shell echo $(GIT_DESC) | cut -c1-16)
|
||||||
|
|
||||||
$(shell mkdir -p $(BUILD_DIR))
|
|
||||||
$(shell rm -f $(BUILD_DIR)git_version.*)
|
|
||||||
$(shell echo "#include <systemlib/git_version.h>" > $(BUILD_DIR)git_version.c)
|
|
||||||
$(shell echo "const char* px4_git_version = \"$(GIT_DESC)\";" >> $(BUILD_DIR)git_version.c)
|
|
||||||
$(shell echo "const uint64_t px4_git_version_binary = 0x$(GIT_DESC_SHORT);" >> $(BUILD_DIR)git_version.c)
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Canned firmware configurations that we (know how to) build.
|
# Canned firmware configurations that we (know how to) build.
|
||||||
#
|
#
|
||||||
|
@ -139,7 +133,7 @@ $(STAGED_FIRMWARES): $(IMAGE_DIR)%.px4: $(BUILD_DIR)%.build/firmware.px4
|
||||||
.PHONY: $(FIRMWARES)
|
.PHONY: $(FIRMWARES)
|
||||||
$(BUILD_DIR)%.build/firmware.px4: config = $(patsubst $(BUILD_DIR)%.build/firmware.px4,%,$@)
|
$(BUILD_DIR)%.build/firmware.px4: config = $(patsubst $(BUILD_DIR)%.build/firmware.px4,%,$@)
|
||||||
$(BUILD_DIR)%.build/firmware.px4: work_dir = $(BUILD_DIR)$(config).build/
|
$(BUILD_DIR)%.build/firmware.px4: work_dir = $(BUILD_DIR)$(config).build/
|
||||||
$(FIRMWARES): $(BUILD_DIR)%.build/firmware.px4: generateuorbtopicheaders checksubmodules
|
$(FIRMWARES): $(BUILD_DIR)%.build/firmware.px4: checkgitversion generateuorbtopicheaders checksubmodules
|
||||||
@$(ECHO) %%%%
|
@$(ECHO) %%%%
|
||||||
@$(ECHO) %%%% Building $(config) in $(work_dir)
|
@$(ECHO) %%%% Building $(config) in $(work_dir)
|
||||||
@$(ECHO) %%%%
|
@$(ECHO) %%%%
|
||||||
|
@ -227,7 +221,7 @@ menuconfig:
|
||||||
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
$(NUTTX_SRC): checksubmodules
|
$(NUTTX_SRC): checkgitversion checksubmodules
|
||||||
|
|
||||||
$(UAVCAN_DIR):
|
$(UAVCAN_DIR):
|
||||||
$(Q) (./Tools/check_submodules.sh)
|
$(Q) (./Tools/check_submodules.sh)
|
||||||
|
@ -248,6 +242,32 @@ ifeq ($(PX4_TARGET_OS),qurt)
|
||||||
include $(PX4_BASE)makefiles/firmware_qurt.mk
|
include $(PX4_BASE)makefiles/firmware_qurt.mk
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
#
|
||||||
|
# Versioning
|
||||||
|
#
|
||||||
|
|
||||||
|
GIT_VER_FILE = $(PX4_VERSIONING_DIR).build_git_ver
|
||||||
|
GIT_HEADER_FILE = $(PX4_VERSIONING_DIR)build_git_version.h
|
||||||
|
|
||||||
|
$(GIT_VER_FILE) :
|
||||||
|
$(Q) if [ ! -f $(GIT_VER_FILE) ]; then \
|
||||||
|
$(MKDIR) -p $(PX4_VERSIONING_DIR); \
|
||||||
|
$(ECHO) "" > $(GIT_VER_FILE); \
|
||||||
|
fi
|
||||||
|
|
||||||
|
.PHONY: checkgitversion
|
||||||
|
checkgitversion: $(GIT_VER_FILE)
|
||||||
|
$(Q) if [ "$(GIT_DESC)" != "$(shell cat $(GIT_VER_FILE))" ]; then \
|
||||||
|
$(ECHO) "/* Auto Magically Generated file */" > $(GIT_HEADER_FILE); \
|
||||||
|
$(ECHO) "/* Do not edit! */" >> $(GIT_HEADER_FILE); \
|
||||||
|
$(ECHO) "#define PX4_GIT_VERSION_STR \"$(GIT_DESC)\"" >> $(GIT_HEADER_FILE); \
|
||||||
|
$(ECHO) "#define PX4_GIT_VERSION_BINARY 0x$(GIT_DESC_SHORT)" >> $(GIT_HEADER_FILE); \
|
||||||
|
$(ECHO) $(GIT_DESC) > $(GIT_VER_FILE); \
|
||||||
|
fi
|
||||||
|
|
||||||
|
#
|
||||||
|
# Submodule Checks
|
||||||
|
#
|
||||||
|
|
||||||
.PHONY: checksubmodules
|
.PHONY: checksubmodules
|
||||||
checksubmodules:
|
checksubmodules:
|
||||||
|
@ -321,7 +341,7 @@ check_format:
|
||||||
clean:
|
clean:
|
||||||
@echo > /dev/null
|
@echo > /dev/null
|
||||||
$(Q) $(RMDIR) $(BUILD_DIR)*.build
|
$(Q) $(RMDIR) $(BUILD_DIR)*.build
|
||||||
$(Q) $(REMOVE) $(BUILD_DIR)git_version.*
|
$(Q) $(RMDIR) $(PX4_VERSIONING_DIR)
|
||||||
$(Q) $(REMOVE) $(IMAGE_DIR)*.px4
|
$(Q) $(REMOVE) $(IMAGE_DIR)*.px4
|
||||||
|
|
||||||
.PHONY: distclean
|
.PHONY: distclean
|
||||||
|
|
|
@ -62,6 +62,7 @@ export ROMFS_SRC = $(abspath $(PX4_BASE)/ROMFS)/
|
||||||
export IMAGE_DIR = $(abspath $(PX4_BASE)/Images)/
|
export IMAGE_DIR = $(abspath $(PX4_BASE)/Images)/
|
||||||
export BUILD_DIR = $(abspath $(PX4_BASE)/Build)/
|
export BUILD_DIR = $(abspath $(PX4_BASE)/Build)/
|
||||||
export ARCHIVE_DIR = $(abspath $(PX4_BASE)/Archives)/
|
export ARCHIVE_DIR = $(abspath $(PX4_BASE)/Archives)/
|
||||||
|
export PX4_VERSIONING_DIR = $(BUILD_DIR)versioning/
|
||||||
|
|
||||||
#
|
#
|
||||||
# Default include paths
|
# Default include paths
|
||||||
|
@ -70,7 +71,8 @@ export INCLUDE_DIRS := $(PX4_MODULE_SRC) \
|
||||||
$(PX4_MODULE_SRC)/modules/ \
|
$(PX4_MODULE_SRC)/modules/ \
|
||||||
$(PX4_INCLUDE_DIR) \
|
$(PX4_INCLUDE_DIR) \
|
||||||
$(PX4_LIB_DIR) \
|
$(PX4_LIB_DIR) \
|
||||||
$(PX4_PLATFORMS_DIR)
|
$(PX4_PLATFORMS_DIR) \
|
||||||
|
$(PX4_VERSIONING_DIR)
|
||||||
|
|
||||||
#
|
#
|
||||||
# Tools
|
# Tools
|
||||||
|
|
|
@ -41,6 +41,8 @@
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#include "build_git_version.h"
|
||||||
|
|
||||||
__BEGIN_DECLS
|
__BEGIN_DECLS
|
||||||
|
|
||||||
__EXPORT extern const char* px4_git_version;
|
__EXPORT extern const char* px4_git_version;
|
||||||
|
|
|
@ -52,8 +52,7 @@ SRCS = \
|
||||||
mcu_version.c \
|
mcu_version.c \
|
||||||
bson/tinybson.c \
|
bson/tinybson.c \
|
||||||
circuit_breaker.cpp \
|
circuit_breaker.cpp \
|
||||||
circuit_breaker_params.c \
|
circuit_breaker_params.c
|
||||||
$(BUILD_DIR)git_version.c
|
|
||||||
|
|
||||||
ifeq ($(PX4_TARGET_OS),nuttx)
|
ifeq ($(PX4_TARGET_OS),nuttx)
|
||||||
SRCS += err.c \
|
SRCS += err.c \
|
||||||
|
|
|
@ -57,6 +57,9 @@ static const char sz_ver_all_str[] = "all";
|
||||||
static const char mcu_ver_str[] = "mcu";
|
static const char mcu_ver_str[] = "mcu";
|
||||||
static const char mcu_uid_str[] = "uid";
|
static const char mcu_uid_str[] = "uid";
|
||||||
|
|
||||||
|
const char* px4_git_version = PX4_GIT_VERSION_STR;
|
||||||
|
const uint64_t px4_git_version_binary = PX4_GIT_VERSION_BINARY;
|
||||||
|
|
||||||
static void usage(const char *reason)
|
static void usage(const char *reason)
|
||||||
{
|
{
|
||||||
if (reason != NULL) {
|
if (reason != NULL) {
|
||||||
|
|
Loading…
Reference in New Issue