diff --git a/CHANGELOG.md b/CHANGELOG.md index 2554fbf..6bfa3ff 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] - ReleaseDate +### Added +- [PR#4](https://github.com/EmbarkStudios/spirv-tools-rs/pull/4) added more clear compile errors if neither of the `use-*-tools` features are enabled for either `spirv-tools` or `spirv-tools-sys`. + +### Changed +- [PR#4](https://github.com/EmbarkStudios/spirv-tools-rs/pull/4) made `use-compiled-tools` the default feature for `spirv-tools-sys`. This would only affect direct consumers of `spirv-tools-sys`. + ## [0.1.0] - 2020-11-13 ### Added - Added initial implementation, which includes the assembler, validator, and most of the optimizer, which meets the current needs of rust-gpu. diff --git a/spirv-tools-sys/Cargo.toml b/spirv-tools-sys/Cargo.toml index 06e42d6..eaeeaf3 100644 --- a/spirv-tools-sys/Cargo.toml +++ b/spirv-tools-sys/Cargo.toml @@ -22,6 +22,7 @@ include = [ ] [features] +default = ["use-compiled-tools"] # Using this feature disables the compilation in the build script, but # preserves the types so that spirv-tools can still work without needing # to keep copies of some of the basic enums etc diff --git a/spirv-tools-sys/build.rs b/spirv-tools-sys/build.rs index 96d7128..05eed06 100644 --- a/spirv-tools-sys/build.rs +++ b/spirv-tools-sys/build.rs @@ -219,9 +219,14 @@ fn val(build: &mut Build) { } fn main() { - if std::env::var("CARGO_FEATURE_USE_INSTALLED_TOOLS").is_ok() - && std::env::var("CARGO_FEATURE_USE_COMPILED_TOOLS").is_err() - { + let use_installed = std::env::var("CARGO_FEATURE_USE_INSTALLED_TOOLS").is_ok(); + let use_compiled = std::env::var("CARGO_FEATURE_USE_COMPILED_TOOLS").is_ok(); + + if !use_compiled && !use_installed { + panic!("Enable at least one of `use-compiled-tools` or `use-installed-tools` features"); + } + + if use_installed && !use_compiled { println!("cargo:warning=use-installed-tools feature on, skipping compilation of C++ code"); return; } diff --git a/spirv-tools-sys/src/lib.rs b/spirv-tools-sys/src/lib.rs index e40dccc..32df4e3 100644 --- a/spirv-tools-sys/src/lib.rs +++ b/spirv-tools-sys/src/lib.rs @@ -1,3 +1,6 @@ +#[cfg(not(any(feature = "use-installed-tools", feature = "use-compiled-tools")))] +compile_error!("Enable at least one of `use-compiled-tools` or `use-installed-tools` features"); + pub mod assembler; pub mod diagnostics; pub mod opt; diff --git a/src/lib.rs b/src/lib.rs index 6b53fa9..3f5b446 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,3 +1,6 @@ +#[cfg(not(any(feature = "use-installed-tools", feature = "use-compiled-tools")))] +compile_error!("Enable at least one of `use-compiled-tools` or `use-installed-tools` features"); + pub mod assembler; pub mod binary; pub mod opt;