factor out config.sh script to update config files (VERSION, SYSCONFDIR)

- use generated/dub as string import path for copied/generated config files
This commit is contained in:
Martin Nowak 2017-07-26 19:58:14 +02:00
parent a7867ca72b
commit 09cc628724
3 changed files with 20 additions and 14 deletions

17
config.sh Executable file
View file

@ -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

View file

@ -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="*"
}

View file

@ -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