1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 11:37:44 +00:00

chcon/runcon: Only build on Linux

chcon/runcon rely on the selinux crate, that is empty on
non-Linux platforms.

This doesn't matter for normal builds that use the default features
for the platform (explicitly trying to build them will fail though).

This is a problem when using `cargo test --workspace` though,
as that tries to build all packages, including uu_chcon/uu_runcon.

Just prevent compilation of these source files when target_os != linux.
This commit is contained in:
Nicolas Boichat 2025-03-25 19:51:27 +01:00
parent 2555fd4039
commit 59396e32bc
7 changed files with 10 additions and 0 deletions

View file

@ -3,6 +3,7 @@
// For the full copyright and license information, please view the LICENSE // For the full copyright and license information, please view the LICENSE
// file that was distributed with this source code. // file that was distributed with this source code.
// spell-checker:ignore (vars) RFILE // spell-checker:ignore (vars) RFILE
#![cfg(target_os = "linux")]
#![allow(clippy::upper_case_acronyms)] #![allow(clippy::upper_case_acronyms)]
use clap::builder::ValueParser; use clap::builder::ValueParser;

View file

@ -2,6 +2,8 @@
// //
// For the full copyright and license information, please view the LICENSE // For the full copyright and license information, please view the LICENSE
// file that was distributed with this source code. // file that was distributed with this source code.
#![cfg(target_os = "linux")]
use std::ffi::OsString; use std::ffi::OsString;
use std::fmt::Write; use std::fmt::Write;
use std::io; use std::io;

View file

@ -2,6 +2,8 @@
// //
// For the full copyright and license information, please view the LICENSE // For the full copyright and license information, please view the LICENSE
// file that was distributed with this source code. // file that was distributed with this source code.
#![cfg(target_os = "linux")]
use std::ffi::{CStr, CString, OsStr}; use std::ffi::{CStr, CString, OsStr};
use std::marker::PhantomData; use std::marker::PhantomData;
use std::os::raw::{c_int, c_long, c_short}; use std::os::raw::{c_int, c_long, c_short};

View file

@ -1 +1,2 @@
#![cfg(target_os = "linux")]
uucore::bin!(uu_chcon); uucore::bin!(uu_chcon);

View file

@ -2,6 +2,8 @@
// //
// For the full copyright and license information, please view the LICENSE // For the full copyright and license information, please view the LICENSE
// file that was distributed with this source code. // file that was distributed with this source code.
#![cfg(target_os = "linux")]
use std::ffi::OsString; use std::ffi::OsString;
use std::fmt::{Display, Formatter, Write}; use std::fmt::{Display, Formatter, Write};
use std::io; use std::io;

View file

@ -1 +1,2 @@
#![cfg(target_os = "linux")]
uucore::bin!(uu_runcon); uucore::bin!(uu_runcon);

View file

@ -3,6 +3,7 @@
// For the full copyright and license information, please view the LICENSE // For the full copyright and license information, please view the LICENSE
// file that was distributed with this source code. // file that was distributed with this source code.
// spell-checker:ignore (vars) RFILE // spell-checker:ignore (vars) RFILE
#![cfg(target_os = "linux")]
use clap::builder::ValueParser; use clap::builder::ValueParser;
use uucore::error::{UClapError, UError, UResult}; use uucore::error::{UClapError, UError, UResult};