Adds a minimal ICU data config for Flutter

This reduces the size of the ICU data file shipping with Flutter:
 from 6.3MB to 1.2MB uncompressed
 from 2.2MB to 534KB compressed (zip)

See go/flutter-icu for detailed analysis.

Change-Id: Iff5a4aa5286c685d5410b28d98ac8d49987d2eef
Reviewed-on: https://chromium-review.googlesource.com/1144234
Reviewed-by: Jungshik Shin <jshin@chromium.org>
diff --git a/BUILD.gn b/BUILD.gn
index f69d500..c782db0 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -96,6 +96,8 @@
       # certain preprocessor defines are set.
       # unistr.cpp also has an unused function for non-component builds.
       "-Wno-unused-function",
+      # putil.cpp contains unused variables when building for iOS simulators.
+      "-Wno-unused-variable",
     ]
   }
   if (is_clang || is_linux || is_android) {
diff --git a/README.chromium b/README.chromium
index 092245c..287215f 100644
--- a/README.chromium
+++ b/README.chromium
@@ -77,7 +77,9 @@
 
      ix) Repeat ii) and iii) for iOS to get ios/icudtl.dat
 
-     x) scripts/clean_up_data_source.sh
+     x) Repeat ii) and iii) for Flutter to get flutter/icudtl.dat
+
+     xi) scripts/clean_up_data_source.sh
 
      This reverts the result of trim_data.sh and patch_locale.sh and
      make the tree ready for committing updated ICU data files for
diff --git a/flutter/flutter-removed-resources.txt b/flutter/flutter-removed-resources.txt
new file mode 100644
index 0000000..b600da1
--- /dev/null
+++ b/flutter/flutter-removed-resources.txt
@@ -0,0 +1,427 @@
+coll/*
+zone/*
+curr/*
+lang/*
+rbnf/*
+region/*
+translit/*
+unit/*
+
+# lang/*
+af.res
+ak.res
+am.res
+an.res
+ar.res
+ar_001.res
+ar_AE.res
+ar_BH.res
+ar_DJ.res
+ar_DZ.res
+ar_EG.res
+ar_EH.res
+ar_ER.res
+ar_IL.res
+ar_IQ.res
+ar_JO.res
+ar_KM.res
+ar_KW.res
+ar_LB.res
+ar_LY.res
+ar_MA.res
+ar_MR.res
+ar_OM.res
+ar_PS.res
+ar_QA.res
+ar_SA.res
+ar_SD.res
+ar_SO.res
+ar_SS.res
+ar_SY.res
+ar_TD.res
+ar_TN.res
+ar_YE.res
+ast.res
+az.res
+be.res
+bem.res
+bg.res
+bn.res
+br.res
+bs.res
+ca.res
+ckb.res
+cs.res
+cy.res
+da.res
+de.res
+de_AT.res
+de_BE.res
+de_CH.res
+de_IT.res
+de_LI.res
+de_LU.res
+ee.res
+el.res
+en.res
+en_001.res
+en_150.res
+en_AG.res
+en_AI.res
+en_AS.res
+en_AT.res
+en_AU.res
+en_BB.res
+en_BE.res
+en_BI.res
+en_BM.res
+en_BS.res
+en_BW.res
+en_BZ.res
+en_CA.res
+en_CC.res
+en_CH.res
+en_CK.res
+en_CM.res
+en_CX.res
+en_CY.res
+en_DE.res
+en_DG.res
+en_DK.res
+en_DM.res
+en_ER.res
+en_FI.res
+en_FJ.res
+en_FK.res
+en_FM.res
+en_GB.res
+en_GD.res
+en_GG.res
+en_GH.res
+en_GI.res
+en_GM.res
+en_GU.res
+en_GY.res
+en_HK.res
+en_IE.res
+en_IL.res
+en_IM.res
+en_IN.res
+en_IO.res
+en_JE.res
+en_JM.res
+en_KE.res
+en_KI.res
+en_KN.res
+en_KY.res
+en_LC.res
+en_LR.res
+en_LS.res
+en_MG.res
+en_MH.res
+en_MO.res
+en_MP.res
+en_MS.res
+en_MT.res
+en_MU.res
+en_MW.res
+en_MY.res
+en_NA.res
+en_NF.res
+en_NG.res
+en_NL.res
+en_NR.res
+en_NU.res
+en_NZ.res
+en_PG.res
+en_PH.res
+en_PK.res
+en_PN.res
+en_PR.res
+en_PW.res
+en_RW.res
+en_SB.res
+en_SC.res
+en_SD.res
+en_SE.res
+en_SG.res
+en_SH.res
+en_SI.res
+en_SL.res
+en_SS.res
+en_SX.res
+en_SZ.res
+en_TC.res
+en_TK.res
+en_TO.res
+en_TT.res
+en_TV.res
+en_TZ.res
+en_UG.res
+en_UM.res
+en_US.res
+en_US_POSIX.res
+en_VC.res
+en_VG.res
+en_VI.res
+en_VU.res
+en_WS.res
+en_ZA.res
+en_ZM.res
+en_ZW.res
+eo.res
+es.res
+es_419.res
+es_AR.res
+es_BO.res
+es_BR.res
+es_BZ.res
+es_CL.res
+es_CO.res
+es_CR.res
+es_CU.res
+es_DO.res
+es_EA.res
+es_EC.res
+es_ES.res
+es_GQ.res
+es_GT.res
+es_HN.res
+es_IC.res
+es_MX.res
+es_NI.res
+es_PA.res
+es_PE.res
+es_PH.res
+es_PR.res
+es_PY.res
+es_SV.res
+es_US.res
+es_UY.res
+es_VE.res
+et.res
+eu.res
+fa.res
+fi.res
+fil.res
+fo.res
+fr.res
+fr_BE.res
+fr_BF.res
+fr_BI.res
+fr_BJ.res
+fr_BL.res
+fr_CA.res
+fr_CD.res
+fr_CF.res
+fr_CG.res
+fr_CH.res
+fr_CI.res
+fr_CM.res
+fr_DJ.res
+fr_DZ.res
+fr_FR.res
+fr_GA.res
+fr_GF.res
+fr_GN.res
+fr_GP.res
+fr_GQ.res
+fr_HT.res
+fr_KM.res
+fr_LU.res
+fr_MA.res
+fr_MC.res
+fr_MF.res
+fr_MG.res
+fr_ML.res
+fr_MQ.res
+fr_MR.res
+fr_MU.res
+fr_NC.res
+fr_NE.res
+fr_PF.res
+fr_PM.res
+fr_RE.res
+fr_RW.res
+fr_SC.res
+fr_SN.res
+fr_SY.res
+fr_TD.res
+fr_TG.res
+fr_TN.res
+fr_VU.res
+fr_WF.res
+fr_YT.res
+ga.res
+gl.res
+gu.res
+ha.res
+haw.res
+he.res
+hi.res
+hr.res
+hu.res
+hy.res
+id.res
+ig.res
+in.res
+is.res
+it.res
+it_CH.res
+iw.res
+ja.res
+ka.res
+kk.res
+km.res
+kn.res
+ko.res
+ku.res
+ky.res
+lg.res
+ln.res
+lo.res
+lt.res
+lv.res
+mfe.res
+mg.res
+mk.res
+ml.res
+mn.res
+mo.res
+mr.res
+ms.res
+mt.res
+my.res
+nb.res
+ne.res
+nl.res
+nl_AW.res
+nl_BE.res
+nl_BQ.res
+nl_CW.res
+nl_NL.res
+nl_SR.res
+nl_SX.res
+nn.res
+no.res
+nyn.res
+om.res
+or.res
+pa.res
+pl.res
+ps.res
+pt.res
+pt_AO.res
+pt_BR.res
+pt_CH.res
+pt_CV.res
+pt_GQ.res
+pt_GW.res
+pt_LU.res
+pt_MO.res
+pt_MZ.res
+pt_PT.res
+pt_ST.res
+pt_TL.res
+rm.res
+rn.res
+ro.res
+ro_MD.res
+root.res
+ru.res
+ru_BY.res
+ru_KG.res
+ru_KZ.res
+ru_MD.res
+ru_RU.res
+ru_UA.res
+rw.res
+sh.res
+si.res
+sk.res
+sl.res
+sn.res
+so.res
+sq.res
+sr.res
+sr_Latn.res
+sv.res
+sw.res
+ta.res
+te.res
+tg.res
+th.res
+ti.res
+tl.res
+to.res
+tr.res
+uk.res
+ur.res
+uz.res
+vi.res
+wa.res
+yo.res
+zh.res
+zh_CN.res
+zh_HK.res
+zh_Hans.res
+zh_Hans_CN.res
+zh_Hans_SG.res
+zh_Hant.res
+zh_Hant_HK.res
+zh_Hant_TW.res
+zh_SG.res
+zh_TW.res
+zu.res
+
+# misc/ (note mising *, only partly removed)
+currencyNumericCodes.res
+dayPeriods.res
+genderList.res
+keyTypeData.res
+metaZones.res
+metadata.res
+numberingSystems.res
+plurals.res
+supplementalData.res
+timezoneTypes.res
+windowsZones.res
+zoneinfo64.res
+
+# *.cnv
+big5-html.cnv
+euc-jp-html.cnv
+euc-kr-html.cnv
+gb18030.cnv
+ibm866-html.cnv
+iso-8859-10-html.cnv
+iso-8859-13-html.cnv
+iso-8859-14-html.cnv
+iso-8859-15-html.cnv
+iso-8859-16-html.cnv
+iso-8859-2-html.cnv
+iso-8859-3-html.cnv
+iso-8859-4-html.cnv
+iso-8859-5-html.cnv
+iso-8859-6-html.cnv
+iso-8859-7-html.cnv
+iso-8859-8-html.cnv
+koi8-r-html.cnv
+koi8-u-html.cnv
+macintosh-html.cnv
+shift_jis-html.cnv
+windows-1250-html.cnv
+windows-1251-html.cnv
+windows-1252-html.cnv
+windows-1253-html.cnv
+windows-1254-html.cnv
+windows-1255-html.cnv
+windows-1256-html.cnv
+windows-1257-html.cnv
+windows-1258-html.cnv
+windows-874-html.cnv
+windows-936-2000.cnv
+x-mac-cyrillic-html.cnv
+
+# other
+confusables.cfu
diff --git a/flutter/icudtl.dat b/flutter/icudtl.dat
new file mode 100644
index 0000000..91d0b16
--- /dev/null
+++ b/flutter/icudtl.dat
Binary files differ
diff --git a/scripts/copy_data.sh b/scripts/copy_data.sh
index a8def76..e83496e 100755
--- a/scripts/copy_data.sh
+++ b/scripts/copy_data.sh
@@ -54,6 +54,21 @@
   echo "Done with copying pre-built ICU data file for $1."
 }
 
+function copy_flutter {
+  echo "Copying icudtl.dat for Flutter"
+
+  cp "data/out/tmp/icudt${VERSION}l.dat" "${TOPSRC}/flutter/icudt${VERSION}l.dat"
+
+  echo "Removing unused resources from icudtl.dat for Flutter"
+
+  LD_LIBRARY_PATH=lib/ bin/icupkg -r \
+    "${TOPSRC}/flutter/flutter-removed-resources.txt" \
+    "${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."
+}
+
 case "$1" in
   "common")
     copy_common
@@ -67,4 +82,7 @@
   "cast")
     copy_cast Cast cast
     ;;
+  "flutter")
+    copy_flutter
+    ;;
 esac
diff --git a/scripts/make_data_all.sh b/scripts/make_data_all.sh
index 557fbdc..a1c2bcc 100755
--- a/scripts/make_data_all.sh
+++ b/scripts/make_data_all.sh
@@ -16,5 +16,6 @@
 $ICUROOT/ios/patch_locale.sh
 $ICUROOT/scripts/make_data.sh
 $ICUROOT/scripts/copy_data.sh ios
+$ICUROOT/scripts/copy_data.sh flutter
 $ICUROOT/scripts/clean_up_data_source.sh