Skip to content

Commit 367c6c3

Browse files
Build: Derive build date from last commit
Rather than requiring bin/setdate to run to update timestamps, make the included date dynamic and based on the last commit. This should be equally stable builds, but also update more frequently. Requires some Makefile trickery, so fingers crossed.
1 parent 0a7b28b commit 367c6c3

File tree

13 files changed

+73
-50
lines changed

13 files changed

+73
-50
lines changed

bin/README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
* Generates a set of disk images for distribution.
1919
* [roll](roll)
2020
* Updates external dependencies.
21-
* [setdate](setdate)
22-
* Updates the config with the current date.
21+
* [make_builddate_inc](make_builddate_inc)
22+
* Generates include file containing the last commit date.
2323
* [setlang](setlang)
2424
* Updates the config to build the specified language.
2525
* [setopt](setopt)
@@ -59,6 +59,8 @@
5959
* Shows the size of the Main and Aux segments of all desk accessories.
6060
* [endproc.pl](endproc.pl)
6161
* Applies the coding style guidelines for `.endproc` comments.
62+
* [mametest](mametest)
63+
* Runs Lua test scripts from `tests/` in MAME.
6264
* [md5](md5)
6365
* Generates MD5 checksums for all built files. Useful for ensuring a change does not alter the binaries in any way.
6466
* [stats.pl](stats.pl)

bin/lkg

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ source "bin/util.sh"
88
# Tweak config
99

1010
git checkout src/config.inc
11-
bin/setdate en
1211
hash=$(git rev-parse --short HEAD)
1312
perl -pni -e "s/define kDeskTopVersionSuffix .*/define kDeskTopVersionSuffix \"-build-${hash}\"/" src/config.inc
1413

bin/make_builddate_inc

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/usr/bin/env bash
2+
3+
# Generate `out/date.inc` based off last commit
4+
5+
set -e
6+
cd "$(dirname "$0")/.."
7+
8+
lang="$(egrep 'define kBuildLang' src/config.inc | cut -d'"' -f2)"
9+
10+
yyyy="$(git log -1 --format="%ad" --date=format:%Y)"
11+
yy="$(git log -1 --format="%ad" --date=format:%y)"
12+
mm="$(git log -1 --format="%ad" --date=format:%m)"
13+
dd="$(git log -1 --format="%ad" --date=format:%d)"
14+
15+
month=$(egrep "\bres_string_month_name_${mm}\b" "src/common/res/common.res.${lang}" | cut -d'"' -f2)
16+
order=$(egrep "\bres_const_date_order\b" "src/common/res/common.res.${lang}" | cut -d' ' -f3)
17+
18+
if [ "$order" = "0" ]; then
19+
date="$month $dd, $yyyy"
20+
else
21+
date="$dd $month $yyyy"
22+
fi
23+
24+
OUTDIR="out"
25+
26+
# Generate tmp file
27+
cat > $OUTDIR/builddate.inc.tmp <<EOF
28+
.define kBuildDate "$date"
29+
kBuildYYYY = $yyyy
30+
kBuildYY = $yy
31+
kBuildMM = $mm
32+
kBuildDD = $dd
33+
EOF
34+
35+
# Only generate real file if it doesn't exist or changed
36+
if [ -r $OUTDIR/builddate.inc ]; then
37+
cmp --silent $OUTDIR/builddate.inc.tmp $OUTDIR/builddate.inc || \
38+
mv -f $OUTDIR/builddate.inc.tmp $OUTDIR/builddate.inc
39+
else
40+
mv -f $OUTDIR/builddate.inc.tmp $OUTDIR/builddate.inc
41+
fi

bin/setdate

Lines changed: 0 additions & 36 deletions
This file was deleted.

bin/setlang

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ test $# -eq 1 || (echo "Usage: $0 LANG"; exit 1)
77
lang=$1
88
decoded_a=$(echo 'a' | bin/transcode.pl decode $lang)
99
supports_lowercase=$(if [ "$decoded_a" == "a" ]; then echo 1; else echo 0; fi);
10-
date=$(bin/setdate $lang)
1110

1211
git checkout src/config.inc
1312
perl -pni \
@@ -23,4 +22,3 @@ if [ "$supports_lowercase" != "1" ]; then
2322
fi
2423

2524
echo Set lang to: $lang
26-
bin/setdate $lang

src/common/Makefile.common

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,13 @@ LDFLAGS = --config ../common/asm.cfg --warnings-as-errors
77
# Each directory builds into an 'out' sibling dir:
88
OUTDIR = ../../out
99

10+
BINDIR = ../../bin
11+
1012
# Evaluated relative to each Makefile - include, library, and resource files
11-
COMMON_HEADERS = $(wildcard ../*.inc ../inc/*.inc *.inc inc/*.inc) \
12-
$(wildcard ../lib/*.s) \
13+
COMMON_HEADERS = \
14+
../config.inc $(OUTDIR)/builddate.inc ../common.inc \
15+
$(wildcard ../inc/*.inc *.inc) \
16+
$(wildcard ../lib/*.s ../lib/*.inc) \
1317
$(wildcard res/*.res.?? ../common/res/*.res.??)
1418

1519
LANGS = da de en es fr it nl pt sv bg
@@ -18,6 +22,9 @@ MONO_FONTS = $(foreach LANG,$(LANGS),$(OUTDIR)/Monaco.$(LANG).font)
1822

1923
### Build Rules
2024

25+
# Nothing here should be default
26+
.DEFAULT_GOAL := all
27+
2128
# Object files
2229
$(OUTDIR)/%.o: %.s $(HEADERS)
2330
ca65 $(CAFLAGS) --listing $(basename $@).list -o $@ $<
@@ -33,5 +40,12 @@ $(OUTDIR)/%.SYS: $(OUTDIR)/%.o ../common/asm.cfg
3340
# Fonts
3441
.SECONDEXPANSION:
3542
$(OUTDIR)/%.font: ../../res/fonts/$$(basename $$*).unicode.txt
36-
../../bin/build_font_from_unicode_txt.pl $(subst .,,$(suffix $*)) < ../../res/fonts/$(basename $*).unicode.txt > $@
43+
$(BINDIR)/build_font_from_unicode_txt.pl $(subst .,,$(suffix $*)) < ../../res/fonts/$(basename $*).unicode.txt > $@
3744
.NOTINTERMEDIATE: $(SYS_FONTS) $(MONO_FONTS)
45+
46+
# Build Date
47+
$(OUTDIR)/builddate.inc: FORCE
48+
@$(BINDIR)/make_builddate_inc
49+
50+
FORCE:
51+

src/config.inc

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,8 @@
1616
kDeskTopVersionMajor = 1
1717
kDeskTopVersionMinor = 6
1818
.define kDeskTopVersionSuffix "-alpha0"
19-
.define kBuildDate "November 13, 2025"
20-
kBuildYYYY = 2025
21-
kBuildYY = 25
22-
kBuildMM = 11
23-
kBuildDD = 13
19+
20+
.include "../out/builddate.inc"
2421

2522
;;; Localization - applies language suffix to filename
2623

src/desk.acc/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,6 @@ clean:
2222
rm -f $(OUTDIR)/*.o
2323
rm -f $(OUTDIR)/*.list
2424
rm -f $(OUTDIR)/*.font
25+
rm -f $(OUTDIR)/*.inc
26+
rm -f $(OUTDIR)/*.tmp
2527
rm -f $(TARGETS)

src/desk.acc/show.image.file.s

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1722,7 +1722,7 @@ str_a2hr_suffix:
17221722

17231723
.include "../lib/uppercase.s"
17241724
.include "../inc/hires_table.inc"
1725-
.include "inc/hr_to_dhr.inc"
1725+
.include "hr_to_dhr.inc"
17261726

17271727
.proc LZ4FH
17281728
.include "../lib/lz4fh6502.s"

0 commit comments

Comments
 (0)