Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions config.sh
Original file line number Diff line number Diff line change
@@ -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
5 changes: 2 additions & 3 deletions dub.sdl
Original file line number Diff line number Diff line change
Expand Up @@ -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="*"
}
Expand Down
12 changes: 1 addition & 11 deletions src/posix.mak
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down