1#!/bin/bash 2# Copyright (c) 2015 The Chromium Authors. All rights reserved. 3# # Use of this source code is governed by a BSD-style license that can be 4# # found in the LICENSE file. 5# 6# This script is tested ONLY on Linux. It may not work correctly on 7# Mac OS X. 8# 9set -e # exit if fail 10 11if [ $# -lt 1 ]; 12then 13 echo "Usage: "$0" (android|cast|chromeos|common|flutter|flutter_desktop|ios)" >&2 14 exit 1 15fi 16 17TOPSRC="$(dirname "$0")/.." 18source "${TOPSRC}/scripts/data_common.sh" 19 20 21function copy_common { 22 DATA_PREFIX="data/out/tmp/icudt${VERSION}" 23 TZRES_PREFIX="data/out/build/icudt${VERSION}l" 24 25 echo "Generating the big endian data bundle" 26 LD_LIBRARY_PATH=lib bin/icupkg -tb --ignore-deps "${DATA_PREFIX}l.dat" "${DATA_PREFIX}b.dat" 27 28 echo "Copying icudtl.dat and icudtlb.dat" 29 for endian in l b 30 do 31 rm "${TOPSRC}/common/icudt${endian}.dat" 32 cp "${DATA_PREFIX}${endian}.dat" "${TOPSRC}/common/icudt${endian}.dat" 33 done 34 35 echo "Copying metaZones.res, timezoneTypes.res, zoneinfo64.res" 36 for tzfile in metaZones timezoneTypes zoneinfo64 37 do 38 rm "${TOPSRC}/tzres/${tzfile}.res" 39 cp "${TZRES_PREFIX}/${tzfile}.res" "${TOPSRC}/tzres/${tzfile}.res" 40 done 41 42 echo "Done with copying pre-built ICU data files." 43} 44 45function copy_data { 46 echo "Copying icudtl.dat for $1" 47 48 rm -f "${TOPSRC}/$2/icudtl.dat" 49 cp "data/out/tmp/icudt${VERSION}l.dat" "${TOPSRC}/$2/icudtl.dat" 50 51 echo "Done with copying pre-built ICU data file for $1." 52} 53 54function copy_hash_data { 55 echo "Copying icudtl.dat.hash for $1" 56 57 rm -f "${TOPSRC}/$2/icudtl.dat.hash" 58 cp "data/out/tmp/icudt${VERSION}l.dat.hash" "${TOPSRC}/$2/icudtl.dat.hash" 59 60 echo "Done with copying icudtl.dat.hash for $1." 61} 62 63function align_data { 64 echo "Aligning files in icudtl.dat for $1" 65 66 local ORIGINAL="data/out/tmp/icudt${VERSION}l.dat" 67 local ALIGNED="data/out/tmp/icudt${VERSION}l-aligned.dat" 68 69 rm -f "${ALIGNED}" 70 "${TOPSRC}/scripts/icualign.py" "${ORIGINAL}" "${ALIGNED}" 71 mv "${ALIGNED}" "${ORIGINAL}" 72 73 echo "Done with aligning files in icudtl.dat for $1." 74} 75 76function hash_data { 77 echo "Hashing icudtl.dat for $1" 78 79 local DATA_FILE="data/out/tmp/icudt${VERSION}l.dat" 80 local HASH_FILE="data/out/tmp/icudt${VERSION}l.dat.hash" 81 82 rm -f "${HASH_FILE}" 83 "$TOPSRC/scripts/icuhash.py" "${DATA_FILE}" "${HASH_FILE}" 84 85 echo "Done with hashing icudtl.dat for $1." 86} 87 88 89BACKUP_DIR="dataout/$1" 90function backup_outdir { 91 rm -rf "${BACKUP_DIR}" 92 mkdir -p "${BACKUP_DIR}" 93 find "data/out" | cpio -pdmv "${BACKUP_DIR}" 94} 95 96case "$1" in 97 "chromeos") 98 align_data ChromeOS 99 hash_data ChromeOS 100 copy_data ChromeOS $1 101 copy_hash_data ChromeOS $1 102 backup_outdir $1 103 ;; 104 "common") 105 copy_common 106 backup_outdir $1 107 ;; 108 "android") 109 copy_data Android $1 110 backup_outdir $1 111 ;; 112 "ios") 113 copy_data iOS $1 114 backup_outdir $1 115 ;; 116 "cast") 117 copy_data Cast $1 118 backup_outdir $1 119 ;; 120 "flutter") 121 copy_data Flutter $1 122 backup_outdir $1 123 ;; 124 "flutter_desktop") 125 copy_data Flutter_Desktop $1 126 backup_outdir $1 127 ;; 128esac 129