Commit dd60179d authored by Michael Hanselmann's avatar Michael Hanselmann
Browse files

run-in-tempdir: Improve speed



By creating symlinks instead of actually creating files we still get the
benefits of using a temporary directory, but the preparation is about
three times as fast. Test used:

$ time bash -c 'for ((i=0; i < 100; ++i)); do
    autotools/run-in-tempdir true; done'
Signed-off-by: default avatarMichael Hanselmann <hansmi@google.com>
Reviewed-by: default avatarBernardo Dal Seno <bdalseno@google.com>
parent 06a6f2cc
......@@ -8,19 +8,27 @@ set -e
tmpdir=$(mktemp -d -t gntbuild.XXXXXXXX)
trap "rm -rf $tmpdir" EXIT
# fully copy items
cp -r autotools daemons scripts lib tools qa $tmpdir
linkcopy() {
cp -L -s -r "$@"
}
dirs=( autotools daemons scripts lib tools qa )
if [[ -z "$COPY_DOC" ]]; then
mkdir $tmpdir/doc
ln -s $PWD/doc/examples $tmpdir/doc
else
# Building documentation requires all files
cp -r doc $tmpdir
dirs+=( doc )
fi
# Create symlinks
for i in ${dirs[@]}; do
linkcopy $PWD/$i $tmpdir
done
mkdir $tmpdir/test/
cp -r test/py $tmpdir/test/py
linkcopy $PWD/test/py $tmpdir/test/py
ln -s $PWD/test/data $tmpdir/test
ln -s $PWD/test/hs $tmpdir/test
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment