Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Give a compile error if neither of the use* features are enabled #4

Merged
merged 4 commits into from
Nov 18, 2020
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: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

<!-- next-header -->
## [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.
Expand Down
1 change: 1 addition & 0 deletions spirv-tools-sys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 8 additions & 3 deletions spirv-tools-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
3 changes: 3 additions & 0 deletions spirv-tools-sys/src/lib.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
3 changes: 3 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down