mirror of
https://github.com/denoland/deno.git
synced 2025-09-26 12:19:12 +00:00
fix: android build (#30360)
Some checks are pending
ci / pre-build (push) Waiting to run
ci / test debug linux-aarch64 (push) Blocked by required conditions
ci / test release linux-aarch64 (push) Blocked by required conditions
ci / test debug macos-aarch64 (push) Blocked by required conditions
ci / test release macos-aarch64 (push) Blocked by required conditions
ci / bench release linux-x86_64 (push) Blocked by required conditions
ci / lint debug linux-x86_64 (push) Blocked by required conditions
ci / lint debug macos-x86_64 (push) Blocked by required conditions
ci / lint debug windows-x86_64 (push) Blocked by required conditions
ci / test debug linux-x86_64 (push) Blocked by required conditions
ci / test release linux-x86_64 (push) Blocked by required conditions
ci / test debug macos-x86_64 (push) Blocked by required conditions
ci / test release macos-x86_64 (push) Blocked by required conditions
ci / test debug windows-x86_64 (push) Blocked by required conditions
ci / test release windows-x86_64 (push) Blocked by required conditions
ci / build libs (push) Blocked by required conditions
ci / publish canary (push) Blocked by required conditions
Some checks are pending
ci / pre-build (push) Waiting to run
ci / test debug linux-aarch64 (push) Blocked by required conditions
ci / test release linux-aarch64 (push) Blocked by required conditions
ci / test debug macos-aarch64 (push) Blocked by required conditions
ci / test release macos-aarch64 (push) Blocked by required conditions
ci / bench release linux-x86_64 (push) Blocked by required conditions
ci / lint debug linux-x86_64 (push) Blocked by required conditions
ci / lint debug macos-x86_64 (push) Blocked by required conditions
ci / lint debug windows-x86_64 (push) Blocked by required conditions
ci / test debug linux-x86_64 (push) Blocked by required conditions
ci / test release linux-x86_64 (push) Blocked by required conditions
ci / test debug macos-x86_64 (push) Blocked by required conditions
ci / test release macos-x86_64 (push) Blocked by required conditions
ci / test debug windows-x86_64 (push) Blocked by required conditions
ci / test release windows-x86_64 (push) Blocked by required conditions
ci / build libs (push) Blocked by required conditions
ci / publish canary (push) Blocked by required conditions
Fix build error on Android. Patches from https://github.com/cions/termux-deno
This commit is contained in:
parent
c69a8fa414
commit
ebfd3c3d7c
17 changed files with 248 additions and 66 deletions
|
@ -195,7 +195,7 @@ deno_subprocess_windows.workspace = true
|
|||
[target.'cfg(unix)'.dependencies]
|
||||
nix.workspace = true
|
||||
shell-escape = "=0.1.5"
|
||||
[target.'cfg(any(target_os = "linux", target_os = "macos"))'.dependencies]
|
||||
[target.'cfg(any(target_os = "android", target_os = "linux", target_os = "macos"))'.dependencies]
|
||||
tokio-vsock.workspace = true
|
||||
|
||||
[dev-dependencies]
|
||||
|
|
18
cli/main.rs
18
cli/main.rs
|
@ -732,9 +732,17 @@ fn wait_for_start(
|
|||
use tokio::io::BufReader;
|
||||
use tokio::net::TcpListener;
|
||||
use tokio::net::UnixSocket;
|
||||
#[cfg(any(target_os = "linux", target_os = "macos"))]
|
||||
#[cfg(any(
|
||||
target_os = "android",
|
||||
target_os = "linux",
|
||||
target_os = "macos"
|
||||
))]
|
||||
use tokio_vsock::VsockAddr;
|
||||
#[cfg(any(target_os = "linux", target_os = "macos"))]
|
||||
#[cfg(any(
|
||||
target_os = "android",
|
||||
target_os = "linux",
|
||||
target_os = "macos"
|
||||
))]
|
||||
use tokio_vsock::VsockListener;
|
||||
|
||||
init_v8(&Flags::default());
|
||||
|
@ -774,7 +782,11 @@ fn wait_for_start(
|
|||
let (rx, tx) = stream.into_split();
|
||||
(Box::new(rx), Box::new(tx))
|
||||
}
|
||||
#[cfg(any(target_os = "linux", target_os = "macos"))]
|
||||
#[cfg(any(
|
||||
target_os = "android",
|
||||
target_os = "linux",
|
||||
target_os = "macos"
|
||||
))]
|
||||
Some(("vsock", addr)) => {
|
||||
let Some((cid, port)) = addr.split_once(':') else {
|
||||
deno_core::anyhow::bail!("invalid vsock addr");
|
||||
|
|
|
@ -46,7 +46,7 @@ tower.workspace = true
|
|||
tower-http.workspace = true
|
||||
tower-service.workspace = true
|
||||
|
||||
[target.'cfg(any(target_os = "linux", target_os = "macos"))'.dependencies]
|
||||
[target.'cfg(any(target_os = "android", target_os = "linux", target_os = "macos"))'.dependencies]
|
||||
tokio-vsock.workspace = true
|
||||
|
||||
[dev-dependencies]
|
||||
|
|
|
@ -1121,12 +1121,20 @@ pub fn create_http_client(
|
|||
Proxy::Unix { .. } => {
|
||||
return Err(HttpClientCreateError::UnixProxyNotSupportedOnWindows);
|
||||
}
|
||||
#[cfg(any(target_os = "linux", target_os = "macos"))]
|
||||
#[cfg(any(
|
||||
target_os = "android",
|
||||
target_os = "linux",
|
||||
target_os = "macos"
|
||||
))]
|
||||
Proxy::Vsock { cid, port } => {
|
||||
let target = proxy::Target::new_vsock(cid, port);
|
||||
proxy::Intercept::all(target)
|
||||
}
|
||||
#[cfg(not(any(target_os = "linux", target_os = "macos")))]
|
||||
#[cfg(not(any(
|
||||
target_os = "android",
|
||||
target_os = "linux",
|
||||
target_os = "macos"
|
||||
)))]
|
||||
Proxy::Vsock { .. } => {
|
||||
return Err(HttpClientCreateError::VsockProxyNotSupported);
|
||||
}
|
||||
|
|
|
@ -31,7 +31,11 @@ use tokio::net::UnixStream;
|
|||
use tokio_rustls::TlsConnector;
|
||||
use tokio_rustls::client::TlsStream;
|
||||
use tokio_socks::tcp::Socks5Stream;
|
||||
#[cfg(any(target_os = "linux", target_os = "macos"))]
|
||||
#[cfg(any(
|
||||
target_os = "android",
|
||||
target_os = "linux",
|
||||
target_os = "macos"
|
||||
))]
|
||||
use tokio_vsock::VsockStream;
|
||||
use tower_service::Service;
|
||||
|
||||
|
@ -77,7 +81,7 @@ pub(crate) enum Target {
|
|||
Unix {
|
||||
path: PathBuf,
|
||||
},
|
||||
#[cfg(any(target_os = "linux", target_os = "macos"))]
|
||||
#[cfg(any(target_os = "android", target_os = "linux", target_os = "macos"))]
|
||||
Vsock {
|
||||
cid: u32,
|
||||
port: u32,
|
||||
|
@ -185,7 +189,11 @@ impl Intercept {
|
|||
Target::Unix { .. } => {
|
||||
// Auth not supported for Unix sockets
|
||||
}
|
||||
#[cfg(any(target_os = "linux", target_os = "macos"))]
|
||||
#[cfg(any(
|
||||
target_os = "android",
|
||||
target_os = "linux",
|
||||
target_os = "macos"
|
||||
))]
|
||||
Target::Vsock { .. } => {
|
||||
// Auth not supported for Vsock sockets
|
||||
}
|
||||
|
@ -272,7 +280,7 @@ impl Target {
|
|||
Target::Unix { path }
|
||||
}
|
||||
|
||||
#[cfg(any(target_os = "linux", target_os = "macos"))]
|
||||
#[cfg(any(target_os = "android", target_os = "linux", target_os = "macos"))]
|
||||
pub(crate) fn new_vsock(cid: u32, port: u32) -> Self {
|
||||
Target::Vsock { cid, port }
|
||||
}
|
||||
|
@ -481,7 +489,7 @@ pub enum Proxied<T> {
|
|||
#[cfg(not(windows))]
|
||||
Unix(TokioIo<UnixStream>),
|
||||
/// Forwarded via Vsock socket
|
||||
#[cfg(any(target_os = "linux", target_os = "macos"))]
|
||||
#[cfg(any(target_os = "android", target_os = "linux", target_os = "macos"))]
|
||||
Vsock(TokioIo<VsockStream>),
|
||||
}
|
||||
|
||||
|
@ -587,7 +595,11 @@ where
|
|||
Ok(Proxied::Unix(TokioIo::new(io)))
|
||||
})
|
||||
}
|
||||
#[cfg(any(target_os = "linux", target_os = "macos"))]
|
||||
#[cfg(any(
|
||||
target_os = "android",
|
||||
target_os = "linux",
|
||||
target_os = "macos"
|
||||
))]
|
||||
Target::Vsock { cid, port } => Box::pin(async move {
|
||||
let addr = tokio_vsock::VsockAddr::new(cid, port);
|
||||
let io = VsockStream::connect(addr).await?;
|
||||
|
@ -704,7 +716,11 @@ where
|
|||
Proxied::SocksTls(ref mut p) => Pin::new(p).poll_read(cx, buf),
|
||||
#[cfg(not(windows))]
|
||||
Proxied::Unix(ref mut p) => Pin::new(p).poll_read(cx, buf),
|
||||
#[cfg(any(target_os = "linux", target_os = "macos"))]
|
||||
#[cfg(any(
|
||||
target_os = "android",
|
||||
target_os = "linux",
|
||||
target_os = "macos"
|
||||
))]
|
||||
Proxied::Vsock(ref mut p) => Pin::new(p).poll_read(cx, buf),
|
||||
}
|
||||
}
|
||||
|
@ -727,7 +743,11 @@ where
|
|||
Proxied::SocksTls(ref mut p) => Pin::new(p).poll_write(cx, buf),
|
||||
#[cfg(not(windows))]
|
||||
Proxied::Unix(ref mut p) => Pin::new(p).poll_write(cx, buf),
|
||||
#[cfg(any(target_os = "linux", target_os = "macos"))]
|
||||
#[cfg(any(
|
||||
target_os = "android",
|
||||
target_os = "linux",
|
||||
target_os = "macos"
|
||||
))]
|
||||
Proxied::Vsock(ref mut p) => Pin::new(p).poll_write(cx, buf),
|
||||
}
|
||||
}
|
||||
|
@ -744,7 +764,11 @@ where
|
|||
Proxied::SocksTls(ref mut p) => Pin::new(p).poll_flush(cx),
|
||||
#[cfg(not(windows))]
|
||||
Proxied::Unix(ref mut p) => Pin::new(p).poll_flush(cx),
|
||||
#[cfg(any(target_os = "linux", target_os = "macos"))]
|
||||
#[cfg(any(
|
||||
target_os = "android",
|
||||
target_os = "linux",
|
||||
target_os = "macos"
|
||||
))]
|
||||
Proxied::Vsock(ref mut p) => Pin::new(p).poll_flush(cx),
|
||||
}
|
||||
}
|
||||
|
@ -761,7 +785,11 @@ where
|
|||
Proxied::SocksTls(ref mut p) => Pin::new(p).poll_shutdown(cx),
|
||||
#[cfg(not(windows))]
|
||||
Proxied::Unix(ref mut p) => Pin::new(p).poll_shutdown(cx),
|
||||
#[cfg(any(target_os = "linux", target_os = "macos"))]
|
||||
#[cfg(any(
|
||||
target_os = "android",
|
||||
target_os = "linux",
|
||||
target_os = "macos"
|
||||
))]
|
||||
Proxied::Vsock(ref mut p) => Pin::new(p).poll_shutdown(cx),
|
||||
}
|
||||
}
|
||||
|
@ -775,7 +803,11 @@ where
|
|||
Proxied::SocksTls(ref p) => p.is_write_vectored(),
|
||||
#[cfg(not(windows))]
|
||||
Proxied::Unix(ref p) => p.is_write_vectored(),
|
||||
#[cfg(any(target_os = "linux", target_os = "macos"))]
|
||||
#[cfg(any(
|
||||
target_os = "android",
|
||||
target_os = "linux",
|
||||
target_os = "macos"
|
||||
))]
|
||||
Proxied::Vsock(ref p) => p.is_write_vectored(),
|
||||
}
|
||||
}
|
||||
|
@ -799,7 +831,11 @@ where
|
|||
Proxied::SocksTls(ref mut p) => Pin::new(p).poll_write_vectored(cx, bufs),
|
||||
#[cfg(not(windows))]
|
||||
Proxied::Unix(ref mut p) => Pin::new(p).poll_write_vectored(cx, bufs),
|
||||
#[cfg(any(target_os = "linux", target_os = "macos"))]
|
||||
#[cfg(any(
|
||||
target_os = "android",
|
||||
target_os = "linux",
|
||||
target_os = "macos"
|
||||
))]
|
||||
Proxied::Vsock(ref mut p) => Pin::new(p).poll_write_vectored(cx, bufs),
|
||||
}
|
||||
}
|
||||
|
@ -832,7 +868,11 @@ where
|
|||
}
|
||||
#[cfg(not(windows))]
|
||||
Proxied::Unix(_) => Connected::new(),
|
||||
#[cfg(any(target_os = "linux", target_os = "macos"))]
|
||||
#[cfg(any(
|
||||
target_os = "android",
|
||||
target_os = "linux",
|
||||
target_os = "macos"
|
||||
))]
|
||||
Proxied::Vsock(_) => Connected::new(),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -57,7 +57,7 @@ thiserror.workspace = true
|
|||
tokio.workspace = true
|
||||
tokio-util = { workspace = true, features = ["io"] }
|
||||
|
||||
[target.'cfg(any(target_os = "linux", target_os = "macos"))'.dependencies]
|
||||
[target.'cfg(any(target_os = "android", target_os = "linux", target_os = "macos"))'.dependencies]
|
||||
tokio-vsock.workspace = true
|
||||
|
||||
[dev-dependencies]
|
||||
|
|
|
@ -1056,7 +1056,11 @@ where
|
|||
NetworkStream::Unix(conn) => {
|
||||
serve_http(conn, connection_properties, lifetime, tx, options)
|
||||
}
|
||||
#[cfg(any(target_os = "linux", target_os = "macos"))]
|
||||
#[cfg(any(
|
||||
target_os = "android",
|
||||
target_os = "linux",
|
||||
target_os = "macos"
|
||||
))]
|
||||
NetworkStream::Vsock(conn) => {
|
||||
serve_http(conn, connection_properties, lifetime, tx, options)
|
||||
}
|
||||
|
|
|
@ -1686,7 +1686,7 @@ fn extract_network_stream<U: CanDowncastUpgrade>(
|
|||
Ok(res) => return res,
|
||||
Err(x) => x,
|
||||
};
|
||||
#[cfg(any(target_os = "linux", target_os = "macos"))]
|
||||
#[cfg(any(target_os = "android", target_os = "linux", target_os = "macos"))]
|
||||
let upgraded =
|
||||
match maybe_extract_network_stream::<tokio_vsock::VsockStream, _>(upgraded)
|
||||
{
|
||||
|
|
|
@ -165,7 +165,11 @@ impl HttpPropertyExtractor for DefaultHttpPropertyExtractor {
|
|||
NetworkStreamAddress::Ip(ip) => Some(ip.port() as _),
|
||||
#[cfg(unix)]
|
||||
NetworkStreamAddress::Unix(_) => None,
|
||||
#[cfg(any(target_os = "linux", target_os = "macos"))]
|
||||
#[cfg(any(
|
||||
target_os = "android",
|
||||
target_os = "linux",
|
||||
target_os = "macos"
|
||||
))]
|
||||
NetworkStreamAddress::Vsock(vsock) => Some(vsock.port()),
|
||||
NetworkStreamAddress::Tunnel(ref addr) => Some(addr.port() as _),
|
||||
};
|
||||
|
@ -173,7 +177,11 @@ impl HttpPropertyExtractor for DefaultHttpPropertyExtractor {
|
|||
NetworkStreamAddress::Ip(addr) => Rc::from(addr.ip().to_string()),
|
||||
#[cfg(unix)]
|
||||
NetworkStreamAddress::Unix(_) => Rc::from("unix"),
|
||||
#[cfg(any(target_os = "linux", target_os = "macos"))]
|
||||
#[cfg(any(
|
||||
target_os = "android",
|
||||
target_os = "linux",
|
||||
target_os = "macos"
|
||||
))]
|
||||
NetworkStreamAddress::Vsock(addr) => {
|
||||
Rc::from(format!("vsock:{}", addr.cid()))
|
||||
}
|
||||
|
@ -216,7 +224,11 @@ fn listener_properties(
|
|||
NetworkStreamAddress::Ip(ip) => Some(ip.port() as _),
|
||||
#[cfg(unix)]
|
||||
NetworkStreamAddress::Unix(_) => None,
|
||||
#[cfg(any(target_os = "linux", target_os = "macos"))]
|
||||
#[cfg(any(
|
||||
target_os = "android",
|
||||
target_os = "linux",
|
||||
target_os = "macos"
|
||||
))]
|
||||
NetworkStreamAddress::Vsock(vsock) => Some(vsock.port()),
|
||||
NetworkStreamAddress::Tunnel(addr) => Some(addr.port() as _),
|
||||
};
|
||||
|
@ -263,7 +275,11 @@ fn req_host_from_addr(
|
|||
percent_encoding::NON_ALPHANUMERIC,
|
||||
)
|
||||
.to_string(),
|
||||
#[cfg(any(target_os = "linux", target_os = "macos"))]
|
||||
#[cfg(any(
|
||||
target_os = "android",
|
||||
target_os = "linux",
|
||||
target_os = "macos"
|
||||
))]
|
||||
NetworkStreamAddress::Vsock(vsock) => {
|
||||
format!("{}:{}", vsock.cid(), vsock.port())
|
||||
}
|
||||
|
@ -283,7 +299,11 @@ fn req_scheme_from_stream_type(stream_type: NetworkStreamType) -> &'static str {
|
|||
NetworkStreamType::Tls | NetworkStreamType::Tunnel => "https://",
|
||||
#[cfg(unix)]
|
||||
NetworkStreamType::Unix => "http+unix://",
|
||||
#[cfg(any(target_os = "linux", target_os = "macos"))]
|
||||
#[cfg(any(
|
||||
target_os = "android",
|
||||
target_os = "linux",
|
||||
target_os = "macos"
|
||||
))]
|
||||
NetworkStreamType::Vsock => "http+vsock://",
|
||||
}
|
||||
}
|
||||
|
@ -309,7 +329,11 @@ fn req_host<'a>(
|
|||
}
|
||||
#[cfg(unix)]
|
||||
NetworkStreamType::Unix => {}
|
||||
#[cfg(any(target_os = "linux", target_os = "macos"))]
|
||||
#[cfg(any(
|
||||
target_os = "android",
|
||||
target_os = "linux",
|
||||
target_os = "macos"
|
||||
))]
|
||||
NetworkStreamType::Vsock => {}
|
||||
}
|
||||
return Some(Cow::Borrowed(auth.as_str()));
|
||||
|
|
|
@ -35,5 +35,5 @@ tokio.workspace = true
|
|||
url.workspace = true
|
||||
web-transport-proto.workspace = true
|
||||
|
||||
[target.'cfg(any(target_os = "linux", target_os = "macos"))'.dependencies]
|
||||
[target.'cfg(any(target_os = "android", target_os = "linux", target_os = "macos"))'.dependencies]
|
||||
tokio-vsock.workspace = true
|
||||
|
|
|
@ -190,14 +190,22 @@ impl Resource for UnixStreamResource {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(any(target_os = "linux", target_os = "macos"))]
|
||||
#[cfg(any(target_os = "android", target_os = "linux", target_os = "macos"))]
|
||||
pub type VsockStreamResource =
|
||||
FullDuplexResource<tokio_vsock::OwnedReadHalf, tokio_vsock::OwnedWriteHalf>;
|
||||
|
||||
#[cfg(not(any(target_os = "linux", target_os = "macos")))]
|
||||
#[cfg(not(any(
|
||||
target_os = "android",
|
||||
target_os = "linux",
|
||||
target_os = "macos"
|
||||
)))]
|
||||
pub struct VsockStreamResource;
|
||||
|
||||
#[cfg(not(any(target_os = "linux", target_os = "macos")))]
|
||||
#[cfg(not(any(
|
||||
target_os = "android",
|
||||
target_os = "linux",
|
||||
target_os = "macos"
|
||||
)))]
|
||||
impl VsockStreamResource {
|
||||
fn read(self: Rc<Self>, _data: &mut [u8]) -> AsyncResult<usize> {
|
||||
unreachable!()
|
||||
|
|
|
@ -638,7 +638,7 @@ where
|
|||
target_os = "linux"
|
||||
))]
|
||||
socket_tmp.set_reuse_address(true)?;
|
||||
#[cfg(all(unix, not(target_os = "linux")))]
|
||||
#[cfg(all(unix, not(any(target_os = "android", target_os = "linux"))))]
|
||||
socket_tmp.set_reuse_port(true)?;
|
||||
}
|
||||
let socket_addr = socket2::SockAddr::from(addr);
|
||||
|
@ -696,7 +696,7 @@ where
|
|||
net_listen_udp::<NP>(state, addr, reuse_address, loopback)
|
||||
}
|
||||
|
||||
#[cfg(any(target_os = "linux", target_os = "macos"))]
|
||||
#[cfg(any(target_os = "android", target_os = "linux", target_os = "macos"))]
|
||||
#[op2(async, stack_trace)]
|
||||
#[serde]
|
||||
pub async fn op_net_connect_vsock<NP>(
|
||||
|
@ -744,7 +744,11 @@ where
|
|||
))
|
||||
}
|
||||
|
||||
#[cfg(not(any(target_os = "linux", target_os = "macos")))]
|
||||
#[cfg(not(any(
|
||||
target_os = "android",
|
||||
target_os = "linux",
|
||||
target_os = "macos"
|
||||
)))]
|
||||
#[op2]
|
||||
#[serde]
|
||||
pub fn op_net_connect_vsock<NP>() -> Result<(), NetError>
|
||||
|
@ -754,7 +758,7 @@ where
|
|||
Err(NetError::VsockUnsupported)
|
||||
}
|
||||
|
||||
#[cfg(any(target_os = "linux", target_os = "macos"))]
|
||||
#[cfg(any(target_os = "android", target_os = "linux", target_os = "macos"))]
|
||||
#[op2(stack_trace)]
|
||||
#[serde]
|
||||
pub fn op_net_listen_vsock<NP>(
|
||||
|
@ -787,7 +791,11 @@ where
|
|||
Ok((rid, local_addr.cid(), local_addr.port()))
|
||||
}
|
||||
|
||||
#[cfg(not(any(target_os = "linux", target_os = "macos")))]
|
||||
#[cfg(not(any(
|
||||
target_os = "android",
|
||||
target_os = "linux",
|
||||
target_os = "macos"
|
||||
)))]
|
||||
#[op2]
|
||||
#[serde]
|
||||
pub fn op_net_listen_vsock<NP>() -> Result<(), NetError>
|
||||
|
@ -797,7 +805,7 @@ where
|
|||
Err(NetError::VsockUnsupported)
|
||||
}
|
||||
|
||||
#[cfg(any(target_os = "linux", target_os = "macos"))]
|
||||
#[cfg(any(target_os = "android", target_os = "linux", target_os = "macos"))]
|
||||
#[op2(async)]
|
||||
#[serde]
|
||||
pub async fn op_net_accept_vsock(
|
||||
|
@ -836,7 +844,11 @@ pub async fn op_net_accept_vsock(
|
|||
))
|
||||
}
|
||||
|
||||
#[cfg(not(any(target_os = "linux", target_os = "macos")))]
|
||||
#[cfg(not(any(
|
||||
target_os = "android",
|
||||
target_os = "linux",
|
||||
target_os = "macos"
|
||||
)))]
|
||||
#[op2]
|
||||
#[serde]
|
||||
pub fn op_net_accept_vsock() -> Result<(), NetError> {
|
||||
|
|
|
@ -257,7 +257,7 @@ macro_rules! network_stream {
|
|||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
#[cfg(any(target_os = "linux", target_os = "macos"))]
|
||||
#[cfg(any(target_os = "android", target_os = "linux", target_os = "macos"))]
|
||||
network_stream!(
|
||||
[
|
||||
Tcp,
|
||||
|
@ -302,7 +302,11 @@ network_stream!(
|
|||
);
|
||||
|
||||
#[cfg(unix)]
|
||||
#[cfg(not(any(target_os = "linux", target_os = "macos")))]
|
||||
#[cfg(not(any(
|
||||
target_os = "android",
|
||||
target_os = "linux",
|
||||
target_os = "macos"
|
||||
)))]
|
||||
network_stream!(
|
||||
[
|
||||
Tcp,
|
||||
|
@ -370,7 +374,7 @@ pub enum NetworkStreamAddress {
|
|||
Ip(std::net::SocketAddr),
|
||||
#[cfg(unix)]
|
||||
Unix(tokio::net::unix::SocketAddr),
|
||||
#[cfg(any(target_os = "linux", target_os = "macos"))]
|
||||
#[cfg(any(target_os = "android", target_os = "linux", target_os = "macos"))]
|
||||
Vsock(tokio_vsock::VsockAddr),
|
||||
Tunnel(crate::tunnel::TunnelAddr),
|
||||
}
|
||||
|
@ -388,7 +392,7 @@ impl From<tokio::net::unix::SocketAddr> for NetworkStreamAddress {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(any(target_os = "linux", target_os = "macos"))]
|
||||
#[cfg(any(target_os = "android", target_os = "linux", target_os = "macos"))]
|
||||
impl From<tokio_vsock::VsockAddr> for NetworkStreamAddress {
|
||||
fn from(value: tokio_vsock::VsockAddr) -> Self {
|
||||
NetworkStreamAddress::Vsock(value)
|
||||
|
@ -413,7 +417,7 @@ pub enum TakeNetworkStreamError {
|
|||
#[class("Busy")]
|
||||
#[error("Unix socket is currently in use")]
|
||||
UnixBusy,
|
||||
#[cfg(any(target_os = "linux", target_os = "macos"))]
|
||||
#[cfg(any(target_os = "android", target_os = "linux", target_os = "macos"))]
|
||||
#[class("Busy")]
|
||||
#[error("Vsock socket is currently in use")]
|
||||
VsockBusy,
|
||||
|
@ -427,7 +431,7 @@ pub enum TakeNetworkStreamError {
|
|||
#[class(generic)]
|
||||
#[error(transparent)]
|
||||
ReuniteUnix(#[from] tokio::net::unix::ReuniteError),
|
||||
#[cfg(any(target_os = "linux", target_os = "macos"))]
|
||||
#[cfg(any(target_os = "android", target_os = "linux", target_os = "macos"))]
|
||||
#[class(generic)]
|
||||
#[error("Cannot reunite halves from different streams")]
|
||||
ReuniteVsock,
|
||||
|
@ -477,7 +481,7 @@ pub fn take_network_stream_resource(
|
|||
return Ok(NetworkStream::Unix(unix_stream));
|
||||
}
|
||||
|
||||
#[cfg(any(target_os = "linux", target_os = "macos"))]
|
||||
#[cfg(any(target_os = "android", target_os = "linux", target_os = "macos"))]
|
||||
if let Ok(resource_rc) =
|
||||
resource_table.take::<crate::io::VsockStreamResource>(stream_rid)
|
||||
{
|
||||
|
|
|
@ -235,7 +235,7 @@ pub fn op_node_fs_constants() -> FsConstants {
|
|||
constants
|
||||
}
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
#[op2]
|
||||
#[serde]
|
||||
pub fn op_node_fs_constants() -> FsConstants {
|
||||
|
|
|
@ -37,5 +37,5 @@ thiserror.workspace = true
|
|||
tokio.workspace = true
|
||||
tower-service.workspace = true
|
||||
|
||||
[target.'cfg(any(target_os = "linux", target_os = "macos"))'.dependencies]
|
||||
[target.'cfg(any(target_os = "android", target_os = "linux", target_os = "macos"))'.dependencies]
|
||||
tokio-vsock.workspace = true
|
||||
|
|
|
@ -524,9 +524,17 @@ mod hyper_client {
|
|||
use opentelemetry_http::Response;
|
||||
use opentelemetry_http::ResponseExt;
|
||||
use tokio::net::TcpStream;
|
||||
#[cfg(any(target_os = "linux", target_os = "macos"))]
|
||||
#[cfg(any(
|
||||
target_os = "android",
|
||||
target_os = "linux",
|
||||
target_os = "macos"
|
||||
))]
|
||||
use tokio_vsock::VsockAddr;
|
||||
#[cfg(any(target_os = "linux", target_os = "macos"))]
|
||||
#[cfg(any(
|
||||
target_os = "android",
|
||||
target_os = "linux",
|
||||
target_os = "macos"
|
||||
))]
|
||||
use tokio_vsock::VsockStream;
|
||||
|
||||
use super::OtelSharedRuntime;
|
||||
|
@ -545,7 +553,11 @@ mod hyper_client {
|
|||
enum Connector {
|
||||
Http(HttpsConnector<HttpConnector>),
|
||||
Tunnel(TunnelConnection),
|
||||
#[cfg(any(target_os = "linux", target_os = "macos"))]
|
||||
#[cfg(any(
|
||||
target_os = "android",
|
||||
target_os = "linux",
|
||||
target_os = "macos"
|
||||
))]
|
||||
Vsock(VsockAddr),
|
||||
}
|
||||
|
||||
|
@ -554,7 +566,11 @@ mod hyper_client {
|
|||
enum IO {
|
||||
Tls(#[pin] TokioIo<MaybeHttpsStream<TokioIo<TcpStream>>>),
|
||||
Tunnel(#[pin] TunnelStream),
|
||||
#[cfg(any(target_os = "linux", target_os = "macos"))]
|
||||
#[cfg(any(
|
||||
target_os = "android",
|
||||
target_os = "linux",
|
||||
target_os = "macos"
|
||||
))]
|
||||
Vsock(#[pin] VsockStream),
|
||||
}
|
||||
|
||||
|
@ -567,7 +583,11 @@ mod hyper_client {
|
|||
match self.project() {
|
||||
IOProj::Tls(stream) => stream.poll_read(cx, buf),
|
||||
IOProj::Tunnel(stream) => stream.poll_read(cx, buf),
|
||||
#[cfg(any(target_os = "linux", target_os = "macos"))]
|
||||
#[cfg(any(
|
||||
target_os = "android",
|
||||
target_os = "linux",
|
||||
target_os = "macos"
|
||||
))]
|
||||
IOProj::Vsock(stream) => stream.poll_read(cx, buf),
|
||||
}
|
||||
}
|
||||
|
@ -582,7 +602,11 @@ mod hyper_client {
|
|||
match self.project() {
|
||||
IOProj::Tls(stream) => stream.poll_write(cx, buf),
|
||||
IOProj::Tunnel(stream) => stream.poll_write(cx, buf),
|
||||
#[cfg(any(target_os = "linux", target_os = "macos"))]
|
||||
#[cfg(any(
|
||||
target_os = "android",
|
||||
target_os = "linux",
|
||||
target_os = "macos"
|
||||
))]
|
||||
IOProj::Vsock(stream) => stream.poll_write(cx, buf),
|
||||
}
|
||||
}
|
||||
|
@ -594,7 +618,11 @@ mod hyper_client {
|
|||
match self.project() {
|
||||
IOProj::Tls(stream) => stream.poll_flush(cx),
|
||||
IOProj::Tunnel(stream) => stream.poll_flush(cx),
|
||||
#[cfg(any(target_os = "linux", target_os = "macos"))]
|
||||
#[cfg(any(
|
||||
target_os = "android",
|
||||
target_os = "linux",
|
||||
target_os = "macos"
|
||||
))]
|
||||
IOProj::Vsock(stream) => stream.poll_flush(cx),
|
||||
}
|
||||
}
|
||||
|
@ -606,7 +634,11 @@ mod hyper_client {
|
|||
match self.project() {
|
||||
IOProj::Tls(stream) => stream.poll_shutdown(cx),
|
||||
IOProj::Tunnel(stream) => stream.poll_shutdown(cx),
|
||||
#[cfg(any(target_os = "linux", target_os = "macos"))]
|
||||
#[cfg(any(
|
||||
target_os = "android",
|
||||
target_os = "linux",
|
||||
target_os = "macos"
|
||||
))]
|
||||
IOProj::Vsock(stream) => stream.poll_shutdown(cx),
|
||||
}
|
||||
}
|
||||
|
@ -615,7 +647,11 @@ mod hyper_client {
|
|||
match self {
|
||||
IO::Tls(stream) => stream.is_write_vectored(),
|
||||
IO::Tunnel(stream) => stream.is_write_vectored(),
|
||||
#[cfg(any(target_os = "linux", target_os = "macos"))]
|
||||
#[cfg(any(
|
||||
target_os = "android",
|
||||
target_os = "linux",
|
||||
target_os = "macos"
|
||||
))]
|
||||
IO::Vsock(stream) => stream.is_write_vectored(),
|
||||
}
|
||||
}
|
||||
|
@ -628,7 +664,11 @@ mod hyper_client {
|
|||
match self.project() {
|
||||
IOProj::Tls(stream) => stream.poll_write_vectored(cx, bufs),
|
||||
IOProj::Tunnel(stream) => stream.poll_write_vectored(cx, bufs),
|
||||
#[cfg(any(target_os = "linux", target_os = "macos"))]
|
||||
#[cfg(any(
|
||||
target_os = "android",
|
||||
target_os = "linux",
|
||||
target_os = "macos"
|
||||
))]
|
||||
IOProj::Vsock(stream) => stream.poll_write_vectored(cx, bufs),
|
||||
}
|
||||
}
|
||||
|
@ -639,7 +679,11 @@ mod hyper_client {
|
|||
match self {
|
||||
Self::Tls(stream) => stream.connected(),
|
||||
Self::Tunnel(_) => Connected::new().proxy(true),
|
||||
#[cfg(any(target_os = "linux", target_os = "macos"))]
|
||||
#[cfg(any(
|
||||
target_os = "android",
|
||||
target_os = "linux",
|
||||
target_os = "macos"
|
||||
))]
|
||||
Self::Vsock(_) => Connected::new().proxy(true),
|
||||
}
|
||||
}
|
||||
|
@ -662,7 +706,11 @@ mod hyper_client {
|
|||
match self {
|
||||
Self::Http(c) => c.poll_ready(cx).map_err(Into::into),
|
||||
Self::Tunnel(_) => Poll::Ready(Ok(())),
|
||||
#[cfg(any(target_os = "linux", target_os = "macos"))]
|
||||
#[cfg(any(
|
||||
target_os = "android",
|
||||
target_os = "linux",
|
||||
target_os = "macos"
|
||||
))]
|
||||
Self::Vsock(_) => Poll::Ready(Ok(())),
|
||||
}
|
||||
}
|
||||
|
@ -679,7 +727,11 @@ mod hyper_client {
|
|||
let stream = listener.create_agent_stream().await?;
|
||||
Ok(TokioIo::new(IO::Tunnel(stream)))
|
||||
}
|
||||
#[cfg(any(target_os = "linux", target_os = "macos"))]
|
||||
#[cfg(any(
|
||||
target_os = "android",
|
||||
target_os = "linux",
|
||||
target_os = "macos"
|
||||
))]
|
||||
Self::Vsock(addr) => {
|
||||
let stream = VsockStream::connect(addr).await?;
|
||||
Ok(TokioIo::new(IO::Vsock(stream)))
|
||||
|
@ -699,13 +751,21 @@ mod hyper_client {
|
|||
let connector = if let Some(tunnel) = get_tunnel() {
|
||||
Connector::Tunnel(tunnel.clone())
|
||||
} else if let Ok(addr) = std::env::var("OTEL_DENO_VSOCK") {
|
||||
#[cfg(not(any(target_os = "linux", target_os = "macos")))]
|
||||
#[cfg(not(any(
|
||||
target_os = "android",
|
||||
target_os = "linux",
|
||||
target_os = "macos"
|
||||
)))]
|
||||
{
|
||||
let _ = addr;
|
||||
deno_core::anyhow::bail!("vsock is not supported on this platform")
|
||||
}
|
||||
|
||||
#[cfg(any(target_os = "linux", target_os = "macos"))]
|
||||
#[cfg(any(
|
||||
target_os = "android",
|
||||
target_os = "linux",
|
||||
target_os = "macos"
|
||||
))]
|
||||
{
|
||||
let Some((cid, port)) = addr.split_once(':') else {
|
||||
deno_core::anyhow::bail!("invalid vsock addr");
|
||||
|
|
|
@ -24,6 +24,16 @@ use crate::surface::GPUCanvasContext;
|
|||
|
||||
#[derive(Debug, thiserror::Error, deno_error::JsError)]
|
||||
pub enum ByowError {
|
||||
#[cfg(not(any(
|
||||
target_os = "macos",
|
||||
target_os = "windows",
|
||||
target_os = "linux",
|
||||
target_os = "freebsd",
|
||||
target_os = "openbsd",
|
||||
)))]
|
||||
#[class(type)]
|
||||
#[error("Unsupported platform")]
|
||||
Unsupported,
|
||||
#[class(type)]
|
||||
#[error(
|
||||
"Cannot create surface outside of WebGPU context. Did you forget to call `navigator.gpu.requestAdapter()`?"
|
||||
|
@ -360,6 +370,6 @@ fn raw_window(
|
|||
_system: UnsafeWindowSurfaceSystem,
|
||||
_window: *const c_void,
|
||||
_display: *const c_void,
|
||||
) -> Result<RawHandles, deno_error::JsErrorBox> {
|
||||
Err(deno_error::JsErrorBox::type_error("Unsupported platform"))
|
||||
) -> Result<RawHandles, ByowError> {
|
||||
Err(ByowError::Unsupported)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue