Allow out-of-vcs builds
This commit is contained in:
parent
70340d7b55
commit
e828fc36ef
4 changed files with 27 additions and 4 deletions
|
@ -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. 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. If `tgl/Makefile.in` is missing, explain that we need submodules, and stop.
|
||||||
1. `make -j12` must work fine
|
1. `make -j12` must work fine
|
||||||
|
1. Must support out-of-CVS builds.
|
||||||
|
|
||||||
## While ensuring that:
|
## While ensuring that:
|
||||||
|
|
||||||
|
@ -20,12 +21,13 @@ This list was previously maintained as [issue #242](https://github.com/majn/tele
|
||||||
|
|
||||||
## Approach:
|
## 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)
|
- 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)
|
- 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)
|
- 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)
|
- 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)
|
- 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:
|
## Side effects:
|
||||||
|
|
||||||
|
|
|
@ -215,7 +215,7 @@ check-clean: .git
|
||||||
|
|
||||||
# Feel free to remove the "check-clean" dependency if you know what you're doing.
|
# Feel free to remove the "check-clean" dependency if you know what you're doing.
|
||||||
.PHONY: dist
|
.PHONY: dist
|
||||||
dist: check-clean .git create_dirs
|
dist: check-clean commit.h .git create_dirs
|
||||||
./gen-origtar
|
./gen-origtar
|
||||||
|
|
||||||
|
|
||||||
|
|
12
commit.h.gen
12
commit.h.gen
|
@ -20,6 +20,18 @@
|
||||||
|
|
||||||
set -e
|
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`
|
GIT_COMMIT=`git rev-parse HEAD | cut -c1-10`
|
||||||
|
|
||||||
if grep -scq "${GIT_COMMIT}" commit.h
|
if grep -scq "${GIT_COMMIT}" commit.h
|
||||||
|
|
13
gen-origtar
13
gen-origtar
|
@ -21,17 +21,26 @@
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
# -- Cleanup possibly left-over artifacts
|
# -- 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
|
# -- Create parts
|
||||||
# Abuse the "bin" dir for temporary files.
|
# 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/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 )
|
( cd tgl && git archive --prefix=telegram-purple/tgl/ --output=../bin/tgl.tar HEAD )
|
||||||
git archive --prefix=telegram-purple/ --output=bin/result.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
|
# -- Concatenate it all
|
||||||
tar --concatenate -f bin/result.tar bin/tgl.tar
|
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/tgl_tl-parser.tar
|
||||||
|
tar --concatenate -f bin/result.tar bin/commit.h.tar
|
||||||
gzip -n bin/result.tar
|
gzip -n bin/result.tar
|
||||||
|
|
||||||
# -- Determine name and move
|
# -- Determine name and move
|
||||||
|
@ -41,4 +50,4 @@ echo mv -f bin/result.tar.gz $TARNAME
|
||||||
mv -f bin/result.tar.gz $TARNAME
|
mv -f bin/result.tar.gz $TARNAME
|
||||||
|
|
||||||
# -- Cleanup (never fail)
|
# -- 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
|
||||||
|
|
Loading…
Add table
Reference in a new issue