diff --git a/Makefile.ac b/Makefile.ac index 3ce3e3616c..1a8c58dea5 100644 --- a/Makefile.ac +++ b/Makefile.ac @@ -76,6 +76,27 @@ else # not auto, explicitly specified NPROCS := $J endif +# +# export paparazzi version +# +GIT_SHA1 := $(shell git log -1 --pretty=format:%H 2> /dev/null) +ifneq ($(words $(GIT_SHA1)),1) +GIT_SHA1 := "UNKNOWN" +endif +GIT_DESC := $(shell ./paparazzi_version) +PPRZ_VER := $(shell echo $(GIT_DESC) | sed 's/[^0-9.]*\([0-9.]*\).*/\1/') +PPRZ_VER_MAJOR := $(shell echo $(GIT_DESC) | sed 's/v\([0-9]*\).*/\1/') +PPRZ_VER_MINOR := $(shell echo $(GIT_DESC) | sed 's/v[0-9]*.\([0-9]*\).*/\1/') +PPRZ_VER_PATCH := $(shell echo $(GIT_DESC) | sed 's/v[0-9]*.[0-9]*.\([0-9]*\).*/\1/') +ifneq ($(words $(PPRZ_VER_PATCH)),1) +PPRZ_VER_PATCH := 0 +endif +export GIT_DESC +export GIT_SHA1 +export PPRZ_VER_MAJOR +export PPRZ_VER_MINOR +export PPRZ_VER_PATCH + # "make Q=''" to get full echo Q=@ @@ -105,7 +126,7 @@ init: print_version: @echo "-----------------------------------------------------------------------" - @echo "Paparazzi version" $(shell ./paparazzi_version) + @echo "Paparazzi version" $(GIT_DESC) @echo "-----------------------------------------------------------------------" diff --git a/conf/conf_example.xml b/conf/conf_example.xml index 5ce88059dd..ab36044051 100644 --- a/conf/conf_example.xml +++ b/conf/conf_example.xml @@ -84,7 +84,7 @@ telemetry="telemetry/default_fixedwing.xml" flight_plan="flight_plans/basic.xml" settings="settings/fixedwing_basic.xml settings/control/ctl_basic.xml" - settings_modules="modules/nav_smooth.xml modules/nav_survey_poly_osam.xml modules/infrared_adc.xml" + settings_modules="modules/nav_smooth.xml modules/nav_survey_poly_osam.xml modules/infrared_adc.xml modules/tune_airspeed.xml" gui_color="#6293ba" /> . + */ + +/** @file pprz_version.h + * + * Provides stringified paparazzi version numbers. + * + * Defined at build time: + * - GIT_SHA1: full git SHA1 hash + * - GIT_DESC: paparazzi version description (from paparazzi_version using git describe) + * - PPRZ_VER: paparazzi version in .. format + * - PPRZ_VER_MAJOR: major version number + * - PPRZ_VER_MINOR: minor version number + * - PPRZ_VER_PATCH: patch version number + * + * Stringified defines provided: + * - GIT_VERSION + * - PPRZ_VERSION_DESC + * - PPRZ_VERSION + * + * + */ + +#ifndef PPRZ_VERSION_H +#define PPRZ_VERSION_H + +#define _STRINGIFY(s) #s +#define STRINGIFY(s) _STRINGIFY(s) + +#define GIT_VERSION STRINGIFY(GIT_SHA1) +#define PPRZ_VERSION_DESC STRINGIFY(GIT_DESC) +#define PPRZ_VERSION STRINGIFY(PPRZ_VER) + +/** paparazzi version encoded as one integer */ +#define PPRZ_VERSION_INT (PPRZ_VER_MAJOR * 100 + PPRZ_VER_MINOR * 10 + PPRZ_VER_PATCH) + +#endif /* PPRZ_VERSION_H */