Forking allwpilib and Contributing

So I’ve forked allwpilib and managed to contribute back to WPILIB this year. It has been a struggle on my end and I do want to thank everyone that has supported me on chief and on the conversations in the PR’s themselves.

I do have a question about editing code. I use simple tools like VS code. I’ve noticed that when I load allwpilib that there are tons of errors, which I’m assuming is because of imports not being loaded and the general way in which the project is constructed. No worries there.

Is there a way to remove these errors by effectively having the import load and not mess anything up. I know I can turn them off, but having autocomplete and autochecking really helps me as I’m sure it does many other people.

I don’t really want to switch editors.

Thanks.

2 Likes

If you run a full local build they should all resolve.

What is the command for that?

Also will that interfere with pull requests?

.\gradlew build

No, because it’s just building the generated code, which is not checked into the repository. You’re going to need to build to test locally anyway.

I personally use vscode for WPILib development. For Java, I just use the standard Java development pack of vscode extensions. For C++ work, I generally use cmake (rather than gradle) to build and clangd (and vscode clangd extension) for intellisense.

2 Likes

Thank you. I thought I had tried that and issue didn’t go away.

I’ll try again.

Also with formatting and linting. Other than silly errors on my part is there a way to automatically handle these and I’m really having difficulties reading the github logs and determining what the formating issues are?

Unfortunately running .\gradlew build didn’t remove the errors. There is like over 4000 of them.
I have the Java extensions and c++ extensions installed.

Most of us devs use vscode as well.

C++ errors can mostly be solved by running ./gradlew generateVsCode. You’ll also need the wpilib extension installed. That generates the same config that robot projects do, and I’ve found work really well.

It’s very difficult to get all the errors out of Java code. But switching to another ide doesn’t help here either. It’s caused by the gradle integration not knowing about the code generation, so it will do a configuration but not be able to find any of the generated code. Which is where most of the errors come from in my experience.

1 Like

Do I need a copy of regular Visual Studio with C++ development installed?

Yes, you need a desktop compiler for allwpilib. On windows that’s vs with the c++ workflow, on Linux that’s build-essential and on Mac that is Xcode.

1 Like

For C++, we have our own tool called wpiformat (pip install wpiformat to install it); most of the heavy lifting is done by clang-format, so when I’m just formatting when editing I can use the clang-format extension in vscode to reformat and it does most of what’s needed (the other parts wpiformat does are things like reordering header files).

For Java, we use spotless; the gradlew spotlessApply command can be used to auto-format the Java code. Spotless doesn’t catch/clean up PMD errors though; those have to be fixed manually.

In GitHub, we have a comment trigger /format to run both of these to clean up PRs–you can look at the GitHub actions file to see what it does.

can I run pip from wpilib vs code terminal or do I need to run it seperately?

You’ll need Python installed for that command to work. If you have it installed, you can probably run it from any terminal? That’s just the command to install it, to run it after it’s installed it’s just wpiformat (assuming it’s on the PATH).

1 Like

At the end of the day am I in the correct order of magnitude or should I be seeing far less Java errors than 4000

I haven’t looked in a while, but that sounds about right. Next time I’m at a computer I can look.

As an aside most of the import errors are coming from
import edu.wpi.first.math.numbers.N1;
inside math.numbers. Not sure if related or if fixable.

Yup. Those are the generated files it has trouble with.

Just noticed that when using the VSCode for beta 2024 that the Java imports are being discovered. Thank you.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.