Commit Graph

96 Commits

Author SHA1 Message Date
Peter Johnson
96fb033deb [build] Remove cmake Java support (#8952)
This is increasingly difficult to maintain, and has very limited
benefit. Modern coprocessors with enough horsepower to run Java
applications can use the Gradle or Bazel build systems instead.
2026-06-05 15:05:09 -07:00
Tyler Veness
af7d68e993 [wpiutil] Use C++23 stacktrace library on Windows (#6839)
This lets us remove the unmaintained StackWalker library and its hacky
upstream_utils script.

@Gold856 reported that StackWalker gives blank stacktraces:
https://discord.com/channels/176186766946992128/368993897495527424/1261940029287301150.
They also reported an earlier version of this PR giving the following
stacktrace instead:
```
D:\allwpilib\developerRobot\src\main\native\cpp\Robot.cpp(18): developerRobotCpp!Robot::RobotInit+0xB6
D:\allwpilib\wpilibc\src\main\native\cpp\TimedRobot.cpp(22): wpilibcd!frc::TimedRobot::StartCompetition+0x4F
D:\allwpilib\wpilibc\src\main\native\include\frc\RobotBase.h(36): developerRobotCpp!frc::impl::RunRobot<Robot>+0xC8
D:\allwpilib\wpilibc\src\main\native\include\frc\RobotBase.h(106): developerRobotCpp!frc::StartRobot<Robot>+0x17E
D:\allwpilib\developerRobot\src\main\native\cpp\Robot.cpp(60): developerRobotCpp!main+0xB
D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl(79): developerRobotCpp!invoke_main+0x39
D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl(288): developerRobotCpp!__scrt_common_main_seh+0x132
D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl(331): developerRobotCpp!__scrt_common_main+0xE
D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_main.cpp(17): developerRobotCpp!mainCRTStartup+0xE
KERNEL32!BaseThreadInitThunk+0x1D
ntdll!RtlUserThreadStart+0x28
```
2026-04-26 00:15:39 -07:00
Gold856
2102a543d1 Change Java JSON to Avaje Jsonb (#8721)
Jackson is a very heavy library; it supports loads of features that we
don't need, and historically has caused issues due to long class loading
times (a little over 2 seconds to load AprilTagFieldLayout). This often
manifests as a help request in the form of "my robot disables when I do
X, but doesn't disable when doing X in subsequent attempts until code
restart." While SC has brought down Jackson loading times significantly,
with AprilTagFieldLayout loads taking only 330 milliseconds, that's
still a rather long delay, and while libraries should handle any JSON
loading ahead of time to prevent delays in auto/teleop, it would still
be good to make the worst case better to reduce user frustration.
Benchmarks indicate using [Avaje
Jsonb](https://github.com/avaje/avaje-jsonb) to load AprilTagFieldLayout
only takes ~70 ms, a fair chunk of which isn't actually in Avaje Jsonb
(~4 ms is spent on using getResourceAsStream to retrieve the JSON file,
~8 ms is spent on just loading the AprilTag class and its dependencies).

Note that all times listed are end-to-end, meaning nothing else was done
except for the operation being benchmarked, and doing arithmetic on them
can be flawed due to some classes being loaded twice, i.e.,
getResourceAsStream and `new AprilTag()` likely load some of the same
JDK classes and so subtracting both from the Avaje Jsonb load time is
likely slightly incorrect because class loading is being double counted.
For our purposes, it's likely accurate enough and is mostly just for
contextualization.

Benchmarks were run on a Raspberry Pi CM5 with 2 GB of RAM. Source code
for the
[results](https://github.com/user-attachments/files/26471452/benchmark.txt)
can be found in the "Fastjson2" commit
(2456d15ca8ebd17635e607cd40bf8816e77869a1).

Avaje Jsonb uses code generation via annotation processors to generate
the classes needed to do JSON serde and uses service providers to find
them, which will require downstream changes in robot projects, as the
different service providers in each library must be merged together for
Avaje Jsonb to function. We will use the Gradle shadow plugin, as its
already used by the installer and therefore adds zero additional
dependencies.
2026-04-10 23:21:00 -07:00
Peter Johnson
de3e211fdb [upstream_utils] Add jart/json.cpp 2026-04-08 08:28:28 -07:00
Peter Johnson
3ac168f9d2 [upstream_utils] Add double-conversion to wpiutil 2026-04-08 08:28:28 -07:00
Peter Johnson
1ce2854a1e Merge branch 'main' into 2027 2025-09-20 11:19:40 -07:00
Gold856
5cd97c6353 [upstream_utils] Add Catch2 (#8203) 2025-09-08 15:14:23 -06:00
Tyler Veness
632749e6f3 [build] Upgrade Maven dependencies (#8173) 2025-09-01 08:13:46 -07:00
Gold856
d4311d5a29 [wpiutil,glass,dlt] Replace libprotobuf with upb for dynamic decode (#7988)
libprotobuf is a very annoying dependency to deal with, and with the switch to nanopb for generated C++ code, libprotobuf is only used for dynamic decode in the GUI apps. libprotobuf has been swapped out with upb, a much smaller C-based library that supports reflection and can therefore do dynamic decode. This means we can remove the libprotobuf dependency and stop dealing with build issues because of it.
2025-08-16 22:56:32 -07:00
Peter Johnson
82ce317083 Merge branch 'main' into 2027 2025-06-30 20:21:11 -07:00
Tyler Veness
ddc5220ed4 [upstream_utils] Remove memory library (#8035)
We added this in 2022. If we haven't used it by now, we probably never
will and it's just wasting space.
2025-06-24 22:35:30 -07:00
DeltaDizzy
da47f06d70 [datalog] Move all DataLog functionality to new datalog library (#7641)
Currently the major DataLog backend API (reading and writing) is split between wpiutil and glass. In the interest of allowing code that wants to use these APIs to not need to link to glass and declutter wpiutil, all of those APIs are moved to a new library named "datalog".

Signed-off-by: Jade Turner <spacey-sooty@proton.me>
Co-authored-by: Jade Turner <spacey-sooty@proton.me>
Co-authored-by: Gold856 <117957790+Gold856@users.noreply.github.com>
2025-02-19 21:08:17 -08:00
Peter Johnson
76625fa0f9 [build] cmake: Build wpiutil dev executable (#7578) 2024-12-22 15:03:33 -08:00
Tyler Veness
b7eb9fb8f9 [upstream_utils] Add std::is_debugger_present() shim (#7423) 2024-11-22 09:17:23 -08:00
Thad House
d39dfd64ea [build] Fix cmake build with WITH_PROTOBUF off (#7368)
Protobuf.cpp only uses nanopb, which is fine to have even with WITH_PROTOBUF off.
2024-11-08 14:05:29 -08:00
Thad House
8b8b634f65 [wpiutil] Change C++ protobuf to nanopb (#7309)
The Google C++ protobuf implementation has issues with dynamic linkage across DLL boundaries because it uses global variables.  It also has a compile-time dependency because the protoc version must exactly match the libprotobuf version.  Using nanopb with a customized generator fixes both of these issues.

Co-authored-by: Gold856 <117957790+Gold856@users.noreply.github.com>
2024-11-07 22:42:50 -08:00
Peter Johnson
dcf5f55a30 [upstream_utils] Remove ConcurrentQueue (#7183)
It appears to be broken under stress testing (dropped/duplicate values).

This reverts commit 97c6c86f3b (#7066).
2024-10-10 23:41:41 -07:00
Tyler Veness
d44b651558 [build] Make Protobuf optional in CMake build (#7061) 2024-09-12 23:44:19 -07:00
Ryan Blue
32252f7d6a [upstream_utils] Import argparse to wpiutil (#7071) 2024-09-12 20:10:43 -07:00
Ryan Blue
97c6c86f3b [upstream_utils] Import ConcurrentQueue to wpiutil (#7066) 2024-09-10 23:12:22 -07:00
Gold856
6b0aeb8e90 [build] CMake: consolidate and clean up include dirs (#6927)
Also remove the thirdparty AprilTag source directory from both CMake and Gradle header setup.
2024-08-10 23:39:17 -07:00
PJ Reiniger
f561a77e75 [upstream_utils] Add googletest (#6820) 2024-07-18 21:10:26 -07:00
Gold856
9703142ebe [build] CMake: simplify source JAR creation and install (#6831)
Bump required minimum CMake version to 3.21.
2024-07-15 15:12:41 -07:00
Gold856
e00bb2f07b [build] CMake: add some compiler flags from native-utils (#6825) 2024-07-12 21:51:55 -07:00
Gold856
bf75c03218 [build] Clean up CMake files (#6802)
Explicitly list required components when using FindJava and FindJNI
Consolidate find_package calls for Java, JNI, and OpenCV into the root CMakeLists.txt file
Remove references to main_lib_dest
Install missing generated headers
Flatten some if statements
Use LinkMacOSGUI macro instead of hand rolling it
Stop installing OpenCV libraries and an extra ntcorejni library; OpenCV JAR will still be installed to make it easy to use
Only print platform version on Windows
Prevent GUI modules from being built when wpimath is off, which would otherwise cause a build failure
Simplify build configuration checks
Clean up fieldImages JAR creation
Place built JARs in the same subdir as installed JARs
Remove unnecessary JAR includes
Remove extra directories in target_include_directories
Improve CMake docs
2024-07-11 16:01:05 -06:00
Gold856
5ce72d43e4 [build] Fix CMake protobuf dependency handling (#6772)
Reverts #6609 since that fix didn't Just Work(tm) on Windows. (edit: or Ubuntu. Seems to have broken everything except macOS.) This PR configures CMake to try and find protobuf-config.cmake first, which allows protobuf to pull in abseil for us. If protobuf-config.cmake is not available (coprocessors which don't have a new enough protobuf installed are a common case), it will fallback to CMake's built-in FindProtobuf module, which is what we were using before.

Add wpi::CreateMessage, a wrapper with an ifdef to switch between Arena::CreateMessage and Arena::Create, since the former is deprecated in newer versions of protobuf. This allows forward compatibility with newer versions of protobuf.
2024-06-28 06:28:39 -07:00
Gold856
72a6d22d9a [build] Organize cmake files (#6617) 2024-05-24 10:48:05 -07:00
Michael Fisher
b0d3bf4ddf [build] cmake: add absl dependency for newer protobuf (#6609)
Works around a bug on some systems where protobuf does not correctly depend on required absl libraries.
2024-05-14 21:25:15 -06:00
Tyler Veness
74f648689e [build] Add exports to CMake subprojects (#6505)
This allows consuming allwpilib via FetchContent.
2024-04-10 22:04:22 -07:00
Tyler Veness
d895a0c09f [wpiutil] Add std::expected shim (#6310)
Its tests use Catch2 instead of GoogleTest, so we can't import them.
2024-01-25 22:21:37 -08:00
Thad House
0e5eb3f35c [wpiutil] Fix DynamicStruct string handling (#6253)
Dynamic structs had a few major issues.

In C++, if the string was the last definition in the schema, attempting to set a string would trigger an assertion. This has been fixed

Setting a string value could truncate the string actually stored in the struct, if the definition was shorter than the string to set.
There was no way to detect if this case occurred. The set string function now returns a bool if the string was fully written or not.

Reading a string that had a value shorter than the schema definition would result in embedded trailing nulls in the string. This would make comparing string equality basically impossible, as those embedded nulls count for the length of the string.

The above truncating didn't take into account UTF8 code points. This means a truncation could happen in the middle of a unicode character. Depending on the language this had different behavior, but unpaired code points are problematic to detect in any case. On the decoding side, detect if a split UTF8 code point has occurred by the writer, and if so just ignore it and treat it as not part of the string. Doing this on the receive side means a newer receive side is all that is needed to fix this, which is generally a better option then requiring all senders to update.

Actual DynamicStruct instances have 0 units tests for them. Added a bunch of unit tests around strings to ensure things work properly.
2024-01-19 22:24:54 -08:00
Isaac Turner
35a1c52788 [build] Upgrade quickbuf to 1.3.3 (#6072) 2023-12-20 22:30:45 -06:00
Gold856
f5fc101fda [build] cmake: Export jars and clean up jar installs (#6014) 2023-12-06 18:28:38 -08:00
Gold856
4fcf0b25a1 [build] Apply a formatter for CMake files (#5973) 2023-11-30 16:52:21 -08:00
Gold856
25b7dca46b [build] Remove CMake flat install option (#5944) 2023-11-21 11:48:32 -08:00
Gold856
9eecf2a456 [build] Add CMake option to build Java sources jars (#5768) 2023-10-30 09:57:28 -07:00
Peter Johnson
cf54d9ccb7 [wpiutil, ntcore] Add structured data support (#5391)
This adds support for two serialization formats for complex data types:

- Protobuf for complex objects with variable length internals that need forward and backward wire compatibility (lower speed, more flexible)
- Raw struct (ByteBuffer-style) for fixed-length objects (higher speed, less flexible)

Deserialization can be done either by creating a new object (for immutable objects) or overwriting the contents of an existing object (for mutable objects).

Implementing classes should provide inner classes that implement the Protobuf or Struct interface (in Java) or specialize the wpi::Protobuf or wpi::Struct struct (in C++). It is possible for classes to implement both. If the class itself does not implement serialization, it's possible for third parties/users to provide an implementation instead.

Uses the Google protobuf implementation for C++ and the QuickBuffers alternative protobuf implementation for Java.
2023-10-19 21:41:47 -07:00
Peter Johnson
7d9ba256c2 Revert "[build] Add CMake option to build Java source jars (#5756)" (#5766)
This reverts commit 1c724884ca.

This commit broke local builds on the second run of cmake configure.
2023-10-14 23:53:27 -07:00
Gold856
1c724884ca [build] Add CMake option to build Java source jars (#5756) 2023-10-11 12:50:54 -07:00
Peter Johnson
7be290147c [wpiutil] Refactor SpanMatcher and TestPrinters from ntcore (#5658) 2023-09-18 00:11:36 -07:00
autoantwort
cb99517838 [build] cmake: Use default install location on windows for dlls (#5580) 2023-09-17 16:17:32 -07:00
autoantwort
25b0622d4c [build] Add Windows CMake CI (#5516) 2023-09-17 16:16:52 -07:00
Tyler Veness
383289bc4b [build] Make custom CMake macros use lowercase (#5594)
Most of them already do use lowercase, and uppercase is like screaming
at the user.
2023-08-30 21:17:09 -07:00
Ryan Blue
45e7720ec1 [build] Add error message when downloading files in CMake (#5593)
CMake's file(DOWNLOAD) function fails silently, leading to an error occurring due to a missing file later in the build. This fails quickly and produces a better error message.
2023-08-30 21:16:48 -07:00
Tyler Veness
9d86624c00 [build] Fix CMake configure warnings (#5577)
FetchContent requires CMake 3.11 (released Mar 28, 2018).

Fixed this warning:
```
CMake Warning (dev) at /usr/share/cmake/Modules/FetchContent.cmake:1316 (message):
  The DOWNLOAD_EXTRACT_TIMESTAMP option was not given and policy CMP0135 is
  not set.  The policy's OLD behavior will be used.  When using a URL
  download, the timestamps of extracted files should preferably be that of
  the time of extraction, otherwise code that depends on the extracted
  contents might not be rebuilt if the URL changes.  The OLD behavior
  preserves the timestamps from the archive instead, but this is usually not
  what you want.  Update your project to the NEW behavior or specify the
  DOWNLOAD_EXTRACT_TIMESTAMP option with a value of true to avoid this
  robustness issue.
Call Stack (most recent call first):
  imgui/CMakeLists.txt:23 (FetchContent_Declare)
```
2023-08-28 15:06:51 -07:00
Tyler Veness
96f7fa662e Upgrade Maven dependencies (#5553)
The following source code changes were required:

* Whitespace changes from spotless
* PMD warning suppressions for utility class tests
* PMD warning rename from "BeanMembersShouldSerialize" to
  "NonSerializableClass"
* Declared more class members as final
2023-08-18 19:18:33 -07:00
autoantwort
6953a303b3 [build] Fix the windows build with fmt (#5544) 2023-08-16 17:07:23 -07:00
autoantwort
e2d385d80a [build] cmake: Respect USE_SYSTEM_FMTLIB (#5429) 2023-07-09 21:24:46 -07:00
Ryan Blue
1fca519fb4 [wpiutil] Remove remnants of ghc fs and tcb_span libraries (#5411) 2023-06-22 19:42:44 -07:00
Peter Johnson
df70351107 [build] Fix cmake install of thirdparty includes (#4741) 2022-11-29 21:58:38 -08:00