From 07a0d22fe6cfa6d322fcf50b5e75afa2433f9a3f Mon Sep 17 00:00:00 2001 From: Tyler Veness Date: Wed, 20 Sep 2023 21:03:55 -0700 Subject: [PATCH] [build] Build examples in CMake CI (#5667) --- .github/workflows/cmake.yml | 8 ++++---- CMakeLists.txt | 2 ++ cmake/modules/CompileWarnings.cmake | 6 ++++++ .../include/networktables/NetworkTableValue.h | 11 ++++++++++- .../cpp/subsystems/SwerveModule.cpp | 10 +++++++--- .../include/subsystems/SwerveModule.h | 3 --- wpinet/src/test/native/cpp/WebSocketServerTest.cpp | 14 ++++++++++++++ 7 files changed, 43 insertions(+), 11 deletions(-) diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index f9399aebae..9e44fcf384 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -15,11 +15,11 @@ jobs: - os: ubuntu-22.04 name: Linux container: wpilib/roborio-cross-ubuntu:2023-22.04 - flags: "" + flags: "-DCMAKE_BUILD_TYPE=Release -DWITH_EXAMPLES=ON" - os: macOS-12 name: macOS container: "" - flags: "-DWITH_JAVA=OFF" + flags: "-DCMAKE_BUILD_TYPE=Release -DWITH_JAVA=OFF -DWITH_EXAMPLES=ON" name: "Build - ${{ matrix.name }}" runs-on: ${{ matrix.os }} @@ -75,8 +75,8 @@ jobs: run: python -m pip install jinja2 - name: configure - run: cmake -S . -B build -G "Ninja Multi-Config" -DWITH_JAVA=OFF -DWITH_TESTS=OFF -DUSE_SYSTEM_FMTLIB=ON -DUSE_SYSTEM_LIBUV=ON -DUSE_SYSTEM_EIGEN=ON -DCMAKE_TOOLCHAIN_FILE=${{ runner.workspace }}/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_INSTALL_OPTIONS=--clean-after-build -DVCPKG_TARGET_TRIPLET=x64-windows-release -DVCPKG_HOST_TRIPLET=x64-windows-release + run: cmake -S . -B build -G "Ninja Multi-Config" -DCMAKE_BUILD_TYPE=Release -DWITH_JAVA=OFF -DWITH_EXAMPLES=ON -DWITH_TESTS=OFF -DUSE_SYSTEM_FMTLIB=ON -DUSE_SYSTEM_LIBUV=ON -DUSE_SYSTEM_EIGEN=ON -DCMAKE_TOOLCHAIN_FILE=${{ runner.workspace }}/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_INSTALL_OPTIONS=--clean-after-build -DVCPKG_TARGET_TRIPLET=x64-windows-release -DVCPKG_HOST_TRIPLET=x64-windows-release - name: build working-directory: build - run: cmake --build . --parallel $(nproc) --config Release + run: cmake --build . --parallel 1 --config Release diff --git a/CMakeLists.txt b/CMakeLists.txt index e77b1b2b3d..47e2366800 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -317,6 +317,8 @@ if (WITH_WPILIB) add_subdirectory(wpilibj) add_subdirectory(wpilibc) add_subdirectory(wpilibNewCommands) + add_subdirectory(romiVendordep) + add_subdirectory(xrpVendordep) if (WITH_EXAMPLES) add_subdirectory(wpilibcExamples) endif() diff --git a/cmake/modules/CompileWarnings.cmake b/cmake/modules/CompileWarnings.cmake index 2d49ba9852..8f5d54ea6c 100644 --- a/cmake/modules/CompileWarnings.cmake +++ b/cmake/modules/CompileWarnings.cmake @@ -13,6 +13,12 @@ macro(wpilib_target_warnings target) target_compile_options(${target} PRIVATE $<$:-Wno-deprecated-anon-enum-enum-conversion>) endif() + # Suppress warning "enumeration types with a fixed underlying type are a + # Clang extension" + if(APPLE) + target_compile_options(${target} PRIVATE $<$:-Wno-fixed-enum-extension>) + endif() + # Compress debug info with GCC if ((${CMAKE_BUILD_TYPE} STREQUAL "Debug" OR ${CMAKE_BUILD_TYPE} STREQUAL "RelWithDebInfo") AND diff --git a/ntcore/src/main/native/include/networktables/NetworkTableValue.h b/ntcore/src/main/native/include/networktables/NetworkTableValue.h index 81e3653885..80cee51f41 100644 --- a/ntcore/src/main/native/include/networktables/NetworkTableValue.h +++ b/ntcore/src/main/native/include/networktables/NetworkTableValue.h @@ -20,6 +20,11 @@ namespace nt { +#if __GNUC__ >= 13 +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wmaybe-uninitialized" +#endif + /** * A network table entry value. * @ingroup ntcore_cpp_api @@ -641,9 +646,13 @@ class Value final { private: NT_Value m_val = {}; std::shared_ptr m_storage; - size_t m_size; + size_t m_size = 0; }; +#if __GNUC__ >= 13 +#pragma GCC diagnostic pop +#endif + bool operator==(const Value& lhs, const Value& rhs); /** diff --git a/wpilibcExamples/src/main/cpp/examples/SwerveControllerCommand/cpp/subsystems/SwerveModule.cpp b/wpilibcExamples/src/main/cpp/examples/SwerveControllerCommand/cpp/subsystems/SwerveModule.cpp index bb0362e012..d4ee6ae6a9 100644 --- a/wpilibcExamples/src/main/cpp/examples/SwerveControllerCommand/cpp/subsystems/SwerveModule.cpp +++ b/wpilibcExamples/src/main/cpp/examples/SwerveControllerCommand/cpp/subsystems/SwerveModule.cpp @@ -18,21 +18,25 @@ SwerveModule::SwerveModule(int driveMotorChannel, int turningMotorChannel, : m_driveMotor(driveMotorChannel), m_turningMotor(turningMotorChannel), m_driveEncoder(driveEncoderPorts[0], driveEncoderPorts[1]), - m_turningEncoder(turningEncoderPorts[0], turningEncoderPorts[1]), - m_reverseDriveEncoder(driveEncoderReversed), - m_reverseTurningEncoder(turningEncoderReversed) { + m_turningEncoder(turningEncoderPorts[0], turningEncoderPorts[1]) { // Set the distance per pulse for the drive encoder. We can simply use the // distance traveled for one rotation of the wheel divided by the encoder // resolution. m_driveEncoder.SetDistancePerPulse( ModuleConstants::kDriveEncoderDistancePerPulse); + // Set whether drive encoder should be reversed or not + m_driveEncoder.SetReverseDirection(driveEncoderReversed); + // Set the distance (in this case, angle) per pulse for the turning encoder. // This is the the angle through an entire rotation (2 * std::numbers::pi) // divided by the encoder resolution. m_turningEncoder.SetDistancePerPulse( ModuleConstants::kTurningEncoderDistancePerPulse); + // Set whether turning encoder should be reversed or not + m_turningEncoder.SetReverseDirection(turningEncoderReversed); + // Limit the PID Controller's input range between -pi and pi and set the input // to be continuous. m_turningPIDController.EnableContinuousInput( diff --git a/wpilibcExamples/src/main/cpp/examples/SwerveControllerCommand/include/subsystems/SwerveModule.h b/wpilibcExamples/src/main/cpp/examples/SwerveControllerCommand/include/subsystems/SwerveModule.h index ee2abaf296..8b9cfa3a47 100644 --- a/wpilibcExamples/src/main/cpp/examples/SwerveControllerCommand/include/subsystems/SwerveModule.h +++ b/wpilibcExamples/src/main/cpp/examples/SwerveControllerCommand/include/subsystems/SwerveModule.h @@ -47,9 +47,6 @@ class SwerveModule { frc::Encoder m_driveEncoder; frc::Encoder m_turningEncoder; - bool m_reverseDriveEncoder; - bool m_reverseTurningEncoder; - frc::PIDController m_drivePIDController{ ModuleConstants::kPModuleDriveController, 0, 0}; frc::ProfiledPIDController m_turningPIDController{ diff --git a/wpinet/src/test/native/cpp/WebSocketServerTest.cpp b/wpinet/src/test/native/cpp/WebSocketServerTest.cpp index 3d74ca2dab..7d33fa2eec 100644 --- a/wpinet/src/test/native/cpp/WebSocketServerTest.cpp +++ b/wpinet/src/test/native/cpp/WebSocketServerTest.cpp @@ -396,7 +396,14 @@ TEST_F(WebSocketServerTest, ReceiveFragment) { std::vector data2(4, 0x04); std::vector data3(4, 0x05); std::vector combData{data}; +#if __GNUC__ == 11 +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wstringop-overread" +#endif // __GNUC__ == 11 combData.insert(combData.end(), data2.begin(), data2.end()); +#if __GNUC__ == 11 +#pragma GCC diagnostic pop +#endif // __GNUC__ == 11 combData.insert(combData.end(), data3.begin(), data3.end()); setupWebSocket = [&] { @@ -481,7 +488,14 @@ TEST_F(WebSocketServerTest, ReceiveFragmentWithControl) { std::vector data3(4, 0x05); std::vector data4(4, 0x06); std::vector combData{data}; +#if __GNUC__ == 11 +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wstringop-overread" +#endif // __GNUC__ == 11 combData.insert(combData.end(), data2.begin(), data2.end()); +#if __GNUC__ == 11 +#pragma GCC diagnostic pop +#endif // __GNUC__ == 11 combData.insert(combData.end(), data4.begin(), data4.end()); setupWebSocket = [&] {