rework build system

master
Avril 4 years ago
parent 6f57fc4c16
commit 6d8d78851e
Signed by: flanchan
GPG Key ID: 284488987C31F630

@ -28,3 +28,6 @@ libc = "0.2"
crc = "1.8" crc = "1.8"
hex-literal = "0.2" hex-literal = "0.2"
getrandom = "0.1" getrandom = "0.1"
[build-dependencies]
rustc_version = "0.2"

@ -5,11 +5,8 @@ CLI:= cli
PROJECT=khash PROJECT=khash
BUILD:=./target/release BUILD =target/release
DEBUG:=./target/debug DEBUG =target/debug
.PHONY: $(PROJECT)
$(PROJECT): release
.PHONY: release .PHONY: release
release: $(BUILD)/lib$(PROJECT).so release: $(BUILD)/lib$(PROJECT).so
@ -17,6 +14,9 @@ release: $(BUILD)/lib$(PROJECT).so
.PHONY: debug .PHONY: debug
debug: $(DEBUG)/lib$(PROJECT).so debug: $(DEBUG)/lib$(PROJECT).so
.PHONY: $(PROJECT)
$(PROJECT): $(BUILD)/lib$(PROJECT).so
$(BUILD)/lib$(PROJECT).so: RUSTFLAGS?= -C target-cpu=native $(BUILD)/lib$(PROJECT).so: RUSTFLAGS?= -C target-cpu=native
$(BUILD)/lib$(PROJECT).so: $(BUILD)/lib$(PROJECT).so:
RUSTFLAGS="$(RUSTFLAGS)" cargo build --release RUSTFLAGS="$(RUSTFLAGS)" cargo build --release
@ -39,7 +39,7 @@ test: | clean
cd $(CLI) && $(MAKE) test cd $(CLI) && $(MAKE) test
clean: clean:
rm -f $(BUILD)/lib rm -f {$(BUILD),$(DEBUG)}/lib*
cd $(CLI) && make clean cd $(CLI) && make clean
install: install:

@ -0,0 +1,24 @@
extern crate rustc_version;
use rustc_version::{version, version_meta, Channel};
fn main() {
// Assert we haven't travelled back in time
assert!(version().unwrap().major >= 1);
// Set cfg flags depending on release channel
match version_meta().unwrap().channel {
Channel::Stable => {
println!("cargo:rustc-cfg=stable");
}
Channel::Beta => {
println!("cargo:rustc-cfg=beta");
}
Channel::Nightly => {
println!("cargo:rustc-cfg=nightly");
}
Channel::Dev => {
println!("cargo:rustc-cfg=dev");
}
}
}

Binary file not shown.

Binary file not shown.
Loading…
Cancel
Save