Skip to content

Commit

Permalink
add template building workflow
Browse files Browse the repository at this point in the history
this also makes a bunch of fixes to the existing templates. this
workflow should hopefully make maintaining templates easier.
  • Loading branch information
Univa committed Dec 6, 2023
1 parent b6c2c81 commit e341f94
Show file tree
Hide file tree
Showing 13 changed files with 233 additions and 17 deletions.
2 changes: 2 additions & 0 deletions .github/values/template-values.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[values]
keyboard-name = "TestKeyboard"
32 changes: 32 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Build all templates

on:
push:
branches: [main]
paths:
- "*-template/**"
- ".github/workflows/build.yml"
workflow_dispatch:

jobs:
build:
strategy:
fail-fast: false
matrix:
template: ["rumcake-basic-template", "rumcake-split-template"]

name: Build template
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Install cargo-binutils and cargo-generate
run: cargo install cargo-binutils cargo-generate

- name: Generate template
run: cargo generate --path . ./${{ matrix.template }} --name ci-template-test --template-values-file="./.github/values/template-values.toml"

- name: Build binary
run: ./build.sh
working-directory: ./ci-template-test
10 changes: 9 additions & 1 deletion rumcake-basic-template/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,15 @@ cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] }
cortex-m-rt = "0.7.0"
embassy-executor = { git = "https://github.com/embassy-rs/embassy", rev = "7703f47" }

rumcake = { git = "https://github.com/Univa/rumcake", rev = "7e1d38a", features = ["usb", "stm32f303cb", "drivers", "vial", "underglow"] }
rumcake = { git = "https://github.com/Univa/rumcake", rev = "d05cf7b", features = ["usb", "stm32f303cb", "drivers", "vial", "underglow"] }

[build-dependencies]
rust-lzma = "0.6.0"
json = "0.12.4"
quote = "1.0.32"
proc-macro2 = "1.0.66"
serde = { version = "1.0", features = ["derive"] }
toml = "0.7.6"

[profile.release]
debug = 2
Expand Down
2 changes: 1 addition & 1 deletion rumcake-basic-template/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ rustup component add llvm-tools-preview
Then, you can build your firmware:

```bash
cargo objcopy --release -- -O binary keyboard.bin
cargo objcopy --release -- -O binary firmware.bin
```

Then, flash it to your keyboard (make sure it is in DFU mode already):
Expand Down
10 changes: 10 additions & 0 deletions rumcake-basic-template/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env bash

# Note: `cargo build` isn't actually needed to generate a binary, but
# `cargo objcopy` doesn't show errors if they happen during the build process,
# so we use `cargo build` anyways to see them. Should be fine as long as
# incremental compilation is enabled.

# Generate bin files
cargo build --release &&
cargo objcopy --release -- -O binary firmware.bin
2 changes: 1 addition & 1 deletion rumcake-basic-template/rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[toolchain]
channel = "nightly-2023-12-05"
components = [ "rust-src", "rustfmt", "llvm-tools-preview" ]
targets = [ "thumbv6m-none-eabi" ]
targets = [ "thumbv7em-none-eabihf" ]

159 changes: 159 additions & 0 deletions rumcake-basic-template/src/definition.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
{
"name": "{{ keyboard-name }}",
"vendorId": "0x0000",
"productId": "0x0000",
"lighting": "qmk_rgblight",
"matrix": {
"rows": 10,
"cols": 8
},
"layouts": {
"keymap": [
[
{
"c": "#777777"
},
"0,0",
{
"c": "#cccccc"
},
"1,0",
"0,1",
"1,1",
"0,2",
"1,2",
"0,3",
"1,3",
"0,4",
"1,4",
"0,5",
"1,5",
"0,6",
{
"c": "#777777",
"w": 2
},
"0,7",
"2,7"
],
[
{
"c": "#aaaaaa",
"w": 1.5
},
"2,0",
{
"c": "#cccccc"
},
"3,0",
"2,1",
"3,1",
"2,2",
"3,2",
"2,3",
"3,3",
"2,4",
"3,4",
"2,5",
"3,5",
"2,6",
{
"w": 1.5
},
"3,6",
{
"c": "#777777"
},
"4,7"
],
[
{
"c": "#aaaaaa",
"w": 1.75
},
"4,0",
{
"c": "#cccccc"
},
"5,0",
"4,1",
"5,1",
"4,2",
"5,2",
"4,3",
"5,3",
"4,4",
"5,4",
"4,5",
"5,5",
{
"c": "#777777",
"w": 2.25
},
"5,6",
"6,7"
],
[
{
"c": "#aaaaaa",
"w": 2.25
},
"6,0",
{
"c": "#cccccc"
},
"6,1",
"7,1",
"6,2",
"7,2",
"6,3",
"7,3",
"6,4",
"7,4",
"6,5",
"7,5",
{
"c": "#777777"
},
"6,6",
{
"c": "#aaaaaa",
"w": 1.75
},
"7,6",
{
"c": "#777777"
},
"8,7"
],
[
{
"x": 1.5,
"c": "#aaaaaa",
"w": 1.25
},
"8,0",
{
"w": 1.25
},
"8,1",
{
"c": "#cccccc",
"w": 6.25
},
"8,3",
{
"c": "#aaaaaa",
"w": 1.25
},
"8,5",
{
"c": "#777777"
},
"9,5",
"8,6",
"9,6"
]
]
}
}
3 changes: 1 addition & 2 deletions rumcake-basic-template/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
#![feature(macro_metavar_expr)]
#![feature(type_alias_impl_trait)]
#![feature(generic_const_exprs)]
#![feature(return_position_impl_trait_in_trait)]

// TODO: Add your `definition.json` file to the `src` folder.
// TODO: Edit the `definition.json` file in the `src` folder to match your keyboard.
// _generated.rs is generated at build time, and will contain a serialized version of your Vial definition file to be compiled into your firmware.
// This file won't be generated if you don't specify the "vial" feature flag for rumcake.
#[cfg(vial)]
Expand Down
2 changes: 1 addition & 1 deletion rumcake-split-template/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ cortex-m = { version = "0.7.6" }
cortex-m-rt = "0.7.0"
embassy-executor = { git = "https://github.com/embassy-rs/embassy", rev = "7703f47" }

rumcake = { git = "https://github.com/Univa/rumcake", rev = "7e1d38a", features = ["nrf52840", "drivers", "nrf-ble"] }
rumcake = { git = "https://github.com/Univa/rumcake", rev = "d05cf7b", features = ["nrf52840", "drivers", "nrf-ble"] }

[profile.dev]
debug = 2
Expand Down
12 changes: 10 additions & 2 deletions rumcake-split-template/build.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
#!/usr/bin/env bash

# Note: `cargo build` isn't actually needed to generate a binary, but
# `cargo objcopy` doesn't show errors if they happen during the build process,
# so we use `cargo build` anyways to see them. Should be fine as long as
# incremental compilation is enabled.

# Generate bin files
cargo objcopy --bin left --features "rumcake/split-central rumcake/bluetooth rumcake/usb" --release -- -O binary left.bin
cargo objcopy --bin right --features "rumcake/split-peripheral" --release -- -O binary right.bin
cargo build --bin left --features "rumcake/split-central rumcake/bluetooth rumcake/usb" --release &&
cargo objcopy --quiet --bin left --features "rumcake/split-central rumcake/bluetooth rumcake/usb" --release -- -O binary left.bin

cargo build --quiet --bin right --features "rumcake/split-peripheral" --release &&
cargo objcopy --quiet --bin right --features "rumcake/split-peripheral" --release -- -O binary right.bin
2 changes: 1 addition & 1 deletion rumcake-split-template/rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[toolchain]
channel = "nightly-2023-12-05"
components = [ "rust-src", "rustfmt", "llvm-tools-preview" ]
targets = [ "thumbv6m-none-eabi" ]
targets = [ "thumbv7em-none-eabihf" ]

13 changes: 6 additions & 7 deletions rumcake-split-template/src/left.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#![feature(macro_metavar_expr)]
#![feature(type_alias_impl_trait)]
#![feature(generic_const_exprs)]
#![feature(return_position_impl_trait_in_trait)]

use defmt_rtt as _;
use panic_probe as _;
Expand All @@ -23,7 +22,7 @@ impl Keyboard for {{ keyboard-name }}Left {

// Layout configuration
use rumcake::bluetooth::BluetoothCommand::*;
use rumcake::keyberon::action::Action::*;
use rumcake::keyberon::action::{Action::Custom, Action::*};
use rumcake::keyboard::{KeyboardLayout, Keycode::*};
impl KeyboardLayout for {{ keyboard-name }}Left {
build_layout! {
Expand All @@ -34,10 +33,10 @@ impl KeyboardLayout for {{ keyboard-name }}Left {
[ No No No 1 LShift LAlt BSpace Space 2 No No No ]
}
{
[ LGui F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 ]
[ t t t t t t Left Down Up Right t t ]
[ {Custom(Bluetooth(ToggleUSB))} t t t t t Home PgDown PgUp End t F12 ]
[ t t t t t t PScreen Enter t t t t ]
[ LGui F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 ]
[ t t t t t t Left Down Up Right t t ]
[ {Custom(Bluetooth(ToggleOutput))} t t t t t Home PgDown PgUp End t F12 ]
[ t t t t t t PScreen Enter t t t t ]
}
{
[ t 1 2 3 4 5 6 7 8 9 0 '(' ]
Expand Down Expand Up @@ -72,7 +71,7 @@ impl BluetoothKeyboard for {{ keyboard-name }}Left {
// Split keyboard setup
use rumcake::drivers::nrf_ble::central::NRFBLECentralDevice;
impl NRFBLECentralDevice for {{ keyboard-name }}Left {
const PERIPHERAL_ADDRESSES: &'static [[u8; 6]] = [[0x00, 0x00, 0x00, 0x00, 0x00, 0x00]]; // TODO: Change this, must contain the address for the right half.
const PERIPHERAL_ADDRESSES: &'static [[u8; 6]] = &[[0x00, 0x00, 0x00, 0x00, 0x00, 0x00]]; // TODO: Change this, must contain the address for the right half.
}

// USB configuration
Expand Down
1 change: 0 additions & 1 deletion rumcake-split-template/src/right.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#![feature(macro_metavar_expr)]
#![feature(type_alias_impl_trait)]
#![feature(generic_const_exprs)]
#![feature(return_position_impl_trait_in_trait)]

use defmt_rtt as _;
use panic_probe as _;
Expand Down

0 comments on commit e341f94

Please sign in to comment.