From 9a7208913d326ca7e840a9c0e237241b648b0899 Mon Sep 17 00:00:00 2001 From: Kyle Isom Date: Thu, 16 Feb 2023 19:56:49 -0800 Subject: [PATCH] Cut over to Bazel. --- .gitignore | 4 ++ CMakeLists.txt | 10 ++--- WORKSPACE | 8 ++++ docs/sphinx/conf.py | 2 +- extern/googletest | 1 - test/BUILD.bazel | 39 +++++++++++++++++++ tools/BUILD.bazel | 11 ++++++ wrmath/BUILD.bazel | 6 +++ {include/wrmath => wrmath}/filter.h | 0 {include/wrmath => wrmath}/filter/madgwick.h | 0 {include/wrmath => wrmath}/geom.h | 0 {include/wrmath => wrmath}/geom/orientation.h | 0 {include/wrmath => wrmath}/geom/quaternion.h | 1 + {include/wrmath => wrmath}/geom/vector.h | 0 {src => wrmath}/math.cc | 0 {include/wrmath => wrmath}/math.h | 6 +++ {src => wrmath}/orientation.cc | 0 {src => wrmath}/quaternion.cc | 0 18 files changed, 81 insertions(+), 7 deletions(-) create mode 100644 WORKSPACE delete mode 160000 extern/googletest create mode 100644 test/BUILD.bazel create mode 100644 tools/BUILD.bazel create mode 100644 wrmath/BUILD.bazel rename {include/wrmath => wrmath}/filter.h (100%) rename {include/wrmath => wrmath}/filter/madgwick.h (100%) rename {include/wrmath => wrmath}/geom.h (100%) rename {include/wrmath => wrmath}/geom/orientation.h (100%) rename {include/wrmath => wrmath}/geom/quaternion.h (99%) rename {include/wrmath => wrmath}/geom/vector.h (100%) rename {src => wrmath}/math.cc (100%) rename {include/wrmath => wrmath}/math.h (95%) rename {src => wrmath}/orientation.cc (100%) rename {src => wrmath}/quaternion.cc (100%) diff --git a/.gitignore b/.gitignore index 62c4dfc..e850549 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,7 @@ /docs/xml/ docs/sphinx/_build/ docs/sphinx/api/ +/bazel-bin/ +/bazel-out/ +/bazel-testlogs/ +/bazel-wrmath/ diff --git a/CMakeLists.txt b/CMakeLists.txt index 40f2ba6..acbcc79 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,7 +15,7 @@ set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH}) # Don't warn on unused functions, because this is a library and not all # functions might be used. -add_compile_options(-Werror -Wno-unused-function -Wall -g -O0) +# add_compile_options(-Werror -Wno-unused-function -Wall -g -O0) if (DEFINED ENV{CMAKE_GCOV}) add_compile_options(-fprofile-arcs -ftest-coverage) @@ -29,10 +29,10 @@ message(STATUS, "Code coverage enabled.") endif() -include_directories(include) +include_directories(wrmath) -file(GLOB_RECURSE ${PROJECT_NAME}_HEADERS include/**.h) -file(GLOB_RECURSE ${PROJECT_NAME}_SOURCES src/*.cc) +file(GLOB_RECURSE ${PROJECT_NAME}_HEADERS wrmath/**.h) +file(GLOB_RECURSE ${PROJECT_NAME}_SOURCES wrmath/*.cc) ## BUILD @@ -109,4 +109,4 @@ include(CMakePack.txt) ## DOCUMENTATE -add_subdirectory ("docs") +## add_subdirectory ("docs") diff --git a/WORKSPACE b/WORKSPACE new file mode 100644 index 0000000..3fad0a7 --- /dev/null +++ b/WORKSPACE @@ -0,0 +1,8 @@ +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") + +http_archive( + name = "com_google_googletest", + sha256 = "983a7f2f4cc2a4d75d94ee06300c46a657291fba965e355d11ab3b6965a7b0e5", + strip_prefix = "googletest-b796f7d44681514f58a683a3a71ff17c94edb0c1", + urls = ["https://github.com/google/googletest/archive/b796f7d44681514f58a683a3a71ff17c94edb0c1.zip"], +) diff --git a/docs/sphinx/conf.py b/docs/sphinx/conf.py index 2d9eb7c..19a5609 100644 --- a/docs/sphinx/conf.py +++ b/docs/sphinx/conf.py @@ -72,7 +72,7 @@ exhale_args = { "createTreeView": True, "exhaleExecutesDoxygen": True, "exhaleDoxygenStdin": """ -INPUT = ../../include ../../src +INPUT = ../../include ../../wrmath USE_XML = YES """ } diff --git a/extern/googletest b/extern/googletest deleted file mode 160000 index 4e29e48..0000000 --- a/extern/googletest +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 4e29e48840e611ecbef33d10960d7480d2e9034a diff --git a/test/BUILD.bazel b/test/BUILD.bazel new file mode 100644 index 0000000..884b942 --- /dev/null +++ b/test/BUILD.bazel @@ -0,0 +1,39 @@ +cc_test( + name = "madgwick_test", + size = "small", + srcs = ["madgwick_test.cc"], + deps = [ + "//wrmath", + "@com_google_googletest//:gtest_main", + ], +) + +cc_test( + name = "orientation_test", + size = "small", + srcs = ["orientation_test.cc"], + deps = [ + "//wrmath", + "@com_google_googletest//:gtest_main", + ], +) + +cc_test( + name = "quaternion_test", + size = "small", + srcs = ["quaternion_test.cc"], + deps = [ + "//wrmath", + "@com_google_googletest//:gtest_main", + ], +) + +cc_test( + name = "vector_test", + size = "small", + srcs = ["vector_test.cc"], + deps = [ + "//wrmath", + "@com_google_googletest//:gtest_main", + ], +) \ No newline at end of file diff --git a/tools/BUILD.bazel b/tools/BUILD.bazel new file mode 100644 index 0000000..55549b9 --- /dev/null +++ b/tools/BUILD.bazel @@ -0,0 +1,11 @@ +cc_binary( + name = "euler2quat", + srcs = ["euler2quat.cc"], + deps = ["//wrmath"], +) + +cc_binary( + name = "quaternion", + srcs = ["quaternion.cc"], + deps = ["//wrmath"], +) \ No newline at end of file diff --git a/wrmath/BUILD.bazel b/wrmath/BUILD.bazel new file mode 100644 index 0000000..9cc3fe6 --- /dev/null +++ b/wrmath/BUILD.bazel @@ -0,0 +1,6 @@ +cc_library( + name = "wrmath", + srcs = glob(["*.cc"]), + hdrs = glob(["**/*.h"]), + visibility = ["//visibility:public"], +) diff --git a/include/wrmath/filter.h b/wrmath/filter.h similarity index 100% rename from include/wrmath/filter.h rename to wrmath/filter.h diff --git a/include/wrmath/filter/madgwick.h b/wrmath/filter/madgwick.h similarity index 100% rename from include/wrmath/filter/madgwick.h rename to wrmath/filter/madgwick.h diff --git a/include/wrmath/geom.h b/wrmath/geom.h similarity index 100% rename from include/wrmath/geom.h rename to wrmath/geom.h diff --git a/include/wrmath/geom/orientation.h b/wrmath/geom/orientation.h similarity index 100% rename from include/wrmath/geom/orientation.h rename to wrmath/geom/orientation.h diff --git a/include/wrmath/geom/quaternion.h b/wrmath/geom/quaternion.h similarity index 99% rename from include/wrmath/geom/quaternion.h rename to wrmath/geom/quaternion.h index e27af9c..66fbb10 100644 --- a/include/wrmath/geom/quaternion.h +++ b/wrmath/geom/quaternion.h @@ -5,6 +5,7 @@ #include +#define _USE_MATH_DEFINES #include #include #include diff --git a/include/wrmath/geom/vector.h b/wrmath/geom/vector.h similarity index 100% rename from include/wrmath/geom/vector.h rename to wrmath/geom/vector.h diff --git a/src/math.cc b/wrmath/math.cc similarity index 100% rename from src/math.cc rename to wrmath/math.cc diff --git a/include/wrmath/math.h b/wrmath/math.h similarity index 95% rename from include/wrmath/math.h rename to wrmath/math.h index e69b9e9..daca2ec 100644 --- a/include/wrmath/math.h +++ b/wrmath/math.h @@ -3,9 +3,15 @@ #define __WRMATH_UTIL_MATH_H +#define _USE_MATH_DEFINES #include +#ifndef M_PI +#define M_PI 3.14159265359 +#endif + + namespace wr { /// math contains utility math functions. namespace math { diff --git a/src/orientation.cc b/wrmath/orientation.cc similarity index 100% rename from src/orientation.cc rename to wrmath/orientation.cc diff --git a/src/quaternion.cc b/wrmath/quaternion.cc similarity index 100% rename from src/quaternion.cc rename to wrmath/quaternion.cc