1
0
mirror of https://github.com/spaam/svtplay-dl.git synced 2024-11-24 12:15:40 +01:00
svtplay-dl/lib/Makefile
Olof Johansson 1a7a9f5662 Add git version info to version string
When building from git, it can be useful to know which version
a user has at commit level resolution. When building in a git
repository, use git describe to generate a version string. If
HEAD matches a tag, use that. Examples:

    $ ./svtplay-dl --version
    0.20.2015.10.08-3-gbd75a67

    $ git tag -a 0.20.2015.10.18
    $ make
    ...
    $ ./svtplay-dl --version
    0.20.2015.10.18

make release is also adjusted, so that it overrides the version
value when building, so that official releases still only has the
tag.
2015-10-18 19:50:53 +02:00

51 lines
1.4 KiB
Makefile

PYLINT_OPTS = --report=no -d I -d C -d R -d W0511
all: svtplay-dl
clean:
find . -name '*.pyc' -exec rm {} \;
rm -f svtplay-dl
pylint:
pylint $(PYLINT_OPTS) svtplay_dl
export PACKAGES = svtplay_dl \
svtplay_dl.fetcher \
svtplay_dl.utils \
svtplay_dl.service \
svtplay_dl.subtitle
export PYFILES = $(sort $(addsuffix /*.py,$(subst .,/,$(PACKAGES))))
PYTHON ?= /usr/bin/env python
VERSION = $(shell git describe 2>/dev/null || $(LATEST_RELEASE)-unknown)
svtplay-dl: $(PYFILES)
@# Verify that there's no .build already \
! [ -d .build ] || { \
echo "ERROR: build already in progress? (or remove $(PWD)/.build/)"; \
exit 1; \
}; \
mkdir -p .build
@# Stage the files in .build for postprocessing
for py in $(PYFILES); do \
install -d ".build/$${py%/*}"; \
install $$py .build/$$py; \
done
# Add git version info to __version__, seen in --version
sed -i -e 's/^__version__ = "\([^"]\+\)"$$/__version__ = "$(VERSION)"/' \
.build/svtplay_dl/__init__.py
@# reset timestamps, to avoid non-determinism in zip file
find .build/ -exec touch -m -t 198001010000 {} \;
(cd .build && zip -X --quiet svtplay-dl $(PYFILES))
(cd .build && zip -X --quiet --junk-paths svtplay-dl svtplay_dl/__main__.py)
echo '#!$(PYTHON)' > svtplay-dl
cat .build/svtplay-dl.zip >> svtplay-dl
rm -rf .build
chmod a+x svtplay-dl