summaryrefslogtreecommitdiff
path: root/chromium/third_party/icu/scripts/copy_data.sh
blob: edc16771c422990e78a531c6d354db7ecb32bb3d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#!/bin/bash
# Copyright (c) 2015 The Chromium Authors. All rights reserved.
# # Use of this source code is governed by a BSD-style license that can be
# # found in the LICENSE file.
#
# This script is tested ONLY on Linux. It may not work correctly on
# Mac OS X.
#

if [ $# -lt 1 ];
then
  echo "Usage: "$0" (android|android_small|cast|chromeos|common|flutter|ios)" >&2
  exit 1
fi

TOPSRC="$(dirname "$0")/.."
source "${TOPSRC}/scripts/data_common.sh"


function copy_common {
  DATA_PREFIX="data/out/tmp/icudt${VERSION}"

  echo "Generating the big endian data bundle"
  LD_LIBRARY_PATH=lib bin/icupkg -tb "${DATA_PREFIX}l.dat" "${DATA_PREFIX}b.dat"

  echo "Copying icudtl.dat and icudtlb.dat"
  for endian in l b
  do
    cp "${DATA_PREFIX}${endian}.dat" "${TOPSRC}/common/icudt${endian}.dat"
  done

  echo "Done with copying pre-built ICU data files."
}

function copy_chromeos {
  DATA_FILE="data/out/tmp/icudt${VERSION}l.dat"

  echo "Copying icudtl.dat"
  cp "${DATA_FILE}" "${TOPSRC}/chromeos/icudtl.dat"

  echo "Done with copying pre-built ICU data files for chromeos."
}

function copy_android_ios {
  echo "Copying icudtl.dat for $1"

  cp "data/out/tmp/icudt${VERSION}l.dat" "${TOPSRC}/$2/icudtl.dat"

  echo "Done with copying pre-built ICU data file for $1."
}

function copy_cast {
  echo "Copying icudtl.dat for $1"

  LD_LIBRARY_PATH=lib/ bin/icupkg -r \
    "${TOPSRC}/$2/cast-removed-resources.txt" \
    "data/out/tmp/icudt${VERSION}l.dat"

  cp "data/out/tmp/icudt${VERSION}l.dat" "${TOPSRC}/$2/icudt${VERSION}l.dat"

  mv "${TOPSRC}/$2/icudt${VERSION}l.dat" "${TOPSRC}/$2/icudtl.dat"

  echo "Done with copying pre-built ICU data file for $1."
}

function copy_flutter {
  echo "Copying icudtl.dat for Flutter"


  echo "Removing unused resources from icudtl.dat for Flutter"
  LD_LIBRARY_PATH=lib/ bin/icupkg -r \
    "${TOPSRC}/flutter/flutter-removed-resources.txt" \
    "data/out/tmp/icudt${VERSION}l.dat"

  cp "data/out/tmp/icudt${VERSION}l.dat" "${TOPSRC}/flutter/icudt${VERSION}l.dat"

  mv "${TOPSRC}/flutter/icudt${VERSION}l.dat" "${TOPSRC}/flutter/icudtl.dat"

  echo "Done with copying pre-built ICU data file for Flutter."
}

BACKUP_DIR="dataout/$1"
function backup_outdir {
  rm -rf "${BACKUP_DIR}"
  mkdir "${BACKUP_DIR}"
  find "data/out" | cpio -pdmv "${BACKUP_DIR}"
}

case "$1" in
  "chromeos")
    copy_chromeos
    backup_outdir $1
    ;;
  "common")
    copy_common
    backup_outdir $1
    ;;
  "android")
    copy_android_ios Android android
    backup_outdir $1
    ;;
  "android_small")
    copy_android_ios AndroidSmall android_small
    backup_outdir $1
    ;;
  "ios")
    copy_android_ios iOS ios
    backup_outdir $1
    ;;
  "cast")
    copy_cast Cast cast
    backup_outdir $1
    ;;
  "flutter")
    copy_flutter
    backup_outdir $1
    ;;
esac