Update build files to account use in ZN/GN.

Change-Id: I7ad5a55b61d59f657e14a1f27709e586f5cb5628
Reviewed-on: https://fuchsia-review.googlesource.com/c/third_party/rapidjson/+/397114
Reviewed-by: Shai Barack <shayba@google.com>
diff --git a/BUILD.gn b/BUILD.gn
index ed48a9c..e2581b5 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -88,5 +88,9 @@
 
   public_configs = [ ":rapidjson_config" ]
 
-  public_deps = [ "//build/config/sanitizers:suppress-lsan.DO-NOT-USE-THIS" ]
+  if (!defined(zx) || zx != "/") {
+    public_deps = [ "//build/config/sanitizers:suppress-lsan.DO-NOT-USE-THIS" ]
+  } else {
+    public_deps = [ "$zx/public/gn/config/instrumentation:suppress-lsan.DO-NOT-USE-THIS" ]
+  }
 }
diff --git a/BUILD.zircon.gn b/BUILD.zircon.gn
index 92b7a01..e2581b5 100644
--- a/BUILD.zircon.gn
+++ b/BUILD.zircon.gn
@@ -40,6 +40,10 @@
     "RAPIDJSON_HAS_CXX11_TYPETRAITS",
     "RAPIDJSON_HAS_CXX11_NOEXCEPT",
   ]
+
+  # TODO(44348): UBSan has found an instance of undefined behavior in this target.
+  # Disable UBSan for this target temporarily until it is migrated into CI/CQ.
+  cflags = [ "-fno-sanitize=undefined" ]
 }
 
 source_set("rapidjson") {
@@ -83,4 +87,10 @@
   ]
 
   public_configs = [ ":rapidjson_config" ]
+
+  if (!defined(zx) || zx != "/") {
+    public_deps = [ "//build/config/sanitizers:suppress-lsan.DO-NOT-USE-THIS" ]
+  } else {
+    public_deps = [ "$zx/public/gn/config/instrumentation:suppress-lsan.DO-NOT-USE-THIS" ]
+  }
 }