• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/bash
2# © 2016 and later: Unicode, Inc. and others.
3# License & terms of use: http://www.unicode.org/copyright.html
4
5if [[ -z $1 ]]; then
6	echo "Pass the current version tag of double-conversion as the first argument to this script";
7	echo "To pull the latest changes, use 'master'"
8	exit 1;
9fi
10
11url="https://github.com/google/double-conversion/archive/$1.tar.gz";
12upstream_root="$(dirname "$0")/upstream";
13icu4c_i18n_root="$(dirname "$0")/../../icu4c/source/i18n";
14tmpdir=`mktemp -d`;
15filename="$tmpdir/$1.tar.gz"
16upstream_root_tmp="$tmpdir/upstream"
17patch_root_tmp="$tmpdir/patches"
18
19echo "Will download $url";
20read -p "Press Enter to continue or s to skip: " ch;
21
22if [ "$ch" != "s" ]; then
23	wget -O "$filename" "$url";
24	mkdir "$upstream_root_tmp";
25	tar zxf $filename --strip 1 -C "$upstream_root_tmp";
26fi
27
28echo "Will apply diffs to $icu4c_i18n_root";
29read -p "Press Enter to continue or s to skip: " ch;
30
31do_patch() {
32	old_vendor_path="$upstream_root/double-conversion/$1";
33	new_vendor_path="$upstream_root_tmp/double-conversion/$1";
34	icu4c_path="$icu4c_i18n_root/$2";
35	tmp_path="$patch_root_tmp/$2.patch";
36	diff -u "$old_vendor_path" "$icu4c_path" > "$tmp_path";
37	cp "$new_vendor_path" "$icu4c_path";
38	patch --merge "$icu4c_path" < "$tmp_path";
39}
40
41do_patch_prefix_extension() {
42	do_patch "$1.$2" "double-conversion-$1.$3";
43}
44
45do_patch_extension() {
46	do_patch "$1.$2" "$1.$3";
47}
48
49if [ "$ch" != "s" ]; then
50	mkdir "$patch_root_tmp";
51	do_patch_prefix_extension bignum cc cpp;
52	do_patch_prefix_extension bignum h h;
53	do_patch_prefix_extension bignum-dtoa cc cpp;
54	do_patch_prefix_extension bignum-dtoa h h;
55	do_patch_prefix_extension cached-powers cc cpp;
56	do_patch_prefix_extension cached-powers h h;
57	do_patch_prefix_extension diy-fp h h;
58	do_patch_prefix_extension double-to-string cc cpp;
59	do_patch_prefix_extension double-to-string h h;
60	do_patch_prefix_extension fast-dtoa cc cpp;
61	do_patch_prefix_extension fast-dtoa h h;
62	do_patch_prefix_extension ieee h h;
63	do_patch_prefix_extension string-to-double cc cpp;
64	do_patch_prefix_extension string-to-double h h;
65	do_patch_prefix_extension strtod cc cpp;
66	do_patch_prefix_extension strtod h h;
67	do_patch_prefix_extension utils h h;
68	do_patch_extension double-conversion h h;
69fi
70
71echo "Will save pristine copy into $upstream_root";
72read -p "Press Enter to continue or s to skip: " ch;
73
74if [ "$ch" != "s" ]; then
75	rm -r "$upstream_root"; # in case any files were deleted in the new version
76	cp -r "$upstream_root_tmp" "$upstream_root";
77fi
78
79echo "Temporary files have been saved in $tmpdir";
80read -p "Press Enter to delete the directory or s to skip: " ch;
81
82if [ "$ch" != "s" ]; then
83	rm -rf "$tmpdir";
84fi
85