Bug 1832937 - Always track nursery string allocations in compiled code r=jandem
[gecko.git] / mfbt / double-conversion / update.sh
blob9e83081abe29601add8c9b3d79e66554dd3c4c68
1 #!/bin/bash
3 # Usage: ./update.sh [<git-rev-to-use>]
5 # Copies the needed files from a directory containing the original
6 # double-conversion source that we need. If no revision is specified, the tip
7 # revision is used. See GIT-INFO for the last revision used.
9 set -e
11 LOCAL_PATCHES=""
13 LOCAL_PATCHES="$LOCAL_PATCHES add-mfbt-api-markers.patch"
14 LOCAL_PATCHES="$LOCAL_PATCHES use-mozilla-assertions.patch"
15 LOCAL_PATCHES="$LOCAL_PATCHES debug-only-functions.patch"
16 LOCAL_PATCHES="$LOCAL_PATCHES to-fixed-dbl-max.patch"
18 TMPDIR=`mktemp -d`
19 LOCAL_CLONE="$TMPDIR/new-double-conversion"
21 git clone https://github.com/google/double-conversion.git "$LOCAL_CLONE"
23 # If a particular revision was requested, check it out.
24 if [ "$1" != "" ]; then
25 git -C "$LOCAL_CLONE" checkout "$1"
28 # First clear out everything already present.
29 DEST=./double-conversion
30 mv "$DEST" "$TMPDIR"/old-double-conversion
31 mkdir "$DEST"
33 # Copy over critical files.
34 cp "$LOCAL_CLONE/LICENSE" "$DEST/"
35 cp "$LOCAL_CLONE/README.md" "$DEST/"
37 # Includes
38 for header in "$LOCAL_CLONE/double-conversion/"*.h; do
39 cp "$header" "$DEST/"
40 done
42 # Source
43 for ccfile in "$LOCAL_CLONE/double-conversion/"*.cc; do
44 cp "$ccfile" "$DEST/"
45 done
47 # Now apply our local patches.
48 for patch in $LOCAL_PATCHES; do
49 patch --directory "$DEST" --strip 4 < "$patch"
51 # Out-of-date patches may spew *.{orig,rej} when applied. Report an error if
52 # any such file is found, and roll the source directory back to its previous
53 # state in such case.
54 detritus_files=`find "$DEST" -name '*.orig' -o -name '*.rej'`
55 if [ "$detritus_files" != "" ]; then
56 echo "ERROR: Local patch $patch created these detritus files when applied:"
57 echo ""
58 echo " $detritus_files"
59 echo ""
60 echo "Please fix $patch before running $0."
62 rm -rf "$DEST"
63 mv "$TMPDIR"/source "$DEST"
65 exit 1
67 done
69 # Update Mercurial file status.
70 hg addremove "$DEST"
72 # Note the revision used in this update.
73 git -C "$LOCAL_CLONE" show -s > ./GIT-INFO
75 # Delete the tmpdir.
76 rm -rf "$TMPDIR"