diff --git a/upstream_utils/drake-dllexport-dare.patch b/upstream_utils/drake-dllexport-dare.patch new file mode 100644 index 0000000000..9e5fb00cd7 --- /dev/null +++ b/upstream_utils/drake-dllexport-dare.patch @@ -0,0 +1,28 @@ +diff --git b/wpimath/src/main/native/include/drake/math/discrete_algebraic_riccati_equation.h a/wpimath/src/main/native/include/drake/math/discrete_algebraic_riccati_equation.h +index cb0a4ee13..5d7a316f3 100644 +--- b/wpimath/src/main/native/include/drake/math/discrete_algebraic_riccati_equation.h ++++ a/wpimath/src/main/native/include/drake/math/discrete_algebraic_riccati_equation.h +@@ -4,6 +4,7 @@ + #include + + #include ++#include + + namespace drake { + namespace math { +@@ -20,6 +21,7 @@ namespace math { + /// "On the Numerical Solution of the Discrete-Time Algebraic Riccati Equation" + /// by Thrasyvoulos Pappas, Alan J. Laub, and Nils R. Sandell + /// ++WPILIB_DLLEXPORT + Eigen::MatrixXd DiscreteAlgebraicRiccatiEquation( + const Eigen::Ref& A, + const Eigen::Ref& B, +@@ -69,6 +71,7 @@ Eigen::MatrixXd DiscreteAlgebraicRiccatiEquation( + /// @throws std::runtime_error if Q − NR⁻¹Nᵀ is not positive semi-definite. + /// @throws std::runtime_error if R is not positive definite. + /// ++WPILIB_DLLEXPORT + Eigen::MatrixXd DiscreteAlgebraicRiccatiEquation( + const Eigen::Ref& A, + const Eigen::Ref& B, diff --git a/upstream_utils/update_drake.py b/upstream_utils/update_drake.py index 4f7fa6b467..246857a473 100755 --- a/upstream_utils/update_drake.py +++ b/upstream_utils/update_drake.py @@ -8,7 +8,7 @@ from upstream_utils import setup_upstream_repo, comment_out_invalid_includes, wa def main(): root, repo = setup_upstream_repo("https://github.com/RobotLocomotion/drake", - "v0.33.0") + "v0.34.0") wpimath = os.path.join(root, "wpimath") # Delete old install @@ -61,7 +61,10 @@ def main(): os.path.join(wpimath, "src/test/native/include") ]) - apply_patches(root, ["upstream_utils/drake-replace-dense-with-core.patch"]) + apply_patches(root, [ + "upstream_utils/drake-dllexport-dare.patch", + "upstream_utils/drake-replace-dense-with-core.patch" + ]) if __name__ == "__main__": diff --git a/wpimath/src/main/native/include/drake/common/drake_assert.h b/wpimath/src/main/native/include/drake/common/drake_assert.h index 51fdfad468..88587fad79 100644 --- a/wpimath/src/main/native/include/drake/common/drake_assert.h +++ b/wpimath/src/main/native/include/drake/common/drake_assert.h @@ -88,6 +88,14 @@ namespace internal { // Report an assertion failure; will either Abort(...) or throw. [[noreturn]] void AssertionFailed(const char* condition, const char* func, const char* file, int line); +template +constexpr void DrakeAssertWasUsedWithRawPointer() {} +template<> +[[deprecated("\nDRAKE DEPRECATED: When using DRAKE_ASSERT or DRAKE_DEMAND on" +" a raw pointer, always write out DRAKE_ASSERT(foo != nullptr), do not write" +" DRAKE_ASSERT(foo) and rely on implicit pointer-to-bool conversion." +"\nThe deprecated code will be removed from Drake on or after 2021-12-01.")]] +constexpr void DrakeAssertWasUsedWithRawPointer() {} } // namespace internal namespace assert { // Allows for specialization of how to bool-convert Conditions used in @@ -114,6 +122,8 @@ struct ConditionTraits { typedef ::drake::assert::ConditionTraits< \ typename std::remove_cv_t> Trait; \ static_assert(Trait::is_valid, "Condition should be bool-convertible."); \ + ::drake::internal::DrakeAssertWasUsedWithRawPointer< \ + std::is_pointer_v>(); \ if (!Trait::Evaluate(condition)) { \ ::drake::internal::AssertionFailed( \ #condition, __func__, __FILE__, __LINE__); \ @@ -139,10 +149,14 @@ namespace drake { constexpr bool kDrakeAssertIsArmed = false; constexpr bool kDrakeAssertIsDisarmed = true; } // namespace drake -# define DRAKE_ASSERT(condition) static_assert( \ - ::drake::assert::ConditionTraits< \ - typename std::remove_cv_t>::is_valid, \ - "Condition should be bool-convertible."); +# define DRAKE_ASSERT(condition) do { \ + static_assert( \ + ::drake::assert::ConditionTraits< \ + typename std::remove_cv_t>::is_valid, \ + "Condition should be bool-convertible."); \ + ::drake::internal::DrakeAssertWasUsedWithRawPointer< \ + std::is_pointer_v>(); \ + } while (0) # define DRAKE_ASSERT_VOID(expression) static_assert( \ std::is_convertible_v, \ "Expression should be void.")