[build][bazel] Add Bazel definition files for rapidjson.
- Add a MODULE.bazel file to define the @rapidjson module
as expected by other third-party dependencies and soon
in-tree Fuchsia Bazel targets.
- Add BUILD.bazel file to define the @rapidjson//:rapidjson
library target, matching the definitions in BUILD.gn.
- Remove obsolete BUILD.zircon.gn file.
NOTE: To be usable, this requires a change in
//build/bazel/toplevel.MODULE.bazel in fuchsia.git to list
the module here with a local_path_override() directive.
Bug: 426154145
Change-Id: Ia4729e90f557e8f3da9deb2b994a286130dc6cec
Reviewed-on: https://fuchsia-review.googlesource.com/c/third_party/rapidjson/+/1307724
Fuchsia-Auto-Submit: David Turner <digit@google.com>
Reviewed-by: Bruno Dal Bo <brunodalbo@google.com>
Commit-Queue: David Turner <digit@google.com>
diff --git a/BUILD.bazel b/BUILD.bazel
new file mode 100644
index 0000000..a808d77
--- /dev/null
+++ b/BUILD.bazel
@@ -0,0 +1,66 @@
+# Copyright 2025 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.
+
+# LINT.IfChange
+cc_library(
+ name = "rapidjson",
+ # All rapidjson headers must be public, even the internal ones
+ # since they are directly included from the public ones.
+ hdrs = [
+ "include/rapidjson/allocators.h",
+ "include/rapidjson/cursorstreamwrapper.h",
+ "include/rapidjson/document.h",
+ "include/rapidjson/encodedstream.h",
+ "include/rapidjson/encodings.h",
+ "include/rapidjson/error/en.h",
+ "include/rapidjson/error/error.h",
+ "include/rapidjson/filereadstream.h",
+ "include/rapidjson/filewritestream.h",
+ "include/rapidjson/fwd.h",
+ "include/rapidjson/internal/biginteger.h",
+ "include/rapidjson/internal/diyfp.h",
+ "include/rapidjson/internal/dtoa.h",
+ "include/rapidjson/internal/clzll.h",
+ "include/rapidjson/internal/ieee754.h",
+ "include/rapidjson/internal/itoa.h",
+ "include/rapidjson/internal/meta.h",
+ "include/rapidjson/internal/pow10.h",
+ "include/rapidjson/internal/regex.h",
+ "include/rapidjson/internal/stack.h",
+ "include/rapidjson/internal/strfunc.h",
+ "include/rapidjson/internal/strtod.h",
+ "include/rapidjson/internal/swap.h",
+ "include/rapidjson/istreamwrapper.h",
+ "include/rapidjson/memorybuffer.h",
+ "include/rapidjson/memorystream.h",
+ "include/rapidjson/msinttypes/inttypes.h",
+ "include/rapidjson/msinttypes/stdint.h",
+ "include/rapidjson/ostreamwrapper.h",
+ "include/rapidjson/pointer.h",
+ "include/rapidjson/prettywriter.h",
+ "include/rapidjson/rapidjson.h",
+ "include/rapidjson/reader.h",
+ "include/rapidjson/schema.h",
+ "include/rapidjson/stream.h",
+ "include/rapidjson/stringbuffer.h",
+ "include/rapidjson/uri.h",
+ "include/rapidjson/writer.h",
+ ],
+ includes = [ "include" ],
+ # rapidjson needs these defines to support C++11 features. These features
+ # are intentionally not autodetected by rapidjson.
+ defines = [
+ "RAPIDJSON_HAS_STDSTRING",
+ "RAPIDJSON_HAS_CXX11_RANGE_FOR",
+ "RAPIDJSON_HAS_CXX11_RVALUE_REFS",
+ "RAPIDJSON_HAS_CXX11_TYPETRAITS",
+ "RAPIDJSON_HAS_CXX11_NOEXCEPT",
+ ],
+ copts = [
+ "-Wno-ambiguous-reversed-operator",
+ "-Wno-option-ignored",
+ ],
+ visibility = ["//visibility:public"],
+)
+# LINT.ThenChange(BUILD.gn)
diff --git a/BUILD.gn b/BUILD.gn
index c12bb46..c2a41e6 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -25,6 +25,7 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+# LINT.IfChange
config("rapidjson_config") {
include_dirs = [
".",
@@ -61,9 +62,9 @@
"include/rapidjson/filewritestream.h",
"include/rapidjson/fwd.h",
"include/rapidjson/internal/biginteger.h",
+ "include/rapidjson/internal/clzll.h",
"include/rapidjson/internal/diyfp.h",
"include/rapidjson/internal/dtoa.h",
- "include/rapidjson/internal/clzll.h",
"include/rapidjson/internal/ieee754.h",
"include/rapidjson/internal/itoa.h",
"include/rapidjson/internal/meta.h",
@@ -92,3 +93,4 @@
public_configs = [ ":rapidjson_config" ]
}
+# LINT.ThenChange(BUILD.bazel)
diff --git a/BUILD.zircon.gn b/BUILD.zircon.gn
deleted file mode 100644
index 92b7a01..0000000
--- a/BUILD.zircon.gn
+++ /dev/null
@@ -1,86 +0,0 @@
-# Copyright 2016 The Fuchsia Authors. All rights reserved.
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions are
-# met:
-#
-# * Redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer.
-# * Redistributions in binary form must reproduce the above
-# copyright notice, this list of conditions and the following disclaimer
-# in the documentation and/or other materials provided with the
-# distribution.
-# * Neither the name of Google Inc. nor the names of its
-# contributors may be used to endorse or promote products derived from
-# this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-config("rapidjson_config") {
- include_dirs = [
- ".",
- "include",
- ]
-
- # rapidjson needs these defines to support C++11 features. These features
- # are intentionally not autodetected by rapidjson.
- defines = [
- "RAPIDJSON_HAS_STDSTRING",
- "RAPIDJSON_HAS_CXX11_RANGE_FOR",
- "RAPIDJSON_HAS_CXX11_RVALUE_REFS",
- "RAPIDJSON_HAS_CXX11_TYPETRAITS",
- "RAPIDJSON_HAS_CXX11_NOEXCEPT",
- ]
-}
-
-source_set("rapidjson") {
- sources = [
- "include/rapidjson/allocators.h",
- "include/rapidjson/cursorstreamwrapper.h",
- "include/rapidjson/document.h",
- "include/rapidjson/encodedstream.h",
- "include/rapidjson/encodings.h",
- "include/rapidjson/error/en.h",
- "include/rapidjson/error/error.h",
- "include/rapidjson/filereadstream.h",
- "include/rapidjson/filewritestream.h",
- "include/rapidjson/fwd.h",
- "include/rapidjson/internal/biginteger.h",
- "include/rapidjson/internal/diyfp.h",
- "include/rapidjson/internal/dtoa.h",
- "include/rapidjson/internal/ieee754.h",
- "include/rapidjson/internal/itoa.h",
- "include/rapidjson/internal/meta.h",
- "include/rapidjson/internal/pow10.h",
- "include/rapidjson/internal/regex.h",
- "include/rapidjson/internal/stack.h",
- "include/rapidjson/internal/strfunc.h",
- "include/rapidjson/internal/strtod.h",
- "include/rapidjson/internal/swap.h",
- "include/rapidjson/istreamwrapper.h",
- "include/rapidjson/memorybuffer.h",
- "include/rapidjson/memorystream.h",
- "include/rapidjson/msinttypes/inttypes.h",
- "include/rapidjson/msinttypes/stdint.h",
- "include/rapidjson/ostreamwrapper.h",
- "include/rapidjson/pointer.h",
- "include/rapidjson/prettywriter.h",
- "include/rapidjson/rapidjson.h",
- "include/rapidjson/reader.h",
- "include/rapidjson/schema.h",
- "include/rapidjson/stream.h",
- "include/rapidjson/stringbuffer.h",
- "include/rapidjson/writer.h",
- ]
-
- public_configs = [ ":rapidjson_config" ]
-}
diff --git a/MODULE.bazel b/MODULE.bazel
new file mode 100644
index 0000000..e4661df
--- /dev/null
+++ b/MODULE.bazel
@@ -0,0 +1,6 @@
+module(name = "rapidjson", version = "")
+
+bazel_dep(name = "rules_cc", version = "0.0.16")
+
+# Required by the unit-test suite only.
+bazel_dep(name = "googletest", version="1.16.0", dev_dependency=True)