diff --git a/Cargo.toml b/Cargo.toml index 6821f21..963846d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -28,3 +28,6 @@ libc = "0.2" crc = "1.8" hex-literal = "0.2" getrandom = "0.1" + +[build-dependencies] +rustc_version = "0.2" diff --git a/Makefile b/Makefile index 16f7fb2..02e8c43 100644 --- a/Makefile +++ b/Makefile @@ -5,11 +5,8 @@ CLI:= cli PROJECT=khash -BUILD:=./target/release -DEBUG:=./target/debug - -.PHONY: $(PROJECT) -$(PROJECT): release +BUILD =target/release +DEBUG =target/debug .PHONY: release release: $(BUILD)/lib$(PROJECT).so @@ -17,6 +14,9 @@ release: $(BUILD)/lib$(PROJECT).so .PHONY: debug 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="$(RUSTFLAGS)" cargo build --release @@ -39,7 +39,7 @@ test: | clean cd $(CLI) && $(MAKE) test clean: - rm -f $(BUILD)/lib + rm -f {$(BUILD),$(DEBUG)}/lib* cd $(CLI) && make clean install: diff --git a/build.rs b/build.rs new file mode 100644 index 0000000..6399463 --- /dev/null +++ b/build.rs @@ -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"); + } + } +} diff --git a/cli/build/kana-hash-release b/cli/build/kana-hash-release deleted file mode 100755 index 317cb11..0000000 Binary files a/cli/build/kana-hash-release and /dev/null differ diff --git a/cli/obj/src/main.o b/cli/obj/src/main.o deleted file mode 100644 index cc95e7c..0000000 Binary files a/cli/obj/src/main.o and /dev/null differ