-
Notifications
You must be signed in to change notification settings - Fork 664
[DO NOT LAND] Script for 2027 major reorg #8259
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 2027
Are you sure you want to change the base?
Conversation
("cameraserver", "edu.wpi.first.cameraserver", "org.wpilib.vision.stream"), | ||
("xrpVendordep", "edu.wpi.first.wpilibj.xrp", "org.wpilib.xrp"), | ||
("romiVendordep", "edu.wpi.first.wpilibj.romi", "org.wpilib.romi"), | ||
("wpilibjExamples", "edu.wpi.first.wpilibj.commands", "org.wpilib.commands"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe org.wpilib.snippets.commands2
? It should have 2
in the package name, but also shouldn't use org.wpilib.commands2
since that would split the package which Java does not like.
The files in this package are also fairly useless; personally, I'd suggest just deleting it, but that'd out of scope for this PR
It looks like the .hpp renames didn't occur in the source directories (e.g. ntcore and cscore have a bunch of internal .h files in their source directories). I think we'd also like to change all the Looks like there's still some things to move in the wpilibj area that I missed in the spreadsheet? I know some of these may eventually move again or get removed.
|
ntcoreffi's DataLogManager still has some frc namespaces. There's also a comment in wpi/main/Main.hpp for |
There's a few std:: shims that I think we want to keep at the top-level wpi:: namespace. |
The LLVM stuff is mostly not polyfill, so should likely stay in the wpi::util namespace? I guess the broader question is how "clean" do we want the wpi level namespace to be--should it be just true WPILib stuff or should it have container classes etc? |
After those, the following are left in the root package
|
wpilibc has the same things, plus
|
AnalogGyro is going to go away (#8205) so don't worry about that one. |
include_replacements["Color.h"] = "wpi/util/Color" + NEW_CC_FILE_SUFFIX | ||
include_replacements["util/Color8Bit.h"] = "wpi/util/Color8Bit" + NEW_CC_FILE_SUFFIX | ||
include_replacements["BooleanEvent.h"] = "wpi/event/BooleanEvent" + NEW_CC_FILE_SUFFIX | ||
include_replacements["../../include/frc/controller/BangBangController.h"] = "wpi/math/controller/BangBangController" + NEW_CC_FILE_SUFFIX |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
... Weird. I'm just gonna clean it up separately.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a fairly significant number of C headers with .hpp extensions. A good heuristic is that any .h file with a |
Should the hpp renames be applied to thirdparty imports into wpi/ as well? We clearly shouldn't do the ones that can be either thirdparty or pull from vcpkg/system (e.g. libfmt), but llvm, json, sigslot, etc could arguably be renamed. Currently the fact that many of those are still .h leads to a pretty inconsistent feeling for the things in the wpi/ source tree. Understand that patching thirdparty stuff gets complicated. |
My gut says leave them how they are upstream, but that isn't actually currently what is happening. For example The original issue created by @calcmogul only really mentions |
In my opinion, if an upstream library was mostly imported as-is, it should keep the upstream extensions. If it was modified to the point of essentially being a different library anyway, we can make the extensions whatever we want. |
From quickly searching the upstream scripts, this is the state of things: apriltag - originally .h LLVM is the most patched up. argparse, llvm, expected, json, mpack, sigslot have their include paths modified to make them feel like they are part of wpilib. I assume LLVM, eigen and json are the most user facing libraries. After saying all of that, I would lobby for leaving the upstreams how they come (i.e. revert json), but since LLVM is so hacked up and user facing, rename those files |
This is the script I used to perform the big refactoring. It is a little bit unwieldy because it was built with duct tape and bubble gum and then I made an attempt to reorganize and clean it up. It is mildly commented, here is a general overview.
Whats included
This effort attempts to cover as much of the reorg spreadsheet as possible without major build system changes and without major code changes
Things covered in the script:
glass
have been moved into their new folders.hpp
instead of.h
as noted here_c
in their name was to change the file. This might be incorrect.Things NOT covered in the script, which I think are outside the scope of this initial effort
wpilibc
andwpilibj
into a common project. Again, build system change, follow up PRwpiunits
project. Again, build systemserde
project might not bring a whole lot of benefit, so it has been left inwpiutil
with namespaces / include paths unchanged.Process
respective changes to other files, i.e. how to change C++ include paths, or
java package / import renames
1b. Additional renames are applied as per this document https://docs.google.com/spreadsheets/d/1NXgby1njo7oZ9_Ezk8q6ez5VzPTXeLAVRSnB3M1TqR4/edit?gid=1323156307#gid=1323156307
Note, some of the proposed renames require substantial build file modifications or need dependencies broken, and therefore are not covered with this script.
3-N. Apply some manual fixes, as well as run scripts like the linters, upstream utils, pregenerated files, etc
N-M. Apply namespace changes. This is a combination of automated find/replace as well as hand fixes.
An intermediate file,
refactor_layout_pp.json
is created to track the file moves and namespace / import changes. This file can be repurposed in a simpler script to help with the upgrade process for vendors / teamsOther notes
The namespace changes were non-trivial. Since some projects (wpiutil, wpinet shared
wpi::
, wpimath, wpilibc sharedfrc::
) you cannot trivially do a bulk replacement and differentiate between what belongs to what new nested namespace. Furthermore, there is no consistency in C++ if files haveusing namespace XXX;
vsnamespace XXX {}
. Also there was no consistency between when fully qualified names were used vs non fully qualified.To address these things a couple of function / types are defined a prior to get replaced before bulk actions happen. In addition, everything, in both .cpp files and .h files will use fully qualified namespaces, regardless of the fact that they all now share a common
wpi::
prefix.Some of the regex's could probably be combined / simplified / more robust, but it works for a temporary script.
The script is not intended to be located inside of
allwpilib
, but I thought this would be the best way to review it.