mirror of
https://github.com/nushell/nushell.git
synced 2025-04-09 21:28:55 +02:00
Fix build on *BSD, illumos, etc. (#6456)
* nu-path: use 'linux' code on all non-macOS unix * nu-command: cfg() the Ps command to platforms it's actually implemented on * nu-system: cfg() the Ps test to the platforms Ps is implemented on
This commit is contained in:
parent
4858a9a817
commit
b27148d14b
@ -160,10 +160,17 @@ pub fn create_default_context() -> EngineState {
|
|||||||
Exec,
|
Exec,
|
||||||
External,
|
External,
|
||||||
NuCheck,
|
NuCheck,
|
||||||
Ps,
|
|
||||||
Sys,
|
Sys,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#[cfg(any(
|
||||||
|
target_os = "android",
|
||||||
|
target_os = "linux",
|
||||||
|
target_os = "macos",
|
||||||
|
target_os = "windows"
|
||||||
|
))]
|
||||||
|
bind_command! { Ps };
|
||||||
|
|
||||||
#[cfg(feature = "which-support")]
|
#[cfg(feature = "which-support")]
|
||||||
bind_command! { Which };
|
bind_command! { Which };
|
||||||
|
|
||||||
|
@ -2,6 +2,12 @@ mod benchmark;
|
|||||||
mod complete;
|
mod complete;
|
||||||
mod exec;
|
mod exec;
|
||||||
mod nu_check;
|
mod nu_check;
|
||||||
|
#[cfg(any(
|
||||||
|
target_os = "android",
|
||||||
|
target_os = "linux",
|
||||||
|
target_os = "macos",
|
||||||
|
target_os = "windows"
|
||||||
|
))]
|
||||||
mod ps;
|
mod ps;
|
||||||
mod run_external;
|
mod run_external;
|
||||||
mod sys;
|
mod sys;
|
||||||
@ -11,6 +17,12 @@ pub use benchmark::Benchmark;
|
|||||||
pub use complete::Complete;
|
pub use complete::Complete;
|
||||||
pub use exec::Exec;
|
pub use exec::Exec;
|
||||||
pub use nu_check::NuCheck;
|
pub use nu_check::NuCheck;
|
||||||
|
#[cfg(any(
|
||||||
|
target_os = "android",
|
||||||
|
target_os = "linux",
|
||||||
|
target_os = "macos",
|
||||||
|
target_os = "windows"
|
||||||
|
))]
|
||||||
pub use ps::Ps;
|
pub use ps::Ps;
|
||||||
pub use run_external::{External, ExternalCommand};
|
pub use run_external::{External, ExternalCommand};
|
||||||
pub use sys::Sys;
|
pub use sys::Sys;
|
||||||
|
@ -11,5 +11,5 @@ version = "0.67.1"
|
|||||||
dirs-next = "2.0.0"
|
dirs-next = "2.0.0"
|
||||||
dunce = "1.0.1"
|
dunce = "1.0.1"
|
||||||
|
|
||||||
[target.'cfg(target_os = "linux")'.dependencies]
|
[target.'cfg(all(unix, not(target_os = "macos")))'.dependencies]
|
||||||
pwd = "1.3.1"
|
pwd = "1.3.1"
|
@ -1,4 +1,4 @@
|
|||||||
#[cfg(target_os = "linux")]
|
#[cfg(all(unix, not(target_os = "macos")))]
|
||||||
use pwd::Passwd;
|
use pwd::Passwd;
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
|
|
||||||
@ -45,7 +45,7 @@ fn expand_tilde_with_home(path: impl AsRef<Path>, home: Option<PathBuf>) -> Path
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(all(unix, not(target_os = "macos")))]
|
||||||
fn user_home_dir(username: &str) -> PathBuf {
|
fn user_home_dir(username: &str) -> PathBuf {
|
||||||
let passwd = Passwd::from_name(username);
|
let passwd = Passwd::from_name(username);
|
||||||
match &passwd.ok() {
|
match &passwd.ok() {
|
||||||
|
@ -1,13 +1,17 @@
|
|||||||
use std::thread::available_parallelism;
|
|
||||||
use std::time::Duration;
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let cores = match available_parallelism() {
|
#[cfg(any(
|
||||||
|
target_os = "android",
|
||||||
|
target_os = "linux",
|
||||||
|
target_os = "macos",
|
||||||
|
target_os = "windows"
|
||||||
|
))]
|
||||||
|
{
|
||||||
|
let cores = match std::thread::available_parallelism() {
|
||||||
Ok(p) => p.get(),
|
Ok(p) => p.get(),
|
||||||
Err(_) => 1usize,
|
Err(_) => 1usize,
|
||||||
};
|
};
|
||||||
for run in 1..=10 {
|
for run in 1..=10 {
|
||||||
for proc in nu_system::collect_proc(Duration::from_millis(100), false) {
|
for proc in nu_system::collect_proc(std::time::Duration::from_millis(100), false) {
|
||||||
if proc.cpu_usage() > 0.00001 {
|
if proc.cpu_usage() > 0.00001 {
|
||||||
println!(
|
println!(
|
||||||
"{} - {} - {} - {} - {:.2}% - {}M - {}M - {} procs",
|
"{} - {} - {} - {} - {:.2}% - {}M - {}M - {} procs",
|
||||||
@ -25,3 +29,4 @@ fn main() {
|
|||||||
std::thread::sleep(std::time::Duration::from_millis(1000));
|
std::thread::sleep(std::time::Duration::from_millis(1000));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user