diff --git a/fs/procfs/fs_procfsversion.c b/fs/procfs/fs_procfsversion.c index 79cf51e39cb..01017a5c909 100644 --- a/fs/procfs/fs_procfsversion.c +++ b/fs/procfs/fs_procfsversion.c @@ -1,7 +1,7 @@ /**************************************************************************** * fs/procfs/fs_procfsversion.c * - * Copyright (C) 2018 Gregory Nutt. All rights reserved. + * Copyright (C) 2018-2019 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -226,17 +226,15 @@ static ssize_t version_read(FAR struct file *filep, FAR char *buffer, "%s\n", CONFIG_VERSION_STRING, CONFIG_VERSION_BUILD, CONFIG_GIT_REVISION_STR); -#else -# if defined(__DATE__) && defined(__TIME__) +#elif defined(__DATE__) && defined(__TIME__) linesize = snprintf(attr->line, VERSION_LINELEN, "NuttX version %s %s %s %s\n", CONFIG_VERSION_STRING, CONFIG_VERSION_BUILD, __DATE__, __TIME__); -# else +#else linesize = snprintf(attr->line, VERSION_LINELEN, "NuttX version %s %s\n", CONFIG_VERSION_STRING, CONFIG_VERSION_BUILD); -# endif #endif /* Save the linesize in case we are re-entered with f_pos > 0 */ diff --git a/tools/Makefile.unix b/tools/Makefile.unix index 7e3d7e1f366..b1f93a648b4 100644 --- a/tools/Makefile.unix +++ b/tools/Makefile.unix @@ -1,7 +1,8 @@ ############################################################################ # tools/Makefile.unix # -# Copyright (C) 2007-2012, 2014-2015, 2018 Gregory Nutt. All rights reserved. +# Copyright (C) 2007-2012, 2014-2015, 2018-2019 Gregory Nutt. All rights +# reserved. # Author: Gregory Nutt # # Redistribution and use in source and binary forms, with or without @@ -80,8 +81,13 @@ endif else BOARD_DIR = $(TOPDIR)$(DELIM)boards$(DELIM)$(CONFIG_ARCH)$(DELIM)$(CONFIG_ARCH_CHIP) endif + COMMON_DIR = $(if $(wildcard $(TOPDIR)$(DELIM)boards$(DELIM)$(CONFIG_ARCH)$(DELIM)$(CONFIG_ARCH_CHIP)/common/Makefile),y,) +# GIT directory present + +GIT_DIR = $(if $(wildcard $(TOPDIR)$(DELIM).git),y,) + # CONFIG_APPS_DIR can be over-ridden from the command line or in the .config file. # The default value of CONFIG_APPS_DIR is ../apps. Ultimately, the application # will be built if APPDIR is defined. APPDIR will be defined if a directory containing @@ -182,7 +188,7 @@ endif NUTTXNAME = nuttx BIN = $(NUTTXNAME)$(EXEEXT) -all: version_info $(BIN) +all: $(BIN) .PHONY: dirlinks context clean_context check_context config oldconfig menuconfig nconfig qconfig gconfig export subdir_clean clean subdir_distclean distclean apps_clean apps_distclean version_info # Target used to copy include/nuttx/lib/math.h. If CONFIG_ARCH_MATH_H is @@ -260,18 +266,24 @@ endif tools/mkversion$(HOSTEXEEXT): $(Q) $(MAKE) -C tools -f Makefile.host TOPDIR="$(TOPDIR)" mkversion$(HOSTEXEEXT) -# create .version iff it doesn't already exist. Note: it may have been +# create .version if it doesn't already exist. Note: it may have been # created manually and may contain other info + $(TOPDIR)/.version: - $(Q) echo "No .version file found, creating one" - $(Q) tools/version.sh -v 0.0 -b 0 .version - $(Q) chmod 755 .version + $(Q) if [ ! -f .version ]; then \ + $(Q) echo "No .version file found, creating one" + $(Q) tools/version.sh -v 0.0 -b 0 .version + $(Q) chmod 755 .version + fi # version_info will add git-specific info to the .version file # which must already exist. First strip out any existing CONFIG_GIT_ info + version_info: $(TOPDIR)/.version +ifeq ($(GIT_DIR),y) $(Q) sed -i '/CONFIG_GIT_/d' $< $(Q) tools/gen_gitrev.sh -t $(TOPDIR) >> $< +endif include/nuttx/version.h: $(TOPDIR)/.version tools/mkversion$(HOSTEXEEXT) version_info $(Q) tools/mkversion $(TOPDIR) > $@ diff --git a/tools/README.txt b/tools/README.txt index 9007e6db7b1..0565bf362a9 100644 --- a/tools/README.txt +++ b/tools/README.txt @@ -78,6 +78,13 @@ discover.py Example script for discovering devices in the local network. It is the counter part to apps/netutils/discover +gen_getrev.sh +------------- + + Creates a GIT revision string and echos the string to stdout. This is + used by the top-level Makefile to generate part of the information in + the .version file. + gencromfs.c ----------- diff --git a/tools/gen_gitrev.sh b/tools/gen_gitrev.sh index 39749dca9bb..ff70dd5911e 100755 --- a/tools/gen_gitrev.sh +++ b/tools/gen_gitrev.sh @@ -196,8 +196,5 @@ fi # # update .version file with the following: # -define git_info <