Reorganize rust code into crate (for multi-file package)

main
Ashelyn Dawn 2 years ago
parent 2058bf9b36
commit af4e7b5e3d

3
.gitignore vendored

@ -1 +1,2 @@
out/
out/
rust-funcs/target/

@ -15,8 +15,13 @@ run qmk setup -y -H /qmk_firmware
run curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -t thumbv7em-none-eabihf -y
env PATH="/root/.cargo/bin/:${PATH}"
copy ./compile.sh /usr/bin/compile.sh
run dos2unix /usr/bin/compile.sh
run chmod +x /usr/bin/compile.sh
copy /scripts/compile.sh /opt/compile.sh
run dos2unix /opt/compile.sh
run chmod +x /opt/compile.sh
copy ./keymap/* /qmk_firmware/keyboards/massdrop/alt/keymaps/ashe/
copy ./rust-funcs /rust-funcs/
run find /qmk_firmware/keyboards/massdrop/alt/keymaps/ashe | xargs dos2unix
run find /rust-funcs/ | xargs dos2unix
cmd /opt/compile.sh

@ -7,11 +7,4 @@ IMAGE=$(sudo docker build -q .)
sudo docker run -it \
--mount type=bind,src=$(pwd)/out,dst=/out \
$IMAGE \
sh -c compile.sh
# cp out/massdrop_alt_ashe.bin ~/bin/Massdrop/qmk/massdrop_alt_ashe.bin
# cd ~/bin/Massdrop/
# ./md_loader_windows.exe --first --download ./qmk/massdrop_alt_ashe.bin --restart
$IMAGE

@ -1,9 +0,0 @@
#!/bin/bash
set -e
cd /qmk_firmware/
rustc -O --emit=obj --target=thumbv7em-none-eabihf --codegen panic=abort -o pomodoro.o ./keyboards/massdrop/alt/keymaps/ashe/pomodoro.rs
cd /qmk_firmware
qmk compile -kb massdrop/alt -km ashe
cp massdrop_alt_ashe.bin /out

@ -15,4 +15,4 @@ EXTRAKEY_ENABLE = yes # Audio control and System control
# LEADER_ENABLE # Enable leader key chording
SRC += lighting_funcs.c
LIB_SRC += pomodoro.o
LIB_SRC += librust_funcs.a

@ -0,0 +1,2 @@
[build]
target = "thumbv7em-none-eabihf"

@ -0,0 +1,7 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3
[[package]]
name = "rust-funcs"
version = "0.1.0"

@ -0,0 +1,9 @@
[package]
name = "rust-funcs"
version = "0.1.0"
edition = "2021"
[dependencies]
[lib]
crate-type = ["staticlib"]

@ -0,0 +1,15 @@
#![no_std]
#![no_builtins]
#![crate_type = "staticlib"]
#![allow(dead_code)]
mod pomodoro;
#[panic_handler]
fn my_panic(_info: &core::panic::PanicInfo) -> ! {
loop {}
}

@ -1,13 +1,3 @@
#![no_std]
#![no_builtins]
#![crate_type = "staticlib"]
#![allow(dead_code)]
#[panic_handler]
fn my_panic(_info: &core::panic::PanicInfo) -> ! {
loop {}
}
#[derive(PartialEq, Copy, Clone)]
enum PomState {
STOPPED,

@ -0,0 +1,10 @@
#!/bin/bash
set -e
cd /rust-funcs
cargo build --release
cp ./target/thumbv7em-none-eabihf/release/librust_funcs.a /qmk_firmware/
cd /qmk_firmware
qmk compile -kb massdrop/alt -km ashe
cp massdrop_alt_ashe.bin /out
Loading…
Cancel
Save