From e1dfa30e382461c2439c1bd2066bbe8546376472 Mon Sep 17 00:00:00 2001 From: Luke Aguilar Date: Wed, 2 Apr 2025 17:31:07 +1100 Subject: [PATCH 1/2] Add bazel support --- .gitignore | 39 +++++++++++++++++++++++++++++++++++++++ BUILD.bazel | 32 ++++++++++++++++++++++++++++++++ MODULE.bazel | 13 +++++++++++++ tests/BUILD.bazel | 10 ++++++++++ 4 files changed, 94 insertions(+) create mode 100644 BUILD.bazel create mode 100644 MODULE.bazel create mode 100644 tests/BUILD.bazel diff --git a/.gitignore b/.gitignore index c36c64c..0a66738 100644 --- a/.gitignore +++ b/.gitignore @@ -42,3 +42,42 @@ Makefile.in *.log *.trs *.pc + +# Bazel +MODULE.bazel.lock +# Ignore backup files. +*~ +# Ignore Vim swap files. +.*.swp +# macOS-specific excludes +.DS_Store +# Ignore files generated by IDEs. +/.aswb/ +/.bazelbsp/ +/.cache/ +/.classpath +/.clwb/ +/.factorypath +/.idea/ +/.ijwb/ +/.project +/.settings +/.vscode/ +.eclipse/ +.settings/ +.classpath +.project +eclipse-*bin/ +/bazel.iml +# Ignore all bazel-* symlinks. There is no full list since this can change +# based on the name of the directory bazel is cloned into. +/bazel-* +# Ignore outputs generated during Bazel bootstrapping. +/output/ +# Ignore jekyll build output. +/production +/.sass-cache +# Bazelisk version file +.bazelversion +# User-specific .bazelrc +user.bazelrc diff --git a/BUILD.bazel b/BUILD.bazel new file mode 100644 index 0000000..0d09f54 --- /dev/null +++ b/BUILD.bazel @@ -0,0 +1,32 @@ +load("@rules_cc//cc:defs.bzl", "cc_library") + +cc_library( + name = "unittest-cpp", + srcs = glob([ + "UnitTest++/*.h", + "UnitTest++/*.cpp", + ]) + select({ + "@platforms//os:windows": glob([ + "UnitTest++/Win32/*.h", + "UnitTest++/Win32/*.cpp", + ]), + "//conditions:default": glob([ + "UnitTest++/Posix/*.h", + "UnitTest++/Posix/*.cpp", + ]), + }), + hdrs = [ + "UnitTest++/UnitTest++.h", + "UnitTest++/UnitTestPP.h", + ], + copts = select({ + "@platforms//os:windows": [ + "-D_CRT_SECURE_NO_DEPRECATE", # Windows-specific define + ], + "//conditions:default": [ + "-std=c++11", # Default to C++11 for POSIX systems + ], + }), + includes = ["UnitTest++"], + visibility = ["//visibility:public"], +) diff --git a/MODULE.bazel b/MODULE.bazel new file mode 100644 index 0000000..ffa513d --- /dev/null +++ b/MODULE.bazel @@ -0,0 +1,13 @@ +""" +Module: unittest-cpp +Purpose: Provides the unittest++ library compileable as a Bazel target. Includes tests through Bazel +""" + +module( + name = "unittest-cpp", + version = "2.0.0-0.20201113052638-10e50ad70c69", + compatibility_level = 1, +) + +bazel_dep(name = "rules_cc", version = "0.1.1") +bazel_dep(name = "platforms", version = "0.0.11") diff --git a/tests/BUILD.bazel b/tests/BUILD.bazel new file mode 100644 index 0000000..b719333 --- /dev/null +++ b/tests/BUILD.bazel @@ -0,0 +1,10 @@ +load("@rules_cc//cc:defs.bzl", "cc_test") + +cc_test( + name = "all_tests", + srcs = glob([ + "*.h", + "*.cpp", + ]), + deps = ["//:unittest-cpp"], +) From 02424076e094f73e6c5100c310e5ccfebf8e7399 Mon Sep 17 00:00:00 2001 From: Luke Aguilar Date: Wed, 2 Apr 2025 21:05:29 +1100 Subject: [PATCH 2/2] Fixed version number --- MODULE.bazel | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MODULE.bazel b/MODULE.bazel index ffa513d..244e956 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -5,7 +5,7 @@ Purpose: Provides the unittest++ library compileable as a Bazel target. Includes module( name = "unittest-cpp", - version = "2.0.0-0.20201113052638-10e50ad70c69", + version = "2.0.1-0.20201113052638-10e50ad70c69", compatibility_level = 1, )