diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e72e6b0..73d6d86 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -10,6 +10,11 @@ jobs: - name: Setup | Checkout uses: actions/checkout@v2 + - name: Setup | Generate + uses: cargo-generate/cargo-generate-action@v0.20.0 + with: + name: vexide-template + - name: Setup | Toolchain uses: dtolnay/rust-toolchain@master with: diff --git a/.gitignore b/.gitignore index 1a6c751..a7070c2 100644 --- a/.gitignore +++ b/.gitignore @@ -5,7 +5,7 @@ target/ # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries # More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html -Cargo.lock +# Cargo.lock # These are backup files generated by rustfmt **/*.rs.bk @@ -94,4 +94,4 @@ $RECYCLE.BIN/ *.vsix # Direnv -.direnv/ \ No newline at end of file +.direnv/ diff --git a/Cargo.toml b/Cargo.toml index b2733a4..9ae98ed 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,11 +5,15 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html +{% if crate_type == "bin" %} # These fields configure default behavior for uploads with `cargo v5`. [package.metadata.v5] -slot = 1 -icon = "cool-x" +{% if slot != "none" %} +slot = {{ slot }} +{% endif %} +icon = "{{ icon }}" compress = true +{% endif %} [dependencies] vexide = "0.3.0" diff --git a/README.md b/README.md index e5cfc30..34bd87d 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,8 @@ # vexide Template + [![Build status](https://github.com/vexide/vexide-template/actions/workflows/build.yml/badge.svg)](https://github.com/vexide/vexide-template/actions/workflows/build.yml) + > Ready-to-use template for developing VEX V5 robots in Rust. @@ -21,28 +23,28 @@ Seasoned vexide user? Delete README.md and update Cargo.toml as needed. - [Compiling and uploading to a VEX V5 robot](#compiling-and-uploading-to-a-vex-v5-robot) - [Viewing program output](#viewing-program-output) + ## Using This Template -To start a project using this template, click the "Use this template" button in the upper right corner of the GitHub repository. Choose an appropriate name and clone the new repository using Git. Finally, update the package name in `Cargo.toml`: +This template uses `cargo-generate`, which can be installed with the following command: -```toml -[package] -name = "my-vex-robot" -version = "0.1.0" -edition = "2021" +```sh +cargo install cargo-generate ``` -You can also configure your program slot and upload behavior in `Cargo.toml`: +Create a new vexide project by then running the following command: -```toml -[package.metadata.v5] -slot = 1 -icon = "cool-x" -compress = true +```sh +cargo generate vexide/vexide-template ``` -> See our [Building & Uploading tutorial](https://vexide.dev/docs/building-uploading/) for more information. +Or, make a library instead: +```sh +cargo generate vexide/vexide-template --lib +``` + + ## Getting Started (Windows) Follow the instructions [here](https://www.rust-lang.org/tools/install) to install `rustup`. diff --git a/cargo-generate.toml b/cargo-generate.toml new file mode 100644 index 0000000..b544a60 --- /dev/null +++ b/cargo-generate.toml @@ -0,0 +1,50 @@ +[template] +cargo_generate_version = ">=0.9.0" +ignore = ["target", ".DS_Store"] # ideally this would include all of .gitignore + +[conditional.'crate_type == "lib"'] +ignore = ["src/main.rs"] + +[conditional.'crate_type == "bin"'] +ignore = ["src/lib.rs"] + +[placeholders] +use_ci = { prompt = "Use recommended GitHub CI configuration?", default = true, type = "bool" } + +[conditional.'crate_type == "bin"'.placeholders] +slot = { prompt = "Choose a default program slot (1-8/none):", default = "1", type = "string", regex = "^([1-8]|none)$" } + +[conditional.'crate_type == "bin"'.placeholders.icon] +prompt = "Choose an icon for the program:" +default = "cool-x" +type = "string" +choices = [ + "cool-x", + "vex-coding-studio", + "question-mark", + "pizza", + "clawbot", + "robot", + "power-button", + "planets", + "alien", + "alien-in-ufo", + "cup-in-field", + "cup-and-ball", + "matlab", + "pros", + "robot-mesh", + "robot-mesh-cpp", + "robot-mesh-blockly", + "robot-mesh-flowol", + "robot-mesh-js", + "robot-mesh-py", + "code-file", + "vexcode-brackets", + "vexcode-blocks", + "vexcode-python", + "vexcode-cpp", +] + +[hooks] +post = ["scripts/ci.rhai"] diff --git a/scripts/ci.rhai b/scripts/ci.rhai new file mode 100644 index 0000000..4e2f4d2 --- /dev/null +++ b/scripts/ci.rhai @@ -0,0 +1,30 @@ +if variable::get("use_ci") { + debug("Generating GitHub CI configuration..."); + file::write(".github/workflows/build.yml", ` +name: Build + +on: [push, pull_request] + +jobs: + check: + name: Check + runs-on: ubuntu-latest + steps: + - name: Setup | Checkout + uses: actions/checkout@v2 + + - name: Setup | Toolchain + uses: dtolnay/rust-toolchain@master + with: + toolchain: nightly-2024-02-07 + components: rust-src + + - name: Check + uses: actions-rs/cargo@v1 + with: + command: check +`); +} else { + debug("Skipping GitHub CI configuration..."); + file::delete(".github"); +} diff --git a/src/lib.rs b/src/lib.rs new file mode 100644 index 0000000..e6483e8 --- /dev/null +++ b/src/lib.rs @@ -0,0 +1,7 @@ +#![no_std] + +use vexide::prelude::*; + +pub fn revolve(left: Position, right: Position) -> Position { + left + right +}