Add support for auto-updated version information
The Makefile will now use a script (autoversion.sh) to update version.h, which in turn defines a VERSION string and gets included from common.h. The idea is that version.h normally receives a git-describe based identifier that represents the current checkout. In cases where git might not be available, e.g. for builds from a tarball, the script will instead fall back to a predefined version (that should reflect the most recent release tag). Signed-off-by: Bernhard Nortmann <bernhard.nortmann@web.de>
This commit is contained in:
parent
fc30490fd4
commit
5792814010
5
.gitignore
vendored
5
.gitignore
vendored
@ -1,9 +1,10 @@
|
|||||||
sunxi-fexc
|
|
||||||
bin2fex
|
bin2fex
|
||||||
fex2bin
|
fex2bin
|
||||||
sunxi-bootinfo
|
sunxi-bootinfo
|
||||||
sunxi-fel
|
sunxi-fel
|
||||||
sunxi-pio
|
sunxi-fexc
|
||||||
sunxi-nand-part
|
sunxi-nand-part
|
||||||
|
sunxi-pio
|
||||||
|
version.h
|
||||||
*.o
|
*.o
|
||||||
*.swp
|
*.swp
|
||||||
|
|||||||
13
Makefile
13
Makefile
@ -61,7 +61,7 @@ all: tools target-tools
|
|||||||
tools: $(TOOLS) $(FEXC_LINKS)
|
tools: $(TOOLS) $(FEXC_LINKS)
|
||||||
target-tools: $(TARGET_TOOLS)
|
target-tools: $(TARGET_TOOLS)
|
||||||
|
|
||||||
misc: $(MISC_TOOLS)
|
misc: version.h $(MISC_TOOLS)
|
||||||
|
|
||||||
binfiles: $(BINFILES)
|
binfiles: $(BINFILES)
|
||||||
|
|
||||||
@ -85,9 +85,9 @@ install-target-tools: $(TARGET_TOOLS)
|
|||||||
|
|
||||||
clean:
|
clean:
|
||||||
@rm -vf $(TOOLS) $(FEXC_LINKS) $(TARGET_TOOLS) $(MISC_TOOLS)
|
@rm -vf $(TOOLS) $(FEXC_LINKS) $(TARGET_TOOLS) $(MISC_TOOLS)
|
||||||
@rm -vf *.o *.elf *.sunxi *.bin *.nm *.orig
|
@rm -vf version.h *.o *.elf *.sunxi *.bin *.nm *.orig
|
||||||
|
|
||||||
$(TOOLS) $(TARGET_TOOLS): Makefile common.h
|
$(TOOLS) $(TARGET_TOOLS): Makefile common.h version.h
|
||||||
|
|
||||||
fex2bin bin2fex: sunxi-fexc
|
fex2bin bin2fex: sunxi-fexc
|
||||||
ln -nsf $< $@
|
ln -nsf $< $@
|
||||||
@ -158,7 +158,10 @@ sunxi-meminfo: meminfo.c
|
|||||||
sunxi-script_extractor: script_extractor.c
|
sunxi-script_extractor: script_extractor.c
|
||||||
$(CROSS_COMPILE)gcc -g -O0 -Wall -static -o $@ $^
|
$(CROSS_COMPILE)gcc -g -O0 -Wall -static -o $@ $^
|
||||||
|
|
||||||
|
version.h:
|
||||||
|
@./autoversion.sh > $@
|
||||||
|
|
||||||
.gitignore: Makefile
|
.gitignore: Makefile
|
||||||
@for x in $(TOOLS) $(FEXC_LINKS) $(TARGET_TOOLS) '*.o' '*.swp'; do \
|
@for x in $(TOOLS) $(FEXC_LINKS) $(TARGET_TOOLS) version.h '*.o' '*.swp'; do \
|
||||||
echo "$$x"; \
|
echo "$$x"; \
|
||||||
done > $@
|
done | sort -V > $@
|
||||||
|
|||||||
18
autoversion.sh
Executable file
18
autoversion.sh
Executable file
@ -0,0 +1,18 @@
|
|||||||
|
#
|
||||||
|
# This script auto-updates a VERSION string definition.
|
||||||
|
# It outputs informational messages to stderr, while the actual
|
||||||
|
# output (on stdout) can easily be redirected to a file.
|
||||||
|
#
|
||||||
|
|
||||||
|
LATEST_RELEASE="v1.3"
|
||||||
|
|
||||||
|
if VER=`git describe --tags --dirty --always`; then
|
||||||
|
echo "Setting version information: ${VER}" >&2
|
||||||
|
else
|
||||||
|
VER=${LATEST_RELEASE}
|
||||||
|
echo "Unable to determine current version (using \"${VER}\" as fallback)" >&2
|
||||||
|
fi
|
||||||
|
echo >&2
|
||||||
|
|
||||||
|
echo "/* Auto-generated information. DO NOT EDIT */"
|
||||||
|
echo "#define VERSION \"${VER}\""
|
||||||
2
common.h
2
common.h
@ -19,6 +19,8 @@
|
|||||||
|
|
||||||
#include <stddef.h> /* offsetof */
|
#include <stddef.h> /* offsetof */
|
||||||
|
|
||||||
|
#include "version.h" /* auto-generated VERSION string */
|
||||||
|
|
||||||
/** flag function argument as unused */
|
/** flag function argument as unused */
|
||||||
#ifdef UNUSED
|
#ifdef UNUSED
|
||||||
#elif defined(__GNUC__)
|
#elif defined(__GNUC__)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user