Skip to content

Commit

Permalink
bump rust nightly ; cargo -> xargo
Browse files Browse the repository at this point in the history
  * Use Xargo to get automatically built core
  * Remove dependency on rust-core
  * Remove cutom targets; add RUSTFLAGS where needed
  * Update use of Unique and NonZero
  * Add "mem" feature to "compiler_builtins" crate
  * auto-install xargo if needed
  • Loading branch information
ppannuto committed May 25, 2017
1 parent bd05ad6 commit 751141b
Show file tree
Hide file tree
Showing 33 changed files with 106 additions and 197 deletions.
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ os:

# If you change this, you must also change README and Common.mk
rust:
- nightly-2017-01-25
- nightly-2017-05-24

before_install:
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then ./.travis-install-gcc; fi
Expand All @@ -23,6 +23,7 @@ before_install:

before_script:
- (cargo install --vers 0.7.1 rustfmt || true)
- (cargo install xargo || true)
- if [[ "$TRAVIS_OS_NAME" != "osx" ]] || [[ "$TRAVIS_BRANCH$TRAVIS_EVENT_TYPE" == "masterpush" ]]; then npm install -g markdown-toc; fi

script:
Expand Down
1 change: 0 additions & 1 deletion arch/cortex-m0/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@ version = "0.1.0"
authors = ["Tock Project Developers <[email protected]>"]

[dependencies]
rust-libcore = "*"
kernel = { path = "../../kernel" }
1 change: 0 additions & 1 deletion arch/cortex-m4/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@ version = "0.1.0"
authors = ["Tock Project Developers <[email protected]>"]

[dependencies]
rust-libcore = "*"
kernel = { path = "../../kernel" }
65 changes: 35 additions & 30 deletions boards/Makefile.common
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@
MAKEFLAGS += -r
MAKEFLAGS += -R

export RUSTUP_TOOLCHAIN ?= nightly-2017-01-25
export RUSTUP_TOOLCHAIN ?= nightly-2017-05-24

TOOLCHAIN ?= arm-none-eabi

XARGO ?= xargo
# This will hopefully move into Cargo.toml (or Cargo.toml.local) eventually
RUSTFLAGS_FOR_XARGO_LINKING := "-C link-arg=-nostartfiles -C link-arg=-Tlayout.ld"

SIZE ?= $(TOOLCHAIN)-size
OBJCOPY ?= $(TOOLCHAIN)-objcopy
OBJDUMP ?= $(TOOLCHAIN)-objdump
Expand All @@ -16,14 +20,6 @@ ifndef PLATFORM
$(error Required make vairable PLATFORM is not defined)
endif

ifndef CHIP
$(error Required make variable CHIP is not defined)
endif

ifndef TARGET
TARGET := $(CHIP).json
endif

# If environment variable V is non-empty, be verbose
ifneq ($(V),)
Q=
Expand All @@ -36,7 +32,7 @@ endif
export TOCK_KERNEL_VERSION := $(shell git describe --always || echo notgit)

# Check that rustc is the right nightly - warn not error if wrong, sometimes useful to test others
RUSTC_VERSION_STRING := rustc 1.16.0-nightly (83c2d9523 2017-01-24)
RUSTC_VERSION_STRING := rustc 1.19.0-nightly (5b13bff52 2017-05-23)
ifneq ($(shell RUSTUP_TOOLCHAIN=$(RUSTUP_TOOLCHAIN) rustc --version), $(RUSTC_VERSION_STRING))
DUMMY := $(shell rustup install $(RUSTUP_TOOLCHAIN))
ifneq ($(shell RUSTUP_TOOLCHAIN=$(RUSTUP_TOOLCHAIN) rustc --version), $(RUSTC_VERSION_STRING))
Expand All @@ -47,6 +43,14 @@ ifneq ($(shell RUSTUP_TOOLCHAIN=$(RUSTUP_TOOLCHAIN) rustc --version), $(RUSTC_VE
endif
endif

# Check that xargo is installed
ifneq ($(strip $(firstword $(shell $(XARGO) --version 2>&1))), xargo)
$(warning Required tool `xargo` not installed.)
$(warning Running `cargo install xargo` in 3 seconds (ctrl-c to cancel))
$(shell sleep 3s)
$(shell cargo install xargo)
endif

# Dump configuration for verbose builds
ifneq ($(V),)
$(info )
Expand All @@ -70,47 +74,48 @@ ifneq ($(V),)
endif

.PHONY: all
all: target/$(CHIP)/release/$(PLATFORM).bin
all: target/$(TARGET)/release/$(PLATFORM).bin

.PHONY: debug
debug: target/$(CHIP)/debug/$(PLATFORM).bin
debug: target/$(TARGET)/debug/$(PLATFORM).bin

.PHONY: doc
doc:
$(Q)cargo doc $(VERBOSE) --release --target=$(TARGET)
$(Q)XARGO doc $(VERBOSE) --release --target=$(TARGET)

target/$(CHIP)/release/$(PLATFORM).elf: target/$(CHIP)/release/$(PLATFORM)
$(Q)cp target/$(CHIP)/release/$(PLATFORM) target/$(CHIP)/release/$(PLATFORM).elf
target/$(TARGET)/release/$(PLATFORM).elf: target/$(TARGET)/release/$(PLATFORM)
$(Q)cp target/$(TARGET)/release/$(PLATFORM) target/$(TARGET)/release/$(PLATFORM).elf

.PHONY: target/$(CHIP)/release/$(PLATFORM)
target/$(CHIP)/release/$(PLATFORM):
$(Q)cargo build $(VERBOSE) --release --target=$(TARGET)
.PHONY: target/$(TARGET)/release/$(PLATFORM)
target/$(TARGET)/release/$(PLATFORM):
$(Q)rustup component add rust-src
$(Q)RUSTFLAGS=$(RUSTFLAGS_FOR_XARGO_LINKING) $(XARGO) build --target=$(TARGET) $(VERBOSE) --release
$(Q)$(SIZE) $@

target/$(CHIP)/debug/$(PLATFORM).elf: target/$(CHIP)/debug/$(PLATFORM)
$(Q)cp target/$(CHIP)/debug/$(PLATFORM) target/$(CHIP)/debug/$(PLATFORM).elf
target/$(TARGET)/debug/$(PLATFORM).elf: target/$(TARGET)/debug/$(PLATFORM)
$(Q)cp target/$(TARGET)/debug/$(PLATFORM) target/$(TARGET)/debug/$(PLATFORM).elf

.PHONY: target/$(CHIP)/debug/$(PLATFORM)
target/$(CHIP)/debug/$(PLATFORM):
$(Q)cargo build $(VERBOSE) --target=$(TARGET)
$(Q)$(OBJDUMP) $(OBJDUMP_FLAGS) $@ > target/$(CHIP)/debug/$(PLATFORM).lst
.PHONY: target/$(TARGET)/debug/$(PLATFORM)
target/$(TARGET)/debug/$(PLATFORM):
$(Q)RUSTFLAGS=$(RUSTFLAGS_FOR_XARGO_LINKING) $(XARGO) build $(VERBOSE) --target=$(TARGET)
$(Q)$(OBJDUMP) $(OBJDUMP_FLAGS) $@ > target/$(TARGET)/debug/$(PLATFORM).lst
$(Q)$(SIZE) $@

target/$(CHIP)/release/$(PLATFORM).hex: target/$(CHIP)/release/$(PLATFORM).elf
target/$(TARGET)/release/$(PLATFORM).hex: target/$(TARGET)/release/$(PLATFORM).elf
$(Q)$(OBJCOPY) -Oihex $^ $@

target/$(CHIP)/debug/$(PLATFORM).hex: target/$(CHIP)/debug/$(PLATFORM).elf
target/$(TARGET)/debug/$(PLATFORM).hex: target/$(TARGET)/debug/$(PLATFORM).elf
$(Q)$(OBJCOPY) -Oihex $^ $@

target/$(CHIP)/release/$(PLATFORM).bin: target/$(CHIP)/release/$(PLATFORM).elf
target/$(TARGET)/release/$(PLATFORM).bin: target/$(TARGET)/release/$(PLATFORM).elf
$(Q)$(OBJCOPY) -Obinary $^ $@

target/$(CHIP)/debug/$(PLATFORM).bin: target/$(CHIP)/debug/$(PLATFORM).elf
target/$(TARGET)/debug/$(PLATFORM).bin: target/$(TARGET)/debug/$(PLATFORM).elf
$(Q)$(OBJCOPY) -Obinary $^ $@

.PHONY: clean
clean::
$(Q)cargo clean $(VERBOSE)
$(Q)$(XARGO) clean $(VERBOSE)

.PHONY: debug
debug: target/$(CHIP)/debug/$(PLATFORM).elf
debug: target/$(TARGET)/debug/$(PLATFORM).elf
14 changes: 0 additions & 14 deletions boards/hail/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 1 addition & 6 deletions boards/hail/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,13 @@ build = "build.rs"
panic = "abort"
lto = true
opt-level = 0
debug = false
# Would prefer to have debug symbols, but there is a Rust bug
# https://github.com/rust-lang/rust/issues/25270
# https://github.com/rust-lang/rust/issues/34434
#debug = true
debug = true

[profile.release]
panic = "abort"
lto = true

[dependencies]
rust-libcore = "*"
cortexm4 = { path = "../../arch/cortex-m4" }
capsules = { path = "../../capsules" }
kernel = { path = "../../kernel" }
Expand Down
8 changes: 4 additions & 4 deletions boards/hail/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Makefile for building the tock kernel for the Hail platform

CHIP=sam4l
TARGET=thumbv7em-none-eabi
PLATFORM=hail

include ../Makefile.common
Expand All @@ -18,16 +18,16 @@ endif
TOCKLOADER_JTAG_FLAGS = --jtag --board hail --arch cortex-m4 --jtag-device ATSAM4LC8C

.PHONY: program
program: target/sam4l/release/$(PLATFORM).bin
program: target/$(TARGET)/release/$(PLATFORM).bin
$(TOCKLOADER) $(TOCKLOADER_GENERAL_FLAGS) flash --address $(KERNEL_ADDRESS) $<

# upload kernel over JTAG
.PHONY: flash
flash: target/sam4l/release/$(PLATFORM).bin
flash: target/$(TARGET)/release/$(PLATFORM).bin
$(TOCKLOADER) $(TOCKLOADER_GENERAL_FLAGS) flash --address $(KERNEL_ADDRESS) $(TOCKLOADER_JTAG_FLAGS) $<

.PHONY: flash-debug
flash-debug: target/sam4l/debug/$(PLATFORM).bin
flash-debug: target/$(TARGET)/debug/$(PLATFORM).bin
$(TOCKLOADER) $(TOCKLOADER_GENERAL_FLAGS) flash --address $(KERNEL_ADDRESS) $(TOCKLOADER_JTAG_FLAGS) $<

# Command to flash the bootloader. Flashes the bootloader onto the SAM4L.
Expand Down
6 changes: 6 additions & 0 deletions boards/hail/Xargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[dependencies.core]

[dependencies.compiler_builtins]
features = ["mem"]
git = "https://github.com/rust-lang-nursery/compiler-builtins"
stage = 1
1 change: 1 addition & 0 deletions boards/hail/build.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
fn main() {
println!("cargo:rerun-if-changed=layout.ld");
println!("cargo:rerun-if-changed=chip_layout.ld");
println!("cargo:rerun-if-changed=../kernel_layout.ld");
}
23 changes: 0 additions & 23 deletions boards/hail/sam4l.json

This file was deleted.

3 changes: 2 additions & 1 deletion boards/hail/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
#![no_std]
#![no_main]
#![feature(asm,const_fn,lang_items)]
#![feature(asm,const_fn,lang_items,compiler_builtins_lib)]

extern crate capsules;
extern crate cortexm4;
extern crate compiler_builtins;
#[macro_use(static_init)]
extern crate kernel;
extern crate sam4l;
Expand Down
14 changes: 0 additions & 14 deletions boards/imix/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 1 addition & 6 deletions boards/imix/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,13 @@ build = "build.rs"
panic = "abort"
lto = true
opt-level = 0
debug = false
# Would prefer to have debug symbols, but there is a Rust bug
# https://github.com/rust-lang/rust/issues/25270
# https://github.com/rust-lang/rust/issues/34434
#debug = true
debug = true

[profile.release]
panic = "abort"
lto = true

[dependencies]
rust-libcore = "*"
cortexm4 = { path = "../../arch/cortex-m4" }
capsules = { path = "../../capsules" }
kernel = { path = "../../kernel" }
Expand Down
6 changes: 3 additions & 3 deletions boards/imix/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Makefile for building the tock kernel for the Imix platform

CHIP=sam4l
TARGET=thumbv7em-none-eabi
PLATFORM=imix

include ../Makefile.common
Expand All @@ -10,11 +10,11 @@ OPENOCD_CONF=connect.cfg

# upload kernel with openocd
.PHONY: flash
flash: target/sam4l/release/imix
flash: target/$(TARGET)/release/imix
#$(OPENOCD) -f $(OPENOCD_CONF) -c "program $< verify reset exit"
$(OPENOCD) -f $(OPENOCD_CONF) -c "init; reset halt; flash write_image $< 0x0 elf; reset; shutdown"

.PHONY: flash-debug
flash-debug: target/sam4l/debug/imix
flash-debug: target/$(TARGET)/debug/imix
$(OPENOCD) -f $(OPENOCD_CONF) -c "init; reset halt; load_image $<; reset; shutdown"

6 changes: 6 additions & 0 deletions boards/imix/Xargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[dependencies.core]

[dependencies.compiler_builtins]
features = ["mem"]
git = "https://github.com/rust-lang-nursery/compiler-builtins"
stage = 1
Loading

0 comments on commit 751141b

Please sign in to comment.