block compilation if both backends are enabled

This commit is contained in:
Lynne Megido 2021-06-14 18:23:49 +10:00
parent ec4ad77136
commit d0a6e918cc
Signed by: lynnesbian
GPG Key ID: F0A184B5213D9F90
3 changed files with 20 additions and 3 deletions

View File

@ -9,6 +9,8 @@ Dates are given in YYYY-MM-DD format.
- Nicer version output: `fif -V` reports "fif v0.3.2" (instead of just "fif 0.3.2" without the "v"), and `fif --version` - Nicer version output: `fif -V` reports "fif v0.3.2" (instead of just "fif 0.3.2" without the "v"), and `fif --version`
reports `fif v0.3.2 (XDG-Mime backend)`, or whatever backend you're using reports `fif v0.3.2 (XDG-Mime backend)`, or whatever backend you're using
- fif's trace output now includes its version, backend, operating system, and architecture - fif's trace output now includes its version, backend, operating system, and architecture
- Block compilation if both the `xdg-mime-backend` and `infer-backend`
[features](https://gitlab.com/Lynnesbian/fif/-/wikis/Cargo-Features) are enabled
### v0.3.1 (2021-07-06) ### v0.3.1 (2021-07-06)
#### Features #### Features
@ -151,7 +153,7 @@ Dates are given in YYYY-MM-DD format.
#### Features #### Features
- Added extension sets -- you can now use, for example, `-E images` to check files with known image extensions - Added extension sets -- you can now use, for example, `-E images` to check files with known image extensions
- Shell script output now uses `printf` instead of `echo` - Shell script output now uses `printf` instead of `echo`
- Added [`infer`] backend - Added [`infer`] backend, configurable with [Cargo features](https://gitlab.com/Lynnesbian/fif/-/wikis/Cargo-Features)
#### Bugfixes #### Bugfixes
- Fixed broken singlethreaded support - Fixed broken singlethreaded support
#### Other #### Other

10
build.rs Normal file
View File

@ -0,0 +1,10 @@
#[allow(unreachable_code, clippy::pedantic)]
fn main() -> Result<(), String> {
#[cfg(all(feature = "infer-backend", feature = "xdg-mime-backend"))]
// fail build if the user has set both the infer and xdg-mime backends
return Err(String::from(
"fif cannot be compiled with multiple backends set - please enable only one, or use the default.",
));
Ok(())
}

View File

@ -34,8 +34,8 @@ use crate::findings::ScanError;
use crate::formats::{Format, PowerShell, Shell}; use crate::formats::{Format, PowerShell, Shell};
use crate::mime_db::MimeDb; use crate::mime_db::MimeDb;
use crate::parameters::{OutputFormat, ScanOpts}; use crate::parameters::{OutputFormat, ScanOpts};
use std::collections::BTreeSet;
use crate::utils::{clap_long_version, os_name}; use crate::utils::{clap_long_version, os_name};
use std::collections::BTreeSet;
mod findings; mod findings;
mod formats; mod formats;
@ -72,7 +72,12 @@ fn main() {
// .target(env_logger::Target::Stdout) // log to stdout rather than stderr // .target(env_logger::Target::Stdout) // log to stdout rather than stderr
.init(); .init();
trace!("fif {}, running on {} {}", clap_long_version(), std::env::consts::ARCH, os_name()); trace!(
"fif {}, running on {} {}",
clap_long_version(),
std::env::consts::ARCH,
os_name()
);
trace!("Initialise mimetype database"); trace!("Initialise mimetype database");
init_db(); init_db();