mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-17 06:09:19 +00:00
Bug 1836402 - Disable clap default features in uniffi-bindgen-gecko-js. r=bdk,supply-chain-reviewers
The tool is not directly user visible, and it's not super useful for features like color to be enabled. Differential Revision: https://phabricator.services.mozilla.com/D179742
This commit is contained in:
parent
45b7084872
commit
25a2da729c
22
Cargo.lock
generated
22
Cargo.lock
generated
@ -231,17 +231,6 @@ version = "0.1.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "857253367827bd9d0fd973f0ef15506a96e79e41b0ad7aa691203a4e3214f6c8"
|
||||
|
||||
[[package]]
|
||||
name = "atty"
|
||||
version = "0.2.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8"
|
||||
dependencies = [
|
||||
"hermit-abi 0.1.999",
|
||||
"libc",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "audio-mixer"
|
||||
version = "0.1.2"
|
||||
@ -747,14 +736,12 @@ version = "3.1.18"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d2dbdf4bdacb33466e854ce889eee8dfd5729abf7ccd7664d0a2d60cd384440b"
|
||||
dependencies = [
|
||||
"atty",
|
||||
"bitflags 1.3.2",
|
||||
"clap_derive",
|
||||
"clap_lex",
|
||||
"indexmap",
|
||||
"lazy_static",
|
||||
"strsim",
|
||||
"termcolor",
|
||||
"terminal_size",
|
||||
"textwrap",
|
||||
]
|
||||
@ -2445,13 +2432,6 @@ version = "0.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8"
|
||||
|
||||
[[package]]
|
||||
name = "hermit-abi"
|
||||
version = "0.1.999"
|
||||
dependencies = [
|
||||
"hermit-abi 0.2.6",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hermit-abi"
|
||||
version = "0.2.6"
|
||||
@ -3765,7 +3745,7 @@ version = "1.15.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0fac9e2da13b5eb447a6ce3d392f23a29d8694bff781bf03a16cd9ac8697593b"
|
||||
dependencies = [
|
||||
"hermit-abi 0.2.6",
|
||||
"hermit-abi",
|
||||
"libc",
|
||||
]
|
||||
|
||||
|
@ -130,9 +130,6 @@ ntapi = { path = "build/rust/ntapi" }
|
||||
# Patch nix 0.24 to 0.26
|
||||
nix = { path = "build/rust/nix" }
|
||||
|
||||
# Patch hermit-abi 0.1 to 0.2
|
||||
hermit-abi = { path = "build/rust/hermit-abi" }
|
||||
|
||||
# Patch autocfg to hide rustc output. Workaround for https://github.com/cuviper/autocfg/issues/30
|
||||
autocfg = { path = "third_party/rust/autocfg" }
|
||||
|
||||
|
@ -1,11 +0,0 @@
|
||||
[package]
|
||||
name = "hermit-abi"
|
||||
version = "0.1.999"
|
||||
edition = "2018"
|
||||
license = "MPL-2.0"
|
||||
|
||||
[lib]
|
||||
path = "lib.rs"
|
||||
|
||||
[dependencies]
|
||||
hermit-abi = "0.2"
|
@ -1,5 +0,0 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
pub use hermit_abi::*;
|
@ -536,16 +536,6 @@ Well documented invariants, good assertions for those invariants in unsafe code,
|
||||
and tested with MIRI to boot. LGTM.
|
||||
"""
|
||||
|
||||
[[audits.bytecode-alliance.audits.atty]]
|
||||
who = "Alex Crichton <alex@alexcrichton.com>"
|
||||
criteria = "safe-to-deploy"
|
||||
version = "0.2.14"
|
||||
notes = """
|
||||
Contains only unsafe code for what this crate's purpose is and only accesses
|
||||
the environment's terminal information when asked. Does its stated purpose and
|
||||
no more.
|
||||
"""
|
||||
|
||||
[[audits.bytecode-alliance.audits.base64]]
|
||||
who = "Pat Hickey <phickey@fastly.com>"
|
||||
criteria = "safe-to-deploy"
|
||||
|
1
third_party/rust/atty/.cargo-checksum.json
vendored
1
third_party/rust/atty/.cargo-checksum.json
vendored
@ -1 +0,0 @@
|
||||
{"files":{"CHANGELOG.md":"70db121262d72acc472ad1a90b78c42de570820e65b566c6b9339b62e636d572","Cargo.lock":"6868f02a96413bcba37a06f01c6bf87e6331dea9461681a47a561cec6acd2546","Cargo.toml":"3af88a07af6a4adb84373fc3cd4920884b0b12b338cdb55ef598fd512ee1a790","LICENSE":"99fa95ba4e4cdaf71c27d73260ea069fc4515b3d02fde3020c5b562280006cbc","README.md":"e559a69c0b2bd20bffcede64fd548df6c671b0d1504613c5e3e5d884d759caea","examples/atty.rs":"1551387a71474d9ac1b5153231f884e9e05213badcfaa3494ad2cb7ea958374a","rustfmt.toml":"8e6ea1bcb79c505490034020c98e9b472f4ac4113f245bae90f5e1217b1ec65a","src/lib.rs":"d5abf6a54e8c496c486572bdc91eef10480f6ad126c4287f039df5feff7a9bbb"},"package":"d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8"}
|
73
third_party/rust/atty/CHANGELOG.md
vendored
73
third_party/rust/atty/CHANGELOG.md
vendored
@ -1,73 +0,0 @@
|
||||
# 0.2.14
|
||||
|
||||
* add support for [RustyHermit](https://github.com/hermitcore/libhermit-rs), a Rust-based unikernel [#41](https://github.com/softprops/atty/pull/41)
|
||||
|
||||
# 0.2.13
|
||||
|
||||
* support older versions of rust that do now support 2018 edition
|
||||
|
||||
# 0.2.12
|
||||
|
||||
* Redox is now in the unix family so redox cfg is no longer needed [#35](https://github.com/softprops/atty/pull/35)
|
||||
|
||||
# 0.2.11
|
||||
|
||||
* fix msys detection with `winapi@0.3.5` [#28](https://github.com/softprops/atty/pull/28)
|
||||
|
||||
# 0.2.10
|
||||
|
||||
* fix wasm regression [#27](https://github.com/softprops/atty/pull/27)
|
||||
|
||||
# 0.2.9
|
||||
|
||||
* Fix fix pty detection [#25](https://github.com/softprops/atty/pull/25)
|
||||
|
||||
# 0.2.8
|
||||
|
||||
* Fix an inverted condition on MinGW [#22](https://github.com/softprops/atty/pull/22)
|
||||
|
||||
# 0.2.7
|
||||
|
||||
* Change `||` to `&&` for whether MSYS is a tty [#24](https://github.com/softprops/atty/pull/24/)
|
||||
|
||||
# 0.2.6
|
||||
|
||||
* updated winapi dependency to [0.3](https://retep998.github.io/blog/winapi-0.3/) [#18](https://github.com/softprops/atty/pull/18)
|
||||
|
||||
# 0.2.5
|
||||
|
||||
* added support for Wasm compile targets [#17](https://github.com/softprops/atty/pull/17)
|
||||
|
||||
# 0.2.4
|
||||
|
||||
* added support for Wasm compile targets [#17](https://github.com/softprops/atty/pull/17)
|
||||
|
||||
# 0.2.3
|
||||
|
||||
* added support for Redox OS [#14](https://github.com/softprops/atty/pull/14)
|
||||
|
||||
# 0.2.2
|
||||
|
||||
* use target specific dependencies [#11](https://github.com/softprops/atty/pull/11)
|
||||
* Add tty detection for MSYS terminals [#12](https://github.com/softprops/atty/pull/12)
|
||||
|
||||
# 0.2.1
|
||||
|
||||
* fix windows bug
|
||||
|
||||
# 0.2.0
|
||||
|
||||
* support for various stream types
|
||||
|
||||
# 0.1.2
|
||||
|
||||
* windows support (with automated testing)
|
||||
* automated code coverage
|
||||
|
||||
# 0.1.1
|
||||
|
||||
* bumped libc dep from `0.1` to `0.2`
|
||||
|
||||
# 0.1.0
|
||||
|
||||
* initial release
|
49
third_party/rust/atty/Cargo.lock
generated
vendored
49
third_party/rust/atty/Cargo.lock
generated
vendored
@ -1,49 +0,0 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
[[package]]
|
||||
name = "atty"
|
||||
version = "0.2.14"
|
||||
dependencies = [
|
||||
"hermit-abi 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"winapi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hermit-abi"
|
||||
version = "0.1.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.66"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "winapi"
|
||||
version = "0.3.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winapi-i686-pc-windows-gnu"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "winapi-x86_64-pc-windows-gnu"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[metadata]
|
||||
"checksum hermit-abi 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "eff2656d88f158ce120947499e971d743c05dbcbed62e5bd2f38f1698bbc3772"
|
||||
"checksum libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)" = "d515b1f41455adea1313a4a2ac8a8a477634fbae63cc6100e3aebb207ce61558"
|
||||
"checksum winapi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "04e3bd221fcbe8a271359c04f21a76db7d0c6028862d1bb5512d85e1e2eb5bb3"
|
||||
"checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
|
||||
"checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
|
34
third_party/rust/atty/Cargo.toml
vendored
34
third_party/rust/atty/Cargo.toml
vendored
@ -1,34 +0,0 @@
|
||||
# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO
|
||||
#
|
||||
# When uploading crates to the registry Cargo will automatically
|
||||
# "normalize" Cargo.toml files for maximal compatibility
|
||||
# with all versions of Cargo and also rewrite `path` dependencies
|
||||
# to registry (e.g., crates.io) dependencies
|
||||
#
|
||||
# If you believe there's an error in this file please file an
|
||||
# issue against the rust-lang/cargo repository. If you're
|
||||
# editing this file be aware that the upstream Cargo.toml
|
||||
# will likely look very different (and much more reasonable)
|
||||
|
||||
[package]
|
||||
name = "atty"
|
||||
version = "0.2.14"
|
||||
authors = ["softprops <d.tangren@gmail.com>"]
|
||||
exclude = ["/.travis.yml", "/appveyor.yml"]
|
||||
description = "A simple interface for querying atty"
|
||||
homepage = "https://github.com/softprops/atty"
|
||||
documentation = "http://softprops.github.io/atty"
|
||||
readme = "README.md"
|
||||
keywords = ["terminal", "tty", "isatty"]
|
||||
license = "MIT"
|
||||
repository = "https://github.com/softprops/atty"
|
||||
[target."cfg(target_os = \"hermit\")".dependencies.hermit-abi]
|
||||
version = "0.1.6"
|
||||
[target."cfg(unix)".dependencies.libc]
|
||||
version = "0.2"
|
||||
default-features = false
|
||||
[target."cfg(windows)".dependencies.winapi]
|
||||
version = "0.3"
|
||||
features = ["consoleapi", "processenv", "minwinbase", "minwindef", "winbase"]
|
||||
[badges.travis-ci]
|
||||
repository = "softprops/atty"
|
20
third_party/rust/atty/LICENSE
vendored
20
third_party/rust/atty/LICENSE
vendored
@ -1,20 +0,0 @@
|
||||
Copyright (c) 2015-2019 Doug Tangren
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
74
third_party/rust/atty/README.md
vendored
74
third_party/rust/atty/README.md
vendored
@ -1,74 +0,0 @@
|
||||
# atty
|
||||
|
||||
[![Build Status](https://travis-ci.org/softprops/atty.svg?branch=master)](https://travis-ci.org/softprops/atty) [![Build status](https://ci.appveyor.com/api/projects/status/geggrsnsjsuse8cv?svg=true)](https://ci.appveyor.com/project/softprops/atty) [![Coverage Status](https://coveralls.io/repos/softprops/atty/badge.svg?branch=master&service=github)](https://coveralls.io/github/softprops/atty?branch=master) [![crates.io](https://img.shields.io/crates/v/atty.svg)](https://crates.io/crates/atty) [![Released API docs](https://docs.rs/atty/badge.svg)](http://docs.rs/atty) [![Master API docs](https://img.shields.io/badge/docs-master-green.svg)](https://softprops.github.io/atty)
|
||||
|
||||
> are you or are you not a tty?
|
||||
|
||||
|
||||
## install
|
||||
|
||||
Add the following to your `Cargo.toml`
|
||||
|
||||
```toml
|
||||
[dependencies]
|
||||
atty = "0.2"
|
||||
```
|
||||
|
||||
## usage
|
||||
|
||||
```rust
|
||||
use atty::Stream;
|
||||
|
||||
fn main() {
|
||||
if atty::is(Stream::Stdout) {
|
||||
println!("I'm a terminal");
|
||||
} else {
|
||||
println!("I'm not");
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## testing
|
||||
|
||||
This library has been unit tested on both unix and windows platforms (via appveyor).
|
||||
|
||||
|
||||
A simple example program is provided in this repo to test various tty's. By default.
|
||||
|
||||
It prints
|
||||
|
||||
```bash
|
||||
$ cargo run --example atty
|
||||
stdout? true
|
||||
stderr? true
|
||||
stdin? true
|
||||
```
|
||||
|
||||
To test std in, pipe some text to the program
|
||||
|
||||
```bash
|
||||
$ echo "test" | cargo run --example atty
|
||||
stdout? true
|
||||
stderr? true
|
||||
stdin? false
|
||||
```
|
||||
|
||||
To test std out, pipe the program to something
|
||||
|
||||
```bash
|
||||
$ cargo run --example atty | grep std
|
||||
stdout? false
|
||||
stderr? true
|
||||
stdin? true
|
||||
```
|
||||
|
||||
To test std err, pipe the program to something redirecting std err
|
||||
|
||||
```bash
|
||||
$ cargo run --example atty 2>&1 | grep std
|
||||
stdout? false
|
||||
stderr? false
|
||||
stdin? true
|
||||
```
|
||||
|
||||
Doug Tangren (softprops) 2015-2019
|
9
third_party/rust/atty/examples/atty.rs
vendored
9
third_party/rust/atty/examples/atty.rs
vendored
@ -1,9 +0,0 @@
|
||||
extern crate atty;
|
||||
|
||||
use atty::{is, Stream};
|
||||
|
||||
fn main() {
|
||||
println!("stdout? {}", is(Stream::Stdout));
|
||||
println!("stderr? {}", is(Stream::Stderr));
|
||||
println!("stdin? {}", is(Stream::Stdin));
|
||||
}
|
4
third_party/rust/atty/rustfmt.toml
vendored
4
third_party/rust/atty/rustfmt.toml
vendored
@ -1,4 +0,0 @@
|
||||
# https://github.com/rust-lang/rustfmt/blob/master/Configurations.md#fn_args_layout
|
||||
fn_args_layout = "Vertical"
|
||||
# https://github.com/rust-lang/rustfmt/blob/master/Configurations.md#merge_imports
|
||||
merge_imports = true
|
210
third_party/rust/atty/src/lib.rs
vendored
210
third_party/rust/atty/src/lib.rs
vendored
@ -1,210 +0,0 @@
|
||||
//! atty is a simple utility that answers one question
|
||||
//! > is this a tty?
|
||||
//!
|
||||
//! usage is just as simple
|
||||
//!
|
||||
//! ```
|
||||
//! if atty::is(atty::Stream::Stdout) {
|
||||
//! println!("i'm a tty")
|
||||
//! }
|
||||
//! ```
|
||||
//!
|
||||
//! ```
|
||||
//! if atty::isnt(atty::Stream::Stdout) {
|
||||
//! println!("i'm not a tty")
|
||||
//! }
|
||||
//! ```
|
||||
|
||||
#![cfg_attr(unix, no_std)]
|
||||
|
||||
#[cfg(unix)]
|
||||
extern crate libc;
|
||||
#[cfg(windows)]
|
||||
extern crate winapi;
|
||||
|
||||
#[cfg(windows)]
|
||||
use winapi::shared::minwindef::DWORD;
|
||||
#[cfg(windows)]
|
||||
use winapi::shared::ntdef::WCHAR;
|
||||
|
||||
/// possible stream sources
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
pub enum Stream {
|
||||
Stdout,
|
||||
Stderr,
|
||||
Stdin,
|
||||
}
|
||||
|
||||
/// returns true if this is a tty
|
||||
#[cfg(all(unix, not(target_arch = "wasm32")))]
|
||||
pub fn is(stream: Stream) -> bool {
|
||||
extern crate libc;
|
||||
|
||||
let fd = match stream {
|
||||
Stream::Stdout => libc::STDOUT_FILENO,
|
||||
Stream::Stderr => libc::STDERR_FILENO,
|
||||
Stream::Stdin => libc::STDIN_FILENO,
|
||||
};
|
||||
unsafe { libc::isatty(fd) != 0 }
|
||||
}
|
||||
|
||||
/// returns true if this is a tty
|
||||
#[cfg(target_os = "hermit")]
|
||||
pub fn is(stream: Stream) -> bool {
|
||||
extern crate hermit_abi;
|
||||
|
||||
let fd = match stream {
|
||||
Stream::Stdout => hermit_abi::STDOUT_FILENO,
|
||||
Stream::Stderr => hermit_abi::STDERR_FILENO,
|
||||
Stream::Stdin => hermit_abi::STDIN_FILENO,
|
||||
};
|
||||
hermit_abi::isatty(fd)
|
||||
}
|
||||
|
||||
/// returns true if this is a tty
|
||||
#[cfg(windows)]
|
||||
pub fn is(stream: Stream) -> bool {
|
||||
use winapi::um::winbase::{
|
||||
STD_ERROR_HANDLE as STD_ERROR, STD_INPUT_HANDLE as STD_INPUT,
|
||||
STD_OUTPUT_HANDLE as STD_OUTPUT,
|
||||
};
|
||||
|
||||
let (fd, others) = match stream {
|
||||
Stream::Stdin => (STD_INPUT, [STD_ERROR, STD_OUTPUT]),
|
||||
Stream::Stderr => (STD_ERROR, [STD_INPUT, STD_OUTPUT]),
|
||||
Stream::Stdout => (STD_OUTPUT, [STD_INPUT, STD_ERROR]),
|
||||
};
|
||||
if unsafe { console_on_any(&[fd]) } {
|
||||
// False positives aren't possible. If we got a console then
|
||||
// we definitely have a tty on stdin.
|
||||
return true;
|
||||
}
|
||||
|
||||
// At this point, we *could* have a false negative. We can determine that
|
||||
// this is true negative if we can detect the presence of a console on
|
||||
// any of the other streams. If another stream has a console, then we know
|
||||
// we're in a Windows console and can therefore trust the negative.
|
||||
if unsafe { console_on_any(&others) } {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Otherwise, we fall back to a very strange msys hack to see if we can
|
||||
// sneakily detect the presence of a tty.
|
||||
unsafe { msys_tty_on(fd) }
|
||||
}
|
||||
|
||||
/// returns true if this is _not_ a tty
|
||||
pub fn isnt(stream: Stream) -> bool {
|
||||
!is(stream)
|
||||
}
|
||||
|
||||
/// Returns true if any of the given fds are on a console.
|
||||
#[cfg(windows)]
|
||||
unsafe fn console_on_any(fds: &[DWORD]) -> bool {
|
||||
use winapi::um::{consoleapi::GetConsoleMode, processenv::GetStdHandle};
|
||||
|
||||
for &fd in fds {
|
||||
let mut out = 0;
|
||||
let handle = GetStdHandle(fd);
|
||||
if GetConsoleMode(handle, &mut out) != 0 {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
false
|
||||
}
|
||||
|
||||
/// Returns true if there is an MSYS tty on the given handle.
|
||||
#[cfg(windows)]
|
||||
unsafe fn msys_tty_on(fd: DWORD) -> bool {
|
||||
use std::{mem, slice};
|
||||
|
||||
use winapi::{
|
||||
ctypes::c_void,
|
||||
shared::minwindef::MAX_PATH,
|
||||
um::{
|
||||
fileapi::FILE_NAME_INFO, minwinbase::FileNameInfo, processenv::GetStdHandle,
|
||||
winbase::GetFileInformationByHandleEx,
|
||||
},
|
||||
};
|
||||
|
||||
let size = mem::size_of::<FILE_NAME_INFO>();
|
||||
let mut name_info_bytes = vec![0u8; size + MAX_PATH * mem::size_of::<WCHAR>()];
|
||||
let res = GetFileInformationByHandleEx(
|
||||
GetStdHandle(fd),
|
||||
FileNameInfo,
|
||||
&mut *name_info_bytes as *mut _ as *mut c_void,
|
||||
name_info_bytes.len() as u32,
|
||||
);
|
||||
if res == 0 {
|
||||
return false;
|
||||
}
|
||||
let name_info: &FILE_NAME_INFO = &*(name_info_bytes.as_ptr() as *const FILE_NAME_INFO);
|
||||
let s = slice::from_raw_parts(
|
||||
name_info.FileName.as_ptr(),
|
||||
name_info.FileNameLength as usize / 2,
|
||||
);
|
||||
let name = String::from_utf16_lossy(s);
|
||||
// This checks whether 'pty' exists in the file name, which indicates that
|
||||
// a pseudo-terminal is attached. To mitigate against false positives
|
||||
// (e.g., an actual file name that contains 'pty'), we also require that
|
||||
// either the strings 'msys-' or 'cygwin-' are in the file name as well.)
|
||||
let is_msys = name.contains("msys-") || name.contains("cygwin-");
|
||||
let is_pty = name.contains("-pty");
|
||||
is_msys && is_pty
|
||||
}
|
||||
|
||||
/// returns true if this is a tty
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
pub fn is(_stream: Stream) -> bool {
|
||||
false
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::{is, Stream};
|
||||
|
||||
#[test]
|
||||
#[cfg(windows)]
|
||||
fn is_err() {
|
||||
// appveyor pipes its output
|
||||
assert!(!is(Stream::Stderr))
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(windows)]
|
||||
fn is_out() {
|
||||
// appveyor pipes its output
|
||||
assert!(!is(Stream::Stdout))
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(windows)]
|
||||
fn is_in() {
|
||||
assert!(is(Stream::Stdin))
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(unix)]
|
||||
fn is_err() {
|
||||
assert!(is(Stream::Stderr))
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(unix)]
|
||||
fn is_out() {
|
||||
assert!(is(Stream::Stdout))
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(target_os = "macos")]
|
||||
fn is_in() {
|
||||
// macos on travis seems to pipe its input
|
||||
assert!(is(Stream::Stdin))
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(all(not(target_os = "macos"), unix))]
|
||||
fn is_in() {
|
||||
assert!(is(Stream::Stdin))
|
||||
}
|
||||
}
|
@ -11,7 +11,7 @@ path = "src/main.rs"
|
||||
[dependencies]
|
||||
anyhow = "1"
|
||||
askama = { version = "0.11", default-features = false, features = ["config"] }
|
||||
clap = { version = "3.1", features = ["std", "derive", "cargo"] }
|
||||
clap = { version = "3.1", default-features = false, features = ["std", "derive", "cargo"] }
|
||||
extend = "1.1"
|
||||
heck = "0.4"
|
||||
uniffi = { workspace = true }
|
||||
|
Loading…
x
Reference in New Issue
Block a user