Skip to content

Commit 362af3f

Browse files
author
Rob Walker
authored
version flap (project-chip#940)
1 parent f47b884 commit 362af3f

File tree

2 files changed

+20
-9
lines changed

2 files changed

+20
-9
lines changed

.default-version.min

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
CHIP_VERSION=0.1.0

Makefile.am

+19-9
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,10 @@ EXTRA_DIST = \
5454
bootstrap-configure \
5555
repos.conf \
5656
$(srcdir)/build/autoconf \
57-
$(srcdir)/config \
58-
$(srcdir)/config/efr32 \
59-
$(srcdir)/config/nrf5 \
60-
$(srcdir)/scripts \
57+
$(srcdir)/config \
58+
$(srcdir)/config/efr32 \
59+
$(srcdir)/config/nrf5 \
60+
$(srcdir)/scripts \
6161
$(NULL)
6262

6363
BUILT_SOURCES = \
@@ -70,6 +70,7 @@ dist_doc_DATA = \
7070

7171
DISTCLEANFILES = \
7272
.local-version \
73+
.local-version.min \
7374
$(NULL)
7475

7576
# There are no source files to lint or prettify in this subdirectory.
@@ -102,24 +103,28 @@ PRETTY_FILES := $(NULL)
102103
# during makefile execution.
103104

104105
VERSION_FILE := $(if $(wildcard $(builddir)/.local-version),$(builddir)/.local-version,$(if $(wildcard $(srcdir)/.dist-version),$(srcdir)/.dist-version,$(srcdir)/.default-version))
106+
105107
#
106108
# Override autotool's default notion of the package version variables.
107109
# This ensures that when we create a source distribution the
108110
# version is always the current version, not the package bootstrap
109111
# version.
110112
#
111-
# The two-level variables ensures that not only can the package version
112-
# be overridden from the command line but also when the version is NOT
113+
# The include ensures that we update CHIP_VERSION and VERSION once
114+
# we've built .local-version (the source of truth unless CHIP_VERSION
115+
# is specified on the make command line).
116+
#
117+
# CHIP_VERSION can be overridden from the command line, but when the version is NOT
113118
# overridden that we bind the version once and only once across potential
114119
# sub-makes to prevent the version from flapping as VERSION_FILE changes.
115120
#
116-
export MAYBE_CHIP_VERSION := $(shell cat $(VERSION_FILE) 2> /dev/null)
117-
118-
CHIP_VERSION ?= $(MAYBE_CHIP_VERSION)
121+
# .local-version.min sets CHIP_VERSION
122+
-include .local-version.min
119123

120124
PACKAGE_VERSION = $(CHIP_VERSION)
121125
VERSION = $(PACKAGE_VERSION)
122126

127+
123128
#
124129
# check-file-.local-version
125130
#
@@ -140,6 +145,7 @@ $(if $(filter-out file,$(origin CHIP_VERSION)),\
140145
> "$(2)")
141146
endef
142147

148+
143149
#
144150
# check-file-.dist-version
145151
#
@@ -172,6 +178,10 @@ $(distdir)/.dist-version: $(builddir)/.local-version force
172178
$(distdir)/.dist-version $(builddir)/.local-version:
173179
$(call check-file,$(@F))
174180

181+
$(builddir)/.local-version.min: $(builddir)/.local-version
182+
(printf "export CHIP_VERSION=" ; cat) < "$(VERSION_FILE)" > $@
183+
184+
175185
#
176186
# When we run 'distcheck' and --with-<any of the third-party packages
177187
# listed in repos.conf>, default to 'internal', the nlbuild-autotools

0 commit comments

Comments
 (0)