Also print Rust-side features/cfg in rpm-ostree --version

Let's make it obvious whether the `fedora-infrastructure` feature
is compiled in.
This commit is contained in:
Colin Walters 2021-01-08 14:32:58 +00:00 committed by OpenShift Merge Robot
parent 29d051e895
commit 9f590fa155
3 changed files with 14 additions and 0 deletions

View File

@ -84,6 +84,7 @@ mod ffi {
// utils.rs
extern "Rust" {
fn varsubstitute(s: &str, vars: &Vec<StringMapping>) -> Result<String>;
fn get_features() -> Vec<String>;
}
#[derive(Default)]

View File

@ -294,3 +294,10 @@ pub(crate) fn varsubstitute(s: &str, subs: &Vec<crate::ffi::StringMapping>) -> R
let m = subs.iter().cloned().map(|i| (i.k, i.v)).collect();
varsubst(s, &m)
}
pub(crate) fn get_features() -> Vec<String> {
let mut r = Vec::new();
#[cfg(feature = "fedora-integration")]
r.push("fedora-integration".to_string());
r
}

View File

@ -32,6 +32,7 @@
#include "rpmostree-util.h"
#include "rpmostree-builtins.h"
#include "rpmostree-cxxrs.h"
#include "rpmostree-polkit-agent.h"
#include "rpmostreemain.h"
@ -248,6 +249,11 @@ rpmostree_option_context_parse (GOptionContext *context,
g_print (" Features:\n");
for (char **iter = features; iter && *iter; iter++)
g_print (" - %s\n", *iter);
auto featuresrs = rpmostreecxx::get_features();
for (auto s : featuresrs)
{
g_print (" - %s\n", s.c_str());
}
exit (EXIT_SUCCESS);
}