From 6b9d41182fcc762f57f3523ab0e7d1a4ee811c12 Mon Sep 17 00:00:00 2001 From: Jade Date: Tue, 16 Jul 2024 01:17:35 +0800 Subject: [PATCH 1/9] [sim] Fix WS sending 1 and 0 instead of booleans (#6836) --- .../src/main/native/cpp/WSProvider_SimDevice.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/simulation/halsim_ws_core/src/main/native/cpp/WSProvider_SimDevice.cpp b/simulation/halsim_ws_core/src/main/native/cpp/WSProvider_SimDevice.cpp index 93852b6703b..7c3d710f47c 100644 --- a/simulation/halsim_ws_core/src/main/native/cpp/WSProvider_SimDevice.cpp +++ b/simulation/halsim_ws_core/src/main/native/cpp/WSProvider_SimDevice.cpp @@ -188,7 +188,8 @@ void HALSimWSProviderSimDevice::OnValueChanged(SimDeviceValueData* valueData, if (ws) { switch (value->type) { case HAL_BOOLEAN: - ProcessHalCallback({{valueData->key, value->data.v_boolean}}); + ProcessHalCallback( + {{valueData->key, static_cast(value->data.v_boolean)}}); break; case HAL_DOUBLE: ProcessHalCallback( From 5825bf46d853dbd49e36a078c6ca1d8d6dfade7e Mon Sep 17 00:00:00 2001 From: Tyler Veness Date: Mon, 15 Jul 2024 14:41:40 -0700 Subject: [PATCH 2/9] [upstream_utils] Suppress has_denorm deprecation in Eigen (#6833) MSVC doesn't yet claim C++23 compliance for c++latest, so we have to be less specific in the preprocessor check. --- .../eigen_patches/0001-Disable-warnings.patch | 4 +- .../eigen_patches/0002-Intellisense-fix.patch | 2 +- ...orm-and-has_denorm_loss-deprecation-.patch | 89 +++++++++++++++++++ upstream_utils/update_eigen.py | 1 + .../Eigen/src/Core/arch/Default/BFloat16.h | 8 -- .../Eigen/src/Core/arch/Default/Half.h | 8 -- 6 files changed, 93 insertions(+), 19 deletions(-) create mode 100644 upstream_utils/eigen_patches/0003-Suppress-has_denorm-and-has_denorm_loss-deprecation-.patch diff --git a/upstream_utils/eigen_patches/0001-Disable-warnings.patch b/upstream_utils/eigen_patches/0001-Disable-warnings.patch index ace8aa06ace..ca9aee77ec8 100644 --- a/upstream_utils/eigen_patches/0001-Disable-warnings.patch +++ b/upstream_utils/eigen_patches/0001-Disable-warnings.patch @@ -1,14 +1,14 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Tyler Veness Date: Wed, 18 May 2022 09:14:24 -0700 -Subject: [PATCH 1/2] Disable warnings +Subject: [PATCH 1/3] Disable warnings --- Eigen/src/Core/util/DisableStupidWarnings.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Eigen/src/Core/util/DisableStupidWarnings.h b/Eigen/src/Core/util/DisableStupidWarnings.h -index 32a427d852355a51dc4263d81498554ff4c3cbba..9f3e3f5b0f15518377c9a8283fd58081902896f2 100644 +index 32a427d852355a51dc4263d81498554ff4c3cbba..1182198231ab784346f8d80838363e4a0abba2ba 100644 --- a/Eigen/src/Core/util/DisableStupidWarnings.h +++ b/Eigen/src/Core/util/DisableStupidWarnings.h @@ -81,6 +81,12 @@ diff --git a/upstream_utils/eigen_patches/0002-Intellisense-fix.patch b/upstream_utils/eigen_patches/0002-Intellisense-fix.patch index 46ac050cfe7..2c7d477f290 100644 --- a/upstream_utils/eigen_patches/0002-Intellisense-fix.patch +++ b/upstream_utils/eigen_patches/0002-Intellisense-fix.patch @@ -1,7 +1,7 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Peter Johnson Date: Fri, 20 Jan 2023 23:41:56 -0800 -Subject: [PATCH 2/2] Intellisense fix +Subject: [PATCH 2/3] Intellisense fix --- Eigen/src/Core/util/ConfigureVectorization.h | 7 +++++++ diff --git a/upstream_utils/eigen_patches/0003-Suppress-has_denorm-and-has_denorm_loss-deprecation-.patch b/upstream_utils/eigen_patches/0003-Suppress-has_denorm-and-has_denorm_loss-deprecation-.patch new file mode 100644 index 00000000000..d89c94f3a55 --- /dev/null +++ b/upstream_utils/eigen_patches/0003-Suppress-has_denorm-and-has_denorm_loss-deprecation-.patch @@ -0,0 +1,89 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Tyler Veness +Date: Sat, 13 Jul 2024 18:51:32 -0700 +Subject: [PATCH 3/3] Suppress has_denorm and has_denorm_loss deprecation + warnings + +MSVC doesn't yet claim C++23 compliance for c++latest, so we have to be +less specific in the preprocessor check. +--- + Eigen/src/Core/arch/Default/BFloat16.h | 8 -------- + Eigen/src/Core/arch/Default/Half.h | 8 -------- + 2 files changed, 16 deletions(-) + +diff --git a/Eigen/src/Core/arch/Default/BFloat16.h b/Eigen/src/Core/arch/Default/BFloat16.h +index 9e79a39a4c81d3c08868e3b70e64d56118a4efe8..14f0524a3b0e4ff836b77092949caafa0949a18c 100644 +--- a/Eigen/src/Core/arch/Default/BFloat16.h ++++ b/Eigen/src/Core/arch/Default/BFloat16.h +@@ -139,15 +139,11 @@ struct numeric_limits_bfloat16_impl { + static EIGEN_CONSTEXPR const bool has_infinity = true; + static EIGEN_CONSTEXPR const bool has_quiet_NaN = true; + static EIGEN_CONSTEXPR const bool has_signaling_NaN = true; +-#if __cplusplus >= 202302L + EIGEN_DIAGNOSTICS(push) + EIGEN_DISABLE_DEPRECATED_WARNING +-#endif + static EIGEN_CONSTEXPR const std::float_denorm_style has_denorm = std::denorm_present; + static EIGEN_CONSTEXPR const bool has_denorm_loss = false; +-#if __cplusplus >= 202302L + EIGEN_DIAGNOSTICS(pop) +-#endif + static EIGEN_CONSTEXPR const std::float_round_style round_style = std::numeric_limits::round_style; + static EIGEN_CONSTEXPR const bool is_iec559 = true; + // The C++ standard defines this as "true if the set of values representable +@@ -194,17 +190,13 @@ template + EIGEN_CONSTEXPR const bool numeric_limits_bfloat16_impl::has_quiet_NaN; + template + EIGEN_CONSTEXPR const bool numeric_limits_bfloat16_impl::has_signaling_NaN; +-#if __cplusplus >= 202302L + EIGEN_DIAGNOSTICS(push) + EIGEN_DISABLE_DEPRECATED_WARNING +-#endif + template + EIGEN_CONSTEXPR const std::float_denorm_style numeric_limits_bfloat16_impl::has_denorm; + template + EIGEN_CONSTEXPR const bool numeric_limits_bfloat16_impl::has_denorm_loss; +-#if __cplusplus >= 202302L + EIGEN_DIAGNOSTICS(pop) +-#endif + template + EIGEN_CONSTEXPR const std::float_round_style numeric_limits_bfloat16_impl::round_style; + template +diff --git a/Eigen/src/Core/arch/Default/Half.h b/Eigen/src/Core/arch/Default/Half.h +index 7754e8f27261f5e10eec8e1125b4869e01e5dde8..90d65c5e3cb099374179223d4b3e50d4991b06cd 100644 +--- a/Eigen/src/Core/arch/Default/Half.h ++++ b/Eigen/src/Core/arch/Default/Half.h +@@ -208,15 +208,11 @@ struct numeric_limits_half_impl { + static EIGEN_CONSTEXPR const bool has_infinity = true; + static EIGEN_CONSTEXPR const bool has_quiet_NaN = true; + static EIGEN_CONSTEXPR const bool has_signaling_NaN = true; +-#if __cplusplus >= 202302L + EIGEN_DIAGNOSTICS(push) + EIGEN_DISABLE_DEPRECATED_WARNING +-#endif + static EIGEN_CONSTEXPR const std::float_denorm_style has_denorm = std::denorm_present; + static EIGEN_CONSTEXPR const bool has_denorm_loss = false; +-#if __cplusplus >= 202302L + EIGEN_DIAGNOSTICS(pop) +-#endif + static EIGEN_CONSTEXPR const std::float_round_style round_style = std::round_to_nearest; + static EIGEN_CONSTEXPR const bool is_iec559 = true; + // The C++ standard defines this as "true if the set of values representable +@@ -263,17 +259,13 @@ template + EIGEN_CONSTEXPR const bool numeric_limits_half_impl::has_quiet_NaN; + template + EIGEN_CONSTEXPR const bool numeric_limits_half_impl::has_signaling_NaN; +-#if __cplusplus >= 202302L + EIGEN_DIAGNOSTICS(push) + EIGEN_DISABLE_DEPRECATED_WARNING +-#endif + template + EIGEN_CONSTEXPR const std::float_denorm_style numeric_limits_half_impl::has_denorm; + template + EIGEN_CONSTEXPR const bool numeric_limits_half_impl::has_denorm_loss; +-#if __cplusplus >= 202302L + EIGEN_DIAGNOSTICS(pop) +-#endif + template + EIGEN_CONSTEXPR const std::float_round_style numeric_limits_half_impl::round_style; + template diff --git a/upstream_utils/update_eigen.py b/upstream_utils/update_eigen.py index fd8cfb4ef60..66c82385e97 100755 --- a/upstream_utils/update_eigen.py +++ b/upstream_utils/update_eigen.py @@ -109,6 +109,7 @@ def main(): for f in [ "0001-Disable-warnings.patch", "0002-Intellisense-fix.patch", + "0003-Suppress-has_denorm-and-has_denorm_loss-deprecation-.patch", ]: git_am(os.path.join(wpilib_root, "upstream_utils/eigen_patches", f)) diff --git a/wpimath/src/main/native/thirdparty/eigen/include/Eigen/src/Core/arch/Default/BFloat16.h b/wpimath/src/main/native/thirdparty/eigen/include/Eigen/src/Core/arch/Default/BFloat16.h index 9e79a39a4c8..14f0524a3b0 100644 --- a/wpimath/src/main/native/thirdparty/eigen/include/Eigen/src/Core/arch/Default/BFloat16.h +++ b/wpimath/src/main/native/thirdparty/eigen/include/Eigen/src/Core/arch/Default/BFloat16.h @@ -139,15 +139,11 @@ struct numeric_limits_bfloat16_impl { static EIGEN_CONSTEXPR const bool has_infinity = true; static EIGEN_CONSTEXPR const bool has_quiet_NaN = true; static EIGEN_CONSTEXPR const bool has_signaling_NaN = true; -#if __cplusplus >= 202302L EIGEN_DIAGNOSTICS(push) EIGEN_DISABLE_DEPRECATED_WARNING -#endif static EIGEN_CONSTEXPR const std::float_denorm_style has_denorm = std::denorm_present; static EIGEN_CONSTEXPR const bool has_denorm_loss = false; -#if __cplusplus >= 202302L EIGEN_DIAGNOSTICS(pop) -#endif static EIGEN_CONSTEXPR const std::float_round_style round_style = std::numeric_limits::round_style; static EIGEN_CONSTEXPR const bool is_iec559 = true; // The C++ standard defines this as "true if the set of values representable @@ -194,17 +190,13 @@ template EIGEN_CONSTEXPR const bool numeric_limits_bfloat16_impl::has_quiet_NaN; template EIGEN_CONSTEXPR const bool numeric_limits_bfloat16_impl::has_signaling_NaN; -#if __cplusplus >= 202302L EIGEN_DIAGNOSTICS(push) EIGEN_DISABLE_DEPRECATED_WARNING -#endif template EIGEN_CONSTEXPR const std::float_denorm_style numeric_limits_bfloat16_impl::has_denorm; template EIGEN_CONSTEXPR const bool numeric_limits_bfloat16_impl::has_denorm_loss; -#if __cplusplus >= 202302L EIGEN_DIAGNOSTICS(pop) -#endif template EIGEN_CONSTEXPR const std::float_round_style numeric_limits_bfloat16_impl::round_style; template diff --git a/wpimath/src/main/native/thirdparty/eigen/include/Eigen/src/Core/arch/Default/Half.h b/wpimath/src/main/native/thirdparty/eigen/include/Eigen/src/Core/arch/Default/Half.h index 7754e8f2726..90d65c5e3cb 100644 --- a/wpimath/src/main/native/thirdparty/eigen/include/Eigen/src/Core/arch/Default/Half.h +++ b/wpimath/src/main/native/thirdparty/eigen/include/Eigen/src/Core/arch/Default/Half.h @@ -208,15 +208,11 @@ struct numeric_limits_half_impl { static EIGEN_CONSTEXPR const bool has_infinity = true; static EIGEN_CONSTEXPR const bool has_quiet_NaN = true; static EIGEN_CONSTEXPR const bool has_signaling_NaN = true; -#if __cplusplus >= 202302L EIGEN_DIAGNOSTICS(push) EIGEN_DISABLE_DEPRECATED_WARNING -#endif static EIGEN_CONSTEXPR const std::float_denorm_style has_denorm = std::denorm_present; static EIGEN_CONSTEXPR const bool has_denorm_loss = false; -#if __cplusplus >= 202302L EIGEN_DIAGNOSTICS(pop) -#endif static EIGEN_CONSTEXPR const std::float_round_style round_style = std::round_to_nearest; static EIGEN_CONSTEXPR const bool is_iec559 = true; // The C++ standard defines this as "true if the set of values representable @@ -263,17 +259,13 @@ template EIGEN_CONSTEXPR const bool numeric_limits_half_impl::has_quiet_NaN; template EIGEN_CONSTEXPR const bool numeric_limits_half_impl::has_signaling_NaN; -#if __cplusplus >= 202302L EIGEN_DIAGNOSTICS(push) EIGEN_DISABLE_DEPRECATED_WARNING -#endif template EIGEN_CONSTEXPR const std::float_denorm_style numeric_limits_half_impl::has_denorm; template EIGEN_CONSTEXPR const bool numeric_limits_half_impl::has_denorm_loss; -#if __cplusplus >= 202302L EIGEN_DIAGNOSTICS(pop) -#endif template EIGEN_CONSTEXPR const std::float_round_style numeric_limits_half_impl::round_style; template From 912d9b220192271b4aa98447dadaac085f98663f Mon Sep 17 00:00:00 2001 From: Tyler Veness Date: Mon, 15 Jul 2024 14:50:19 -0700 Subject: [PATCH 3/9] [upstream_utils] Fix LLVM's AlignedCharArrayUnion for C++23 (#6830) C++23 deprecated std::aligned_union_t. --- ...move-StringRef-ArrayRef-and-Optional.patch | 2 +- ...-calls-in-parens-for-Windows-warning.patch | 2 +- ...-Change-unique_function-storage-size.patch | 2 +- .../llvm_patches/0004-Threading-updates.patch | 2 +- .../0005-ifdef-guard-safety.patch | 2 +- .../0006-Explicitly-use-std.patch | 2 +- .../0007-Remove-format_provider.patch | 2 +- .../0008-Add-compiler-warning-pragmas.patch | 2 +- .../0009-Remove-unused-functions.patch | 2 +- .../0010-Detemplatize-SmallVectorBase.patch | 2 +- .../0011-Add-vectors-to-raw_ostream.patch | 2 +- .../0012-Extra-collections-features.patch | 2 +- .../0013-EpochTracker-ABI-macro.patch | 2 +- .../0014-Delete-numbers-from-MathExtras.patch | 2 +- .../llvm_patches/0015-Add-lerp-and-sgn.patch | 2 +- .../llvm_patches/0016-Fixup-includes.patch | 2 +- ...-std-is_trivially_copy_constructible.patch | 2 +- .../llvm_patches/0018-Windows-support.patch | 2 +- .../llvm_patches/0019-Prefer-fmtlib.patch | 2 +- .../llvm_patches/0020-Prefer-wpi-s-fs.h.patch | 2 +- .../0021-Remove-unused-functions.patch | 2 +- .../0022-OS-specific-changes.patch | 2 +- ...3-Use-SmallVector-for-UTF-conversion.patch | 2 +- ...o-use-static-pointers-in-raw_ostream.patch | 2 +- .../0025-constexpr-endian-byte-swap.patch | 2 +- ...-from-STLExtras.h-into-PointerUnion..patch | 2 +- ...-Remove-StringMap-test-for-llvm-sort.patch | 2 +- ...0028-Unused-variable-in-release-mode.patch | 2 +- .../0029-Use-C-20-bit-header.patch | 2 +- ...0-Remove-DenseMap-GTest-printer-test.patch | 2 +- ...ace-deprecated-std-aligned_storage_t.patch | 2 +- ...-raw_ostream-Add-SetNumBytesInBuffer.patch | 2 +- .../0033-type_traits.h-Add-is_constexpr.patch | 2 +- ...emoved-raw_string_ostream-write_impl.patch | 2 +- ...ove-auto-conversion-from-raw_ostream.patch | 2 +- .../0036-Add-SmallVector-erase_if.patch | 2 +- ...7-Fix-AlignedCharArrayUnion-for-C-23.patch | 39 +++++++++++++++++++ upstream_utils/update_llvm.py | 1 + .../thirdparty/llvm/include/wpi/AlignOf.h | 14 +++---- 39 files changed, 81 insertions(+), 45 deletions(-) create mode 100644 upstream_utils/llvm_patches/0037-Fix-AlignedCharArrayUnion-for-C-23.patch diff --git a/upstream_utils/llvm_patches/0001-Remove-StringRef-ArrayRef-and-Optional.patch b/upstream_utils/llvm_patches/0001-Remove-StringRef-ArrayRef-and-Optional.patch index 7ec8a38696e..a1c558bcb3d 100644 --- a/upstream_utils/llvm_patches/0001-Remove-StringRef-ArrayRef-and-Optional.patch +++ b/upstream_utils/llvm_patches/0001-Remove-StringRef-ArrayRef-and-Optional.patch @@ -1,7 +1,7 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Sat, 7 May 2022 22:09:18 -0400 -Subject: [PATCH 01/36] Remove StringRef, ArrayRef, and Optional +Subject: [PATCH 01/37] Remove StringRef, ArrayRef, and Optional --- llvm/include/llvm/ADT/PointerUnion.h | 1 - diff --git a/upstream_utils/llvm_patches/0002-Wrap-std-min-max-calls-in-parens-for-Windows-warning.patch b/upstream_utils/llvm_patches/0002-Wrap-std-min-max-calls-in-parens-for-Windows-warning.patch index 1e4335b5e89..51b7215c2c5 100644 --- a/upstream_utils/llvm_patches/0002-Wrap-std-min-max-calls-in-parens-for-Windows-warning.patch +++ b/upstream_utils/llvm_patches/0002-Wrap-std-min-max-calls-in-parens-for-Windows-warning.patch @@ -1,7 +1,7 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Sat, 7 May 2022 22:12:41 -0400 -Subject: [PATCH 02/36] Wrap std::min/max calls in parens, for Windows warnings +Subject: [PATCH 02/37] Wrap std::min/max calls in parens, for Windows warnings --- llvm/include/llvm/ADT/DenseMap.h | 4 ++-- diff --git a/upstream_utils/llvm_patches/0003-Change-unique_function-storage-size.patch b/upstream_utils/llvm_patches/0003-Change-unique_function-storage-size.patch index ff920af4b52..dfc643346e3 100644 --- a/upstream_utils/llvm_patches/0003-Change-unique_function-storage-size.patch +++ b/upstream_utils/llvm_patches/0003-Change-unique_function-storage-size.patch @@ -1,7 +1,7 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Sat, 7 May 2022 22:13:55 -0400 -Subject: [PATCH 03/36] Change unique_function storage size +Subject: [PATCH 03/37] Change unique_function storage size --- llvm/include/llvm/ADT/FunctionExtras.h | 4 ++-- diff --git a/upstream_utils/llvm_patches/0004-Threading-updates.patch b/upstream_utils/llvm_patches/0004-Threading-updates.patch index 894050c88d9..cee1b2eb6da 100644 --- a/upstream_utils/llvm_patches/0004-Threading-updates.patch +++ b/upstream_utils/llvm_patches/0004-Threading-updates.patch @@ -1,7 +1,7 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Sat, 7 May 2022 22:17:19 -0400 -Subject: [PATCH 04/36] Threading updates +Subject: [PATCH 04/37] Threading updates - Remove guards for threads and exception - Prefer scope gaurd over lock gaurd diff --git a/upstream_utils/llvm_patches/0005-ifdef-guard-safety.patch b/upstream_utils/llvm_patches/0005-ifdef-guard-safety.patch index 50d93406cf7..fcb8e5c3738 100644 --- a/upstream_utils/llvm_patches/0005-ifdef-guard-safety.patch +++ b/upstream_utils/llvm_patches/0005-ifdef-guard-safety.patch @@ -1,7 +1,7 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Sat, 7 May 2022 22:28:13 -0400 -Subject: [PATCH 05/36] \#ifdef guard safety +Subject: [PATCH 05/37] \#ifdef guard safety Prevents redefinition if someone is pulling in real LLVM, since the macros are in global namespace --- diff --git a/upstream_utils/llvm_patches/0006-Explicitly-use-std.patch b/upstream_utils/llvm_patches/0006-Explicitly-use-std.patch index 2fffd4a5de8..2f8ee1aafa4 100644 --- a/upstream_utils/llvm_patches/0006-Explicitly-use-std.patch +++ b/upstream_utils/llvm_patches/0006-Explicitly-use-std.patch @@ -1,7 +1,7 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Sat, 7 May 2022 22:37:34 -0400 -Subject: [PATCH 06/36] Explicitly use std:: +Subject: [PATCH 06/37] Explicitly use std:: --- llvm/include/llvm/ADT/SmallSet.h | 2 +- diff --git a/upstream_utils/llvm_patches/0007-Remove-format_provider.patch b/upstream_utils/llvm_patches/0007-Remove-format_provider.patch index 914aeb183ef..dc76e10c8d9 100644 --- a/upstream_utils/llvm_patches/0007-Remove-format_provider.patch +++ b/upstream_utils/llvm_patches/0007-Remove-format_provider.patch @@ -1,7 +1,7 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Sat, 7 May 2022 22:53:50 -0400 -Subject: [PATCH 07/36] Remove format_provider +Subject: [PATCH 07/37] Remove format_provider --- llvm/include/llvm/Support/Chrono.h | 114 ------------------------ diff --git a/upstream_utils/llvm_patches/0008-Add-compiler-warning-pragmas.patch b/upstream_utils/llvm_patches/0008-Add-compiler-warning-pragmas.patch index f5996fd9668..a325299c074 100644 --- a/upstream_utils/llvm_patches/0008-Add-compiler-warning-pragmas.patch +++ b/upstream_utils/llvm_patches/0008-Add-compiler-warning-pragmas.patch @@ -1,7 +1,7 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Sun, 8 May 2022 13:34:07 -0400 -Subject: [PATCH 08/36] Add compiler warning pragmas +Subject: [PATCH 08/37] Add compiler warning pragmas --- llvm/include/llvm/ADT/FunctionExtras.h | 11 +++++++++++ diff --git a/upstream_utils/llvm_patches/0009-Remove-unused-functions.patch b/upstream_utils/llvm_patches/0009-Remove-unused-functions.patch index 071e7891297..110c273bdf2 100644 --- a/upstream_utils/llvm_patches/0009-Remove-unused-functions.patch +++ b/upstream_utils/llvm_patches/0009-Remove-unused-functions.patch @@ -1,7 +1,7 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Sun, 8 May 2022 13:43:50 -0400 -Subject: [PATCH 09/36] Remove unused functions +Subject: [PATCH 09/37] Remove unused functions --- llvm/include/llvm/ADT/SmallString.h | 79 ------ diff --git a/upstream_utils/llvm_patches/0010-Detemplatize-SmallVectorBase.patch b/upstream_utils/llvm_patches/0010-Detemplatize-SmallVectorBase.patch index cdb642e87c5..a05d7019a8e 100644 --- a/upstream_utils/llvm_patches/0010-Detemplatize-SmallVectorBase.patch +++ b/upstream_utils/llvm_patches/0010-Detemplatize-SmallVectorBase.patch @@ -1,7 +1,7 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Thu, 5 May 2022 23:18:34 -0400 -Subject: [PATCH 10/36] Detemplatize SmallVectorBase +Subject: [PATCH 10/37] Detemplatize SmallVectorBase --- llvm/include/llvm/ADT/SmallVector.h | 35 ++++++++++----------------- diff --git a/upstream_utils/llvm_patches/0011-Add-vectors-to-raw_ostream.patch b/upstream_utils/llvm_patches/0011-Add-vectors-to-raw_ostream.patch index d9610107453..6d45796efd6 100644 --- a/upstream_utils/llvm_patches/0011-Add-vectors-to-raw_ostream.patch +++ b/upstream_utils/llvm_patches/0011-Add-vectors-to-raw_ostream.patch @@ -1,7 +1,7 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Sun, 8 May 2022 13:48:59 -0400 -Subject: [PATCH 11/36] Add vectors to raw_ostream +Subject: [PATCH 11/37] Add vectors to raw_ostream --- llvm/include/llvm/Support/raw_ostream.h | 115 ++++++++++++++++++++++++ diff --git a/upstream_utils/llvm_patches/0012-Extra-collections-features.patch b/upstream_utils/llvm_patches/0012-Extra-collections-features.patch index 42c18074880..2d4243eae73 100644 --- a/upstream_utils/llvm_patches/0012-Extra-collections-features.patch +++ b/upstream_utils/llvm_patches/0012-Extra-collections-features.patch @@ -1,7 +1,7 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Tue, 3 May 2022 22:16:10 -0400 -Subject: [PATCH 12/36] Extra collections features +Subject: [PATCH 12/37] Extra collections features --- llvm/include/llvm/ADT/StringMap.h | 103 +++++++++++++++++++++++++++++- diff --git a/upstream_utils/llvm_patches/0013-EpochTracker-ABI-macro.patch b/upstream_utils/llvm_patches/0013-EpochTracker-ABI-macro.patch index d142b8e81a7..7f74ecd9375 100644 --- a/upstream_utils/llvm_patches/0013-EpochTracker-ABI-macro.patch +++ b/upstream_utils/llvm_patches/0013-EpochTracker-ABI-macro.patch @@ -1,7 +1,7 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Wed, 4 May 2022 00:01:00 -0400 -Subject: [PATCH 13/36] EpochTracker ABI macro +Subject: [PATCH 13/37] EpochTracker ABI macro --- llvm/include/llvm/ADT/EpochTracker.h | 2 +- diff --git a/upstream_utils/llvm_patches/0014-Delete-numbers-from-MathExtras.patch b/upstream_utils/llvm_patches/0014-Delete-numbers-from-MathExtras.patch index ebf7baf9c71..a896f9b084f 100644 --- a/upstream_utils/llvm_patches/0014-Delete-numbers-from-MathExtras.patch +++ b/upstream_utils/llvm_patches/0014-Delete-numbers-from-MathExtras.patch @@ -1,7 +1,7 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Thu, 5 May 2022 18:09:45 -0400 -Subject: [PATCH 14/36] Delete numbers from MathExtras +Subject: [PATCH 14/37] Delete numbers from MathExtras --- llvm/include/llvm/Support/MathExtras.h | 36 -------------------------- diff --git a/upstream_utils/llvm_patches/0015-Add-lerp-and-sgn.patch b/upstream_utils/llvm_patches/0015-Add-lerp-and-sgn.patch index 92a744d351b..4612f614f2b 100644 --- a/upstream_utils/llvm_patches/0015-Add-lerp-and-sgn.patch +++ b/upstream_utils/llvm_patches/0015-Add-lerp-and-sgn.patch @@ -1,7 +1,7 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Tue, 3 May 2022 22:50:24 -0400 -Subject: [PATCH 15/36] Add lerp and sgn +Subject: [PATCH 15/37] Add lerp and sgn --- llvm/include/llvm/Support/MathExtras.h | 20 ++++++++++++++++++++ diff --git a/upstream_utils/llvm_patches/0016-Fixup-includes.patch b/upstream_utils/llvm_patches/0016-Fixup-includes.patch index faa4f49c780..cf04342f349 100644 --- a/upstream_utils/llvm_patches/0016-Fixup-includes.patch +++ b/upstream_utils/llvm_patches/0016-Fixup-includes.patch @@ -1,7 +1,7 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Sun, 8 May 2022 16:38:11 -0400 -Subject: [PATCH 16/36] Fixup includes +Subject: [PATCH 16/37] Fixup includes --- llvm/include/llvm/ADT/StringMap.h | 4 ++++ diff --git a/upstream_utils/llvm_patches/0017-Use-std-is_trivially_copy_constructible.patch b/upstream_utils/llvm_patches/0017-Use-std-is_trivially_copy_constructible.patch index 486d887d58e..40adf0eab90 100644 --- a/upstream_utils/llvm_patches/0017-Use-std-is_trivially_copy_constructible.patch +++ b/upstream_utils/llvm_patches/0017-Use-std-is_trivially_copy_constructible.patch @@ -1,7 +1,7 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Sun, 8 May 2022 16:42:09 -0400 -Subject: [PATCH 17/36] Use std::is_trivially_copy_constructible +Subject: [PATCH 17/37] Use std::is_trivially_copy_constructible --- llvm/include/llvm/Support/type_traits.h | 16 ---------------- diff --git a/upstream_utils/llvm_patches/0018-Windows-support.patch b/upstream_utils/llvm_patches/0018-Windows-support.patch index 15e423509bc..f9793cc69c6 100644 --- a/upstream_utils/llvm_patches/0018-Windows-support.patch +++ b/upstream_utils/llvm_patches/0018-Windows-support.patch @@ -1,7 +1,7 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Tue, 3 May 2022 20:22:38 -0400 -Subject: [PATCH 18/36] Windows support +Subject: [PATCH 18/37] Windows support --- .../llvm/Support/Windows/WindowsSupport.h | 45 +++++---- diff --git a/upstream_utils/llvm_patches/0019-Prefer-fmtlib.patch b/upstream_utils/llvm_patches/0019-Prefer-fmtlib.patch index c2704d278cc..8995a7e32a5 100644 --- a/upstream_utils/llvm_patches/0019-Prefer-fmtlib.patch +++ b/upstream_utils/llvm_patches/0019-Prefer-fmtlib.patch @@ -1,7 +1,7 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Sun, 8 May 2022 16:46:20 -0400 -Subject: [PATCH 19/36] Prefer fmtlib +Subject: [PATCH 19/37] Prefer fmtlib --- llvm/lib/Support/ErrorHandling.cpp | 20 ++++++-------------- diff --git a/upstream_utils/llvm_patches/0020-Prefer-wpi-s-fs.h.patch b/upstream_utils/llvm_patches/0020-Prefer-wpi-s-fs.h.patch index ad4189436d9..c8a6bd3c813 100644 --- a/upstream_utils/llvm_patches/0020-Prefer-wpi-s-fs.h.patch +++ b/upstream_utils/llvm_patches/0020-Prefer-wpi-s-fs.h.patch @@ -1,7 +1,7 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Sun, 8 May 2022 16:49:36 -0400 -Subject: [PATCH 20/36] Prefer wpi's fs.h +Subject: [PATCH 20/37] Prefer wpi's fs.h --- llvm/include/llvm/Support/raw_ostream.h | 7 ++----- diff --git a/upstream_utils/llvm_patches/0021-Remove-unused-functions.patch b/upstream_utils/llvm_patches/0021-Remove-unused-functions.patch index c326bc4cbe1..ec263b299ed 100644 --- a/upstream_utils/llvm_patches/0021-Remove-unused-functions.patch +++ b/upstream_utils/llvm_patches/0021-Remove-unused-functions.patch @@ -1,7 +1,7 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Sun, 8 May 2022 19:16:51 -0400 -Subject: [PATCH 21/36] Remove unused functions +Subject: [PATCH 21/37] Remove unused functions --- llvm/include/llvm/Support/raw_ostream.h | 5 +- diff --git a/upstream_utils/llvm_patches/0022-OS-specific-changes.patch b/upstream_utils/llvm_patches/0022-OS-specific-changes.patch index 91f1302b168..1f0d6112673 100644 --- a/upstream_utils/llvm_patches/0022-OS-specific-changes.patch +++ b/upstream_utils/llvm_patches/0022-OS-specific-changes.patch @@ -1,7 +1,7 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Sun, 8 May 2022 19:30:43 -0400 -Subject: [PATCH 22/36] OS-specific changes +Subject: [PATCH 22/37] OS-specific changes --- llvm/lib/Support/ErrorHandling.cpp | 16 +++++++--------- diff --git a/upstream_utils/llvm_patches/0023-Use-SmallVector-for-UTF-conversion.patch b/upstream_utils/llvm_patches/0023-Use-SmallVector-for-UTF-conversion.patch index bb096a2b05f..84fc17c40b7 100644 --- a/upstream_utils/llvm_patches/0023-Use-SmallVector-for-UTF-conversion.patch +++ b/upstream_utils/llvm_patches/0023-Use-SmallVector-for-UTF-conversion.patch @@ -1,7 +1,7 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Mon, 9 May 2022 00:04:30 -0400 -Subject: [PATCH 23/36] Use SmallVector for UTF conversion +Subject: [PATCH 23/37] Use SmallVector for UTF conversion --- llvm/include/llvm/Support/ConvertUTF.h | 6 +++--- diff --git a/upstream_utils/llvm_patches/0024-Prefer-to-use-static-pointers-in-raw_ostream.patch b/upstream_utils/llvm_patches/0024-Prefer-to-use-static-pointers-in-raw_ostream.patch index ecab45a58bd..d37d60d4dd3 100644 --- a/upstream_utils/llvm_patches/0024-Prefer-to-use-static-pointers-in-raw_ostream.patch +++ b/upstream_utils/llvm_patches/0024-Prefer-to-use-static-pointers-in-raw_ostream.patch @@ -1,7 +1,7 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Thu, 19 May 2022 00:58:36 -0400 -Subject: [PATCH 24/36] Prefer to use static pointers in raw_ostream +Subject: [PATCH 24/37] Prefer to use static pointers in raw_ostream See #1401 --- diff --git a/upstream_utils/llvm_patches/0025-constexpr-endian-byte-swap.patch b/upstream_utils/llvm_patches/0025-constexpr-endian-byte-swap.patch index 5b13f98db01..2770541a963 100644 --- a/upstream_utils/llvm_patches/0025-constexpr-endian-byte-swap.patch +++ b/upstream_utils/llvm_patches/0025-constexpr-endian-byte-swap.patch @@ -1,7 +1,7 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Fri, 1 Mar 2024 11:56:17 -0800 -Subject: [PATCH 25/36] constexpr endian byte swap +Subject: [PATCH 25/37] constexpr endian byte swap --- llvm/include/llvm/Support/Endian.h | 4 +++- diff --git a/upstream_utils/llvm_patches/0026-Copy-type-traits-from-STLExtras.h-into-PointerUnion..patch b/upstream_utils/llvm_patches/0026-Copy-type-traits-from-STLExtras.h-into-PointerUnion..patch index 28831db7bc6..13bb23fde53 100644 --- a/upstream_utils/llvm_patches/0026-Copy-type-traits-from-STLExtras.h-into-PointerUnion..patch +++ b/upstream_utils/llvm_patches/0026-Copy-type-traits-from-STLExtras.h-into-PointerUnion..patch @@ -1,7 +1,7 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Tyler Veness Date: Wed, 10 Aug 2022 17:07:52 -0700 -Subject: [PATCH 26/36] Copy type traits from STLExtras.h into PointerUnion.h +Subject: [PATCH 26/37] Copy type traits from STLExtras.h into PointerUnion.h --- llvm/include/llvm/ADT/PointerUnion.h | 46 ++++++++++++++++++++++++++++ diff --git a/upstream_utils/llvm_patches/0027-Remove-StringMap-test-for-llvm-sort.patch b/upstream_utils/llvm_patches/0027-Remove-StringMap-test-for-llvm-sort.patch index a6356bfd6ac..f238466956d 100644 --- a/upstream_utils/llvm_patches/0027-Remove-StringMap-test-for-llvm-sort.patch +++ b/upstream_utils/llvm_patches/0027-Remove-StringMap-test-for-llvm-sort.patch @@ -1,7 +1,7 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Tyler Veness Date: Wed, 10 Aug 2022 22:35:00 -0700 -Subject: [PATCH 27/36] Remove StringMap test for llvm::sort() +Subject: [PATCH 27/37] Remove StringMap test for llvm::sort() --- llvm/unittests/ADT/StringMapTest.cpp | 14 -------------- diff --git a/upstream_utils/llvm_patches/0028-Unused-variable-in-release-mode.patch b/upstream_utils/llvm_patches/0028-Unused-variable-in-release-mode.patch index 3841f9d7068..3cbe6ff2c5f 100644 --- a/upstream_utils/llvm_patches/0028-Unused-variable-in-release-mode.patch +++ b/upstream_utils/llvm_patches/0028-Unused-variable-in-release-mode.patch @@ -1,7 +1,7 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Leander Schulten Date: Mon, 10 Jul 2023 00:53:43 +0200 -Subject: [PATCH 28/36] Unused variable in release mode +Subject: [PATCH 28/37] Unused variable in release mode --- llvm/include/llvm/ADT/DenseMap.h | 2 +- diff --git a/upstream_utils/llvm_patches/0029-Use-C-20-bit-header.patch b/upstream_utils/llvm_patches/0029-Use-C-20-bit-header.patch index a0c7919f458..567fa7f7b74 100644 --- a/upstream_utils/llvm_patches/0029-Use-C-20-bit-header.patch +++ b/upstream_utils/llvm_patches/0029-Use-C-20-bit-header.patch @@ -1,7 +1,7 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Tyler Veness Date: Tue, 11 Jul 2023 22:56:09 -0700 -Subject: [PATCH 29/36] Use C++20 header +Subject: [PATCH 29/37] Use C++20 header --- llvm/include/llvm/ADT/DenseMap.h | 3 +- diff --git a/upstream_utils/llvm_patches/0030-Remove-DenseMap-GTest-printer-test.patch b/upstream_utils/llvm_patches/0030-Remove-DenseMap-GTest-printer-test.patch index b3cdfa81b17..8cf920d2752 100644 --- a/upstream_utils/llvm_patches/0030-Remove-DenseMap-GTest-printer-test.patch +++ b/upstream_utils/llvm_patches/0030-Remove-DenseMap-GTest-printer-test.patch @@ -1,7 +1,7 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Tyler Veness Date: Sun, 30 Jul 2023 14:17:37 -0700 -Subject: [PATCH 30/36] Remove DenseMap GTest printer test +Subject: [PATCH 30/37] Remove DenseMap GTest printer test LLVM modifies internal GTest headers to support it, which we can't do. --- diff --git a/upstream_utils/llvm_patches/0031-Replace-deprecated-std-aligned_storage_t.patch b/upstream_utils/llvm_patches/0031-Replace-deprecated-std-aligned_storage_t.patch index b68a78e4dd0..e31e52869ed 100644 --- a/upstream_utils/llvm_patches/0031-Replace-deprecated-std-aligned_storage_t.patch +++ b/upstream_utils/llvm_patches/0031-Replace-deprecated-std-aligned_storage_t.patch @@ -1,7 +1,7 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Tyler Veness Date: Fri, 15 Sep 2023 18:26:50 -0700 -Subject: [PATCH 31/36] Replace deprecated std::aligned_storage_t +Subject: [PATCH 31/37] Replace deprecated std::aligned_storage_t --- llvm/include/llvm/ADT/FunctionExtras.h | 4 ++-- diff --git a/upstream_utils/llvm_patches/0032-raw_ostream-Add-SetNumBytesInBuffer.patch b/upstream_utils/llvm_patches/0032-raw_ostream-Add-SetNumBytesInBuffer.patch index db3c34e670f..f90c64d2762 100644 --- a/upstream_utils/llvm_patches/0032-raw_ostream-Add-SetNumBytesInBuffer.patch +++ b/upstream_utils/llvm_patches/0032-raw_ostream-Add-SetNumBytesInBuffer.patch @@ -1,7 +1,7 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Peter Johnson Date: Sun, 29 Oct 2023 23:00:08 -0700 -Subject: [PATCH 32/36] raw_ostream: Add SetNumBytesInBuffer +Subject: [PATCH 32/37] raw_ostream: Add SetNumBytesInBuffer --- llvm/include/llvm/Support/raw_ostream.h | 5 +++++ diff --git a/upstream_utils/llvm_patches/0033-type_traits.h-Add-is_constexpr.patch b/upstream_utils/llvm_patches/0033-type_traits.h-Add-is_constexpr.patch index 1b2497e7d66..51d178286f0 100644 --- a/upstream_utils/llvm_patches/0033-type_traits.h-Add-is_constexpr.patch +++ b/upstream_utils/llvm_patches/0033-type_traits.h-Add-is_constexpr.patch @@ -1,7 +1,7 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Peter Johnson Date: Sat, 2 Dec 2023 15:21:32 -0800 -Subject: [PATCH 33/36] type_traits.h: Add is_constexpr() +Subject: [PATCH 33/37] type_traits.h: Add is_constexpr() --- llvm/include/llvm/Support/type_traits.h | 5 +++++ diff --git a/upstream_utils/llvm_patches/0034-Add-back-removed-raw_string_ostream-write_impl.patch b/upstream_utils/llvm_patches/0034-Add-back-removed-raw_string_ostream-write_impl.patch index ff650b7f290..fe5a59cae64 100644 --- a/upstream_utils/llvm_patches/0034-Add-back-removed-raw_string_ostream-write_impl.patch +++ b/upstream_utils/llvm_patches/0034-Add-back-removed-raw_string_ostream-write_impl.patch @@ -1,7 +1,7 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Tyler Veness Date: Fri, 1 Mar 2024 11:37:36 -0800 -Subject: [PATCH 34/36] Add back removed raw_string_ostream::write_impl() +Subject: [PATCH 34/37] Add back removed raw_string_ostream::write_impl() --- llvm/lib/Support/raw_ostream.cpp | 8 ++++++++ diff --git a/upstream_utils/llvm_patches/0035-Remove-auto-conversion-from-raw_ostream.patch b/upstream_utils/llvm_patches/0035-Remove-auto-conversion-from-raw_ostream.patch index df8bd0aefab..5487edc3aef 100644 --- a/upstream_utils/llvm_patches/0035-Remove-auto-conversion-from-raw_ostream.patch +++ b/upstream_utils/llvm_patches/0035-Remove-auto-conversion-from-raw_ostream.patch @@ -1,7 +1,7 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Tyler Veness Date: Sun, 17 Mar 2024 14:51:11 -0700 -Subject: [PATCH 35/36] Remove auto-conversion from raw_ostream +Subject: [PATCH 35/37] Remove auto-conversion from raw_ostream --- llvm/lib/Support/raw_ostream.cpp | 9 --------- diff --git a/upstream_utils/llvm_patches/0036-Add-SmallVector-erase_if.patch b/upstream_utils/llvm_patches/0036-Add-SmallVector-erase_if.patch index 78bb7ee6293..8bff0003604 100644 --- a/upstream_utils/llvm_patches/0036-Add-SmallVector-erase_if.patch +++ b/upstream_utils/llvm_patches/0036-Add-SmallVector-erase_if.patch @@ -1,7 +1,7 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Tyler Veness Date: Tue, 18 Jun 2024 09:07:33 -0700 -Subject: [PATCH 36/36] Add SmallVector erase_if() +Subject: [PATCH 36/37] Add SmallVector erase_if() --- llvm/include/llvm/ADT/SmallVector.h | 8 ++++++++ diff --git a/upstream_utils/llvm_patches/0037-Fix-AlignedCharArrayUnion-for-C-23.patch b/upstream_utils/llvm_patches/0037-Fix-AlignedCharArrayUnion-for-C-23.patch new file mode 100644 index 00000000000..a0a25ce8033 --- /dev/null +++ b/upstream_utils/llvm_patches/0037-Fix-AlignedCharArrayUnion-for-C-23.patch @@ -0,0 +1,39 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Tyler Veness +Date: Sat, 13 Jul 2024 15:24:30 -0700 +Subject: [PATCH 37/37] Fix AlignedCharArrayUnion for C++23 + +--- + llvm/include/llvm/Support/AlignOf.h | 14 +++++--------- + 1 file changed, 5 insertions(+), 9 deletions(-) + +diff --git a/llvm/include/llvm/Support/AlignOf.h b/llvm/include/llvm/Support/AlignOf.h +index f586d7f182aab6e56b7fae6ae98a7cd89e63976c..ca98a564733a07a5e16122d31805e970bf76b673 100644 +--- a/llvm/include/llvm/Support/AlignOf.h ++++ b/llvm/include/llvm/Support/AlignOf.h +@@ -13,20 +13,16 @@ + #ifndef LLVM_SUPPORT_ALIGNOF_H + #define LLVM_SUPPORT_ALIGNOF_H + +-#include ++#include ++#include + + namespace llvm { + + /// A suitably aligned and sized character array member which can hold elements + /// of any type. +-/// +-/// This template is equivalent to std::aligned_union_t<1, ...>, but we cannot +-/// use it due to a bug in the MSVC x86 compiler: +-/// https://github.com/microsoft/STL/issues/1533 +-/// Using `alignas` here works around the bug. +-template struct AlignedCharArrayUnion { +- using AlignedUnion = std::aligned_union_t<1, T, Ts...>; +- alignas(alignof(AlignedUnion)) char buffer[sizeof(AlignedUnion)]; ++template struct AlignedCharArrayUnion { ++ alignas((std::max)({alignof(Ts)...})) ++ std::byte buffer[(std::max)({static_cast(1), sizeof(Ts)...})]; + }; + + } // end namespace llvm diff --git a/upstream_utils/update_llvm.py b/upstream_utils/update_llvm.py index 9180442a631..d2d3c379df6 100755 --- a/upstream_utils/update_llvm.py +++ b/upstream_utils/update_llvm.py @@ -214,6 +214,7 @@ def main(): "0034-Add-back-removed-raw_string_ostream-write_impl.patch", "0035-Remove-auto-conversion-from-raw_ostream.patch", "0036-Add-SmallVector-erase_if.patch", + "0037-Fix-AlignedCharArrayUnion-for-C-23.patch", ]: git_am( os.path.join(wpilib_root, "upstream_utils/llvm_patches", f), diff --git a/wpiutil/src/main/native/thirdparty/llvm/include/wpi/AlignOf.h b/wpiutil/src/main/native/thirdparty/llvm/include/wpi/AlignOf.h index 5d400e48071..515455c96d0 100644 --- a/wpiutil/src/main/native/thirdparty/llvm/include/wpi/AlignOf.h +++ b/wpiutil/src/main/native/thirdparty/llvm/include/wpi/AlignOf.h @@ -13,20 +13,16 @@ #ifndef WPIUTIL_WPI_ALIGNOF_H #define WPIUTIL_WPI_ALIGNOF_H -#include +#include +#include namespace wpi { /// A suitably aligned and sized character array member which can hold elements /// of any type. -/// -/// This template is equivalent to std::aligned_union_t<1, ...>, but we cannot -/// use it due to a bug in the MSVC x86 compiler: -/// https://github.com/microsoft/STL/issues/1533 -/// Using `alignas` here works around the bug. -template struct AlignedCharArrayUnion { - using AlignedUnion = std::aligned_union_t<1, T, Ts...>; - alignas(alignof(AlignedUnion)) char buffer[sizeof(AlignedUnion)]; +template struct AlignedCharArrayUnion { + alignas((std::max)({alignof(Ts)...})) + std::byte buffer[(std::max)({static_cast(1), sizeof(Ts)...})]; }; } // end namespace wpi From fc57f6a560df94be3d367cd45ee387ffe429d6e5 Mon Sep 17 00:00:00 2001 From: sciencewhiz Date: Mon, 15 Jul 2024 14:51:10 -0700 Subject: [PATCH 4/9] [ci] Filter python commands comment only for Java sources (#6832) Co-authored-by: David Vo --- .github/workflows/command-robotpy-pr.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/command-robotpy-pr.yml b/.github/workflows/command-robotpy-pr.yml index 7fa28eec1c5..2ba4d6b07fc 100644 --- a/.github/workflows/command-robotpy-pr.yml +++ b/.github/workflows/command-robotpy-pr.yml @@ -5,7 +5,7 @@ on: types: - opened paths: - - 'wpilibNewCommands/**' + - 'wpilibNewCommands/src/**/*.java' jobs: comment: From 9703142ebe926f320f5e339d094dfe541a99bafb Mon Sep 17 00:00:00 2001 From: Gold856 <117957790+Gold856@users.noreply.github.com> Date: Mon, 15 Jul 2024 18:12:41 -0400 Subject: [PATCH 5/9] [build] CMake: simplify source JAR creation and install (#6831) Bump required minimum CMake version to 3.21. --- CMakeLists.txt | 2 +- apriltag/CMakeLists.txt | 16 +++---- cameraserver/CMakeLists.txt | 15 +++---- cmake/modules/CreateSourceJar.cmake | 34 +++++++++++++++ cscore/CMakeLists.txt | 15 +++---- hal/CMakeLists.txt | 24 +++-------- ntcore/CMakeLists.txt | 19 +++------ romiVendordep/CMakeLists.txt | 13 +++--- wpilibNewCommands/CMakeLists.txt | 21 +++------ wpilibj/CMakeLists.txt | 66 +++++++++-------------------- wpimath/CMakeLists.txt | 48 +++------------------ wpinet/CMakeLists.txt | 13 +++--- wpiunits/CMakeLists.txt | 13 ++++++ wpiutil/CMakeLists.txt | 23 +++------- xrpVendordep/CMakeLists.txt | 13 +++--- 15 files changed, 131 insertions(+), 204 deletions(-) create mode 100644 cmake/modules/CreateSourceJar.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 957114d2805..ba4eba9029b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,7 +15,7 @@ if("${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "Windows") message(STATUS "Platform version: ${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION}") endif() -cmake_minimum_required(VERSION 3.11) +cmake_minimum_required(VERSION 3.21) project(allwpilib) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules") diff --git a/apriltag/CMakeLists.txt b/apriltag/CMakeLists.txt index 9be0eaa2675..72360354491 100644 --- a/apriltag/CMakeLists.txt +++ b/apriltag/CMakeLists.txt @@ -87,22 +87,16 @@ endif() if(WITH_JAVA_SOURCE) include(UseJava) - file(GLOB APRILTAG_SOURCES src/main/java/edu/wpi/first/apriltag/*.java) - add_jar( + include(CreateSourceJar) + add_source_jar( apriltag_src_jar - RESOURCES - NAMESPACE "edu/wpi/first/apriltag" ${APRILTAG_SOURCES} - NAMESPACE - "edu/wpi/first/apriltag/jni" - src/main/java/edu/wpi/first/apriltag/jni/AprilTagJNI.java + BASE_DIRECTORIES ${CMAKE_CURRENT_SOURCE_DIR}/src/main/java OUTPUT_NAME apriltag-sources OUTPUT_DIR ${WPILIB_BINARY_DIR}/${java_lib_dest} ) - - get_property(APRILTAG_SRC_JAR_FILE TARGET apriltag_src_jar PROPERTY JAR_FILE) - install(FILES ${APRILTAG_SRC_JAR_FILE} DESTINATION "${java_lib_dest}") - set_property(TARGET apriltag_src_jar PROPERTY FOLDER "java") + + install_jar(apriltag_src_jar DESTINATION ${java_lib_dest}) endif() generate_resources( diff --git a/cameraserver/CMakeLists.txt b/cameraserver/CMakeLists.txt index 2ea645470e2..3b04c94bba1 100644 --- a/cameraserver/CMakeLists.txt +++ b/cameraserver/CMakeLists.txt @@ -42,21 +42,16 @@ endif() if(WITH_JAVA_SOURCE) include(UseJava) - file(GLOB CAMERASERVER_SOURCES src/main/java/edu/wpi/first/cameraserver/*.java) - file(GLOB VISION_SOURCES src/main/java/edu/wpi/first/vision/*.java) - add_jar( + include(CreateSourceJar) + add_source_jar( cameraserver_src_jar - RESOURCES - NAMESPACE "edu/wpi/first/cameraserver" ${CAMERASERVER_SOURCES} - NAMESPACE "edu/wpi/first/vision" ${VISION_SOURCES} + BASE_DIRECTORIES ${CMAKE_CURRENT_SOURCE_DIR}/src/main/java OUTPUT_NAME cameraserver-sources OUTPUT_DIR ${WPILIB_BINARY_DIR}/${java_lib_dest} ) - - get_property(CAMERASERVER_SRC_JAR_FILE TARGET cameraserver_src_jar PROPERTY JAR_FILE) - install(FILES ${CAMERASERVER_SRC_JAR_FILE} DESTINATION "${java_lib_dest}") - set_property(TARGET cameraserver_src_jar PROPERTY FOLDER "java") + + install_jar(cameraserver_src_jar DESTINATION ${java_lib_dest}) endif() file(GLOB_RECURSE cameraserver_native_src src/main/native/cpp/*.cpp) diff --git a/cmake/modules/CreateSourceJar.cmake b/cmake/modules/CreateSourceJar.cmake new file mode 100644 index 00000000000..cb83866eb85 --- /dev/null +++ b/cmake/modules/CreateSourceJar.cmake @@ -0,0 +1,34 @@ +macro(add_source_jar target) + set(oneValueArgs OUTPUT_NAME OUTPUT_DIR) + cmake_parse_arguments(SOURCE_JAR "" "${oneValueArgs}" "BASE_DIRECTORIES" ${ARGN}) + foreach(base_package_dir ${SOURCE_JAR_BASE_DIRECTORIES}) + file(GLOB_RECURSE directories LIST_DIRECTORIES true ${base_package_dir}/*.directoriesonly) + # Find all packages + foreach(directory ${directories}) + cmake_path( + RELATIVE_PATH + directory + BASE_DIRECTORY ${base_package_dir} + OUTPUT_VARIABLE package_name + ) + file(GLOB package_sources ${directory}/*.java) + if(package_sources STREQUAL "") + continue() + endif() + # If package sources are scattered across different places, consolidate them under one package + list(FIND packages ${package_name} index) + if(index EQUAL -1) + list(APPEND packages ${package_name}) + endif() + list(APPEND ${package_name} ${package_sources}) + endforeach() + endforeach() + set(resources "") + foreach(package ${packages}) + string(APPEND resources "NAMESPACE \"${package}\" ${${package}} ") + endforeach() + cmake_language( + EVAL CODE + "add_jar(${target} RESOURCES ${resources} OUTPUT_NAME ${SOURCE_JAR_OUTPUT_NAME} OUTPUT_DIR ${SOURCE_JAR_OUTPUT_DIR})" + ) +endmacro() diff --git a/cscore/CMakeLists.txt b/cscore/CMakeLists.txt index 24b605e9026..8bc10478d4a 100644 --- a/cscore/CMakeLists.txt +++ b/cscore/CMakeLists.txt @@ -129,21 +129,16 @@ endif() if(WITH_JAVA_SOURCE) include(UseJava) - file(GLOB CSCORE_SOURCES src/main/java/edu/wpi/first/cscore/*.java) - file(GLOB CSCORE_RAW_SOURCES src/main/java/edu/wpi/first/cscore/raw/*.java) - add_jar( + include(CreateSourceJar) + add_source_jar( cscore_src_jar - RESOURCES - NAMESPACE "edu/wpi/first/cscore" ${CSCORE_SOURCES} - NAMESPACE "edu/wpi/first/cscore/raw" ${CSCORE_RAW_SOURCES} + BASE_DIRECTORIES ${CMAKE_CURRENT_SOURCE_DIR}/src/main/java OUTPUT_NAME cscore-sources OUTPUT_DIR ${WPILIB_BINARY_DIR}/${java_lib_dest} ) - - get_property(CSCORE_SRC_JAR_FILE TARGET cscore_src_jar PROPERTY JAR_FILE) - install(FILES ${CSCORE_SRC_JAR_FILE} DESTINATION "${java_lib_dest}") - set_property(TARGET cscore_src_jar PROPERTY FOLDER "java") + + install_jar(cscore_src_jar DESTINATION ${java_lib_dest}) endif() if(WITH_TESTS) diff --git a/hal/CMakeLists.txt b/hal/CMakeLists.txt index 31f640cec8a..1b8c49b4c80 100644 --- a/hal/CMakeLists.txt +++ b/hal/CMakeLists.txt @@ -80,28 +80,18 @@ endif() if(WITH_JAVA_SOURCE) include(UseJava) - file(GLOB HAL_SOURCES src/main/java/edu/wpi/first/hal/*.java src/generated/main/java/*.java) - file(GLOB HAL_CAN_SOURCES src/main/java/edu/wpi/first/hal/can/*.java) - file(GLOB HAL_SIMULATION_SOURCES src/main/java/edu/wpi/first/hal/simulation/*.java) - file(GLOB HAL_UTIL_SOURCES src/main/java/edu/wpi/first/hal/util/*.java) - add_jar( + include(CreateSourceJar) + add_source_jar( hal_src_jar - RESOURCES - NAMESPACE "edu/wpi/first/hal" ${HAL_SOURCES} - NAMESPACE "edu/wpi/first/hal/can" ${HAL_CAN_SOURCES} - NAMESPACE - "edu/wpi/first/hal/communication" - src/main/java/edu/wpi/first/hal/communication/NIRioStatus.java - NAMESPACE "edu/wpi/first/hal/simulation" ${HAL_SIMULATION_SOURCES} - NAMESPACE "edu/wpi/first/hal/util" ${HAL_UTIL_SOURCES} + BASE_DIRECTORIES + ${CMAKE_CURRENT_SOURCE_DIR}/src/main/java + ${CMAKE_CURRENT_SOURCE_DIR}/src/generated/main/java OUTPUT_NAME wpiHal-sources OUTPUT_DIR ${WPILIB_BINARY_DIR}/${java_lib_dest} ) - - get_property(HAL_SRC_JAR_FILE TARGET hal_src_jar PROPERTY JAR_FILE) - install(FILES ${HAL_SRC_JAR_FILE} DESTINATION "${java_lib_dest}") - set_property(TARGET hal_src_jar PROPERTY FOLDER "java") + + install_jar(hal_src_jar DESTINATION ${java_lib_dest}) endif() if(WITH_TESTS) diff --git a/ntcore/CMakeLists.txt b/ntcore/CMakeLists.txt index 101307886df..ab4cc08d7ec 100644 --- a/ntcore/CMakeLists.txt +++ b/ntcore/CMakeLists.txt @@ -76,23 +76,18 @@ endif() if(WITH_JAVA_SOURCE) include(UseJava) - file( - GLOB NTCORE_SOURCES - src/main/java/edu/wpi/first/networktables/*.java - src/generated/main/java/*.java - ) - add_jar( + include(CreateSourceJar) + add_source_jar( ntcore_src_jar - RESOURCES - NAMESPACE "edu/wpi/first/networktables" ${NTCORE_SOURCES} + BASE_DIRECTORIES + ${CMAKE_CURRENT_SOURCE_DIR}/src/main/java + ${CMAKE_CURRENT_SOURCE_DIR}/src/generated/main/java OUTPUT_NAME ntcore-sources OUTPUT_DIR ${WPILIB_BINARY_DIR}/${java_lib_dest} ) - - get_property(NTCORE_SRC_JAR_FILE TARGET ntcore_src_jar PROPERTY JAR_FILE) - install(FILES ${NTCORE_SRC_JAR_FILE} DESTINATION "${java_lib_dest}") - set_property(TARGET ntcore_src_jar PROPERTY FOLDER "java") + + install_jar(ntcore_src_jar DESTINATION ${java_lib_dest}) endif() add_executable(ntcoredev src/dev/native/cpp/main.cpp) diff --git a/romiVendordep/CMakeLists.txt b/romiVendordep/CMakeLists.txt index cae07076089..9cadf9c6553 100644 --- a/romiVendordep/CMakeLists.txt +++ b/romiVendordep/CMakeLists.txt @@ -35,19 +35,16 @@ endif() if(WITH_JAVA_SOURCE) include(UseJava) - file(GLOB_RECURSE ROMIVENDORDEP_SOURCES src/main/java/*.java) - add_jar( + include(CreateSourceJar) + add_source_jar( romiVendordep_src_jar - RESOURCES - NAMESPACE "edu/wpi/first/wpilibj/romi" ${ROMIVENDORDEP_SOURCES} + BASE_DIRECTORIES ${CMAKE_CURRENT_SOURCE_DIR}/src/main/java OUTPUT_NAME romiVendordep-sources OUTPUT_DIR ${WPILIB_BINARY_DIR}/${java_lib_dest} ) - - get_property(ROMIVENDORDEP_SRC_JAR_FILE TARGET romiVendordep_src_jar PROPERTY JAR_FILE) - install(FILES ${ROMIVENDORDEP_JAR_FILE} DESTINATION "${java_lib_dest}") - set_property(TARGET romiVendordep_src_jar PROPERTY FOLDER "java") + + install_jar(romiVendordep_src_jar DESTINATION ${java_lib_dest}) endif() file(GLOB_RECURSE romiVendordep_native_src src/main/native/cpp/*.cpp) diff --git a/wpilibNewCommands/CMakeLists.txt b/wpilibNewCommands/CMakeLists.txt index 43292dfbe47..ea13d68d477 100644 --- a/wpilibNewCommands/CMakeLists.txt +++ b/wpilibNewCommands/CMakeLists.txt @@ -37,25 +37,18 @@ endif() if(WITH_JAVA_SOURCE) include(UseJava) - file(GLOB WPILIBNEWCOMMANDS_SOURCES src/main/java/edu/wpi/first/wpilibj2/command/*.java) - file( - GLOB WPILIBNEWCOMMANDS_BUTTON_SOURCES - src/main/java/edu/wpi/first/wpilibj2/command/button/*.java - src/generated/main/java/edu/wpi/first/wpilibj2/command/button/*.java - ) - add_jar( + include(CreateSourceJar) + add_source_jar( wpilibNewCommands_src_jar - RESOURCES - NAMESPACE "edu/wpi/first/wpilibj2/command" ${WPILIBNEWCOMMANDS_SOURCES} - NAMESPACE "edu/wpi/first/wpilibj2/command/button" ${WPILIBNEWCOMMANDS_BUTTON_SOURCES} + BASE_DIRECTORIES + ${CMAKE_CURRENT_SOURCE_DIR}/src/main/java + ${CMAKE_CURRENT_SOURCE_DIR}/src/generated/main/java OUTPUT_NAME wpilibNewCommands-sources OUTPUT_DIR ${WPILIB_BINARY_DIR}/${java_lib_dest} ) - - get_property(WPILIBNEWCOMMANDS_SRC_JAR_FILE TARGET wpilibNewCommands_src_jar PROPERTY JAR_FILE) - install(FILES ${WPILIBNEWCOMMANDS_SRC_JAR_FILE} DESTINATION "${java_lib_dest}") - set_property(TARGET wpilibNewCommands_src_jar PROPERTY FOLDER "java") + + install_jar(wpilibNewCommands_src_jar DESTINATION ${java_lib_dest}) endif() file( diff --git a/wpilibj/CMakeLists.txt b/wpilibj/CMakeLists.txt index 6124368075f..440f7585592 100644 --- a/wpilibj/CMakeLists.txt +++ b/wpilibj/CMakeLists.txt @@ -17,7 +17,10 @@ if(WITH_JAVA) NO_DEFAULT_PATH ) - configure_file(src/generate/WPILibVersion.java.in WPILibVersion.java) + configure_file( + src/generate/WPILibVersion.java.in + generated/main/java/edu/wpi/first/wpilibj/WPILibVersion.java + ) file(GLOB_RECURSE JAVA_SOURCES src/main/java/*.java src/generated/main/java/*.java) file(GLOB EJML_JARS "${WPILIB_BINARY_DIR}/wpimath/thirdparty/ejml/*.jar") @@ -26,7 +29,7 @@ if(WITH_JAVA) add_jar( wpilibj_jar ${JAVA_SOURCES} - ${CMAKE_CURRENT_BINARY_DIR}/WPILibVersion.java + ${CMAKE_CURRENT_BINARY_DIR}/generated/main/java/edu/wpi/first/wpilibj/WPILibVersion.java INCLUDE_JARS hal_jar ntcore_jar @@ -51,53 +54,24 @@ endif() if(WITH_JAVA_SOURCE) include(UseJava) - file( - GLOB WPILIBJ_SOURCES - src/main/java/edu/wpi/first/wpilibj/*.java - src/generated/main/java/edu/wpi/first/wpilibj/*.java - ) - file(GLOB WPILIBJ_COUNTER_SOURCES src/main/java/edu/wpi/first/wpilibj/counter/*.java) - file(GLOB WPILIBJ_DRIVE_SOURCES src/main/java/edu/wpi/first/wpilibj/drive/*.java) - file(GLOB WPILIBJ_EVENT_SOURCES src/main/java/edu/wpi/first/wpilibj/event/*.java) - file(GLOB WPILIBJ_INTERFACES_SOURCES src/main/java/edu/wpi/first/wpilibj/interfaces/*.java) - file(GLOB WPILIBJ_MOTORCONTROL_SOURCES src/main/java/edu/wpi/first/wpilibj/motorcontrol*.java) - file(GLOB WPILIBJ_SHUFFLEBOARD_SOURCES src/main/java/edu/wpi/first/wpilibj/shuffleboard*.java) - file( - GLOB WPILIBJ_SIMULATION_SOURCES - src/main/java/edu/wpi/first/wpilibj/simulation/*.java - src/generated/main/java/edu/wpi/first/wpilibj/simulation/*.java - ) - file(GLOB WPILIBJ_SMARTDASHBOARD_SOURCES src/main/java/edu/wpi/first/wpilibj/*.java) - file( - GLOB WPILIBJ_UTIL_SOURCES - src/main/java/edu/wpi/first/wpilibj/*.java - ${CMAKE_CURRENT_BINARY_DIR}/WPILibVersion.java - ) - add_jar( + include(CreateSourceJar) + # Generate version file if it wasn't generated already + if(NOT WITH_JAVA) + configure_file( + src/generate/WPILi1bVersion.java.in + generated/main/java/edu/wpi/first/wpilibj/WPILibVersion.java + ) + endif() + add_source_jar( wpilibj_src_jar - RESOURCES - NAMESPACE "edu/wpi/first/wpilibj" ${WPILIBJ_SOURCES} - NAMESPACE "edu/wpi/first/wpilibj/counter" ${WPILIBJ_COUNTER_SOURCES} - NAMESPACE "edu/wpi/first/wpilibj/drive" ${WPILIBJ_DRIVE_SOURCES} - NAMESPACE "edu/wpi/first/wpilibj/event" ${WPILIBJ_EVENT_SOURCES} - NAMESPACE "edu/wpi/first/wpilibj/interfaces" ${WPILIBJ_INTERFACES_SOURCES} - NAMESPACE - "edu/wpi/first/wpilibj/internal" - src/main/java/edu/wpi/first/wpilibj/internal/DriverStationModeThread.java - NAMESPACE - "edu/wpi/first/wpilibj/livewindow" - src/main/java/edu/wpi/first/wpilibj/livewindow/LiveWindow.java - NAMESPACE "edu/wpi/first/wpilibj/motorcontrol" ${WPILIBJ_MOTORCONTROL_SOURCES} - NAMESPACE "edu/wpi/first/wpilibj/shuffleboard" ${WPILIBJ_SHUFFLEBOARD_SOURCES} - NAMESPACE "edu/wpi/first/wpilibj/simulation" ${WPILIBJ_SIMULATION_SOURCES} - NAMESPACE "edu/wpi/first/wpilibj/smartdashboard" ${WPILIBJ_SMARTDASHBOARD_SOURCES} - NAMESPACE "edu/wpi/first/wpilibj/util" ${WPILIBJ_UTIL_SOURCES} + BASE_DIRECTORIES + ${CMAKE_CURRENT_SOURCE_DIR}/src/main/java + ${CMAKE_CURRENT_SOURCE_DIR}/src/generated/main/java + ${CMAKE_CURRENT_BINARY_DIR}/generated/main/java OUTPUT_NAME wpilibj-sources OUTPUT_DIR ${WPILIB_BINARY_DIR}/${java_lib_dest} ) - - get_property(WPILIBJ_SRC_JAR_FILE TARGET wpilibj_src_jar PROPERTY JAR_FILE) - install(FILES ${WPILIBJ_SRC_JAR_FILE} DESTINATION "${java_lib_dest}") - set_property(TARGET wpilibj_src_jar PROPERTY FOLDER "java") + + install_jar(wpilibj_src_jar DESTINATION ${java_lib_dest}) endif() diff --git a/wpimath/CMakeLists.txt b/wpimath/CMakeLists.txt index 80ed18d40cd..39473631a40 100644 --- a/wpimath/CMakeLists.txt +++ b/wpimath/CMakeLists.txt @@ -107,52 +107,18 @@ endif() if(WITH_JAVA_SOURCE) include(UseJava) - file( - GLOB WPIMATH_SOURCES - src/main/java/edu/wpi/first/math/*.java - src/generated/main/java/edu/wpi/first/math/Nat.java - ) - file(GLOB WPIMATH_CONTROLLER_SOURCES src/main/java/edu/wpi/first/math/controller/*.java) - file(GLOB WPIMATH_ESTIMATOR_SOURCES src/main/java/edu/wpi/first/math/estimator/*.java) - file(GLOB WPIMATH_FILTER_SOURCES src/main/java/edu/wpi/first/math/filter/*.java) - file(GLOB WPIMATH_GEOMETRY_SOURCES src/main/java/edu/wpi/first/math/geometry/*.java) - file(GLOB WPIMATH_INTERPOLATION_SOURCES src/main/java/edu/wpi/first/math/interpolation/*.java) - file(GLOB WPIMATH_KINEMATICS_SOURCES src/main/java/edu/wpi/first/math/kinematics/*.java) - file(GLOB WPIMATH_NUMBERS_SOURCES src/generated/main/java/edu/wpi/first/math/numbers/*.java) - file(GLOB WPIMATH_SPLINE_SOURCES src/main/java/edu/wpi/first/math/spline/*.java) - file(GLOB WPIMATH_SYSTEM_SOURCES src/main/java/edu/wpi/first/math/system/*.java) - file(GLOB WPIMATH_SYSTEM_PLANT_SOURCES src/main/java/edu/wpi/first/math/system/plant/*.java) - file(GLOB WPIMATH_TRAJECTORY_SOURCES src/main/java/edu/wpi/first/math/trajectory/*.java) - file( - GLOB WPIMATH_TRAJECTORY_CONSTRAINT_SOURCES - src/main/java/edu/wpi/first/math/trajectory/constraint/*.java - ) - add_jar( + include(CreateSourceJar) + add_source_jar( wpimath_src_jar - RESOURCES - NAMESPACE "edu/wpi/first/math" ${WPIMATH_SOURCES} - NAMESPACE "edu/wpi/first/math/controller" ${WPIMATH_CONTROLLER_SOURCES} - NAMESPACE "edu/wpi/first/math/estimator" ${WPIMATH_ESTIMATOR_SOURCES} - NAMESPACE "edu/wpi/first/math/filter" ${WPIMATH_FILTER_SOURCES} - NAMESPACE "edu/wpi/first/math/geometry" ${WPIMATH_GEOMETRY_SOURCES} - NAMESPACE "edu/wpi/first/math/interpolation" ${WPIMATH_INTERPOLATION_SOURCES} - NAMESPACE "edu/wpi/first/math/kinematics" ${WPIMATH_KINEMATICS_SOURCES} - NAMESPACE "edu/wpi/first/math/spline" ${WPIMATH_SPLINE_SOURCES} - NAMESPACE "edu/wpi/first/math/system" ${WPIMATH_SYSTEM_SOURCES} - NAMESPACE "edu/wpi/first/math/system/plant" ${WPIMATH_SYSTEM_PLANT_SOURCES} - NAMESPACE "edu/wpi/first/math/trajectory" ${WPIMATH_TRAJECTORY_SOURCES} - NAMESPACE - "edu/wpi/first/math/trajectory/constraint" - ${WPIMATH_TRAJECTORY_CONSTRAINT_SOURCES} - NAMESPACE "edu/wpi/first/math/util" src/main/java/edu/wpi/first/math/util/Units.java + BASE_DIRECTORIES + ${CMAKE_CURRENT_SOURCE_DIR}/src/main/java + ${CMAKE_CURRENT_SOURCE_DIR}/src/generated/main/java OUTPUT_NAME wpimath-sources OUTPUT_DIR ${WPILIB_BINARY_DIR}/${java_lib_dest} ) - - get_property(WPIMATH_SRC_JAR_FILE TARGET wpimath_src_jar PROPERTY JAR_FILE) - install(FILES ${WPIMATH_SRC_JAR_FILE} DESTINATION "${java_lib_dest}") - set_property(TARGET wpimath_src_jar PROPERTY FOLDER "java") + + install_jar(wpimath_src_jar DESTINATION ${java_lib_dest}) endif() file( diff --git a/wpinet/CMakeLists.txt b/wpinet/CMakeLists.txt index bddb4db83a9..f978be5cfba 100644 --- a/wpinet/CMakeLists.txt +++ b/wpinet/CMakeLists.txt @@ -43,19 +43,16 @@ endif() if(WITH_JAVA_SOURCE) include(UseJava) - file(GLOB WPINET_SOURCES src/main/java/edu/wpi/first/net/*.java) - add_jar( + include(CreateSourceJar) + add_source_jar( wpinet_src_jar - RESOURCES - NAMESPACE "edu/wpi/first/net" ${WPINET_SOURCES} + BASE_DIRECTORIES ${CMAKE_CURRENT_SOURCE_DIR}/src/main/java OUTPUT_NAME wpinet-sources OUTPUT_DIR ${WPILIB_BINARY_DIR}/${java_lib_dest} ) - - get_property(WPINET_SRC_JAR_FILE TARGET wpinet_src_jar PROPERTY JAR_FILE) - install(FILES ${WPINET_SRC_JAR_FILE} DESTINATION "${java_lib_dest}") - set_property(TARGET wpinet_src_jar PROPERTY FOLDER "java") + + install_jar(wpinet_src_jar DESTINATION ${java_lib_dest}) endif() set(THREADS_PREFER_PTHREAD_FLAG ON) diff --git a/wpiunits/CMakeLists.txt b/wpiunits/CMakeLists.txt index 3cba94bfd63..1bfa329089d 100644 --- a/wpiunits/CMakeLists.txt +++ b/wpiunits/CMakeLists.txt @@ -18,3 +18,16 @@ if(WITH_JAVA) install_jar_exports(TARGETS wpiunits_jar FILE wpiunits.cmake DESTINATION share/wpiunits) install(FILES wpiunits-config.cmake DESTINATION share/wpiunits) endif() + +if(WITH_JAVA_SOURCE) + include(UseJava) + include(CreateSourceJar) + add_source_jar( + wpiunits_src_jar + BASE_DIRECTORIES ${CMAKE_CURRENT_SOURCE_DIR}/src/main/java + OUTPUT_NAME wpiunits-sources + ) + set_property(TARGET wpiunits_src_jar PROPERTY FOLDER "java") + + install_jar(wpiunits_src_jar DESTINATION ${java_lib_dest}) +endif() diff --git a/wpiutil/CMakeLists.txt b/wpiutil/CMakeLists.txt index 3b26931b182..a296a58691c 100644 --- a/wpiutil/CMakeLists.txt +++ b/wpiutil/CMakeLists.txt @@ -87,29 +87,16 @@ endif() if(WITH_JAVA_SOURCE) include(UseJava) - file(GLOB WPIUTIL_SOURCES src/main/java/edu/wpi/first/util/*.java) - file(GLOB WPIUTIL_CLEANUP_SOURCES src/main/java/edu/wpi/first/util/cleanup/*.java) - file(GLOB WPIUTIL_CONCURRENT_SOURCES src/main/java/edu/wpi/first/util/concurrent/*.java) - file(GLOB WPIUTIL_DATALOG_SOURCES src/main/java/edu/wpi/first/util/datalog/*.java) - file(GLOB WPIUTIL_FUNCTION_SOURCES src/main/java/edu/wpi/first/util/function/*.java) - file(GLOB WPIUTIL_SENDABLE_SOURCES src/main/java/edu/wpi/first/util/sendable/*.java) - add_jar( + include(CreateSourceJar) + add_source_jar( wpiutil_src_jar - RESOURCES - NAMESPACE "edu/wpi/first/util" ${WPIUTIL_SOURCES} - NAMESPACE "edu/wpi/first/util/cleanup" ${WPIUTIL_CLEANUP_SOURCES} - NAMESPACE "edu/wpi/first/util/concurrent" ${WPIUTIL_CONCURRENT_SOURCES} - NAMESPACE "edu/wpi/first/util/datalog" ${WPIUTIL_DATALOG_SOURCES} - NAMESPACE "edu/wpi/first/util/function" ${WPIUTIL_FUNCTION_SOURCES} - NAMESPACE "edu/wpi/first/util/sendable" ${WPIUTIL_SENDABLE_SOURCES} + BASE_DIRECTORIES ${CMAKE_CURRENT_SOURCE_DIR}/src/main/java OUTPUT_NAME wpiutil-sources OUTPUT_DIR ${WPILIB_BINARY_DIR}/${java_lib_dest} ) - - get_property(WPIUTIL_SRC_JAR_FILE TARGET wpiutil_src_jar PROPERTY JAR_FILE) - install(FILES ${WPIUTIL_SRC_JAR_FILE} DESTINATION "${java_lib_dest}") - set_property(TARGET wpiutil_src_jar PROPERTY FOLDER "java") + + install_jar(wpiutil_src_jar DESTINATION ${java_lib_dest}) endif() set(THREADS_PREFER_PTHREAD_FLAG ON) diff --git a/xrpVendordep/CMakeLists.txt b/xrpVendordep/CMakeLists.txt index e57c703417a..6229de558c1 100644 --- a/xrpVendordep/CMakeLists.txt +++ b/xrpVendordep/CMakeLists.txt @@ -35,19 +35,16 @@ endif() if(WITH_JAVA_SOURCE) include(UseJava) - file(GLOB XRPVENDORDEP_SOURCES src/main/java/edu/wpi/first/wpilibj/xrp/*.java) - add_jar( + include(CreateSourceJar) + add_source_jar( xrpVendordep_src_jar - RESOURCES - NAMESPACE "edu/wpi/first/wpilibj/xrp" ${XRPVENDORDEP_SOURCES} + BASE_DIRECTORIES ${CMAKE_CURRENT_SOURCE_DIR}/src/main/java OUTPUT_NAME xrpVendordep-sources OUTPUT_DIR ${WPILIB_BINARY_DIR}/${java_lib_dest} ) - - get_property(xrpVendordep_src_JAR_FILE TARGET xrpVendordep_src_jar PROPERTY JAR_FILE) - install(FILES ${xrpVendordep_src_JAR_FILE} DESTINATION "${java_lib_dest}") - set_property(TARGET xrpVendordep_src_jar PROPERTY FOLDER "java") + + install_jar(xrpVendordep_src_jar DESTINATION ${java_lib_dest}) endif() file(GLOB_RECURSE xrpVendordep_native_src src/main/native/cpp/*.cpp) From 636450ab7b0b19d7531b2d30726ce583beb10cfe Mon Sep 17 00:00:00 2001 From: Ryan Blue Date: Mon, 15 Jul 2024 20:19:07 -0400 Subject: [PATCH 6/9] [build] Disable std::mutex constexpr constructor on Windows (#6791) We will plan to re-enable this after we release an installer with an updated runtime. --- cmake/modules/CompileWarnings.cmake | 5 +++++ shared/config.gradle | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/cmake/modules/CompileWarnings.cmake b/cmake/modules/CompileWarnings.cmake index 94d952ce5d7..432c810ca9b 100644 --- a/cmake/modules/CompileWarnings.cmake +++ b/cmake/modules/CompileWarnings.cmake @@ -54,4 +54,9 @@ macro(wpilib_target_warnings target) ) target_compile_options(${target} PRIVATE -gz=zlib) endif() + + # Disable std::mutex constexpr constructor on MSVC + if(MSVC) + target_compile_options(${target} PRIVATE /D_DISABLE_CONSTEXPR_MUTEX_CONSTRUCTOR) + endif() endmacro() diff --git a/shared/config.gradle b/shared/config.gradle index 6c4f3942b42..1d184295afa 100644 --- a/shared/config.gradle +++ b/shared/config.gradle @@ -41,6 +41,11 @@ nativeUtils.platformConfigs.each { } } +// Disable std::mutex constexpr constructor on MSVC +nativeUtils.platformConfigs.named(nativeUtils.wpi.platforms.windowsx64).configure { + it.cppCompiler.args.add("/D_DISABLE_CONSTEXPR_MUTEX_CONSTRUCTOR") +} + nativeUtils.platformConfigs.linuxathena.linker.args.add("-Wl,--fatal-warnings") model { From 7b7d17ccd79bcf8ff0edda6f54c86cfa0d2aeaf0 Mon Sep 17 00:00:00 2001 From: Joseph Eng <91924258+KangarooKoala@users.noreply.github.com> Date: Mon, 15 Jul 2024 17:19:31 -0700 Subject: [PATCH 7/9] [wpimath] Add and use kinematics.copyInto() (#6789) --- .../math/kinematics/DifferentialDriveKinematics.java | 7 +++++++ .../edu/wpi/first/math/kinematics/Kinematics.java | 9 +++++++++ .../first/math/kinematics/MecanumDriveKinematics.java | 8 ++++++++ .../java/edu/wpi/first/math/kinematics/Odometry.java | 6 +++--- .../first/math/kinematics/SwerveDriveKinematics.java | 11 +++++++++++ .../main/native/include/frc/kinematics/Kinematics.h | 3 ++- 6 files changed, 40 insertions(+), 4 deletions(-) diff --git a/wpimath/src/main/java/edu/wpi/first/math/kinematics/DifferentialDriveKinematics.java b/wpimath/src/main/java/edu/wpi/first/math/kinematics/DifferentialDriveKinematics.java index 8bcb6a74cfa..d67a7816475 100644 --- a/wpimath/src/main/java/edu/wpi/first/math/kinematics/DifferentialDriveKinematics.java +++ b/wpimath/src/main/java/edu/wpi/first/math/kinematics/DifferentialDriveKinematics.java @@ -120,6 +120,13 @@ public DifferentialDriveWheelPositions copy(DifferentialDriveWheelPositions posi return new DifferentialDriveWheelPositions(positions.leftMeters, positions.rightMeters); } + @Override + public void copyInto( + DifferentialDriveWheelPositions positions, DifferentialDriveWheelPositions output) { + output.leftMeters = positions.leftMeters; + output.rightMeters = positions.rightMeters; + } + @Override public DifferentialDriveWheelPositions interpolate( DifferentialDriveWheelPositions startValue, diff --git a/wpimath/src/main/java/edu/wpi/first/math/kinematics/Kinematics.java b/wpimath/src/main/java/edu/wpi/first/math/kinematics/Kinematics.java index a64c9a20091..307999d6552 100644 --- a/wpimath/src/main/java/edu/wpi/first/math/kinematics/Kinematics.java +++ b/wpimath/src/main/java/edu/wpi/first/math/kinematics/Kinematics.java @@ -53,4 +53,13 @@ public interface Kinematics extends Interpolator

{ * @return A copy. */ P copy(P positions); + + /** + * Copies the value of the wheel positions object into the output. + * + * @param positions The wheel positions object to copy. Will not be modified. + * @param output The output variable of the copy operation. Will have the same value as the + * positions object after the call. + */ + void copyInto(P positions, P output); } diff --git a/wpimath/src/main/java/edu/wpi/first/math/kinematics/MecanumDriveKinematics.java b/wpimath/src/main/java/edu/wpi/first/math/kinematics/MecanumDriveKinematics.java index 4589a448533..26108088c63 100644 --- a/wpimath/src/main/java/edu/wpi/first/math/kinematics/MecanumDriveKinematics.java +++ b/wpimath/src/main/java/edu/wpi/first/math/kinematics/MecanumDriveKinematics.java @@ -266,6 +266,14 @@ public MecanumDriveWheelPositions copy(MecanumDriveWheelPositions positions) { positions.rearRightMeters); } + @Override + public void copyInto(MecanumDriveWheelPositions positions, MecanumDriveWheelPositions output) { + output.frontLeftMeters = positions.frontLeftMeters; + output.frontRightMeters = positions.frontRightMeters; + output.rearLeftMeters = positions.rearLeftMeters; + output.rearRightMeters = positions.rearRightMeters; + } + @Override public MecanumDriveWheelPositions interpolate( MecanumDriveWheelPositions startValue, MecanumDriveWheelPositions endValue, double t) { diff --git a/wpimath/src/main/java/edu/wpi/first/math/kinematics/Odometry.java b/wpimath/src/main/java/edu/wpi/first/math/kinematics/Odometry.java index 66ce592957d..6a09f92bffd 100644 --- a/wpimath/src/main/java/edu/wpi/first/math/kinematics/Odometry.java +++ b/wpimath/src/main/java/edu/wpi/first/math/kinematics/Odometry.java @@ -25,7 +25,7 @@ public class Odometry { private Rotation2d m_gyroOffset; private Rotation2d m_previousAngle; - private T m_previousWheelPositions; + private final T m_previousWheelPositions; /** * Constructs an Odometry object. @@ -61,7 +61,7 @@ public void resetPosition(Rotation2d gyroAngle, T wheelPositions, Pose2d poseMet m_poseMeters = poseMeters; m_previousAngle = m_poseMeters.getRotation(); m_gyroOffset = m_poseMeters.getRotation().minus(gyroAngle); - m_previousWheelPositions = m_kinematics.copy(wheelPositions); + m_kinematics.copyInto(wheelPositions, m_previousWheelPositions); } /** @@ -122,7 +122,7 @@ public Pose2d update(Rotation2d gyroAngle, T wheelPositions) { var newPose = m_poseMeters.exp(twist); - m_previousWheelPositions = m_kinematics.copy(wheelPositions); + m_kinematics.copyInto(wheelPositions, m_previousWheelPositions); m_previousAngle = angle; m_poseMeters = new Pose2d(newPose.getTranslation(), angle); diff --git a/wpimath/src/main/java/edu/wpi/first/math/kinematics/SwerveDriveKinematics.java b/wpimath/src/main/java/edu/wpi/first/math/kinematics/SwerveDriveKinematics.java index 39306d0ac69..a25a2bed7da 100644 --- a/wpimath/src/main/java/edu/wpi/first/math/kinematics/SwerveDriveKinematics.java +++ b/wpimath/src/main/java/edu/wpi/first/math/kinematics/SwerveDriveKinematics.java @@ -392,6 +392,17 @@ public SwerveModulePosition[] copy(SwerveModulePosition[] positions) { return newPositions; } + @Override + public void copyInto(SwerveModulePosition[] positions, SwerveModulePosition[] output) { + if (positions.length != output.length) { + throw new IllegalArgumentException("Inconsistent number of modules!"); + } + for (int i = 0; i < positions.length; ++i) { + output[i].distanceMeters = positions[i].distanceMeters; + output[i].angle = positions[i].angle; + } + } + @Override public SwerveModulePosition[] interpolate( SwerveModulePosition[] startValue, SwerveModulePosition[] endValue, double t) { diff --git a/wpimath/src/main/native/include/frc/kinematics/Kinematics.h b/wpimath/src/main/native/include/frc/kinematics/Kinematics.h index 181c9a0abbe..f683dffa943 100644 --- a/wpimath/src/main/native/include/frc/kinematics/Kinematics.h +++ b/wpimath/src/main/native/include/frc/kinematics/Kinematics.h @@ -20,7 +20,8 @@ namespace frc { * forward kinematics converts wheel speeds into chassis speed. */ template - requires std::copy_constructible + requires std::copy_constructible && + std::assignable_from class WPILIB_DLLEXPORT Kinematics { public: /** From cd6b70af0e567fb8f070666564b8f81a24e9a15e Mon Sep 17 00:00:00 2001 From: Gold856 <117957790+Gold856@users.noreply.github.com> Date: Mon, 15 Jul 2024 20:26:25 -0400 Subject: [PATCH 8/9] [docs] Add documentation for simulation extensions (#6729) --- simulation/README.md | 46 +++++++++++++++++++++++++++ simulation/halsim_ds_socket/README.md | 6 ++++ 2 files changed, 52 insertions(+) create mode 100644 simulation/README.md create mode 100644 simulation/halsim_ds_socket/README.md diff --git a/simulation/README.md b/simulation/README.md new file mode 100644 index 00000000000..7d2c40e69e0 --- /dev/null +++ b/simulation/README.md @@ -0,0 +1,46 @@ +# Simulation Extensions +This is where WPILib's simulation extensions are housed. Simulation extensions are referred to by various names: simulation plugins, simulation modules, sim extensions, HALSIM extensions, but they all refer to the same thing, which are dynamically loaded libraries that can use HALSIM functions to register callbacks that update HAL data. The robot program loads simulation extensions by looking for the `HALSIM_EXTENSIONS` environment variable, which contains the paths to the libraries separated by colons on Linux/Mac, and semicolons on Windows. + +# Writing a custom simulation extension +All simulation extensions contain a `int HALSIM_InitExtension(void)` function, which is the entry point. The function declaration should look like this: + +```c++ +extern "C" { +#if defined(WIN32) || defined(_WIN32) +__declspec(dllexport) +#endif +int HALSIM_InitExtension(void) { +} +} +``` + +The function is contained with an `extern "C"` block so it can be called by the robot program and has `__declspec(dllexport)` for Windows. From here, you can interface with the HAL to provide data. + +## Extension registration +Extensions can register themselves by calling `HAL_RegisterExtension`. This will register the extension's name, and a pointer to some sort of data. A separate extension can listen for extension registration by calling `HAL_RegisterExtensionListener`. It takes a callback accepting the data initially passed into `HAL_RegisterExtension`. This can be used to detect if a specific extension was loaded, and take action if it was. Note that extensions must opt-in to registration; extensions that do not register will not trigger the registration listener. + +## Using HALSIM functions +Several devices in the HAL have functions that allow you to feed data from an external source into the HAL. The full list can be found in the HAL subdirectory in `include/hal/simulation`. For example, the AccelerometerData header declares functions that update the X, Y, and Z axes with data. Some functions accept callbacks; the I2CData header declares functions which accept other functions with parameters that allow it to accept data. This allows the implementation of a simulation extension that interfaces with an I2C bus and connects it to the HAL, allowing the use of real I2C hardware in simulation. Note that these callbacks are called synchronously and in the same thread as the robot program; long delays in callbacks will block the main thread and can cause loop overruns. + +## Building the extension +To build an extension for use in a robot project, you'll need to build with Gradle. The easiest way to get a working build.gradle file is to copy the build.gradle file from halsim_xrp. It doesn't have any tests, and it only depends on halsim_ws_core. The important line is `lib project: ':wpinet', library: 'wpinet', linkage: 'shared'`. This tells Gradle to link the extension with wpinet using shared libraries. Other libraries can be included in a similar way by referencing the Gradle subproject name. Note that you do not need to include the HAL since it is automatically included. + +# Using a custom extension +After setting up a build.gradle file for a custom extension, follow the guides to build and publish your own local build of allwpilib. Once you've published a local build, follow the instructions in [DevelopmentBuilds.md](/DevelopmentBuilds.md) to use the locally published build in a robot project. Then, place this line your robot project's build.gradle file: +```groovy +wpi.sim.addDep("Custom Sim Extension", "edu.wpi.first.halsim", "pluginName") +``` +where `Custom Sim Extension` is the name of the extension shown by VS Code and `pluginName` is the same as `pluginName` declared in the build.gradle file for the simulation extension. + +# Built-in extensions +halsim_ds_socket: Allows the real Driver Station to control the robot program. + +halsim_gui: Provides the simulation GUI. + +halsim_ws_client: A websockets client that allows robot hardware interface state to be transmitted over websockets. + +halsim_ws_core: A websockets library for use by other extensions. Not directly usable. + +halsim_ws_server: A websockets server that allows robot hardware interface state to be transmitted over websockets. + +halsim_xrp: A client that supports the XRP protocol, allowing the robot program to control and receive data from the XRP. diff --git a/simulation/halsim_ds_socket/README.md b/simulation/halsim_ds_socket/README.md new file mode 100644 index 00000000000..c8f307838b1 --- /dev/null +++ b/simulation/halsim_ds_socket/README.md @@ -0,0 +1,6 @@ +# HAL DS Socket +This is an extension that allows the Driver Station to communicate with the robot program. Note that not everything has been reimplemented, since lots of DS data like battery voltage doesn't apply in simulation. + +# Configuration + +The only environment variable the extension supports is `DS_TIMEOUT_MS`, which is the amount of milliseconds it takes for a UDP packet to arrive from the DS before the robot program automatically disables. Default value is `100`, representing 100 milliseconds. From 7d64d4e24cb9b89ddc7cdb2484a762c461ab86e3 Mon Sep 17 00:00:00 2001 From: Wispy <101812473+WispySparks@users.noreply.github.com> Date: Mon, 15 Jul 2024 19:28:05 -0500 Subject: [PATCH 9/9] [sim] Add GUI support for the REV PH (#6704) --- .../cpp/hardware/{PCM.cpp => Pneumatic.cpp} | 51 ++-- .../glass/hardware/{PCM.h => Pneumatic.h} | 38 ++- .../src/main/native/cpp/PCMSimGui.cpp | 65 +++-- .../src/main/native/cpp/PCMSimGui.h | 6 + .../src/main/native/cpp/PHSimGui.cpp | 225 ++++++++++++++++++ .../halsim_gui/src/main/native/cpp/PHSimGui.h | 20 ++ .../halsim_gui/src/main/native/cpp/main.cpp | 36 +++ 7 files changed, 374 insertions(+), 67 deletions(-) rename glass/src/lib/native/cpp/hardware/{PCM.cpp => Pneumatic.cpp} (75%) rename glass/src/lib/native/include/glass/hardware/{PCM.h => Pneumatic.h} (50%) create mode 100644 simulation/halsim_gui/src/main/native/cpp/PHSimGui.cpp create mode 100644 simulation/halsim_gui/src/main/native/cpp/PHSimGui.h diff --git a/glass/src/lib/native/cpp/hardware/PCM.cpp b/glass/src/lib/native/cpp/hardware/Pneumatic.cpp similarity index 75% rename from glass/src/lib/native/cpp/hardware/PCM.cpp rename to glass/src/lib/native/cpp/hardware/Pneumatic.cpp index 6238fd9ae4d..10ec61e142b 100644 --- a/glass/src/lib/native/cpp/hardware/PCM.cpp +++ b/glass/src/lib/native/cpp/hardware/Pneumatic.cpp @@ -2,7 +2,7 @@ // Open Source Software; you can modify and/or share it under the terms of // the WPILib BSD license file in the root directory of this project. -#include "glass/hardware/PCM.h" +#include "glass/hardware/Pneumatic.h" #include #include @@ -20,8 +20,8 @@ using namespace glass; -bool glass::DisplayPCMSolenoids(PCMModel* model, int index, - bool outputsEnabled) { +bool glass::DisplayPneumaticControlSolenoids(PneumaticControlModel* model, + int index, bool outputsEnabled) { wpi::SmallVector channels; model->ForEachSolenoid([&](SolenoidModel& solenoid, int j) { if (auto data = solenoid.GetOutputData()) { @@ -50,7 +50,8 @@ bool glass::DisplayPCMSolenoids(PCMModel* model, int index, wpi::format_to_n_c_str(label, sizeof(label), "{} [{}]###header", name, index); } else { - wpi::format_to_n_c_str(label, sizeof(label), "PCM[{}]###header", index); + wpi::format_to_n_c_str(label, sizeof(label), "{}[{}]###header", + model->GetName(), index); } // header @@ -85,32 +86,29 @@ bool glass::DisplayPCMSolenoids(PCMModel* model, int index, return true; } -void glass::DisplayPCMsSolenoids(PCMsModel* model, bool outputsEnabled, - std::string_view noneMsg) { +void glass::DisplayPneumaticControlsSolenoids(PneumaticControlsModel* model, + bool outputsEnabled, + std::string_view noneMsg) { bool hasAny = false; - model->ForEachPCM([&](PCMModel& pcm, int i) { - PushID(i); - if (DisplayPCMSolenoids(&pcm, i, outputsEnabled)) { - hasAny = true; - } - PopID(); - }); + model->ForEachPneumaticControl( + [&](PneumaticControlModel& pneumaticControl, int i) { + PushID(i); + if (DisplayPneumaticControlSolenoids(&pneumaticControl, i, + outputsEnabled)) { + hasAny = true; + } + PopID(); + }); if (!hasAny && !noneMsg.empty()) { ImGui::TextUnformatted(noneMsg.data(), noneMsg.data() + noneMsg.size()); } } -void glass::DisplayCompressorDevice(PCMModel* model, int index, +void glass::DisplayCompressorDevice(CompressorModel* model, int index, bool outputsEnabled) { - auto compressor = model->GetCompressor(); - if (!compressor || !compressor->Exists()) { + if (!model || !model->Exists()) { return; } - DisplayCompressorDevice(compressor, index, outputsEnabled); -} - -void glass::DisplayCompressorDevice(CompressorModel* model, int index, - bool outputsEnabled) { char name[32]; wpi::format_to_n_c_str(name, sizeof(name), "Compressor[{}]", index); @@ -155,8 +153,11 @@ void glass::DisplayCompressorDevice(CompressorModel* model, int index, } } -void glass::DisplayCompressorsDevice(PCMsModel* model, bool outputsEnabled) { - model->ForEachPCM([&](PCMModel& pcm, int i) { - DisplayCompressorDevice(&pcm, i, outputsEnabled); - }); +void glass::DisplayCompressorsDevice(PneumaticControlsModel* model, + bool outputsEnabled) { + model->ForEachPneumaticControl( + [&](PneumaticControlModel& pneumaticControl, int i) { + DisplayCompressorDevice(pneumaticControl.GetCompressor(), i, + outputsEnabled); + }); } diff --git a/glass/src/lib/native/include/glass/hardware/PCM.h b/glass/src/lib/native/include/glass/hardware/Pneumatic.h similarity index 50% rename from glass/src/lib/native/include/glass/hardware/PCM.h rename to glass/src/lib/native/include/glass/hardware/Pneumatic.h index 107a2a84fc6..0e9e525f261 100644 --- a/glass/src/lib/native/include/glass/hardware/PCM.h +++ b/glass/src/lib/native/include/glass/hardware/Pneumatic.h @@ -4,7 +4,9 @@ #pragma once +#include #include +#include #include @@ -34,27 +36,45 @@ class SolenoidModel : public Model { virtual void SetOutput(bool val) = 0; }; -class PCMModel : public Model { +class PneumaticControlModel : public Model { public: virtual CompressorModel* GetCompressor() = 0; virtual void ForEachSolenoid( wpi::function_ref func) = 0; + + virtual std::string_view GetName() = 0; }; -class PCMsModel : public Model { +class PneumaticControlsModel : public Model { public: - virtual void ForEachPCM( - wpi::function_ref func) = 0; + virtual void ForEachPneumaticControl( + wpi::function_ref + func) = 0; +}; + +struct AllPneumaticControlsModel : public Model { + AllPneumaticControlsModel(std::unique_ptr pcms, + std::unique_ptr phs) + : pcms{std::move(pcms)}, phs{std::move(phs)} {}; + std::unique_ptr pcms; + std::unique_ptr phs; + void Update() override { + pcms->Update(); + phs->Update(); + }; + bool Exists() override { return true; } }; -bool DisplayPCMSolenoids(PCMModel* model, int index, bool outputsEnabled); -void DisplayPCMsSolenoids(PCMsModel* model, bool outputsEnabled, - std::string_view noneMsg = "No solenoids"); +bool DisplayPneumaticControlSolenoids(PneumaticControlModel* model, int index, + bool outputsEnabled); +void DisplayPneumaticControlsSolenoids( + PneumaticControlsModel* model, bool outputsEnabled, + std::string_view noneMsg = "No solenoids"); -void DisplayCompressorDevice(PCMModel* model, int index, bool outputsEnabled); void DisplayCompressorDevice(CompressorModel* model, int index, bool outputsEnabled); -void DisplayCompressorsDevice(PCMsModel* model, bool outputsEnabled); +void DisplayCompressorsDevice(PneumaticControlsModel* model, + bool outputsEnabled); } // namespace glass diff --git a/simulation/halsim_gui/src/main/native/cpp/PCMSimGui.cpp b/simulation/halsim_gui/src/main/native/cpp/PCMSimGui.cpp index 869c5b102cb..d5a3f3604e4 100644 --- a/simulation/halsim_gui/src/main/native/cpp/PCMSimGui.cpp +++ b/simulation/halsim_gui/src/main/native/cpp/PCMSimGui.cpp @@ -4,7 +4,7 @@ #include "PCMSimGui.h" -#include +#include #include #include @@ -25,7 +25,8 @@ namespace { HALSIMGUI_DATASOURCE_BOOLEAN_INDEXED(CTREPCMCompressorOn, "Compressor On"); HALSIMGUI_DATASOURCE_BOOLEAN_INDEXED(CTREPCMClosedLoopEnabled, "Closed Loop"); HALSIMGUI_DATASOURCE_BOOLEAN_INDEXED(CTREPCMPressureSwitch, "Pressure Switch"); -HALSIMGUI_DATASOURCE_DOUBLE_INDEXED(CTREPCMCompressorCurrent, "Comp Current"); +HALSIMGUI_DATASOURCE_DOUBLE_INDEXED(CTREPCMCompressorCurrent, + "Compressor Current"); HALSIMGUI_DATASOURCE_BOOLEAN_INDEXED2(CTREPCMSolenoidOutput, "Solenoid"); class CompressorSimModel : public glass::CompressorModel { @@ -90,7 +91,7 @@ class SolenoidSimModel : public glass::SolenoidModel { CTREPCMSolenoidOutputSource m_output; }; -class PCMSimModel : public glass::PCMModel { +class PCMSimModel : public glass::PneumaticControlModel { public: explicit PCMSimModel(int32_t index) : m_index{index}, @@ -107,6 +108,8 @@ class PCMSimModel : public glass::PCMModel { wpi::function_ref func) override; + std::string_view GetName() override { return "PCM"; } + int GetNumSolenoids() const { return m_solenoidInitCount; } private: @@ -116,7 +119,7 @@ class PCMSimModel : public glass::PCMModel { int m_solenoidInitCount = 0; }; -class PCMsSimModel : public glass::PCMsModel { +class PCMsSimModel : public glass::PneumaticControlsModel { public: PCMsSimModel() : m_models(HAL_GetNumCTREPCMModules()) {} @@ -124,8 +127,9 @@ class PCMsSimModel : public glass::PCMsModel { bool Exists() override { return true; } - void ForEachPCM( - wpi::function_ref func) override; + void ForEachPneumaticControl( + wpi::function_ref + func) override; private: std::vector> m_models; @@ -176,8 +180,9 @@ void PCMsSimModel::Update() { } } -void PCMsSimModel::ForEachPCM( - wpi::function_ref func) { +void PCMsSimModel::ForEachPneumaticControl( + wpi::function_ref + func) { int32_t numCTREPCMs = m_models.size(); for (int32_t i = 0; i < numCTREPCMs; ++i) { if (auto model = m_models[i].get()) { @@ -186,7 +191,7 @@ void PCMsSimModel::ForEachPCM( } } -static bool PCMsAnyInitialized() { +bool PCMSimGui::PCMsAnyInitialized() { static const int32_t num = HAL_GetNumCTREPCMModules(); for (int32_t i = 0; i < num; ++i) { if (HALSIM_GetCTREPCMInitialized(i)) { @@ -196,31 +201,25 @@ static bool PCMsAnyInitialized() { return false; } -void PCMSimGui::Initialize() { - HALSimGui::halProvider->RegisterModel("CTREPCMs", PCMsAnyInitialized, [] { - return std::make_unique(); - }); - HALSimGui::halProvider->RegisterView( - "Solenoids", "CTREPCMs", - [](glass::Model* model) { - bool any = false; - static_cast(model)->ForEachPCM( - [&](glass::PCMModel& CTREPCM, int) { - if (static_cast(&CTREPCM)->GetNumSolenoids() > 0) { - any = true; - } - }); - return any; - }, - [](glass::Window* win, glass::Model* model) { - win->SetFlags(ImGuiWindowFlags_AlwaysAutoResize); - win->SetDefaultPos(290, 20); - return glass::MakeFunctionView([=] { - glass::DisplayPCMsSolenoids( - static_cast(model), - HALSimGui::halProvider->AreOutputsEnabled()); - }); +bool PCMSimGui::PCMsAnySolenoids(glass::PneumaticControlsModel* model) { + bool any = false; + static_cast(model)->ForEachPneumaticControl( + [&](glass::PneumaticControlModel& CTREPCM, int) { + if (static_cast(&CTREPCM)->GetNumSolenoids() > 0) { + any = true; + } }); + return any; +} + +std::unique_ptr PCMSimGui::GetPCMsModel() { + return std::make_unique(); +} + +void PCMSimGui::Initialize() { + HALSimGui::halProvider->RegisterModel( + "CTREPCMs", PCMSimGui::PCMsAnyInitialized, + [] { return std::make_unique(); }); SimDeviceGui::GetDeviceTree().Add( HALSimGui::halProvider->GetModel("CTREPCMs"), [](glass::Model* model) { diff --git a/simulation/halsim_gui/src/main/native/cpp/PCMSimGui.h b/simulation/halsim_gui/src/main/native/cpp/PCMSimGui.h index aef771784d9..da20022ef14 100644 --- a/simulation/halsim_gui/src/main/native/cpp/PCMSimGui.h +++ b/simulation/halsim_gui/src/main/native/cpp/PCMSimGui.h @@ -3,12 +3,18 @@ // the WPILib BSD license file in the root directory of this project. #pragma once +#include + +#include namespace halsimgui { class PCMSimGui { public: static void Initialize(); + static bool PCMsAnyInitialized(); + static bool PCMsAnySolenoids(glass::PneumaticControlsModel* model); + static std::unique_ptr GetPCMsModel(); }; } // namespace halsimgui diff --git a/simulation/halsim_gui/src/main/native/cpp/PHSimGui.cpp b/simulation/halsim_gui/src/main/native/cpp/PHSimGui.cpp new file mode 100644 index 00000000000..47e65e1e5b2 --- /dev/null +++ b/simulation/halsim_gui/src/main/native/cpp/PHSimGui.cpp @@ -0,0 +1,225 @@ +// Copyright (c) FIRST and other WPILib contributors. +// Open Source Software; you can modify and/or share it under the terms of +// the WPILib BSD license file in the root directory of this project. + +#include "PHSimGui.h" + +#include +#include + +#include +#include +#include + +#include +#include +#include + +#include "HALDataSource.h" +#include "HALSimGui.h" +#include "SimDeviceGui.h" + +using namespace halsimgui; + +namespace { +HALSIMGUI_DATASOURCE_BOOLEAN_INDEXED(REVPHCompressorOn, "Compressor On"); +HALSIMGUI_DATASOURCE_BOOLEAN_INDEXED(REVPHPressureSwitch, "Pressure Switch"); +HALSIMGUI_DATASOURCE_DOUBLE_INDEXED(REVPHCompressorCurrent, + "Compressor Current"); +HALSIMGUI_DATASOURCE_BOOLEAN_INDEXED2(REVPHSolenoidOutput, "Solenoid"); + +class CompressorSimModel : public glass::CompressorModel { + public: + explicit CompressorSimModel(int32_t index) + : m_index{index}, + m_running{index}, + m_pressureSwitch{index}, + m_current{index} {} + + void Update() override {} + + bool Exists() override { return HALSIM_GetREVPHInitialized(m_index); } + + glass::DataSource* GetRunningData() override { return &m_running; } + glass::DataSource* GetEnabledData() override { return nullptr; } + glass::DataSource* GetPressureSwitchData() override { + return &m_pressureSwitch; + } + glass::DataSource* GetCurrentData() override { return &m_current; } + + void SetRunning(bool val) override { + HALSIM_SetREVPHCompressorOn(m_index, val); + } + void SetEnabled(bool val) override {} + void SetPressureSwitch(bool val) override { + HALSIM_SetREVPHPressureSwitch(m_index, val); + } + void SetCurrent(double val) override { + HALSIM_SetREVPHCompressorCurrent(m_index, val); + } + + private: + int32_t m_index; + REVPHCompressorOnSource m_running; + REVPHPressureSwitchSource m_pressureSwitch; + REVPHCompressorCurrentSource m_current; +}; + +class SolenoidSimModel : public glass::SolenoidModel { + public: + SolenoidSimModel(int32_t index, int32_t channel) + : m_index{index}, m_channel{channel}, m_output{index, channel} {} + + void Update() override {} + + bool Exists() override { return HALSIM_GetREVPHInitialized(m_index); } + + glass::DataSource* GetOutputData() override { return &m_output; } + + void SetOutput(bool val) override { + HALSIM_SetREVPHSolenoidOutput(m_index, m_channel, val); + } + + private: + int32_t m_index; + int32_t m_channel; + REVPHSolenoidOutputSource m_output; +}; + +class PHSimModel : public glass::PneumaticControlModel { + public: + explicit PHSimModel(int32_t index) + : m_index{index}, + m_compressor{index}, + m_solenoids(HAL_GetNumREVPHChannels()) {} + + void Update() override; + + bool Exists() override { return true; } + + CompressorSimModel* GetCompressor() override { return &m_compressor; } + + void ForEachSolenoid( + wpi::function_ref func) + override; + + std::string_view GetName() override { return "PH"; } + + int GetNumSolenoids() const { return m_solenoidInitCount; } + + private: + int32_t m_index; + CompressorSimModel m_compressor; + std::vector> m_solenoids; + int m_solenoidInitCount = 0; +}; + +class PHsSimModel : public glass::PneumaticControlsModel { + public: + PHsSimModel() : m_models(HAL_GetNumREVPHModules()) {} + + void Update() override; + + bool Exists() override { return true; } + + void ForEachPneumaticControl( + wpi::function_ref + func) override; + + private: + std::vector> m_models; +}; +} // namespace + +void PHSimModel::Update() { + int32_t numChannels = m_solenoids.size(); + m_solenoidInitCount = 0; + for (int32_t i = 0; i < numChannels; ++i) { + auto& model = m_solenoids[i]; + if (HALSIM_GetREVPHInitialized(m_index)) { + if (!model) { + model = std::make_unique(m_index, i); + } + ++m_solenoidInitCount; + } else { + model.reset(); + } + } +} + +void PHSimModel::ForEachSolenoid( + wpi::function_ref func) { + if (m_solenoidInitCount == 0) { + return; + } + int32_t numSolenoids = m_solenoids.size(); + for (int32_t i = 0; i < numSolenoids; ++i) { + if (auto model = m_solenoids[i].get()) { + func(*model, i); + } + } +} + +void PHsSimModel::Update() { + for (int32_t i = 0, iend = static_cast(m_models.size()); i < iend; + ++i) { + auto& model = m_models[i]; + if (HALSIM_GetREVPHInitialized(i)) { + if (!model) { + model = std::make_unique(i); + } + model->Update(); + } else { + model.reset(); + } + } +} + +void PHsSimModel::ForEachPneumaticControl( + wpi::function_ref + func) { + int32_t numREVPHs = m_models.size(); + for (int32_t i = 0; i < numREVPHs; ++i) { + if (auto model = m_models[i].get()) { + func(*model, i); + } + } +} + +bool PHSimGui::PHsAnyInitialized() { + static const int32_t num = HAL_GetNumREVPHModules(); + for (int32_t i = 0; i < num; ++i) { + if (HALSIM_GetREVPHInitialized(i)) { + return true; + } + } + return false; +} + +bool PHSimGui::PHsAnySolenoids(glass::PneumaticControlsModel* model) { + bool any = false; + static_cast(model)->ForEachPneumaticControl( + [&](glass::PneumaticControlModel& REVPH, int) { + if (static_cast(&REVPH)->GetNumSolenoids() > 0) { + any = true; + } + }); + return any; +} + +std::unique_ptr PHSimGui::GetPHsModel() { + return std::make_unique(); +} + +void PHSimGui::Initialize() { + HALSimGui::halProvider->RegisterModel( + "REVPHs", PHSimGui::PHsAnyInitialized, + [] { return std::make_unique(); }); + + SimDeviceGui::GetDeviceTree().Add( + HALSimGui::halProvider->GetModel("REVPHs"), [](glass::Model* model) { + glass::DisplayCompressorsDevice( + static_cast(model), + HALSimGui::halProvider->AreOutputsEnabled()); + }); +} diff --git a/simulation/halsim_gui/src/main/native/cpp/PHSimGui.h b/simulation/halsim_gui/src/main/native/cpp/PHSimGui.h new file mode 100644 index 00000000000..84fe9d76ac7 --- /dev/null +++ b/simulation/halsim_gui/src/main/native/cpp/PHSimGui.h @@ -0,0 +1,20 @@ +// Copyright (c) FIRST and other WPILib contributors. +// Open Source Software; you can modify and/or share it under the terms of +// the WPILib BSD license file in the root directory of this project. + +#pragma once +#include + +#include + +namespace halsimgui { + +class PHSimGui { + public: + static void Initialize(); + static bool PHsAnyInitialized(); + static bool PHsAnySolenoids(glass::PneumaticControlsModel* model); + static std::unique_ptr GetPHsModel(); +}; + +} // namespace halsimgui diff --git a/simulation/halsim_gui/src/main/native/cpp/main.cpp b/simulation/halsim_gui/src/main/native/cpp/main.cpp index 54510239bc8..574090b974c 100644 --- a/simulation/halsim_gui/src/main/native/cpp/main.cpp +++ b/simulation/halsim_gui/src/main/native/cpp/main.cpp @@ -4,6 +4,7 @@ #include #include +#include #include #include @@ -26,6 +27,7 @@ #include "HALSimGuiExt.h" #include "NetworkTablesSimGui.h" #include "PCMSimGui.h" +#include "PHSimGui.h" #include "PWMSimGui.h" #include "PowerDistributionSimGui.h" #include "RelaySimGui.h" @@ -85,9 +87,43 @@ __declspec(dllexport) PowerDistributionSimGui::Initialize(); PWMSimGui::Initialize(); RelaySimGui::Initialize(); + PHSimGui::Initialize(); RoboRioSimGui::Initialize(); TimingGui::Initialize(); + HALSimGui::halProvider->RegisterModel( + "AllPneumaticControls", + [] { + return PCMSimGui::PCMsAnyInitialized() || PHSimGui::PHsAnyInitialized(); + }, + [] { + return std::make_unique( + PCMSimGui::GetPCMsModel(), PHSimGui::GetPHsModel()); + }); + + HALSimGui::halProvider->RegisterView( + "Solenoids", "AllPneumaticControls", + [](glass::Model* model) { + auto pneumaticModel = + static_cast(model); + return PCMSimGui::PCMsAnySolenoids(pneumaticModel->pcms.get()) || + PHSimGui::PHsAnySolenoids(pneumaticModel->phs.get()); + }, + [](glass::Window* win, glass::Model* model) { + win->SetFlags(ImGuiWindowFlags_AlwaysAutoResize); + win->SetDefaultPos(290, 20); + return glass::MakeFunctionView([=] { + auto pneumaticModel = + static_cast(model); + glass::DisplayPneumaticControlsSolenoids( + pneumaticModel->pcms.get(), + HALSimGui::halProvider->AreOutputsEnabled()); + glass::DisplayPneumaticControlsSolenoids( + pneumaticModel->phs.get(), + HALSimGui::halProvider->AreOutputsEnabled()); + }); + }); + HALSimGui::mainMenu.AddMainMenu([] { if (ImGui::BeginMenu("Hardware")) { HALSimGui::halProvider->DisplayMenu();