summaryrefslogtreecommitdiffstats
path: root/third_party/googletest/gen_moz_build.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
commit36d22d82aa202bb199967e9512281e9a53db42c9 (patch)
tree105e8c98ddea1c1e4784a60a5a6410fa416be2de /third_party/googletest/gen_moz_build.py
parentInitial commit. (diff)
downloadfirefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz
firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'third_party/googletest/gen_moz_build.py')
-rwxr-xr-xthird_party/googletest/gen_moz_build.py91
1 files changed, 91 insertions, 0 deletions
diff --git a/third_party/googletest/gen_moz_build.py b/third_party/googletest/gen_moz_build.py
new file mode 100755
index 0000000000..1e78c5f881
--- /dev/null
+++ b/third_party/googletest/gen_moz_build.py
@@ -0,0 +1,91 @@
+#!/usr/bin/env python3
+# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
+# vim: set filetype=python:
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+import os
+import json
+
+
+def gen_includes(export_prefix, path_prefix):
+ result = ""
+
+ exports = []
+ for f in os.listdir(path_prefix):
+ # Explicitly ignore the "{gtest,gmock}/internal/custom" paths, as we
+ # replace files in them for custom configurations.
+ if f == "custom":
+ continue
+
+ path = os.path.join(path_prefix, f)
+ if os.path.isfile(path):
+ if os.path.splitext(f)[1] != ".h":
+ continue
+ exports.append(path)
+ else:
+ result += gen_includes(export_prefix + "." + f, path)
+
+ if exports:
+ result += "%s += [\n" % export_prefix
+ for export in sorted(exports):
+ result += " %s,\n" % json.dumps(export)
+ result += "]\n"
+
+ return result
+
+
+if __name__ == "__main__":
+ GTEST_PATH = "googletest/include/gtest"
+ GMOCK_PATH = "googlemock/include/gmock"
+
+ exports = "\n".join(
+ [
+ # Normal include paths used by most code
+ gen_includes("EXPORTS.gtest", GTEST_PATH),
+ gen_includes("EXPORTS.gmock", GMOCK_PATH),
+ # webrtc.org unit tests use this include path
+ gen_includes("EXPORTS.testing.gtest.include.gtest", GTEST_PATH),
+ gen_includes("EXPORTS.testing.gmock.include.gmock", GMOCK_PATH),
+ ]
+ )
+ exports = exports.replace("\n", "\n ")
+
+ mozbuild = f"""\
+# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
+# vim: set filetype=python:
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+# !!! THIS FILE IS AUTOGENERATED USING gen_moz_build.py DO NOT EDIT !!!
+
+with Files("**"):
+ BUG_COMPONENT = ("Testing", "GTest")
+ SCHEDULES.exclusive = ["gtest"]
+
+if CONFIG["ENABLE_TESTS"]:
+
+ {exports}
+
+ SOURCES += [
+ "googlemock/src/gmock-all.cc",
+ "googletest/src/gtest-all.cc",
+ ]
+
+ Library("gtest")
+
+ LOCAL_INCLUDES += [
+ "googlemock",
+ "googletest",
+ ]
+
+ if CONFIG["OS_ARCH"] == "WINNT":
+ DEFINES["UNICODE"] = True
+
+ FINAL_LIBRARY = "xul-gtest"
+"""
+
+ with open("moz.build", "w") as f:
+ f.write(mozbuild)