diff --git a/.travis.yml b/.travis.yml index 6fd8524c7700b6135599834c4beed11ee3d2a348..5fd93bf0624fc457df0f360a883af846da4f9461 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,8 +10,6 @@ before_script: - rustup component add rustfmt-preview - if [ -n "$TARGET" ]; then rustup target add $TARGET; fi script: - - ./fmt.sh -- --write-mode=diff - - cargo build $([ -n "$TARGET" ] && echo --target="$TARGET") - - if [ -z "$TARGET" ]; then ./test.sh; fi + - ./ci.sh notifications: email: false diff --git a/Makefile b/Makefile index ab51c74061c69231c8135fae0a2756c16a0b7632..afb4bca8a4b7c232ef8da1cc21056064b00eb3ab 100644 --- a/Makefile +++ b/Makefile @@ -1,15 +1,22 @@ TARGET?= -BUILD=target/debug +BUILD=target ifneq ($(TARGET),) - BUILD=target/$(TARGET)/debug + BUILD="target/$(TARGET)" CARGOFLAGS+="--target=$(TARGET)" - CC=$(TARGET)-gcc +endif + +ifeq ($(TARGET),aarch64-unknown-linux-gnu) + CC="aarch64-linux-gnu-gcc" +endif + +ifeq ($(TARGET),x86_64-unknown-redox) + CC="x86_64-unknown-redox-gcc" endif .PHONY: all clean fmt test -all: $(BUILD)/libc.a $(BUILD)/libcrt0.a $(BUILD)/openlibm/libopenlibm.a +all: $(BUILD)/debug/libc.a $(BUILD)/debug/libcrt0.a $(BUILD)/openlibm/libopenlibm.a clean: cargo clean @@ -21,16 +28,22 @@ fmt: test: all make -C tests run -$(BUILD)/libc.a: +$(BUILD)/debug/libc.a: src/* src/*/* src/*/*/* src/*/*/*/* cargo build $(CARGOFLAGS) -$(BUILD)/libcrt0.a: +$(BUILD)/debug/libcrt0.a: $(BUILD)/debug/libc.a cargo build --manifest-path src/crt0/Cargo.toml $(CARGOFLAGS) +$(BUILD)/release/libc.a: src/* src/*/* src/*/*/* src/*/*/*/* + cargo build --release $(CARGOFLAGS) + +$(BUILD)/release/libcrt0.a: $(BUILD)/release/libc.a + cargo build --release --manifest-path src/crt0/Cargo.toml $(CARGOFLAGS) + $(BUILD)/openlibm: openlibm rm -rf $@ $@.partial cp -r $< $@.partial mv $@.partial $@ $(BUILD)/openlibm/libopenlibm.a: $(BUILD)/openlibm - CC=$(CC) CFLAGS=-fno-stack-protector make -C $< libopenlibm.a + make CC=$(CC) CFLAGS=-fno-stack-protector -C $< libopenlibm.a diff --git a/README.md b/README.md index 59d8525083085602fcd77d4118225f79b650d88d..b1838dd9b73c5b3ac71617f7ffd29a8b1009ddf4 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ relibc is a portable POSIX C standard library written in Rust. It is under heavy The motivation for this project is twofold: Reduce issues the redox crew was having with newlib, and create a safer alternative to a C standard library written in C. It is mainly designed to be used under redox, as an alternative to newlib, but it also supports linux syscalls via the [sc](https://crates.io/crates/sc) crate. ## Contributing -Just search for any invocation of the `unimplemented` macro, and hop in! The ci server checks builds for linux and redox, checks formatting (via rustfmt), and runs the test suite. Run `ci.sh` locally to check that your changes will pass travis. Use `fmt.sh` to format your code and `test.sh` to run the C test suite. +Just search for any invocation of the `unimplemented` macro, and hop in! The ci server checks builds for linux and redox, checks formatting (via rustfmt), and runs the test suite. Run `ci.sh` locally to check that your changes will pass travis. Use `fmt.sh` to format your code and `make test` to run the C test suite. ## Supported OSes diff --git a/ci.sh b/ci.sh new file mode 100755 index 0000000000000000000000000000000000000000..1a5fee268dbe218bebdfee0b8f1c8bca59d016e5 --- /dev/null +++ b/ci.sh @@ -0,0 +1,9 @@ +#!/bin/bash +set -ex + +./fmt.sh -- --write-mode=diff +make +if [ -z "$TARGET" ] +then + make test +fi diff --git a/test.sh b/test.sh deleted file mode 100755 index 6b3063413f9a556053d62161dfc498902c050eda..0000000000000000000000000000000000000000 --- a/test.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash -set -ex - -make - -make -C tests clean -make -C tests run diff --git a/tests/Makefile b/tests/Makefile index 3f68491a04857e20713cbd36caaf5593cf3ac6df..efc09a0377c31f85b3672697ca2ffb9c3856a887 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -87,18 +87,20 @@ verify: $(EXPECT_BINS) diff -u "gen/$${bin}.stderr" "expected/$${bin}.stderr" || exit $$?; \ done -GCCHEAD=\ +CFLAGS=\ -nostdinc \ -nostdlib \ -I ../include \ -I ../target/include \ - -I ../openlibm/include \ - -I ../openlibm/src \ + -I ../target/openlibm/include \ + -I ../target/openlibm/src \ + +HEADLIBS=\ ../target/debug/libcrt0.a -GCCTAIL=\ +TAILLIBS=\ ../target/debug/libc.a \ - ../openlibm/libopenlibm.a + ../target/openlibm/libopenlibm.a -%: %.c - gcc -fno-stack-protector -Wall $(GCCHEAD) "$<" $(GCCTAIL) -o "$@" +%: %.c $(HEADLIBS) $(TAILLIBS) + gcc -fno-stack-protector -Wall $(CFLAGS) $(HEADLIBS) "$<" $(TAILLIBS) -o "$@"