stephenjsweeney/tbftss

New REVISION macro is not packaging-friendly (static archives)

Closed this issue · 3 comments

When using a static archive (e.g. https://github.com/stephenjsweeney/tbftss/archive/v1.0.tar.gz) to build tbftss, the buildsystem will complain a lot about not being in a git repo, and eventually fail:

gcc -O2 -g -pipe -Wformat -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector --param=ssp-buffer-size=4 -Wno-error=unused-result `sdl2-config --cflags` -DVERSION=1.0 -DREVISION= -DDATA_DIR=\"/usr/share/games/tbftss\" -DLOCALE_DIR=\"/usr/share/locale\" -Wall -Wempty-body -ansi -pedantic -Werror -Wstrict-prototypes -Werror=maybe-uninitialized -Warray-bounds -g -lefence -c src/game/title.c
fatal: Not a git repository (or any parent up to mount point /home)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
gcc -O2 -g -pipe -Wformat -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector --param=ssp-buffer-size=4 -Wno-error=unused-result `sdl2-config --cflags` -DVERSION=1.0 -DREVISION= -DDATA_DIR=\"/usr/share/games/tbftss\" -DLOCALE_DIR=\"/usr/share/locale\" -Wall -Wempty-body -ansi -pedantic -Werror -Wstrict-prototypes -Werror=maybe-uninitialized -Warray-bounds -g -lefence -c src/system/transition.c
fatal: Not a git repository (or any parent up to mount point /home)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
gcc -O2 -g -pipe -Wformat -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector --param=ssp-buffer-size=4 -Wno-error=unused-result `sdl2-config --cflags` -DVERSION=1.0 -DREVISION= -DDATA_DIR=\"/usr/share/games/tbftss\" -DLOCALE_DIR=\"/usr/share/locale\" -Wall -Wempty-body -ansi -pedantic -Werror -Wstrict-prototypes -Werror=maybe-uninitialized -Warray-bounds -g -lefence -c src/game/trophies.c
fatal: Not a git repository (or any parent up to mount point /home)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
src/game/title.c: In function 'draw':
src/game/title.c:185:114: error: expected expression before ')' token
  drawText(SCREEN_WIDTH - 10, SCREEN_HEIGHT - 25, 14, TA_RIGHT, colors.white, "Version %.2f-%d", VERSION, REVISION);
                                                                                                                  ^
common.mk:37: recipe for target 'title.o' failed

I see that you have code to handle REVISION not being defined:

src/defs.h
21:#ifndef REVISION
22:#define REVISION 0

But actually it's still defined even if the archive is not a git repo:

common.mk
2:REVISION = $(shell git rev-list HEAD --count)
makefile
22:CXXFLAGS += `sdl2-config --cflags` -DVERSION=$(VERSION) -DREVISION=$(REVISION) -DDATA_DIR=\"$(DATA_DIR)\" -DLOCALE_DIR=\"$(LOCALE_DIR)\"

For the reference, I can easily work it around in my package with sed -i -e 's/^REVISION = .*/REVISION = 0/' common.mk. But it would be better if it worked out of the box (especially for curious users who would download the zip archive of the master branch instead of clone the repo).

That's a fair point. I could always go back to using:

$(shell date +"%y%m%d")

or:

REVISION = $(shell git rev-list HEAD | wc -l)

which would compile okay, too. Thoughts?

This should now be fixed in the develop branch.