Browse Source

Add robustness to the version calculations

pull/889/head
Hamish Coleman 3 years ago
parent
commit
108c9436d5
  1. 12
      CMakeLists.txt
  2. 9
      Makefile.in

12
CMakeLists.txt

@ -11,7 +11,19 @@ execute_process(
COMMAND scripts/version.sh COMMAND scripts/version.sh
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
OUTPUT_VARIABLE PACKAGE_VERSION OUTPUT_VARIABLE PACKAGE_VERSION
RESULT_VARIABLE GIT_ERROR_CODE
) )
if (NOT GIT_ERROR_CODE EQUAL 0)
# - if we can run version.sh and it exits with an error that is signaling
# a build failure.
# - if we are on windows with no MSYS or Cygwin, we cannot run version.sh
# which is the fallback case handled below
# TODO: Distinguish between these two cases
# Fallback to just using the non dynamic short version string
file(STRINGS VERSION PACKAGE_VERSION)
endif (NOT GIT_ERROR_CODE EQUAL 0)
string(STRIP "${PACKAGE_VERSION}" PACKAGE_VERSION) string(STRIP "${PACKAGE_VERSION}" PACKAGE_VERSION)
MESSAGE(STATUS "Build for version: ${PACKAGE_VERSION}") MESSAGE(STATUS "Build for version: ${PACKAGE_VERSION}")

9
Makefile.in

@ -148,7 +148,14 @@ COVERAGEDIR?=coverage
.PHONY: steps build push all clean distclean install test cover gcov build-dep .PHONY: steps build push all clean distclean install test cover gcov build-dep
.PHONY: lint lint.python lint.ccode lint.shell lint.yaml .PHONY: lint lint.python lint.ccode lint.shell lint.yaml
all: $(APPS) $(DOCS) $(SUBDIRS) all: version $(APPS) $(DOCS) $(SUBDIRS)
# This allows breaking the build if the version.sh script discovers
# any inconsistancies
.PHONY: version
version:
@echo -n "Build for version: "
@scripts/version.sh
tools: $(N2N_LIB) tools: $(N2N_LIB)
$(MAKE) -C $@ $(MAKE) -C $@

Loading…
Cancel
Save