-
Notifications
You must be signed in to change notification settings - Fork 276
Jarvis Build System
Jarvis is MRover's custom build system. It is the tool used to build and execute rover applications. After creating a simple project.ini
file, an application may be built with the build
command and executed with the exec
command, regardless of language.
- Introduction
- Building Dependencies
- Creating an Application
- Building an Application
- Running an Application
- Troubleshooting
Under the hood, Jarvis is a bash script that wraps Python code. To invoke jarvis
, run the bash script of the same name in the workspace root directory. When you run the script for the first time, Jarvis will bootstrap itself.
$ ./jarvis
To save keystrokes, create an alias for jarvis
.
$ echo "alias jarvis=\"<path to workspace>/mrover-workspace/jarvis\"" >> ~/.bashrc
Note: Be sure to use >>
rather than >
in the above command. >>
will append the output of echo
to the specified file, while >
will overwrite the file.
Now, when you invoke jarvis
, you can do so without the leading ./
.
$ jarvis
The remainder of this guide will show you how to create, build, and execute an application from scratch using Jarvis. It assumes you have configured the alias for jarvis
.
When you build an application, Jarvis ensures that the required third-party and pip dependencies have been installed. To force Jarvis to install dependencies, you can run
$ jarvis dep
By default, this installs all third-party dependencies contained in the 3rdparty
sub-directory (LCM, RapidJSON, and the Phoenix library) and all pip dependencies specified in the pip_deps
sub-directory. There, requirements are broken into multiple files:
-
requirements.txt
contains general pip dependencies for the repository -
onboard_requirements.txt
contains pip dependencies required only by certainonboard
programs.
Some dependencies are large, and you may want to omit those that you do not require when using Jarvis. For example, some of the pip dependencies required by onboard
programs are too large to be installed on a BeagleBone Black. Jarvis allows the user to create an mrover.site
file in the user's home directory (~/
) to configure which dependencies should be installed on the current platform. The following example mrover.site
is used to configure which dependencies should be installed when building programs on BeagleBone Blacks:
[third_party]
rapidjson=False
phoenix=False
[pip_deps]
onboard=False
- The
[third_party]
header tells Jarvis that this section of the file describes which of the third-party dependencies to install. Because this is on a BeagleBone Black, therapidjson
andphoenix
dependencies are not required (there are currently no C++ rover applications that run on the BeagleBones, andphoenix
is only required to interface with the Talon SRX motor controllers. See the Software Overview page for more details). - The
[pip_deps]
header tells Jarvis that this section of the file describes which of the pip dependencies to install. Because this is on a BeagleBone Black, the dependencies inonboard_requirements.txt
are not required and so Jarvis ignores them to save the time required to build them.
Currently, the following options may be specified in an mrover.site
file:
Header | Options |
---|---|
[third_party] |
lcm , rapidjson , phoenix
|
[pip_deps] |
onboard |
To create a new application, create a sub-directory in an appropriate location within the mrover-workspace
tree. We'll create a new onboard
program as an example.
$ mkdir onboard/hello_world
Next, create a project.ini
file and a directory for our source code.
$ touch onboard/hello_world/project.ini
$ mkdir onboard/hello_world/src
The project.ini
file will tell Jarvis important information about the application such as language and dependencies. The following values may be specified in a project.ini
file under a [build]
header:
Option | Possible Values |
---|---|
lang |
python , js , cpp , lcm , shell , config
|
deps |
comma separated list of rover application sub-directories |
executable (Python only) |
True , False
|
app (JavaScript only) |
True , False
|
port (JavaScript only) |
port number |
We'll use the following project.ini
to specify our application as a Python executable:
[build]
lang=python
executable=True
Create a source file and write some code.
$ touch onboard/hello_world/src/__main__.py
def main():
print("Hello World!")
print("This program was built and executed by Jarvis.")
if __name__ == "__main__":
main()
Now we're ready to build our application.
To build an application, run jarvis build
and provide the path to the application's sub-directory:
$ jarvis build onboard/hello_world
Jarvis will print the build output to the terminal. When building a Python program, Jarvis will lint the program for syntax and style. It is a fairly strict linter, used to enforce good style in MRover's Python code.
Note: For C++ programs, Jarvis wraps the Meson Build system. Thus, to build C++ programs, you'll have to create the additional files required by Meson to build your application (notably, a meson.build
file). There are plenty of docs for Meson available online, so discussion of the syntax for those files is omitted here.
To execute an application, run jarvis exec
and provide the path to the application's sub-directory:
$ jarvis exec onboard/hello_world
Hello World!
This program was built and executed by Jarvis.
If Jarvis ever begins behaving strangely or failing with confusing errors you don't recognize, you can implode and re-bootstrap Jarvis.
$ jarvis implode
$ jarvis
This will completely reinstall Jarvis in your environment. After imploding, all dependencies and programs will need to be rebuilt. Sometimes this is unavoidable, but to save yourself some time ask a member of leadership about your Jarvis errors before resorting to imploding.
Something not right? Contact the Software Branch lead.