Skip to content

Commit

Permalink
Use cfg_attr instead of macro
Browse files Browse the repository at this point in the history
Signed-off-by: James Sturtevant <[email protected]>
  • Loading branch information
jsturtevant committed Aug 22, 2023
1 parent 1936b20 commit 42dc656
Show file tree
Hide file tree
Showing 12 changed files with 23 additions and 81 deletions.
4 changes: 2 additions & 2 deletions crates/containerd-shim-wasm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
)]

pub mod sandbox;

mod macros;
pub mod services;
#[cfg_attr(unix, path = "sys/unix.rs")]
#[cfg_attr(windows, path = "sys/windows.rs")]
pub mod sys;

#[cfg(all(feature = "libcontainer", not(target_os = "windows")))]
Expand Down
19 changes: 0 additions & 19 deletions crates/containerd-shim-wasm/src/macros.rs

This file was deleted.

2 changes: 1 addition & 1 deletion crates/containerd-shim-wasm/src/sandbox/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use super::error::Error;
use super::instance::Instance;
use super::{oci, sandbox};
use crate::services::sandbox_ttrpc::{Manager, ManagerClient};
use crate::sys::networking::setup_namespaces;
use crate::sys::setup_namespaces;

/// Sandbox wraps an Instance and is used with the `Service` to manage multiple instances.
pub trait Sandbox: Task + Send + Sync {
Expand Down
21 changes: 9 additions & 12 deletions crates/containerd-shim-wasm/src/sandbox/shim.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ use std::collections::HashMap;
use std::env::current_dir;
use std::fs::{self, canonicalize, create_dir_all, DirBuilder, File, OpenOptions};
use std::ops::Not;
#[cfg(unix)]
use std::os::unix::fs::DirBuilderExt;
use std::path::Path;
use std::sync::mpsc::{channel, Receiver, Sender};
use std::sync::{Arc, Condvar, Mutex, RwLock};
Expand All @@ -14,6 +16,8 @@ use std::thread;
use chrono::{DateTime, Utc};
use containerd_shim::error::Error as ShimError;
use containerd_shim::event::Event;
#[cfg(unix)]
use containerd_shim::mount::mount_rootfs;
use containerd_shim::protos::events::task::{TaskCreate, TaskDelete, TaskExit, TaskIO, TaskStart};
use containerd_shim::protos::protobuf::well_known_types::timestamp::Timestamp;
use containerd_shim::protos::protobuf::{MessageDyn, MessageField};
Expand All @@ -23,23 +27,16 @@ use containerd_shim::publisher::RemotePublisher;
use containerd_shim::util::{timestamp as new_timestamp, write_address, IntoOption};
use containerd_shim::{self as shim, api, warn, ExitSignal, TtrpcContext, TtrpcResult};
use log::{debug, error};
#[cfg(unix)]
use nix::mount::{mount, MsFlags};
use oci_spec::runtime;
use shim::api::{StatsRequest, StatsResponse};
use shim::Flags;
use ttrpc::context::Context;

use super::instance::{Instance, InstanceConfig, Nop, Wait};
use super::{oci, Error, SandboxService};
use crate::cfg_unix;
use crate::sys::metrics::get_metrics;
use crate::sys::networking::setup_namespaces;

cfg_unix! {
use containerd_shim::mount::mount_rootfs;
use nix::mount::{mount, MsFlags};
use std::os::unix::fs::DirBuilderExt;
}

use shim::Flags;
use ttrpc::context::Context;
use crate::sys::{get_metrics, setup_namespaces};

type InstanceDataStatus = (Mutex<Option<(u32, DateTime<Utc>)>>, Condvar);

Expand Down
18 changes: 0 additions & 18 deletions crates/containerd-shim-wasm/src/sys/mod.rs

This file was deleted.

11 changes: 0 additions & 11 deletions crates/containerd-shim-wasmedge/src/instance.rs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -369,4 +369,4 @@ mod rootdirtest {
);
Ok(())
}
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use std::path::PathBuf;
use std::process::ExitCode;

use containerd_shim_wasm::sandbox::{Instance, InstanceConfig};
use containerd_shim_wasm::sandbox::error::Error;
use containerd_shim_wasm::sandbox::instance::Wait;
use containerd_shim_wasm::sandbox::{Instance, InstanceConfig};
use wasmedge_sdk::Vm;
use containerd_shim_wasm::sandbox::error::Error;

pub struct Wasi {
id: String,
Expand Down Expand Up @@ -41,4 +41,4 @@ impl Instance for Wasi {
fn wait(&self, waiter: &Wait) -> std::result::Result<(), Error> {
todo!()
}
}
}
2 changes: 2 additions & 0 deletions crates/containerd-shim-wasmedge/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
pub mod error;

#[cfg_attr(unix, path = "instance/instance_linux.rs")]
#[cfg_attr(windows, path = "instance/instance_windows.rs")]
pub mod instance;
pub mod oci_utils;

Expand Down
11 changes: 0 additions & 11 deletions crates/containerd-shim-wasmtime/src/instance.rs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use std::path::PathBuf;

use containerd_shim_wasm::sandbox::{Instance, InstanceConfig};
use containerd_shim_wasm::sandbox::instance::{Wait, ExitCode};
use containerd_shim_wasm::sandbox::error::Error;
use containerd_shim_wasm::sandbox::instance::{ExitCode, Wait};
use containerd_shim_wasm::sandbox::{Instance, InstanceConfig};

pub struct Wasi {
exit_code: ExitCode,
Expand Down Expand Up @@ -40,4 +40,4 @@ impl Instance for Wasi {
) -> std::result::Result<(), Error> {
todo!()
}
}
}
2 changes: 2 additions & 0 deletions crates/containerd-shim-wasmtime/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
pub mod error;
#[cfg_attr(unix, path = "instance/instance_linux.rs")]
#[cfg_attr(windows, path = "instance/instance_windows.rs")]
pub mod instance;
pub mod oci_wasmtime;

Expand Down

0 comments on commit 42dc656

Please sign in to comment.