Skip to content
Snippets Groups Projects
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
No related branches found
No related tags found
No related merge requests found
...@@ -8,19 +8,27 @@ set -e ...@@ -8,19 +8,27 @@ set -e
tmpdir=$(mktemp -d -t gntbuild.XXXXXXXX) tmpdir=$(mktemp -d -t gntbuild.XXXXXXXX)
trap "rm -rf $tmpdir" EXIT trap "rm -rf $tmpdir" EXIT
# fully copy items linkcopy() {
cp -r autotools daemons scripts lib tools qa $tmpdir cp -L -s -r "$@"
}
dirs=( autotools daemons scripts lib tools qa )
if [[ -z "$COPY_DOC" ]]; then if [[ -z "$COPY_DOC" ]]; then
mkdir $tmpdir/doc mkdir $tmpdir/doc
ln -s $PWD/doc/examples $tmpdir/doc ln -s $PWD/doc/examples $tmpdir/doc
else else
# Building documentation requires all files # Building documentation requires all files
cp -r doc $tmpdir dirs+=( doc )
fi fi
# Create symlinks
for i in ${dirs[@]}; do
linkcopy $PWD/$i $tmpdir
done
mkdir $tmpdir/test/ 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/data $tmpdir/test
ln -s $PWD/test/hs $tmpdir/test ln -s $PWD/test/hs $tmpdir/test
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment