Skip to content
This repository was archived by the owner on Jul 6, 2019. It is now read-only.

Cargo Build System + Nightly Updates #285

Merged
merged 15 commits into from
May 30, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
/build/
/thirdparty/
.DS_Store
Cargo.lock
target
.cargo
*.o
*.bin
*.lst
autom4te.cache
17 changes: 13 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,26 @@
language: rust
rust: nightly
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice to also test on 1.0.0. This can be done easily with a list. For example, posborne/rust-sysfs-gpio@f080e9a

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On 1.0.0, you can't enable unstable features afaik, and zinc makes pretty heavy use of some of them. Most notably, compiler plugins.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, good call. I thought I was running 1.0.0, but I guess that I am actually not based on how I compiled the source.

before_install:
- sudo add-apt-repository -y ppa:terry.guo/gcc-arm-embedded
- sudo apt-get update -o Dir::Etc::sourcelist="sources.list.d/terry_guo-gcc-arm-embedded-precise.list" -o Dir::Etc::sourceparts="-" -o APT::Get::List-Cleanup="0"
install:
- sudo apt-get install gcc-arm-none-eabi
- (mkdir -p ./thirdparty/rust)
- (cd ./thirdparty/rust; wget -O rust.tar.gz https://github.com/rust-lang/rust/tarball/`rustc --version|awk '{sub(/\\(/, "", $3); print $3}'`; tar -zx --strip-components=1 -f rust.tar.gz)
script:
- rake build_all test
- ./configure --host=arm-none-eabi
- cargo build --target=$TARGET --verbose --features $PLATFORM
after_script:
- cargo test --lib --verbose
- (cd ./platformtree; cargo build --verbose; cargo test --verbose)
- (cd ./macro_platformtree; cargo build --verbose; cargo test --verbose)
env:
matrix:
- PLATFORM=lpc17xx
TARGET=thumbv7m-none-eabi
- PLATFORM=k20
TARGET=thumbv7em-none-eabi
- PLATFORM=stm32f4
TARGET=thumbv7em-none-eabi
- PLATFORM=stm32l1
- PLATFORM=k20
TARGET=thumbv7m-none-eabi
- PLATFORM=tiva_c
TARGET=thumbv7em-none-eabi
95 changes: 95 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
[package]
name = "zinc"
version = "0.1.0"
authors = ["Zinc Developers <[email protected]>"]
build = "build.rs"

[lib]
name = "zinc"
crate-type = ["lib"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be rlib to avoid the Travis build error.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There was also a bug for dylib not working in this case that is fixed in cargo upstream: rust-lang/cargo#1612. That being said, rlib is the proper thing to have here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bharrisau Actually, that's a bug in cargo with trying to link against syntax extensions while cross compiling for a target that doesn't support dylibs.

See rust-lang/cargo#1612. It was fixed by rust-lang/cargo#1617 but something is wrong with the PR on windows right now.

EDIT: Tested again just to confirm.

-crate-type = ["lib"]
+crate-type = ["rlib"]

Will not fix the travis builds.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Roger that. Looks like buildbot is broken holding up a few different Cargo PRs.


[features]
lpc17xx = []
stm32f4 = []
stm32l1 = []
k20 = []
tiva_c = []

[target.thumbv7m-none-eabi.dependencies.core]
git = "https://github.com/hackndev/rust-libcore"

[target.thumbv7em-none-eabi.dependencies.core]
git = "https://github.com/hackndev/rust-libcore"

[dependencies.ioreg]
path = "./ioreg"

[dependencies.rlibc]
git = "https://github.com/mcoffin/rlibc"
branch = "zinc"

[dev-dependencies.platformtree]
path = "./platformtree"

[dev-dependencies.macro_platformtree]
path = "./macro_platformtree"

[[example]]
name = "nothing"
path = "examples/app_nothing.rs"

[[example]]
name = "blink"
path = "examples/app_blink.rs"

[[example]]
name = "blink_k20"
path = "examples/app_blink_k20.rs"

[[example]]
name = "blink_k20_isr"
path = "examples/app_blink_k20_isr.rs"

[[example]]
name = "blink_pt"
path = "examples/app_blink_pt.rs"

[[example]]
name = "blink_stm32f4"
path = "examples/app_blink_stm32f4.rs"

[[example]]
name = "blink_stm32l1"
path = "examples/app_blink_stm32l1.rs"

[[example]]
name = "blink_tiva_c"
path = "examples/app_blink_tiva_c.rs"

[[example]]
name = "bluenrg_stm32l1"
path = "examples/app_bluenrg_stm32l1.rs"

[[example]]
name = "dht22"
path = "examples/app_dht22.rs"

[[example]]
name = "empty"
path = "examples/app_empty.rs"

[[example]]
name = "lcd_tiva_c"
path = "examples/app_lcd_tiva_c.rs"

[[example]]
name = "uart"
path = "examples/app_uart.rs"

[[example]]
name = "uart_tiva_c"
path = "examples/app_uart_tiva_c.rs"

[[example]]
name = "uart_stm32l1"
path = "examples/app_uart_stm32l1.rs"
39 changes: 39 additions & 0 deletions Makefile.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
STRIP=@STRIP@
OBJCOPY=@OBJCOPY@
OBJDUMP=@OBJDUMP@

CARGO_ROOT=@srcdir@

PLATFORM=@PLATFORM@
TARGET=@TARGET@

$(if $(value EXAMPLE_NAME),, \
$(error EXAMPLE_NAME must be set))

# Output directory
OUT_DIR=$(CARGO_ROOT)/target/$(TARGET)/release
EXAMPLE_DIR=$(OUT_DIR)/examples

BIN_FILE=$(EXAMPLE_DIR)/$(EXAMPLE_NAME).bin
LST_FILE=$(EXAMPLE_DIR)/$(EXAMPLE_NAME).lst
EXAMPLE_FILE=$(EXAMPLE_DIR)/$(EXAMPLE_NAME)

.PHONY: build clean listing $(EXAMPLE_FILE)

build: $(BIN_FILE)

clean:
cargo clean

listing: $(LST_FILE)

# Target is PHONY so cargo can deal with dependencies
$(EXAMPLE_FILE):
cd $(CARGO_ROOT)
cargo build --example $(EXAMPLE_NAME) --release --target=$(TARGET) --verbose --features $(PLATFORM)

$(BIN_FILE): $(EXAMPLE_FILE)
$(OBJCOPY) -O binary $< $@

$(LST_FILE): $(EXAMPLE_FILE)
$(OBJDUMP) -D $< > $@
21 changes: 16 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,23 @@ Zinc is distributed under Apache-2.0, see LICENSE for more details.

## Usage

Get a gcc cross-toolchain for arm and configure `TOOLCHAIN` and `RUNTIME_LIB` in
Rakefile header as appropriate. `RUNTIME_LIB` should be either libgcc or
libcompiler-rt ar archive, compiled for appropriate architecture.
### Environment Setup

To build an application from apps/ use the following rake command:
Get a gcc cross-toolchain for arm and make sure it is accessible.

### Examples

First, generate a `Makefile` and `.cargo/config` with `configure` so cargo
can find your toolchain. Your toolchain triple is probably `arm-none-eabi`
````
./configure PLATFORM=<platform> --host=<toolchain-triple>
````

To build an application from examples/ use the following command after having
run `configure`:

```
rake PLATFORM=<platform> build_all # or build_<appname>
EXAMPLE_NAME=<example> make build
```

Ouput will go to `target/<target-triple>/release/examples`.
181 changes: 0 additions & 181 deletions Rakefile

This file was deleted.

Loading