From 2c58b11e50ac6a33f0c3e3bc357ff3be484a0458 Mon Sep 17 00:00:00 2001 From: Ouss4 Date: Sat, 18 Apr 2020 19:47:04 +0100 Subject: [PATCH] tools/: Update version generation tools to account for the patch number. --- tools/Makefile.unix | 2 +- tools/Makefile.win | 4 +++- tools/README.txt | 18 +++++++++--------- tools/mkconfigvars.sh | 6 +++--- tools/mkversion.c | 6 ++++-- tools/version.sh | 31 +++++++++++++++++++++++-------- tools/zipme.sh | 6 +++--- 7 files changed, 46 insertions(+), 27 deletions(-) diff --git a/tools/Makefile.unix b/tools/Makefile.unix index 550493ac0f5..f71e91a248c 100644 --- a/tools/Makefile.unix +++ b/tools/Makefile.unix @@ -50,7 +50,7 @@ ifneq ($(GIT_DIR),y) # In case the version file does not exist -CONFIG_VERSION_STRING ?= "0.0" +CONFIG_VERSION_STRING ?= "0.0.0" CONFIG_VERSION_BUILD ?= "0" VERSION_ARG = -v $(CONFIG_VERSION_STRING) -b $(CONFIG_VERSION_BUILD) diff --git a/tools/Makefile.win b/tools/Makefile.win index a9eaee19a88..12f6d057045 100644 --- a/tools/Makefile.win +++ b/tools/Makefile.win @@ -44,9 +44,10 @@ include $(TOPDIR)\tools\Config.mk # In case .version file does not exist -CONFIG_VERSION_STRING ?= "0.0" +CONFIG_VERSION_STRING ?= "0.0.0" CONFIG_VERSION_MAJOR ?= 0 CONFIG_VERSION_MINOR ?= 0 +CONFIG_VERSION_PATCH ?= 0 CONFIG_VERSION_BUILD ?= "0" # Control build verbosity @@ -255,6 +256,7 @@ $(TOPDIR)\.version: $(Q) echo CONFIG_VERSION_STRING="0" > .version $(Q) echo CONFIG_VERSION_MAJOR=0 >> .version $(Q) echo CONFIG_VERSION_MINOR=0 >> .version + $(Q) echo CONFIG_VERSION_PATCH=0 >> .version $(Q) echo CONFIG_VERSION_BUILD="0" >> .version include\nuttx\version.h: $(TOPDIR)\.version tools\mkversion$(HOSTEXEEXT) diff --git a/tools/README.txt b/tools/README.txt index dc43240216e..42c71fd52d5 100644 --- a/tools/README.txt +++ b/tools/README.txt @@ -207,11 +207,11 @@ mkconfigvars.sh $ tools/mkconfigvars.sh -h tools/mkconfigvars.sh is a tool for generation of configuration variable documentation - USAGE: tools/mkconfigvars.sh [-d|h] [-v ] + USAGE: tools/mkconfigvars.sh [-d|h] [-v ] Where: - -v - The NuttX version number expressed as a major and minor number separated + -v + The NuttX version number expressed as a major, minor and patch number separated by a period -d Enable script debug @@ -1129,11 +1129,11 @@ zipme.sh Any VCS files or directories are excluded from the final tarballs. $ ./tools/zipme.sh -h - USAGE="USAGE: ./tools/zipme.sh [-d|h|v|s] [-b [-e ] [-k ] " + USAGE="USAGE: ./tools/zipme.sh [-d|h|v|s] [-b [-e ] [-k ] " Examples: - ./tools/zipme.sh -s 9.0 - Create version 9.0 tarballs and sign them. - ./tools/zipme.sh -s -k XXXXXX 9.0 + ./tools/zipme.sh -s 9.0.0 + Create version 9.0.0 tarballs and sign them. + ./tools/zipme.sh -s -k XXXXXX 9.0.0 Same as above but use the key-id XXXXXX to sign the tarballs - ./tools/zipme.sh -e "*.swp tmp" 9.0 - Create the tarballs but exclude any *.swp file and the "tmp" directory. + ./tools/zipme.sh -e "*.swp tmp" 9.0.0 + Create the tarballs but exclude any .swp file and the "tmp" directory. diff --git a/tools/mkconfigvars.sh b/tools/mkconfigvars.sh index c01a2e4f228..c22176a655e 100755 --- a/tools/mkconfigvars.sh +++ b/tools/mkconfigvars.sh @@ -32,7 +32,7 @@ # POSSIBILITY OF SUCH DAMAGE. # -USAGE="USAGE: $0 [-d|h] [-v ]" +USAGE="USAGE: $0 [-d|h] [-v ]" ADVICE="Try '$0 -h' for more information" unset VERSION @@ -52,8 +52,8 @@ while [ ! -z "$1" ]; do echo $USAGE echo "" echo "Where:" - echo " -v " - echo " The NuttX version number expressed as a major and minor number separated" + echo " -v " + echo " The NuttX version number expressed as a major, minor and patch number separated" echo " by a period" echo " -d" echo " Enable script debug" diff --git a/tools/mkversion.c b/tools/mkversion.c index 879545fafd3..34291e390e0 100644 --- a/tools/mkversion.c +++ b/tools/mkversion.c @@ -88,7 +88,7 @@ int main(int argc, char **argv, char **envp) exit(2); } - stream= fopen(filepath, "r"); + stream = fopen(filepath, "r"); if (!stream) { fprintf(stderr, "open %s failed: %s\n", filepath, strerror(errno)); @@ -99,7 +99,9 @@ int main(int argc, char **argv, char **envp) printf("#ifndef __INCLUDE_NUTTX_VERSION_H\n"); printf("#define __INCLUDE_NUTTX_VERSION_H\n\n"); generate_definitions(stream); - printf("\n#define CONFIG_VERSION ((CONFIG_VERSION_MAJOR << 8) | (CONFIG_VERSION_MINOR))\n\n"); + printf("\n#define CONFIG_VERSION ((CONFIG_VERSION_MAJOR << 16) |\\\n" + " (CONFIG_VERSION_MINOR << 8) |\\\n" + " (CONFIG_VERSION_PATCH))\n\n"); printf("#endif /* __INCLUDE_NUTTX_VERSION_H */\n"); fclose(stream); diff --git a/tools/version.sh b/tools/version.sh index 64b2b1aa9d7..d5574d318a0 100755 --- a/tools/version.sh +++ b/tools/version.sh @@ -36,7 +36,7 @@ WD=`pwd` # Get command line parameters -USAGE="USAGE: $0 [-d|-h] [-b ] [-v ] " +USAGE="USAGE: $0 [-d|-h] [-b ] [-v ] " ADVICE="Try '$0 -h' for more information" unset VERSION @@ -69,9 +69,9 @@ while [ ! -z "$1" ]; do echo " Enable script debug" echo " -h" echo " show this help message and exit" - echo " -v " - echo " The NuttX version number expressed as a major and minor number separated" - echo " by a period" + echo " -v " + echo " The NuttX version number expressed as a major, minor and patch" + echo " number seperated by a period" echo " " echo " The full path to the version file to be created" exit 0 @@ -87,6 +87,12 @@ OUTFILE=$1 if [ -z ${VERSION} ] ; then VERSION=`git tag --sort=taggerdate | tail -1 | cut -d'-' -f2` + + # Earlier tags used the format "major.minor", append a "0" for a patch. + + if [[ ${VERSION} =~ ^([0-9]+[\.][0-9]+)$ ]] ; then + VERSION=${VERSION}.0 + fi fi # Make sure we know what is going on @@ -102,19 +108,27 @@ if [ -z ${OUTFILE} ] ; then echo "Missing path to the output file" echo $USAGE echo $ADVICE - exit 1 + exit 2 fi -# Get the major and minor version numbers +# Get the major, minor and patch version numbers MAJOR=`echo ${VERSION} | cut -d'.' -f1` if [ "X${MAJOR}" = "X${VERSION}" ]; then echo "Missing minor version number" echo $USAGE echo $ADVICE - exit 2 + exit 3 fi + MINOR=`echo ${VERSION} | cut -d'.' -f2` +if [ "X${MAJOR}.${MINOR}" = "X${VERSION}" ]; then + echo "Missing patch version number" + echo $USAGE + echo $ADVICE + exit 4 +fi +PATCH=`echo ${VERSION} | cut -d'.' -f3` # Get GIT information (if not provided on the command line) @@ -122,7 +136,7 @@ if [ -z "${BUILD}" ]; then BUILD=`git log --oneline -1 | cut -d' ' -f1 2>/dev/null` if [ -z "${BUILD}" ]; then echo "GIT version information is not available" - exit 3 + exit 5 fi if [ -n "`git diff-index --name-only HEAD | head -1`" ]; then BUILD=${BUILD}-dirty @@ -137,4 +151,5 @@ echo "" >>${OUTFILE} echo "CONFIG_VERSION_STRING=\"${VERSION}\"" >>${OUTFILE} echo "CONFIG_VERSION_MAJOR=${MAJOR}" >>${OUTFILE} echo "CONFIG_VERSION_MINOR=${MINOR}" >>${OUTFILE} +echo "CONFIG_VERSION_PATCH=${PATCH}" >>${OUTFILE} echo "CONFIG_VERSION_BUILD=\"${BUILD}\"" >>${OUTFILE} diff --git a/tools/zipme.sh b/tools/zipme.sh index 0b8c05bf4b0..b46cacc4740 100755 --- a/tools/zipme.sh +++ b/tools/zipme.sh @@ -50,7 +50,7 @@ EXCLPAT=" " # Get command line parameters -USAGE="USAGE: $0 [-d|h|v|s] [-b [-e ] [-k ] " +USAGE="USAGE: $0 [-d|h|v|s] [-b [-e ] [-k ] " ADVICE="Try '$0 -h' for more information" unset VERSION @@ -104,8 +104,8 @@ while [ ! -z "$1" ]; do echo " PGP sign the final tarballs and create digests." echo " -k" echo " PGP key ID. If not provided the default ID will be used." - echo " " - echo " The NuttX version number expressed as a major and minor number separated" + echo " " + echo " The NuttX version number expressed as a major, minor and patch number separated" echo " by a period" exit 0 ;;