From 5707d01cc381b58fcfdac92dcfb02e7cf4e149f5 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Sat, 7 Sep 2019 09:14:21 -0600 Subject: [PATCH] tools/version.h and Makefile.unix: Minor improvement to previous commit: Permit custom version strings that do not derive from the major and minor version number --- tools/Makefile.unix | 4 ++-- tools/version.sh | 17 ++++++++++++++--- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/tools/Makefile.unix b/tools/Makefile.unix index a40c6521a29..351e7176d22 100644 --- a/tools/Makefile.unix +++ b/tools/Makefile.unix @@ -42,7 +42,7 @@ include $(TOPDIR)/tools/Config.mk # In case .version file does not exist -CONFIG_VERSION_STRING ?= "0.0" +CONFIG_VERSION_STRING ?= "Unversioned" CONFIG_VERSION_MAJOR ?= 0 CONFIG_VERSION_MINOR ?= 0 CONFIG_VERSION_BUILD ?= "0" @@ -288,7 +288,7 @@ tools/mkversion$(HOSTEXEEXT): $(TOPDIR)/.version: $(Q) echo "Create .version" - $(Q) tools/version.sh -v $(CONFIG_VERSION_MAJOR).$(CONFIG_VERSION_MINOR) -b $(CONFIG_VERSION_BUILD) .version + $(Q) tools/version.sh -s $(CONFIG_VERSION_STRING) -v $(CONFIG_VERSION_MAJOR).$(CONFIG_VERSION_MINOR) -b $(CONFIG_VERSION_BUILD) .version ifeq ($(GIT_DIR),y) $(Q) tools/gen_gitrev.sh -t $(TOPDIR) >> .version endif diff --git a/tools/version.sh b/tools/version.sh index 4c2ade1676b..0db17d389a3 100755 --- a/tools/version.sh +++ b/tools/version.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash # version.sh # -# Copyright (C) 2011 Gregory Nutt. All rights reserved. +# Copyright (C) 2011, 2019 Gregory Nutt. All rights reserved. # Author: Gregory Nutt # # Redistribution and use in source and binary forms, with or without @@ -36,12 +36,13 @@ WD=`pwd` # Get command line parameters -USAGE="USAGE: $0 [-d|-h] [-b ] -v " +USAGE="USAGE: $0 [-d|-h] [-b ] [-s ] -v " ADVICE="Try '$0 -h' for more information" unset VERSION unset BUILD unset OUTFILE +unset VERSION_STRING while [ ! -z "$1" ]; do case $1 in @@ -52,6 +53,10 @@ while [ ! -z "$1" ]; do -d ) set -x ;; + -s ) + shift + VERSION_STRING=$1 + ;; -v ) shift VERSION=$1 @@ -101,6 +106,12 @@ if [ -z ${OUTFILE} ] ; then exit 1 fi +# If the version string was not provided, then set it to the version + +if [ -z "${VERSION_STRING}" ]; then + VERSION_STRING=${VERSION} +fi + # Get the major and minor version numbers MAJOR=`echo ${VERSION} | cut -d'.' -f1` @@ -132,7 +143,7 @@ fi echo "#!/bin/bash" >${OUTFILE} echo "" >>${OUTFILE} -echo "CONFIG_VERSION_STRING=\"${VERSION}\"" >>${OUTFILE} +echo "CONFIG_VERSION_STRING=\"${VERSION_STRING}\"" >>${OUTFILE} echo "CONFIG_VERSION_MAJOR=${MAJOR}" >>${OUTFILE} echo "CONFIG_VERSION_MINOR=${MINOR}" >>${OUTFILE} echo "CONFIG_VERSION_BUILD=\"${BUILD}\"" >>${OUTFILE}