Skip to content
This repository was archived by the owner on Dec 2, 2020. It is now read-only.

remove build dependency on arm-none-eabi-gcc #20

Merged
merged 3 commits into from
Aug 27, 2018
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
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
target
.#*
Cargo.lock
bin/*.after
bin/*.before
bin/*.o
target
38 changes: 20 additions & 18 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,23 @@ language: rust
matrix:
include:
- env: TARGET=x86_64-unknown-linux-gnu
rust: stable
if: (branch = staging OR branch = trying) OR (type = pull_request AND branch = master)

- env: TARGET=thumbv6m-none-eabi
rust: beta
addons:
apt:
packages:
- gcc-arm-none-eabi
rust: stable
if: (branch = staging OR branch = trying) OR (type = pull_request AND branch = master)

- env: TARGET=thumbv7m-none-eabi
rust: beta
addons:
apt:
packages:
- gcc-arm-none-eabi
rust: stable
if: (branch = staging OR branch = trying) OR (type = pull_request AND branch = master)

- env: TARGET=thumbv7em-none-eabi
rust: stable
if: (branch = staging OR branch = trying) OR (type = pull_request AND branch = master)

- env: TARGET=thumbv7em-none-eabihf
rust: stable
if: (branch = staging OR branch = trying) OR (type = pull_request AND branch = master)

- env: TARGET=x86_64-unknown-linux-gnu
Expand All @@ -27,24 +28,25 @@ matrix:

- env: TARGET=thumbv6m-none-eabi
rust: nightly
addons:
apt:
packages:
- gcc-arm-none-eabi
if: (branch = staging OR branch = trying) OR (type = pull_request AND branch = master)

- env: TARGET=thumbv7m-none-eabi
rust: nightly
addons:
apt:
packages:
- gcc-arm-none-eabi
if: (branch = staging OR branch = trying) OR (type = pull_request AND branch = master)

- env: TARGET=thumbv7em-none-eabi
rust: nightly
if: (branch = staging OR branch = trying) OR (type = pull_request AND branch = master)

- env: TARGET=thumbv7em-none-eabihf
rust: nightly
if: (branch = staging OR branch = trying) OR (type = pull_request AND branch = master)

before_install: set -e

install:
- bash ci/install.sh
- export PATH="$PATH:$PWD/gcc/bin"

script:
- bash ci/script.sh
Expand Down
3 changes: 0 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,5 @@ name = "cortex-m-semihosting"
repository = "https://github.com/japaric/cortex-m-semihosting"
version = "0.3.0"

[build-dependencies]
cc = "1.0.10"

[features]
inline-asm = []
5 changes: 3 additions & 2 deletions asm.s
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
.global __syscall

.section .text.__syscall
.global __syscall
.thumb_func
__syscall:
bkpt 0xAB
bx lr
19 changes: 19 additions & 0 deletions assemble.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash

set -euxo pipefail

# cflags taken from cc 1.0.22

crate=cortex-m-semihosting

arm-none-eabi-as -march=armv6s-m asm.s -o bin/$crate.o
ar crs bin/thumbv6m-none-eabi.a bin/$crate.o

arm-none-eabi-as -march=armv7-m asm.s -o bin/$crate.o
ar crs bin/thumbv7m-none-eabi.a bin/$crate.o

arm-none-eabi-as -march=armv7e-m asm.s -o bin/$crate.o
ar crs bin/thumbv7em-none-eabi.a bin/$crate.o
ar crs bin/thumbv7em-none-eabihf.a bin/$crate.o

rm bin/$crate.o
Binary file added bin/thumbv6m-none-eabi.a
Binary file not shown.
Binary file added bin/thumbv7em-none-eabi.a
Binary file not shown.
Binary file added bin/thumbv7em-none-eabihf.a
Binary file not shown.
Binary file added bin/thumbv7m-none-eabi.a
Binary file not shown.
15 changes: 11 additions & 4 deletions build.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
extern crate cc;

use std::env;
use std::path::PathBuf;
use std::{env, fs};

fn main() {
let target = env::var("TARGET").unwrap();
let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap());
let name = env::var("CARGO_PKG_NAME").unwrap();

if target.starts_with("thumbv") {
if env::var_os("CARGO_FEATURE_INLINE_ASM").is_none() {
cc::Build::new().file("asm.s").compile("asm");
fs::copy(
format!("bin/{}.a", target),
out_dir.join(format!("lib{}.a", name)),
).unwrap();

println!("cargo:rustc-link-lib=static={}", name);
println!("cargo:rustc-link-search={}", out_dir.display());
}

println!("cargo:rustc-cfg=thumb");
Expand Down
21 changes: 21 additions & 0 deletions check-blobs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash

# Checks that the blobs are up to date with the committed assembly files

set -euxo pipefail

for lib in $(ls bin/*.a); do
filename=$(basename $lib)
arm-none-eabi-objdump -Cd $lib > bin/${filename%.a}.before
done

./assemble.sh

for lib in $(ls bin/*.a); do
filename=$(basename $lib)
arm-none-eabi-objdump -Cd $lib > bin/${filename%.a}.after
done

for cksum in $(ls bin/*.after); do
diff -u $cksum ${cksum%.after}.before
done
4 changes: 4 additions & 0 deletions ci/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ main() {
if [ $TARGET != x86_64-unknown-linux-gnu ]; then
rustup target add $TARGET
fi

mkdir gcc

curl -L https://developer.arm.com/-/media/Files/downloads/gnu-rm/7-2018q2/gcc-arm-none-eabi-7-2018-q2-update-linux.tar.bz2?revision=bc2c96c0-14b5-4bb4-9f18-bceb4050fee7?product=GNU%20Arm%20Embedded%20Toolchain,64-bit,,Linux,7-2018-q2-update | tar --strip-components=1 -C gcc -xj
}

main
4 changes: 4 additions & 0 deletions ci/script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ main() {
if [ $TRAVIS_RUST_VERSION = nightly ]; then
cargo check --target $TARGET --features inline-asm
fi

if [ $TARGET = x86_64-unknown-linux-gnu ]; then
./check-blobs.sh
fi
}

main