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
This commit is contained in:
parent
f166caf9f0
commit
e0aa4f2977
16
Makefile
16
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
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
|
||||
|
168
tools/cfgparser.c
Normal file
168
tools/cfgparser.c
Normal file
@ -0,0 +1,168 @@
|
||||
/****************************************************************************
|
||||
* tools/cfgpaser.c
|
||||
*
|
||||
* Copyright (C) 2007-2011 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
*
|
||||
* 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 <string.h>
|
||||
#include <ctype.h>
|
||||
#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);
|
||||
}
|
64
tools/cfgparser.h
Normal file
64
tools/cfgparser.h
Normal file
@ -0,0 +1,64 @@
|
||||
/****************************************************************************
|
||||
* tools/cfgpaser.h
|
||||
*
|
||||
* Copyright (C) 2007-2011 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
*
|
||||
* 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 <stdio.h>
|
||||
#include <limits.h>
|
||||
|
||||
/****************************************************************************
|
||||
* 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 */
|
127
tools/mkconfig.c
127
tools/mkconfig.c
@ -37,136 +37,23 @@
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <limits.h>
|
||||
#include <ctype.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
|
||||
#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;
|
||||
}
|
||||
|
106
tools/mkversion.c
Normal file
106
tools/mkversion.c
Normal file
@ -0,0 +1,106 @@
|
||||
/****************************************************************************
|
||||
* tools/mkversion.c
|
||||
*
|
||||
* Copyright (C) 2011 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
*
|
||||
* 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 <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
|
||||
#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 <abs path to .version>\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;
|
||||
}
|
136
tools/version.sh
Executable file
136
tools/version.sh
Executable file
@ -0,0 +1,136 @@
|
||||
#!/bin/bash
|
||||
# version.sh
|
||||
#
|
||||
# Copyright (C) 2011 Gregory Nutt. All rights reserved.
|
||||
# Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
#
|
||||
# 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 <major.minor> <outfile-path>"
|
||||
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 <major.minor>"
|
||||
echo " The NuttX version number expressed a major and minor number separated"
|
||||
echo " by a period"
|
||||
echo " <outfile-path>"
|
||||
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}
|
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user