Copy files for rapidjson build

Needed for compatibility with third_party/tink

Change-Id: If957487fc0e1d58aa933300659de7579844f8d0b
diff --git a/BUILD.gn b/BUILD.gn
index 031ded3..50701f9 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -28,6 +28,7 @@
 config("rapidjson_config") {
   include_dirs = [
     ".",
+    "$target_gen_dir",
   ]
 
   # rapidjson needs these defines to support C++11 features. These features
@@ -80,4 +81,8 @@
   ]
 
   public_configs = [ ":rapidjson_config" ]
+
+  deps = [
+    "rapidjson:copyfiles",
+  ]
 }
diff --git a/rapidjson/BUILD.gn b/rapidjson/BUILD.gn
new file mode 100644
index 0000000..a60d3e6
--- /dev/null
+++ b/rapidjson/BUILD.gn
@@ -0,0 +1,37 @@
+# Copyright 2018 The Fuchsia Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+# We add this copy target in order to support //third_party/tink. Tink expects
+# include files for rapidjson to be under the directory include/rapidjson, so
+# simply adding an include directory to the cflags is not sufficient. See CB-181
+# for more details.
+copy("copyfiles") {
+  sources = [
+    "allocators.h",
+    "cursorstreamwrapper.h",
+    "document.h",
+    "encodedstream.h",
+    "encodings.h",
+    "filereadstream.h",
+    "filewritestream.h",
+    "fwd.h",
+    "istreamwrapper.h",
+    "memorybuffer.h",
+    "memorystream.h",
+    "ostreamwrapper.h",
+    "pointer.h",
+    "prettywriter.h",
+    "rapidjson.h",
+    "reader.h",
+    "schema.h",
+    "stream.h",
+    "stringbuffer.h",
+    "writer.h",
+  ]
+  outputs = ["$target_gen_dir/../include/rapidjson/{{source_file_part}}"]
+  deps = [
+    "internal:copyfiles",
+    "error:copyfiles",
+  ]
+}
diff --git a/rapidjson/error/BUILD.gn b/rapidjson/error/BUILD.gn
new file mode 100644
index 0000000..6512a55
--- /dev/null
+++ b/rapidjson/error/BUILD.gn
@@ -0,0 +1,11 @@
+# Copyright 2018 The Fuchsia Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+copy("copyfiles") {
+  sources = [
+    "en.h",
+    "error.h",
+  ]
+  outputs = ["$target_gen_dir/../../include/rapidjson/error/{{source_file_part}}"]
+}
diff --git a/rapidjson/internal/BUILD.gn b/rapidjson/internal/BUILD.gn
new file mode 100644
index 0000000..20217ea
--- /dev/null
+++ b/rapidjson/internal/BUILD.gn
@@ -0,0 +1,21 @@
+# Copyright 2018 The Fuchsia Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+copy("copyfiles") {
+  sources = [
+    "biginteger.h",
+    "diyfp.h",
+    "dtoa.h",
+    "ieee754.h",
+    "itoa.h",
+    "meta.h",
+    "pow10.h",
+    "regex.h",
+    "stack.h",
+    "strfunc.h",
+    "strtod.h",
+    "swap.h",
+  ]
+  outputs = ["$target_gen_dir/../../include/rapidjson/internal/{{source_file_part}}"]
+}