Update build to use musl toolchain
This commit is contained in:
		@@ -1,8 +1,8 @@
 | 
			
		||||
[build]
 | 
			
		||||
target = "armv5te-unknown-linux-musleabi"
 | 
			
		||||
 | 
			
		||||
[target.armv5te-unknown-linux-musleabi]
 | 
			
		||||
linker = "rust-lld"
 | 
			
		||||
 | 
			
		||||
[target.armv5te-unknown-linux-gnueabi]
 | 
			
		||||
linker = "/usr/bin/arm-linux-gnueabi-gcc"
 | 
			
		||||
 | 
			
		||||
[source.crates-io]
 | 
			
		||||
replace-with = "vendored-sources"
 | 
			
		||||
 | 
			
		||||
[source.vendored-sources]
 | 
			
		||||
directory = "vendor"
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										20
									
								
								Cargo.lock
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										20
									
								
								Cargo.lock
									
									
									
										generated
									
									
									
								
							@@ -4,9 +4,9 @@ version = 3
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
name = "ev3dev-lang-rust"
 | 
			
		||||
version = "0.11.0"
 | 
			
		||||
version = "0.12.0"
 | 
			
		||||
source = "registry+https://github.com/rust-lang/crates.io-index"
 | 
			
		||||
checksum = "617633ccf9b91429eaba5f52d702f4fdb97304eb35c9bd5456389ef1f40a3cb5"
 | 
			
		||||
checksum = "fa23e3ddfd1fc7ac4c7db1c4eb5d6376a76f756261d8ab2444881ed405cbb1f7"
 | 
			
		||||
dependencies = [
 | 
			
		||||
 "ev3dev-lang-rust-derive",
 | 
			
		||||
 "libc",
 | 
			
		||||
@@ -32,33 +32,33 @@ dependencies = [
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
name = "libc"
 | 
			
		||||
version = "0.2.101"
 | 
			
		||||
version = "0.2.116"
 | 
			
		||||
source = "registry+https://github.com/rust-lang/crates.io-index"
 | 
			
		||||
checksum = "3cb00336871be5ed2c8ed44b60ae9959dc5b9f08539422ed43f09e34ecaeba21"
 | 
			
		||||
checksum = "565dbd88872dbe4cc8a46e527f26483c1d1f7afa6b884a3bd6cd893d4f98da74"
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
name = "proc-macro2"
 | 
			
		||||
version = "1.0.29"
 | 
			
		||||
version = "1.0.36"
 | 
			
		||||
source = "registry+https://github.com/rust-lang/crates.io-index"
 | 
			
		||||
checksum = "b9f5105d4fdaab20335ca9565e106a5d9b82b6219b5ba735731124ac6711d23d"
 | 
			
		||||
checksum = "c7342d5883fbccae1cc37a2353b09c87c9b0f3afd73f5fb9bba687a1f733b029"
 | 
			
		||||
dependencies = [
 | 
			
		||||
 "unicode-xid",
 | 
			
		||||
]
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
name = "quote"
 | 
			
		||||
version = "1.0.9"
 | 
			
		||||
version = "1.0.15"
 | 
			
		||||
source = "registry+https://github.com/rust-lang/crates.io-index"
 | 
			
		||||
checksum = "c3d0b9745dc2debf507c8422de05d7226cc1f0644216dfdfead988f9b1ab32a7"
 | 
			
		||||
checksum = "864d3e96a899863136fc6e99f3d7cae289dafe43bf2c5ac19b70df7210c0a145"
 | 
			
		||||
dependencies = [
 | 
			
		||||
 "proc-macro2",
 | 
			
		||||
]
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
name = "syn"
 | 
			
		||||
version = "1.0.75"
 | 
			
		||||
version = "1.0.86"
 | 
			
		||||
source = "registry+https://github.com/rust-lang/crates.io-index"
 | 
			
		||||
checksum = "b7f58f7e8eaa0009c5fec437aabf511bd9933e4b2d7407bd05273c01a8906ea7"
 | 
			
		||||
checksum = "8a65b3f4ffa0092e9887669db0eae07941f023991ab58ea44da8fe8e2d511c6b"
 | 
			
		||||
dependencies = [
 | 
			
		||||
 "proc-macro2",
 | 
			
		||||
 "quote",
 | 
			
		||||
 
 | 
			
		||||
@@ -4,7 +4,7 @@ version = "0.1.0"
 | 
			
		||||
edition = "2021"
 | 
			
		||||
 | 
			
		||||
[dependencies]
 | 
			
		||||
ev3dev-lang-rust = "0.11.0"
 | 
			
		||||
ev3dev-lang-rust = "0.12.0"
 | 
			
		||||
 | 
			
		||||
[profile.release]
 | 
			
		||||
lto = true
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										10
									
								
								Makefile
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								Makefile
									
									
									
									
									
								
							@@ -1,10 +1,4 @@
 | 
			
		||||
ARTIFACT := $(shell cargo pkgid |  rev | cut -d "/" -f1  | rev | cut -d "\#" -f1) # Try to determine the artifact name. If this does not work replace it with the explicit name.
 | 
			
		||||
 | 
			
		||||
install-dependencies:
 | 
			
		||||
	cargo vendor
 | 
			
		||||
 | 
			
		||||
build:
 | 
			
		||||
	docker run --rm -v $(PWD):/opt/project/ -w /opt/project/ pixix4/ev3dev-rust /bin/bash -c "cargo build --release --target armv5te-unknown-linux-gnueabi && /usr/bin/arm-linux-gnueabi-strip /opt/project/target/armv5te-unknown-linux-gnueabi/release/$(ARTIFACT)"
 | 
			
		||||
 | 
			
		||||
clean:
 | 
			
		||||
	cargo clean
 | 
			
		||||
strip:
 | 
			
		||||
	docker run --rm -v $(PWD):/build -w /build pixix4/ev3dev-rust:latest arm-linux-gnueabi-strip /build/target/armv5te-unknown-linux-musleabi/release/$(ARTIFACT)
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										25
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										25
									
								
								README.md
									
									
									
									
									
								
							@@ -8,21 +8,28 @@ This is a template for creating and building projects with [`ev3dev-lang-rust`](
 | 
			
		||||
- `docker`
 | 
			
		||||
- `make` (optional)
 | 
			
		||||
 | 
			
		||||
## Initial setup
 | 
			
		||||
## Setup
 | 
			
		||||
 | 
			
		||||
Install the `armv5te-musl` toolchain
 | 
			
		||||
 | 
			
		||||
This template uses `cargo vendor` to cache all dependencies for the docker build. Before the first run and after changes to your dependencies you need to rebuild this dependency cache
 | 
			
		||||
```bash
 | 
			
		||||
make install-dependencies
 | 
			
		||||
# or
 | 
			
		||||
cargo vendor
 | 
			
		||||
rustup target add armv5te-unknown-linux-musleabi
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
## Usage
 | 
			
		||||
 | 
			
		||||
Build this project:
 | 
			
		||||
 | 
			
		||||
```bash
 | 
			
		||||
make build
 | 
			
		||||
# or
 | 
			
		||||
docker run --rm -v $(PWD):/opt/project/ -w /opt/project/ pixix4/ev3dev-rust /bin/bash -c "cargo build --release --target armv5te-unknown-linux-gnueabi && /usr/bin/arm-linux-gnueabi-strip /opt/project/target/armv5te-unknown-linux-gnueabi/release/<ARTIFACT>"
 | 
			
		||||
cargo build --release
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
The resulting binary can be found at `./target/armv5te-unknown-linux-gnueabi/release/<ARTIFACT>`.
 | 
			
		||||
The resulting binary can be found at `./target/armv5te-unknown-linux-musleabi/release/<ARTIFACT>`.
 | 
			
		||||
 | 
			
		||||
Optionally strip the executable to reduce binary size:
 | 
			
		||||
 | 
			
		||||
```bash
 | 
			
		||||
make strip
 | 
			
		||||
# or
 | 
			
		||||
docker run --rm -v $(PWD):/build -w /build pixix4/ev3dev-rust:latest arm-linux-gnueabi-strip /build/target/armv5te-unknown-linux-musleabi/release/<ARTIFACT>
 | 
			
		||||
```
 | 
			
		||||
 
 | 
			
		||||
@@ -15,7 +15,7 @@ fn main() -> Ev3Result<()> {
 | 
			
		||||
    // Run motor.
 | 
			
		||||
    large_motor.set_duty_cycle_sp(50)?;
 | 
			
		||||
 | 
			
		||||
    // Find color sensor. Always returns the first recognised one.
 | 
			
		||||
    // Find color sensor. Always returns the first recognized one.
 | 
			
		||||
    let color_sensor = ColorSensor::find()?;
 | 
			
		||||
 | 
			
		||||
    // Switch to rgb mode.
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user