Skip to content

Commit d850352

Browse files
committed
Change how $deft-version is managed.
Use the git config filter mechanism instead of a Makefile hack. Each dev needs to run these two commands in the top-level repo directory once per clone: git config filter.version.smudge ./scripts/version-smudge.sh git config filter.version.clean ./scripts/version-clean.sh
1 parent 3b38911 commit d850352

File tree

5 files changed

+25
-24
lines changed

5 files changed

+25
-24
lines changed

.gitattributes

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# To actually use this filter you must run the following commands in the top-level Def directory.
2+
# git config filter.version.smudge ./scripts/version-smudge.sh
3+
# git config filter.version.clean ./scripts/version-clean.sh
4+
# There is no way to configure that for all users of the repo.
5+
sources/commands/utils.dylan filter=version

Makefile

+4-14
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,15 @@
1-
# Low-tech Makefile to build and install deft.
1+
# Low-tech Makefile to build and install deft. You will need a working "dylan" binary on
2+
# your PATH somewhere.
23

34
DYLAN ?= $${HOME}/dylan
45

56
.PHONY: build clean install remove-deft-artifacts test dist distclean
67

78
git_version := $(shell git describe --tags --always --match 'v*')
89

9-
# Hack to add the version to the binary with Git tag info. During development I (cgay)
10-
# just build with "deft build" so the unnecessary rebuilds that this would cause aren't
11-
# an issue.
1210
build:
1311
dylan update
14-
file="sources/commands/utils.dylan"; \
15-
orig=$$(mktemp); \
16-
temp=$$(mktemp); \
17-
cp -p $${file} $${orig}; \
18-
cat $${file} | sed "s,/.__./.*/.__./,/*__*/ \"${git_version}\ built on $$(date -Iseconds)\" /*__*/,g" > $${temp}; \
19-
mv $${temp} $${file}; \
20-
OPEN_DYLAN_USER_REGISTRIES=${PWD}/registry dylan-compiler -build deft-app; \
21-
cp -p $${orig} $${file}
12+
dylan build deft-app
2213

2314
install: build
2415
mkdir -p $(DYLAN)/bin
@@ -36,8 +27,7 @@ install: build
3627

3728
test:
3829
dylan update
39-
OPEN_DYLAN_USER_REGISTRIES=${PWD}/registry dylan-compiler -build deft-test-suite \
40-
&& _build/bin/deft-test-suite
30+
dylan build deft-test-suite && _build/bin/deft-test-suite
4131

4232
dist: distclean install
4333

scripts/version-clean.sh

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/bash
2+
3+
echo "$(date -Iseconds) clean $(pwd)" >> /tmp/version.log
4+
sed "s,\"v.*built on.*\",\"DEVELOPMENT_VERSION\",g"

scripts/version-smudge.sh

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/bash
2+
3+
git_version="$(git describe --tags --always --match 'v*')"
4+
date="$(date -Iseconds)"
5+
echo "$(date -Iseconds) smudge $(pwd)" >> /tmp/version.log
6+
sed "s,DEVELOPMENT_VERSION,${git_version} built on ${date},g"

sources/commands/utils.dylan

+6-10
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,14 @@ Module: deft
22
Synopsis: Utilities for use by deft commands
33

44

5-
// The Makefile replaces this string with the actual tagged version before
6-
// building. DON'T MOVE THE /*__*/ MARKERS since they're part of the regex.
7-
// Using the comment markers enables recovery if someone commits a string
8-
// other than "HEAD" by accident. git's `ident` attribute doesn't use tag
9-
// names and `filter` looks more complex than it's worth.
10-
define constant $deft-version :: <string> = /*__*/ "HEAD" /*__*/;
5+
// This string is replaced by Git filters on checkout. See the .gitattributes file.
6+
define constant $deft-version :: <string> = "DEVELOPMENT_VERSION";
117

128

13-
// Run an executable or shell command. `command` may be a string or a sequence
14-
// of strings. If a string it is run with `/bin/sh -c`. If a sequence of
15-
// strings the first element is the executable pathname. Returns the exit
16-
// status of the command and the combined output to stdout and stderr.
9+
// Run an executable or shell command. `command` may be a string or a sequence of
10+
// strings. If a string it is run with `/bin/sh -c`. If a sequence of strings the first
11+
// element is the executable pathname. Returns the exit status of the command and the
12+
// combined output to stdout and stderr.
1713
define function run
1814
(command :: <seq>, #key working-directory :: false-or(<directory-locator>))
1915
=> (status :: <int>, output :: <string>)

0 commit comments

Comments
 (0)