Skip to content

Commit ab4a410

Browse files
committed
factor out config.sh script to update config files (VERSION, SYSCONFDIR)
- use generated/dub as string import path for copied/generated config files
1 parent a7867ca commit ab4a410

3 files changed

Lines changed: 18 additions & 14 deletions

File tree

config.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#/bin/sh
2+
3+
OUTDIR="$1"
4+
VERSIONFILE="$2"
5+
SYSCONFDIR="$3"
6+
VERSION=$(git describe --dirty 2>/dev/null || cat "$VERSIONFILE") # prefer git describe
7+
8+
mkdir -p "$OUTDIR"
9+
# only update config files when they actually differ to avoid unnecessary rebuilds
10+
if [ "$VERSION" != "$(cat "$OUTDIR/VERSION" 2>/dev/null)" ]; then
11+
printf "$VERSION" > "$OUTDIR/VERSION"
12+
fi
13+
if [ "$SYSCONFDIR" != "$(cat "$OUTDIR/SYSCONFDIR.imp" 2>/dev/null)" ]; then
14+
printf "$SYSCONFDIR" > "$OUTDIR/SYSCONFDIR.imp"
15+
fi

dub.sdl

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,8 @@ subPackage {
2929
"src/ddmd/tokens.d" \
3030
"src/ddmd/utf.d"
3131

32-
// stringImportPaths cannot be used because it will make Dub extremely slow
33-
// https://github.com/dlang/dub/issues/1199
34-
dflags "-J$PACKAGE_DIR"
32+
preGenerateCommands `cd "$${DUB_PACKAGE_DIR}" && ./config.sh generated/dub VERSION /etc`
33+
stringImportPaths "generated/dub"
3534

3635
dependency "dmd:root" version="*"
3736
}

src/posix.mak

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -459,17 +459,7 @@ optabgen.out : $G/optabgen
459459

460460
######## VERSION
461461

462-
VERSION := $(shell cat ../VERSION) # default to checked-in VERSION file
463-
ifneq (1,$(RELEASE)) # unless building a release
464-
VERSION := $(shell printf "`$(GIT) describe --dirty || cat ../VERSION`") # use git describe
465-
endif
466-
467-
# only update $G/VERSION when it differs to avoid unnecessary rebuilds
468-
$(shell test $(VERSION) != "`cat $G/VERSION 2> /dev/null`" \
469-
&& printf $(VERSION) > $G/VERSION )
470-
471-
$(shell test $(SYSCONFDIR) != "`cat $G/SYSCONFDIR.imp 2> /dev/null`" \
472-
&& printf '$(SYSCONFDIR)' > $G/SYSCONFDIR.imp )
462+
$(shell ../config.sh "$G" ../VERSION $(SYSCONFDIR))
473463

474464
#########
475465
# Specific dependencies other than the source file for all objects

0 commit comments

Comments
 (0)