Building with the WPILib source code

Often it is desirable to build your robot project with the WPILib source code rather than just using the supplied libraries. This might be because you are modifying the library or just trying to understand how it works. WindRiver Workbench has provisions for having one project (your robot program) reference another project (WPILib in this case). So the strategy to build with WPILib is to open it as a project in Workbench.

WPILib Modification

Many desired changes to or extensions of WPILib classes can be made by making a renamed copy of the class in your team code or making a class that inherits from the WPILib class. This approach is often preferable to modifying WPILib as it makes it much easier to integrate any updates to the libraries.

Locating the WPILib source code

The WPILib source code is supplied as a .zip file archive as part of the FRC WPILib update for WindRiver Workbench. It is located in the C:\WindRiver\WPILib directory in a zip file named with the version number of the source code. This zip file will always match the libraries that were also installed as part of this release.

Extracting the library files from the zip file

Extracting the library files from the zip file

Right-click on the WPILib source zip archive and select "Extract files...". This menu might be different depending on the other .zip file handing programs that you have installed. The idea is to extract the zip file to the directory containing your project.

Right-click inside the Project Explorer tab and select "Import...".

Import the WPILib source code into the WindRiver Workbench workspace

Import the WPILib source code into the WindRiver Workbench workspace

Select "Existing Projects into Workspace" to locate the WPILib source code unzipped in the previous step. Then click "Next>".

Browse For Folder

Browse For Folder

Select the location of the WPILibC++ source code folder that was unzipped and click OK.

Import

Import

With the directory selected, click Finish. You can optionally have Workbench copy the library into your current workspace if you have not already done that.

Project Properties

Project Properties

Right-click on your robot project in the Project Explorer. Select Properties to get the project properties.

Properties for MyRobot

Properties for MyRobot

In the Project Properties window, select "Project References" and then check "WPILib" as the project to reference from your robot project. Then click "OK".

Referenced Project

Referenced Project

WPILib has been inserted (logically) into your project as a referenced project. Workbench hasn't moved any files on disk, just rearranged the tree view of your projects. If you have a second robot project that you want to build with the WPILib source code, it will appear inside both projects even though there is only a single copy of the source code on the disk.

Properties for MyRobot

Properties for MyRobot

Once again, get the properties for your project by right-clicking on the project name in the Project Explorer tab and select "Properties". Select the "Build Properties" section of the window. Notice that there is a "Paths" tab that refers to all the include file directories and a "Libraries" tab that refers to the libraries that your project will use. These must be changed to use the WPILib library.

Change the "Paths" property to refer to the copy of WPILib in your workspace

Change the "Paths" property to refer to the copy of WPILib in your workspace

Set the path to the place where WPILib is unpacked. In this case it's in c:\temp\workspace\wpilib. It would usually be in c:\windriver\workspace\wpilib.

Set library path for the copy of WPILib in your workspace

Set library path for the copy of WPILib in your workspace

The copy of WPILib must also be set to refer to the version in the workspace. Notice that it's in the PPC603gnu directory and the file is WPILib.a. This is the library file.