From 748943d47c6a11cd8d45f0469cac84d06134dec7 Mon Sep 17 00:00:00 2001 From: patacongo Date: Thu, 14 Apr 2011 16:46:17 +0000 Subject: Add tools to manage a version file git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3502 42af7a65-404d-4744-a932-0658087f49c3 --- misc/buildroot/toolchain/nxflat/Makefile | 2 +- nuttx/Makefile | 16 ++- nuttx/arch/arm/src/cortexm3/mpu.h | 2 +- nuttx/include/sys/syscall.h | 2 +- nuttx/tools/Makefile.host | 13 ++- nuttx/tools/cfgparser.c | 168 +++++++++++++++++++++++++++++++ nuttx/tools/cfgparser.h | 64 ++++++++++++ nuttx/tools/mkconfig.c | 127 ++--------------------- nuttx/tools/mkversion.c | 106 +++++++++++++++++++ nuttx/tools/version.sh | 136 +++++++++++++++++++++++++ nuttx/tools/zipme.sh | 11 +- 11 files changed, 515 insertions(+), 132 deletions(-) create mode 100644 nuttx/tools/cfgparser.c create mode 100644 nuttx/tools/cfgparser.h create mode 100644 nuttx/tools/mkversion.c create mode 100755 nuttx/tools/version.sh diff --git a/misc/buildroot/toolchain/nxflat/Makefile b/misc/buildroot/toolchain/nxflat/Makefile index 7b677c12c..b2a465827 100644 --- a/misc/buildroot/toolchain/nxflat/Makefile +++ b/misc/buildroot/toolchain/nxflat/Makefile @@ -35,7 +35,7 @@ CFLAGS += -Wall -I. -I$(BINUTILS_DIR1)/bfd -I$(BINUTILS_DIR)/include LDFLAGS += -L$(BINUTILS_DIR1)/bfd -L$(BINUTILS_DIR1)/libiberty -LIBS = -lbfd -lc -liberty -lz +LIBS = -lbfd -liberty -lz -lc LDNXFLAT_OBJS = ldnxflat.o MKNXFLAT_OBJS = mknxflat.o diff --git a/nuttx/Makefile b/nuttx/Makefile index af09e5eda..cb16bd597 100644 --- a/nuttx/Makefile +++ b/nuttx/Makefile @@ -250,6 +250,20 @@ BIN = nuttx$(EXEEXT) all: $(BIN) .PHONY: context clean_context check_context subdir_clean clean subdir_distclean distclean +# Build the mkconfig tool used to create include/nuttx/config.h +tools/mkversion: + @$(MAKE) -C tools -f Makefile.host TOPDIR="$(TOPDIR)" mkversion + +$(TOPDIR)/.version: + @if [ ! -f .version ]; then \ + echo "No .version file found, creating one"; \ + tools/version.sh -v 0.0 -b 0 .version; \ + fi + +# Create the include/nuttx/version.h file +include/nuttx/version.h: $(TOPDIR)/.version tools/mkversion + tools/mkversion $(TOPDIR) > include/nuttx/version.h + # Build the mkconfig tool used to create include/nuttx/config.h tools/mkconfig: @$(MAKE) -C tools -f Makefile.host TOPDIR="$(TOPDIR)" mkconfig @@ -290,7 +304,7 @@ endif dirlinks: include/arch include/arch/board include/arch/chip $(ARCH_SRC)/board $(ARCH_SRC)/chip -context: check_context include/nuttx/config.h dirlinks +context: check_context include/nuttx/config.h include/nuttx/version.h dirlinks @for dir in $(CONTEXTDIRS) ; do \ $(MAKE) -C $$dir TOPDIR="$(TOPDIR)" context; \ done diff --git a/nuttx/arch/arm/src/cortexm3/mpu.h b/nuttx/arch/arm/src/cortexm3/mpu.h index 1902a4ee3..30d1d4af9 100644 --- a/nuttx/arch/arm/src/cortexm3/mpu.h +++ b/nuttx/arch/arm/src/cortexm3/mpu.h @@ -190,7 +190,7 @@ static inline void mpu_showtype(void) dbg("%s MPU Regions: data=%d instr=%d\n", (regval & MPU_TYPE_SEPARATE) != 0 ? "Separate" : "Unified", (regval & MPU_TYPE_DREGION_MASK) >> MPU_TYPE_DREGION_SHIFT, - (regval & MPU_TYPE_IREGION_MASK) >> MPU_TYPE_IREGION_SHIFT, + (regval & MPU_TYPE_IREGION_MASK) >> MPU_TYPE_IREGION_SHIFT); #endif } diff --git a/nuttx/include/sys/syscall.h b/nuttx/include/sys/syscall.h index 1f1e37f36..616c39546 100644 --- a/nuttx/include/sys/syscall.h +++ b/nuttx/include/sys/syscall.h @@ -134,7 +134,7 @@ */ #ifndef CONFIG_DISABLE_CLOCK -# define SYS_os_systime32 (__SYS_clock+0) +# define SYS_clock_systimer (__SYS_clock+0) # define SYS_clock_getres (__SYS_clock+1) # define SYS_clock_gettime (__SYS_clock+2) # define SYS_clock_settime (__SYS_clock+3) diff --git a/nuttx/tools/Makefile.host b/nuttx/tools/Makefile.host index 95cf64c68..cf44f3e58 100644 --- a/nuttx/tools/Makefile.host +++ b/nuttx/tools/Makefile.host @@ -33,18 +33,23 @@ # ############################################################################ -all: mkconfig mksyscall +all: mkconfig mkversion mksyscall default: mkconfig mksyscall .PHONY: clean # Add CFLAGS=-g on the make command line build debug versions -CFLAGS = -O2 -Wall +CFLAGS = -O2 -Wall -I. # mkconfig - Convert a .config file into a C config.h file -mkconfig: mkconfig.c - @gcc $(CFLAGS) -o mkconfig mkconfig.c +mkconfig: mkconfig.c cfgparser.c + @gcc $(CFLAGS) -o mkconfig mkconfig.c cfgparser.c + +# mkversion - Convert a .version file into a C version.h file + +mkversion: mkconfig.c cfgparser.c + @gcc $(CFLAGS) -o mkversion mkversion.c cfgparser.c # mksyscall - Convert a CSV file into syscall stubs and proxies diff --git a/nuttx/tools/cfgparser.c b/nuttx/tools/cfgparser.c new file mode 100644 index 000000000..2917a2f60 --- /dev/null +++ b/nuttx/tools/cfgparser.c @@ -0,0 +1,168 @@ +/**************************************************************************** + * tools/cfgpaser.c + * + * Copyright (C) 2007-2011 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include +#include "cfgparser.h" + +/**************************************************************************** + * Definitions + ****************************************************************************/ + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +char line[LINESIZE+1]; + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +static char *skip_space(char *ptr) +{ + while (*ptr && isspace((int)*ptr)) ptr++; + return ptr; +} + +static char *find_name_end(char *ptr) +{ + while (*ptr && (isalnum((int)*ptr) || *ptr == '_')) ptr++; + return ptr; +} + +static char *find_value_end(char *ptr) +{ + while (*ptr && !isspace((int)*ptr)) + { + if (*ptr == '"') + { + do ptr++; while (*ptr && *ptr != '"'); + if (*ptr) ptr++; + } + else + { + do ptr++; while (*ptr && !isspace((int)*ptr) && *ptr != '"'); + } + } + return ptr; +} + +static char *read_line(FILE *stream) +{ + char *ptr; + + for (;;) + { + line[LINESIZE] = '\0'; + if (!fgets(line, LINESIZE, stream)) + { + return NULL; + } + else + { + ptr = skip_space(line); + if (*ptr && *ptr != '#' && *ptr != '\n') + { + return ptr; + } + } + } +} + +static void parse_line(char *ptr, char **varname, char **varval) +{ + *varname = ptr; + *varval = NULL; + + ptr = find_name_end(ptr); + if (*ptr && *ptr != '=') + { + *ptr = '\0'; + ptr = skip_space(ptr + 1); + } + + if (*ptr == '=') + { + *ptr = '\0'; + ptr = skip_space(ptr + 1); + if (*ptr) + { + *varval = ptr; + ptr = find_value_end(ptr); + *ptr = '\0'; + } + } +} + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +void parse_file(FILE *stream) +{ + char *varname; + char *varval; + char *ptr; + + do + { + ptr = read_line(stream); + if (ptr) + { + parse_line(ptr, &varname, &varval); + if (varname) + { + if (!varval || strcmp(varval, "n") == 0) + { + printf("#undef %s\n", varname); + } + else if (strcmp(varval, "y") == 0) + { + printf("#define %s 1\n", varname); + } + else + { + printf("#define %s %s\n", varname, varval); + } + } + } + } + while (ptr); +} diff --git a/nuttx/tools/cfgparser.h b/nuttx/tools/cfgparser.h new file mode 100644 index 000000000..02de42928 --- /dev/null +++ b/nuttx/tools/cfgparser.h @@ -0,0 +1,64 @@ +/**************************************************************************** + * tools/cfgpaser.h + * + * Copyright (C) 2007-2011 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +#ifndef __TOOLS_CFGPARSER_H +#define __TOOLS_CFGPARSER_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include + +/**************************************************************************** + * Definitions + ****************************************************************************/ + +#define LINESIZE ( PATH_MAX > 256 ? PATH_MAX : 256 ) + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +extern char line[LINESIZE+1]; + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +extern void parse_file(FILE *stream); + +#endif /* __TOOLS_CFGPARSER_H */ diff --git a/nuttx/tools/mkconfig.c b/nuttx/tools/mkconfig.c index cee430cd6..a10f359d3 100644 --- a/nuttx/tools/mkconfig.c +++ b/nuttx/tools/mkconfig.c @@ -37,136 +37,23 @@ * Included Files ****************************************************************************/ -#include -#include #include -#include -#include -#include +#include #include +#include "cfgparser.h" + /**************************************************************************** * Definitions ****************************************************************************/ #define DEFCONFIG ".config" -#define LINESIZE ( PATH_MAX > 256 ? PATH_MAX : 256 ) /**************************************************************************** * Private Functions ****************************************************************************/ -static char line[LINESIZE+1]; - -static char *skip_space(char *ptr) -{ - while (*ptr && isspace(*ptr)) ptr++; - return ptr; -} - -static char *find_name_end(char *ptr) -{ - while (*ptr && (isalnum(*ptr) || *ptr == '_')) ptr++; - return ptr; -} - -static char *find_value_end(char *ptr) -{ - while (*ptr && !isspace(*ptr)) - { - if (*ptr == '"') - { - do ptr++; while (*ptr && *ptr != '"'); - if (*ptr) ptr++; - } - else - { - do ptr++; while (*ptr && !isspace(*ptr) && *ptr != '"'); - } - } - return ptr; -} - -static char *read_line(FILE *stream) -{ - char *ptr; - - for (;;) - { - line[LINESIZE] = '\0'; - if (!fgets(line, LINESIZE, stream)) - { - return NULL; - } - else - { - ptr = skip_space(line); - if (*ptr && *ptr != '#' && *ptr != '\n') - { - return ptr; - } - } - } -} - -static void parse_line(char *ptr, char **varname, char **varval) -{ - *varname = ptr; - *varval = NULL; - - ptr = find_name_end(ptr); - if (*ptr && *ptr != '=') - { - *ptr = '\0'; - ptr = skip_space(ptr + 1); - } - - if (*ptr == '=') - { - *ptr = '\0'; - ptr = skip_space(ptr + 1); - if (*ptr) - { - *varval = ptr; - ptr = find_value_end(ptr); - *ptr = '\0'; - } - } -} - -static void parse_file(FILE *stream) -{ - char *varname; - char *varval; - char *ptr; - - do - { - ptr = read_line(stream); - if (ptr) - { - parse_line(ptr, &varname, &varval); - if (varname) - { - if (!varval || strcmp(varval, "n") == 0) - { - printf("#undef %s\n", varname); - } - else if (strcmp(varval, "y") == 0) - { - printf("#define %s 1\n", varname); - } - else - { - printf("#define %s %s\n", varname, varval); - } - } - } - } - while (ptr); -} - -static inline char *getfilepath(const char *name) + static inline char *getfilepath(const char *name) { snprintf(line, PATH_MAX, "%s/" DEFCONFIG, name); line[PATH_MAX] = '\0'; @@ -209,8 +96,8 @@ int main(int argc, char **argv, char **envp) } printf("/* config.h -- Autogenerated! Do not edit. */\n\n"); - printf("#ifndef __ARCH_CONFIG_H\n"); - printf("#define __ARCH_CONFIG_H\n\n"); + printf("#ifndef __INCLUDE_NUTTX_CONFIG_H\n"); + printf("#define __INCLUDE_NUTTX_CONFIG_H\n\n"); printf("/* Architecture-specific options *************************/\n\n"); parse_file(stream); printf("\n/* Sanity Checks *****************************************/\n\n"); @@ -349,7 +236,7 @@ int main(int argc, char **argv, char **envp) printf("# undef CONFIG_DEBUG_GRAPHICS\n"); printf("# undef CONFIG_DEBUG_GPIO\n"); printf("#endif\n\n"); - printf("#endif /* __ARCH_CONFIG_H */\n"); + printf("#endif /* __INCLUDE_NUTTX_CONFIG_H */\n"); fclose(stream); return 0; } diff --git a/nuttx/tools/mkversion.c b/nuttx/tools/mkversion.c new file mode 100644 index 000000000..f2086d13a --- /dev/null +++ b/nuttx/tools/mkversion.c @@ -0,0 +1,106 @@ +/**************************************************************************** + * tools/mkversion.c + * + * Copyright (C) 2011 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include +#include + +#include "cfgparser.h" + +/**************************************************************************** + * Definitions + ****************************************************************************/ + +#define DEFCONFIG ".version" + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + + static inline char *getfilepath(const char *name) +{ + snprintf(line, PATH_MAX, "%s/" DEFCONFIG, name); + line[PATH_MAX] = '\0'; + return strdup(line); +} + +static void show_usage(const char *progname) +{ + fprintf(stderr, "USAGE: %s \n", progname); + exit(1); +} + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +int main(int argc, char **argv, char **envp) +{ + char *filepath; + FILE *stream; + + if (argc != 2) + { + fprintf(stderr, "Unexpected number of arguments\n"); + show_usage(argv[0]); + } + + filepath = getfilepath(argv[1]); + if (!filepath) + { + fprintf(stderr, "getfilepath failed\n"); + exit(2); + } + + stream= fopen(filepath, "r"); + if (!stream) + { + fprintf(stderr, "open %s failed: %s\n", filepath, strerror(errno)); + exit(3); + } + + printf("/* version.h -- Autogenerated! Do not edit. */\n\n"); + printf("#ifndef __INCLUDE_NUTTX_VERSION_H\n"); + printf("#define __INCLUDE_NUTTX_VERSION_H\n\n"); + parse_file(stream); + printf("\n#define CONFIG_VERSION ((CONFIG_VERSION_MAJOR << 8) | (CONFIG_VERSION_MINOR))\n\n"); + printf("#endif /* __INCLUDE_NUTTX_VERSION_H */\n"); + fclose(stream); + return 0; +} diff --git a/nuttx/tools/version.sh b/nuttx/tools/version.sh new file mode 100755 index 000000000..e098695a7 --- /dev/null +++ b/nuttx/tools/version.sh @@ -0,0 +1,136 @@ +#!/bin/bash +# version.sh +# +# Copyright (C) 2011 Gregory Nutt. All rights reserved. +# Author: Gregory Nutt +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name NuttX nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# + +WD=`pwd` + +# Get command line parameters + +USAGE="USAGE: $0 [-d|-h] [-b build] -v " +ADVICE="Try '$0 -h' for more information" + +unset VERSION +unset BUILD +unset OUTFILE + +while [ ! -z "$1" ]; do + case $1 in + -b ) + shift + BUILD=$1 + ;; + -d ) + set -x + ;; + -v ) + shift + VERSION=$1 + ;; + -h ) + echo "$progname is a tool for flexible generation of include path arguments for a" + echo "variety of different compilers in a variety of compilation environments" + echo "" + echo $USAGE + echo "" + echo "Where:" + echo " -d" + echo " Enable script debug" + echo " -h" + echo " show this help message and exit" + echo " -v " + echo " The NuttX version number expressed a major and minor number separated" + echo " by a period" + echo " " + echo " The full path to the version file to be created" + exit 0 + ;; + * ) + break; + ;; + esac + shift +done + +OUTFILE=$1 + +# Make sure we know what is going on + +if [ -z ${VERSION} ] ; then + echo "Missing versioning information" + echo $USAGE + echo $ADVICE + exit 1 +fi + +if [ -z ${OUTFILE} ] ; then + echo "Missing path to the output file" + echo $USAGE + echo $ADVICE + exit 1 +fi + +# Get the major and minor 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 +fi +MINOR=`echo ${VERSION} | cut -d'.' -f2` + +# Get SVN information (if not provided on the command line) + +if [ -z "${BUILD}" ]; then + SVNINFO=`svn info 2>/dev/null | fgrep 'Revision:'` + if [ -z "${SVNINFO}" ]; then + echo "SVN version information is not available" + exit 3 + fi + BUILD=`echo ${SVNINFO} | cut -d' ' -f2` + if [ -z "${BUILD}" ]; then + echo "SVN build information not found" + exit 4 + fi +fi + +# Write a version file into the NuttX directoy. The syntax of file is such that it +# may be sourced by a bash script or included by a Makefile. + +echo "#!/bin/bash" >${OUTFILE} +echo "" >>${OUTFILE} +echo "CONFIG_VERSION_STRING=\"${VERSION}\"" >>${OUTFILE} +echo "CONFIG_VERSION_MAJOR=${MAJOR}" >>${OUTFILE} +echo "CONFIG_VERSION_MINOR=${MINOR}" >>${OUTFILE} +echo "CONFIG_VERSION_BUILD=${BUILD}" >>${OUTFILE} diff --git a/nuttx/tools/zipme.sh b/nuttx/tools/zipme.sh index a0410a87f..1bf09f198 100755 --- a/nuttx/tools/zipme.sh +++ b/nuttx/tools/zipme.sh @@ -117,10 +117,13 @@ ln -sf ../ChangeLog ChangeLog.txt # Write a version file into the NuttX directoy. The syntax of file is such that it # may be sourced by a bash script or included by a Makefile. -echo "#!/bin/bash" >${NUTTX}/.version -echo "" >>${NUTTX}/.version -echo "CONFIG_NUTTX_VERSION=\"${VERSION}\"" >>${NUTTX}/.version -chmod 755 ${NUTTX}/.version +VERSIONSH=${NUTTX}/tools/version.sh +if [ ! -x "${VERSIONSH}" ]; then + echo "No executable script was found at: ${VERSIONSH}" + exit 1 +fi +${VERSIONSH} -v ${VERSION} ${NUTTX}/.version || \ + { echo "${VERSIONSH} failed"; cat ${NUTTX}/.version; exit 1; } # Perform a full clean for the distribution -- cgit v1.2.3