Support Big Endian in ICU:  part 3

Add big endian (mips and mips64) support to BUILD.gn

- icudt[lb]_dat.S (assembly source) is generated at build-time from
  icudt[lb].dat (data bundle) when icu_use_data_file is false.
- icudt[lb].dat is copied depending on the endinaness when icu_use_data_file
  is true.

Part 1:  https://codereview.chromium.org/2162393003
Part 2:  https://codereview.chromium.org/2165403003

It works on Linux (both Chrome and v8) and Mac (v8).
Android was also tested by building base_unittests target with
icu_use_data_file=true/false.

v8 does not yet support mips/mips64 in GN so that this CL cannot be
tested with target_cpu={mips,mips64}.

With Chrome on Mac, TEST below has to be done with
https://codereview.chromium.org/2181043003 for http://crbug.com/630929.

Windows should not be affected at all.

BUG=v8:4828
TEST='gn args <builddir>' with icu_use_data_file set to true or false
TEST=build base_unittests and run with --gtest_filter=ICU*
TEST=build base_unittests and run with --gtest_filter=Message*ormat*
TEST=build 'd8' (v8) and try `(new Date()).toLocaleString("de")`
R=machenbach@chromium.org

Review URL: https://codereview.chromium.org/2174993002 .
diff --git a/BUILD.gn b/BUILD.gn
index 2e63fa9..80764aa 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -569,32 +569,28 @@
   }
 }
 
+# TODO(GYP): Gyp has considerations here for QNX and for the host toolchain
+#  that have not been ported over.
+data_bundle = "common/icudtl.dat"
+if (is_android) {
+  data_bundle = "android/icudtl.dat"
+} else if (current_cpu == "mips" || current_cpu == "mips64") {
+  data_bundle = "common/icudtb.dat"
+} else {
+  data_bundle = "common/icudtl.dat"
+}
+
 # TODO(GYP) support use_system_icu.
 if (icu_use_data_file) {
   if (is_ios) {
     bundle_data("icudata") {
-      sources = [ "common/icudtl.dat" ]
+      sources = [ "$data_bundle" ]
       outputs = [ "{{bundle_resources_dir}}/{{source_file_part}}" ]
     }
   } else {
     copy("icudata") {
-      if (is_android) {
-        sources = [
-          "android/icudtl.dat",
-        ]
-      } else {
-        sources = [
-          "common/icudtl.dat",
-        ]
-      }
-
-      outputs = [
-        "$root_out_dir/icudtl.dat",
-      ]
-
-      data = [
-        "$root_out_dir/icudtl.dat",
-      ]
+      sources = [ "$data_bundle" ]
+      outputs = [ "$root_out_dir/{{source_file_part}}" ]
     }
   }
 } else {
@@ -607,33 +603,30 @@
       outputs = [
         "$root_out_dir/icudt.dll",
       ]
-
-      data = [
-        "$root_out_dir/icudtl.dll",
-      ]
     }
   } else {
-    source_set("icudata") {
-      # These are hand-generated, but will do for now.
-      #
-      # TODO(GYP): Gyp has considerations here for QNX and for the host toolchain
-      #  that have not been ported over.
-      if (is_linux) {
-        sources = [
-          "linux/icudtl_dat.S",
-        ]
-      } else if (is_mac) {
-        sources = [
-          "mac/icudtl_dat.S",
-        ]
-      } else if (is_android) {
-        sources = [
-          "android/icudtl_dat.S",
-        ]
-      } else {
-        assert(false, "No icu data for this platform")
+    if (current_cpu == "mips" || current_cpu == "mips64") {
+      data_assembly = "$target_gen_dir/icudtb_dat.S"
+    } else {
+      data_assembly = "$target_gen_dir/icudtl_dat.S"
+    }
+    action("make_data_assembly") {
+      script = "scripts/make_data_assembly.py"
+      inputs = [ "$data_bundle" ]
+      outputs = [ "$data_assembly" ]
+      args = [
+        rebase_path(data_bundle, root_build_dir),
+        rebase_path(data_assembly, root_build_dir),
+      ]
+      if (is_mac) {
+        args += [ "--mac" ]
       }
+    }
+
+    source_set("icudata") {
+      sources = [ "$data_assembly" ]
       defines = [ "U_HIDE_DATA_SYMBOL" ]
+      deps = [ ":make_data_assembly", ]
     }
   }
 }