Generate version header for zip exports as well
This commit is contained in:
3
.VERSION
Normal file
3
.VERSION
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
COMMIT: $Format:%H$
|
||||||
|
REFS: $Format:%D$
|
||||||
|
DATE: $Format:%ci$
|
2
.gitattributes
vendored
Normal file
2
.gitattributes
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
GNUmakefile export-ignore
|
||||||
|
.VERSION export-subst
|
14
GNUmakefile
14
GNUmakefile
@ -26,16 +26,14 @@ HEADERS += src/StreamBuffer.h
|
|||||||
HEADERS += src/StreamError.h
|
HEADERS += src/StreamError.h
|
||||||
HEADERS += src/StreamVersion.h
|
HEADERS += src/StreamVersion.h
|
||||||
|
|
||||||
CPPFLAGS += -DSTREAM_INTERNAL
|
CPPFLAGS += -DSTREAM_INTERNAL -I$(COMMON_DIR)
|
||||||
|
|
||||||
# Update version string (contains __DATE__ and __TIME__)
|
# Update version string each time anything changes
|
||||||
# each time anything changed.
|
StreamVersion$(OBJ) StreamVersion$(DEP): $(COMMON_DIR)/StreamVersion.h $(filter-out StreamVersion$(OBJ) stream_exportAddress$(OBJ),$(LIBOBJS) $(LIBRARY_OBJS))
|
||||||
StreamVersion$(OBJ): StreamVersion.h $(filter-out StreamVersion$(OBJ) stream_exportAddress$(OBJ),$(LIBOBJS) $(LIBRARY_OBJS))
|
|
||||||
|
|
||||||
MAKE_FIRST=src/StreamVersion.h
|
$(COMMON_DIR)/StreamVersion.h: $(filter-out StreamVersion.h,$(notdir $(SOURCES) $(HEADERS)))
|
||||||
src/StreamVersion.h: $(SOURCES) $(filter-out %StreamVersion.h, $(HEADERS))
|
@echo Creating $@
|
||||||
@echo Creating $@ from git tag
|
$(PERL) ../src/makeStreamVersion.pl $@
|
||||||
$(PERL) src/makeStreamVersion.pl > $@
|
|
||||||
|
|
||||||
StreamCore$(OBJ) StreamCore$(DEP): streamReferences
|
StreamCore$(OBJ) StreamCore$(DEP): streamReferences
|
||||||
streamReferences:
|
streamReferences:
|
||||||
|
@ -90,8 +90,8 @@ CPPFLAGS += -DSTREAM_INTERNAL
|
|||||||
# Update version string whenever something changed.
|
# Update version string whenever something changed.
|
||||||
StreamVersion$(OBJ): $(COMMON_DIR)/StreamVersion.h $(filter-out StreamVersion$(OBJ),$(LIBOBJS) $(LIBRARY_OBJS)) ../CONFIG_STREAM
|
StreamVersion$(OBJ): $(COMMON_DIR)/StreamVersion.h $(filter-out StreamVersion$(OBJ),$(LIBOBJS) $(LIBRARY_OBJS)) ../CONFIG_STREAM
|
||||||
$(COMMON_DIR)/StreamVersion.h: $(SRCS) $(filter-out StreamVersion.h, $(INC))
|
$(COMMON_DIR)/StreamVersion.h: $(SRCS) $(filter-out StreamVersion.h, $(INC))
|
||||||
@echo Creating $@ from git tag
|
@echo Creating $@
|
||||||
$(PERL) ../makeStreamVersion.pl > $@
|
$(PERL) ../makeStreamVersion.pl $@
|
||||||
|
|
||||||
# Add references to all registrars to main file to avoid
|
# Add references to all registrars to main file to avoid
|
||||||
# missing initialization.
|
# missing initialization.
|
||||||
|
@ -29,4 +29,4 @@ const char StreamVersion [] =
|
|||||||
"." STR(STREAM_MINOR)
|
"." STR(STREAM_MINOR)
|
||||||
"." STR(STREAM_PATCHLEVEL)
|
"." STR(STREAM_PATCHLEVEL)
|
||||||
STREAM_DEV
|
STREAM_DEV
|
||||||
" built " __DATE__ " " __TIME__;
|
" commit:" STREAM_COMMIT_HASH;
|
||||||
|
@ -22,21 +22,38 @@
|
|||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
|
|
||||||
my $dir = "O.Common";
|
|
||||||
my $versionfile = "StreamVersion.h";
|
|
||||||
|
|
||||||
my $version = `git describe --tags --dirty --match "[0-9]*"`
|
my ( $major, $minor, $patch, $dev, $branch, $date, $hash );
|
||||||
or die "Cannot run git.\n";
|
|
||||||
|
|
||||||
my ( $major, $minor, $patch, $dev );
|
if (my $version = `git describe --tags --dirty --match "[0-9]*" 2>/dev/null`) {
|
||||||
|
if ($version =~ m/(\d+)\.(\d+)\.(\d+)?(.*)?/) {
|
||||||
|
$major = $1; $minor = $2; $patch = $3; $dev = $4;
|
||||||
|
}
|
||||||
|
if (`git log -1 --format="%H %ci"`=~ m/([[:xdigit:]]+) (.+)/) {
|
||||||
|
$hash = $1; $date = $2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!$major) {
|
||||||
|
if (open(my $fh, '<', '../../.VERSION')) {
|
||||||
|
while (my $line = <$fh>) {
|
||||||
|
if ($line =~ m/COMMIT: *([[:xdigit:]]+)/) {
|
||||||
|
$hash = $1;
|
||||||
|
}
|
||||||
|
if ($line =~ m/REFS: *tag: *((\d+)\.(\d+)\.(\d+)?,)? *(.*)/) {
|
||||||
|
$major = $2; $minor = $3; $patch = $4; $branch = $5;
|
||||||
|
}
|
||||||
|
if ($line =~ m/DATE: *(.+)/) {
|
||||||
|
$date = $1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
print "neither git repo nor .VERSION file found\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$version =~ m/(\d+)\.(\d+)\.(\d+)?(.*)?/
|
open my $out, '>', @ARGV or die $!;
|
||||||
or die "Unexpected git tag format $version\n";
|
print $out <<EOF;
|
||||||
|
/* Generated file */
|
||||||
$major = $1; $minor=$2; $patch=$3; $dev=$4;
|
|
||||||
|
|
||||||
print << "EOF";
|
|
||||||
/* Generated file $versionfile */
|
|
||||||
|
|
||||||
#ifndef StreamVersion_h
|
#ifndef StreamVersion_h
|
||||||
#define StreamVersion_h
|
#define StreamVersion_h
|
||||||
@ -45,6 +62,10 @@ print << "EOF";
|
|||||||
#define STREAM_MINOR $minor
|
#define STREAM_MINOR $minor
|
||||||
#define STREAM_PATCHLEVEL $patch
|
#define STREAM_PATCHLEVEL $patch
|
||||||
#define STREAM_DEV "$dev"
|
#define STREAM_DEV "$dev"
|
||||||
|
#define STREAM_COMMIT_HASH "$hash"
|
||||||
|
#define STREAM_COMMIT_DATE "$date"
|
||||||
|
|
||||||
#endif /* StreamVersion_h */
|
#endif /* StreamVersion_h */
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
|
close $out
|
||||||
|
Reference in New Issue
Block a user