From 09cc628724be87a6e317223059202ea652630ef5 Mon Sep 17 00:00:00 2001 From: Martin Nowak Date: Wed, 26 Jul 2017 19:58:14 +0200 Subject: [PATCH] factor out config.sh script to update config files (VERSION, SYSCONFDIR) - use generated/dub as string import path for copied/generated config files --- config.sh | 17 +++++++++++++++++ dub.sdl | 5 ++--- src/posix.mak | 12 +----------- 3 files changed, 20 insertions(+), 14 deletions(-) create mode 100755 config.sh diff --git a/config.sh b/config.sh new file mode 100755 index 000000000000..82d64eb40394 --- /dev/null +++ b/config.sh @@ -0,0 +1,17 @@ +#!/bin/sh + +set -ue + +OUTDIR="$1" +VERSIONFILE="$2" +SYSCONFDIR="$3" +VERSION=$(git describe --dirty 2>/dev/null || cat "$VERSIONFILE") # prefer git describe + +mkdir -p "$OUTDIR" +# only update config files when they actually differ to avoid unnecessary rebuilds +if [ "$VERSION" != "$(cat "$OUTDIR/VERSION" 2>/dev/null)" ]; then + printf "$VERSION" > "$OUTDIR/VERSION" +fi +if [ "$SYSCONFDIR" != "$(cat "$OUTDIR/SYSCONFDIR.imp" 2>/dev/null)" ]; then + printf "$SYSCONFDIR" > "$OUTDIR/SYSCONFDIR.imp" +fi diff --git a/dub.sdl b/dub.sdl index 811cde6fb83e..74096ecfadf7 100644 --- a/dub.sdl +++ b/dub.sdl @@ -29,9 +29,8 @@ subPackage { "src/ddmd/tokens.d" \ "src/ddmd/utf.d" - // stringImportPaths cannot be used because it will make Dub extremely slow - // https://github.com/dlang/dub/issues/1199 - dflags "-J$PACKAGE_DIR" + preGenerateCommands `cd "$${DUB_PACKAGE_DIR}" && ./config.sh generated/dub VERSION /etc` + stringImportPaths "generated/dub" dependency "dmd:root" version="*" } diff --git a/src/posix.mak b/src/posix.mak index dd8948e14e61..0a5040e5fe38 100644 --- a/src/posix.mak +++ b/src/posix.mak @@ -459,17 +459,7 @@ optabgen.out : $G/optabgen ######## VERSION -VERSION := $(shell cat ../VERSION) # default to checked-in VERSION file -ifneq (1,$(RELEASE)) # unless building a release - VERSION := $(shell printf "`$(GIT) describe --dirty || cat ../VERSION`") # use git describe -endif - -# only update $G/VERSION when it differs to avoid unnecessary rebuilds -$(shell test $(VERSION) != "`cat $G/VERSION 2> /dev/null`" \ - && printf $(VERSION) > $G/VERSION ) - -$(shell test $(SYSCONFDIR) != "`cat $G/SYSCONFDIR.imp 2> /dev/null`" \ - && printf '$(SYSCONFDIR)' > $G/SYSCONFDIR.imp ) +$(shell ../config.sh "$G" ../VERSION $(SYSCONFDIR)) ######### # Specific dependencies other than the source file for all objects