Allow out-of-vcs builds

This commit is contained in:
Ben Wiederhake 2016-03-03 17:18:27 +01:00
parent 70340d7b55
commit e828fc36ef
4 changed files with 27 additions and 4 deletions

View file

@ -11,6 +11,7 @@ This list was previously maintained as [issue #242](https://github.com/majn/tele
1. Any changes due to `make -C tgl` must cause all necessary rebuilds in telegram-purple during the same invocation of make. ("Too often" is acceptable as long as `make && make` isn't violated.)
1. If `tgl/Makefile.in` is missing, explain that we need submodules, and stop.
1. `make -j12` must work fine
1. Must support out-of-CVS builds.
## While ensuring that:
@ -20,12 +21,13 @@ This list was previously maintained as [issue #242](https://github.com/majn/tele
## Approach:
- `commit.h` is a regular file which depends on a .PHONY target `commit`. Building `commit.h` *only* touches `commit.h` if necessary. (=> 1 & 2)
- `commit.h` is a regular file which depends on a .PHONY target `commit`. Building `commit.h` *only* touches `commit.h` if necessary and possible. (=> 1, 2, half of 8)
- Have a target `tgl/Makefile` which depends on `Makefile`. (=> 3)
- The central target `${PRPL_LIBNAME}` shall depend on the .PHONY `submade`, which depends on `tgl/Makefile`, and essentially executes `make -C tgl`. (=> 4, time constraint of 5)
- All objects of telegram-purple depend on `tgl/libs/libtgl.a`. Rationale: if `tgl/libs/libtgl.a` stays the same, then nothing in tgl changed. If `tgl/libs/libtgl.a` changes, then due to lots of black preprocessor magic within tgl, it can't be safely determined which, if any, objects of telegram-purple can be re-used. Also, if tgl got recompiled (~ 1 minute), then tgp can be recompiled, too (~ 5 seconds). (=> dependency constraint of 5)
- Let `tgl/Makefile` depend on `tgl/Makefile.in`, and put the warning into the rule for the latter. (=> 6)
- The above already implies a dependency DAG that is completely known to make; except at one point: let `tgl/libs/libtgl.a` depend on `submade`, without any own code. Now make ensure thread-safety on it's own. (=> 7)
- Bundle commit.h into the origtar (=> other half of 8)
## Side effects:

View file

@ -215,7 +215,7 @@ check-clean: .git
# Feel free to remove the "check-clean" dependency if you know what you're doing.
.PHONY: dist
dist: check-clean .git create_dirs
dist: check-clean commit.h .git create_dirs
./gen-origtar

View file

@ -20,6 +20,18 @@
set -e
if ! (command -v git && git status) >/dev/null 2>&1
then
if test -r commit.h
then
echo "No git available. Assuming everything is up-to-date."
exit 0
else
echo >&2 "No git available. Can't reconstruct commit.h"
exit 1
fi
fi
GIT_COMMIT=`git rev-parse HEAD | cut -c1-10`
if grep -scq "${GIT_COMMIT}" commit.h

View file

@ -21,17 +21,26 @@
set -e
# -- Cleanup possibly left-over artifacts
rm -f bin/tgl_tl-parser.tar bin/tgl.tar bin/result.tar bin/result.tar.gz
rm -f bin/tgl_tl-parser.tar bin/tgl.tar bin/commit.h.tar bin/result.tar bin/result.tar.gz
# -- Create parts
# Abuse the "bin" dir for temporary files.
( cd tgl/tl-parser && git archive --prefix=telegram-purple/tgl/tl-parser/ --output=../../bin/tgl_tl-parser.tar HEAD )
( cd tgl && git archive --prefix=telegram-purple/tgl/ --output=../bin/tgl.tar HEAD )
git archive --prefix=telegram-purple/ --output=bin/result.tar HEAD
# This is a lot of options. Here's why.
# --sort --mtime --owner --group => be reproducible (same commit produces binarily identical files)
# --transform => be in the same "tar-folder" as the rest
# (absence of --numeric-ids) => have identical behavior as git-archive
# --mode=664 => have identical behavior as git-archive
# http://www.gelato.unsw.edu.au/archives/git/0701/36326.html
# This is hacky. TODO: Find a better way to unify permissions.
tar --sort=name --mtime="1970-01-01 00:00Z" --owner=root --group=root --transform s%^%telegram-purple/% --mode=664 -cf bin/commit.h.tar commit.h
# -- Concatenate it all
tar --concatenate -f bin/result.tar bin/tgl.tar
tar --concatenate -f bin/result.tar bin/tgl_tl-parser.tar
tar --concatenate -f bin/result.tar bin/commit.h.tar
gzip -n bin/result.tar
# -- Determine name and move
@ -41,4 +50,4 @@ echo mv -f bin/result.tar.gz $TARNAME
mv -f bin/result.tar.gz $TARNAME
# -- Cleanup (never fail)
rm -f bin/tgl_tl-parser.tar bin/tgl.tar bin/result.tar bin/result.tar.gz || true
rm -f bin/tgl_tl-parser.tar bin/tgl.tar bin/commit.h.tar bin/result.tar bin/result.tar.gz || true