From 362af3f10395ce4a3da1e661e94ecfce7297fcfc Mon Sep 17 00:00:00 2001 From: Rob Walker Date: Tue, 2 Jun 2020 07:03:34 -0700 Subject: [PATCH] version flap (#940) --- .default-version.min | 1 + Makefile.am | 28 +++++++++++++++++++--------- 2 files changed, 20 insertions(+), 9 deletions(-) create mode 100644 .default-version.min diff --git a/.default-version.min b/.default-version.min new file mode 100644 index 00000000000000..251d043e50d591 --- /dev/null +++ b/.default-version.min @@ -0,0 +1 @@ +CHIP_VERSION=0.1.0 diff --git a/Makefile.am b/Makefile.am index e57335ef9394a2..fcce0293287cdd 100644 --- a/Makefile.am +++ b/Makefile.am @@ -54,10 +54,10 @@ EXTRA_DIST = \ bootstrap-configure \ repos.conf \ $(srcdir)/build/autoconf \ - $(srcdir)/config \ - $(srcdir)/config/efr32 \ - $(srcdir)/config/nrf5 \ - $(srcdir)/scripts \ + $(srcdir)/config \ + $(srcdir)/config/efr32 \ + $(srcdir)/config/nrf5 \ + $(srcdir)/scripts \ $(NULL) BUILT_SOURCES = \ @@ -70,6 +70,7 @@ dist_doc_DATA = \ DISTCLEANFILES = \ .local-version \ + .local-version.min \ $(NULL) # There are no source files to lint or prettify in this subdirectory. @@ -102,24 +103,28 @@ PRETTY_FILES := $(NULL) # during makefile execution. VERSION_FILE := $(if $(wildcard $(builddir)/.local-version),$(builddir)/.local-version,$(if $(wildcard $(srcdir)/.dist-version),$(srcdir)/.dist-version,$(srcdir)/.default-version)) + # # Override autotool's default notion of the package version variables. # This ensures that when we create a source distribution the # version is always the current version, not the package bootstrap # version. # -# The two-level variables ensures that not only can the package version -# be overridden from the command line but also when the version is NOT +# The include ensures that we update CHIP_VERSION and VERSION once +# we've built .local-version (the source of truth unless CHIP_VERSION +# is specified on the make command line). +# +# CHIP_VERSION can be overridden from the command line, but when the version is NOT # overridden that we bind the version once and only once across potential # sub-makes to prevent the version from flapping as VERSION_FILE changes. # -export MAYBE_CHIP_VERSION := $(shell cat $(VERSION_FILE) 2> /dev/null) - -CHIP_VERSION ?= $(MAYBE_CHIP_VERSION) +# .local-version.min sets CHIP_VERSION +-include .local-version.min PACKAGE_VERSION = $(CHIP_VERSION) VERSION = $(PACKAGE_VERSION) + # # check-file-.local-version # @@ -140,6 +145,7 @@ $(if $(filter-out file,$(origin CHIP_VERSION)),\ > "$(2)") endef + # # check-file-.dist-version # @@ -172,6 +178,10 @@ $(distdir)/.dist-version: $(builddir)/.local-version force $(distdir)/.dist-version $(builddir)/.local-version: $(call check-file,$(@F)) +$(builddir)/.local-version.min: $(builddir)/.local-version + (printf "export CHIP_VERSION=" ; cat) < "$(VERSION_FILE)" > $@ + + # # When we run 'distcheck' and --with-, default to 'internal', the nlbuild-autotools