forked from bazelRio/bazelRio
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME.md.template
111 lines (86 loc) · 3.37 KB
/
README.md.template
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
<h1 align="center">
<img src="https://avatars.githubusercontent.com/u/84363228?s=200&v=4" width="256">
<br />
BazelRIO
<br />
<img src="https://img.shields.io/badge/semver-$TAG-blue">
<img src="https://img.shields.io/badge/license-MIT-blue.svg">
<img src="https://img.shields.io/badge/PRs-welcome-brightgreen.svg">
<img src="https://github.com/bazelRio/bazelRio/actions/workflows/build-example.yaml/badge.svg">
</h1>
<p align="center">
<b>
A collection of <a href="https://bazel.build">bazel</a> utilities for FRC
</b>
</p>
## Installation
You can include BazelRIO in your project like so:
```bazel
http_archive(
name = "bazelrio",
url = "https://github.com/bazelRio/bazelRio/archive/refs/tags/$TAG.zip",
sha256 = "$SHA256",
strip_prefix = "bazelRio-$TAG/bazelrio",
)
load("@bazelrio//:deps.bzl", "setup_bazelrio_dependencies")
setup_bazelrio_dependencies()
load("@bazelrio//:defs.bzl", "setup_bazelrio")
setup_bazelrio()
```
You **must** copy the `.bazelrc` file from the [C++](./examples/cpp_example) or [Java](./examples/java_example) example into your project workspace and update your `BUILD` and `WORKSPACE` files in the same fashion.
## Features
### Support matrix
| Language | Compilation | Simulation | Deployment |
| --- | --- | --- | --- |
| C++ | 🟢 | 🟢 | 🟢 |
| Java | 🟢 | 🔴 | 🟢 |
| Kotlin | 🟢 | 🔴 | 🟢 |
| Python | 🔴 | 🔴 | 🔴 |
### Cross compilation
BazelRIO provides a RoboRIO target for easy cross-compilation.
```sh
bazel build <target> --platforms=@bazelrio//platforms/roborio
```
BazelRIO will automatically download an official roboRIO toolchain (from [WPILib](https://github.com/wpilibsuite/roborio-toolchain)) for your host OS and use it.
### Robot code rules
BazelRIO provides rules for robot code targets of multiple languages.
#### C++
```bazel
load("@bazelrio//:defs.bzl", "robot_cc_binary")
robot_cc_binary(
name = "hello",
team_number = 1337,
srcs = ["hello.cpp"],
)
```
BazelRIO will create a `cc_binary` target named `hello`, as well as a special target named `hello.deploy` that can be used to deploy your binary:
```
bazel run //:hello.deploy --platforms=@bazelrio//platforms/roborio
...
Attempting to connect to roborio-1337-frc.local...
Connected to roborio-1337-frc.local.
Attempting to deploy bazel-out/darwin-fastbuild/bin/hello...
Deployed bazel-out/darwin-fastbuild/bin/hello. Exiting.
```
#### Java / Kotlin
```bazel
robot_java_binary(
name = "hello",
main_class = "frc.robot.Main",
team_number = 1337,
runtime_deps = [
"//src/main/java/frc/robot",
],
)
```
BazelRIO will create a `java_binary` target named `hello`, as well as a special target named `hello.deploy` that can be used to deploy your binary. If you are using Kotlin, you *must* build your code as a `kt_jvm_library` and add it to `runtime_deps`, rather than adding Kotlin files directly to `srcs`.
### Libraries
BazelRIO containts library targets for WPILib and some vendor libraries:
- `@bazelrio//libraries/cpp/wpilib/wpilibc`
- `@bazelrio//libraries/java/wpilib/wpilibj`
- `@bazelrio//libraries/cpp/ctre/phoenix`
- `@bazelrio//libraries/cpp/rev/sparkmax`
- `@bazelrio//libraries/cpp/rev/colorsensor`
- `@bazelrio//libraries/cpp/kauailabs/navx`
## Simulations
Simulations (alongside halsim extensions) are supported! Take a look at the [C++ example](./examples/cpp_example) to get started.