mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-20 09:03:28 +00:00
xous-rs: remove log, hex, and debug-here deps
The `xous-rs` library is used in many places, and should have as few dependencies as possible. Remove these as dependencies. Signed-off-by: Sean Cross <sean@xobs.io>
This commit is contained in:
parent
8edf03a243
commit
58dd02c282
6 changed files with 45 additions and 45 deletions
3
Cargo.lock
generated
3
Cargo.lock
generated
|
|
@ -3843,10 +3843,7 @@ version = "0.9.7"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags",
|
"bitflags",
|
||||||
"compiler_builtins",
|
"compiler_builtins",
|
||||||
"debug-here",
|
|
||||||
"hex",
|
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
"log",
|
|
||||||
"rustc-std-workspace-core",
|
"rustc-std-workspace-core",
|
||||||
"xous-macros",
|
"xous-macros",
|
||||||
]
|
]
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,6 @@ homepage = "https://betrusted.io/"
|
||||||
[dependencies]
|
[dependencies]
|
||||||
bitflags = {version = "1.2.1", optional = true }
|
bitflags = {version = "1.2.1", optional = true }
|
||||||
xous-macros = { path = "../macros", version = "0.1.0", optional = true }
|
xous-macros = { path = "../macros", version = "0.1.0", optional = true }
|
||||||
log = { version = "0.4.14", optional = true }
|
|
||||||
core = { version = '1.0.0', optional = true, package = 'rustc-std-workspace-core' }
|
core = { version = '1.0.0', optional = true, package = 'rustc-std-workspace-core' }
|
||||||
compiler_builtins = { version = '0.1.0', optional = true }
|
compiler_builtins = { version = '0.1.0', optional = true }
|
||||||
|
|
||||||
|
|
@ -25,10 +24,6 @@ forget-memory-messages = []
|
||||||
# Enable using `bitflags`
|
# Enable using `bitflags`
|
||||||
bit-flags = ["bitflags"]
|
bit-flags = ["bitflags"]
|
||||||
|
|
||||||
# `logging` causes this program to connect to a log server on startup
|
|
||||||
# so you can run log commands such as `info!()`.
|
|
||||||
logging = ["log"]
|
|
||||||
|
|
||||||
# This is being built as part of libstd
|
# This is being built as part of libstd
|
||||||
rustc-dep-of-std = ['core', 'compiler_builtins/rustc-dep-of-std']
|
rustc-dep-of-std = ['core', 'compiler_builtins/rustc-dep-of-std']
|
||||||
|
|
||||||
|
|
@ -40,5 +35,3 @@ default = ["bit-flags", "xous-macros"]
|
||||||
|
|
||||||
[target.'cfg(any(windows,unix))'.dependencies]
|
[target.'cfg(any(windows,unix))'.dependencies]
|
||||||
lazy_static = "1.4.0"
|
lazy_static = "1.4.0"
|
||||||
hex = "0.4.3"
|
|
||||||
debug-here = "0.2.2"
|
|
||||||
|
|
|
||||||
|
|
@ -39,11 +39,7 @@ lazy_static::lazy_static! {
|
||||||
|
|
||||||
// resume with PROCESS_KEY initialization
|
// resume with PROCESS_KEY initialization
|
||||||
std::env::var("XOUS_PROCESS_KEY")
|
std::env::var("XOUS_PROCESS_KEY")
|
||||||
.map(|s| {
|
.map(|s| s.as_str().into())
|
||||||
let mut base = ProcessKey([0u8; 16]);
|
|
||||||
hex::decode_to_slice(s, &mut base.0).unwrap();
|
|
||||||
base
|
|
||||||
})
|
|
||||||
.unwrap_or(ProcessKey([0u8; 16]))
|
.unwrap_or(ProcessKey([0u8; 16]))
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -286,8 +282,7 @@ fn read_next_syscall_result(
|
||||||
if data != previous_data.as_slice() {
|
if data != previous_data.as_slice() {
|
||||||
println!("Data: {:x?}", data);
|
println!("Data: {:x?}", data);
|
||||||
println!("Previous data: {:x?}", previous_data);
|
println!("Previous data: {:x?}", previous_data);
|
||||||
::debug_here::debug_here!();
|
panic!("Data changed during borrow!");
|
||||||
panic!("Data was not equal!");
|
|
||||||
}
|
}
|
||||||
// assert_eq!(
|
// assert_eq!(
|
||||||
// data,
|
// data,
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,26 @@ impl ProcessKey {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Into<String> for ProcessKey {
|
||||||
|
fn into(self) -> String {
|
||||||
|
let mut out = String::new();
|
||||||
|
for i in self.0 {
|
||||||
|
out.push_str(&format!("{:02x}", i));
|
||||||
|
}
|
||||||
|
out
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<&str> for ProcessKey {
|
||||||
|
fn from(v: &str) -> ProcessKey {
|
||||||
|
let mut key = [0u8; 16];
|
||||||
|
for (src, dest) in v.as_bytes().chunks(2).zip(key.iter_mut()) {
|
||||||
|
*dest = u8::from_str_radix(core::str::from_utf8(src).unwrap(), 16).unwrap();
|
||||||
|
}
|
||||||
|
ProcessKey::new(key)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Describes all parameters that are required to start a new process
|
/// Describes all parameters that are required to start a new process
|
||||||
/// on this platform.
|
/// on this platform.
|
||||||
#[derive(Copy, Clone, Debug, PartialEq)]
|
#[derive(Copy, Clone, Debug, PartialEq)]
|
||||||
|
|
@ -125,7 +145,7 @@ pub fn create_process_post(
|
||||||
let server_env = format!("{}", CHILD_PROCESS_ADDRESS.lock().unwrap());
|
let server_env = format!("{}", CHILD_PROCESS_ADDRESS.lock().unwrap());
|
||||||
let pid_env = format!("{}", startup.pid);
|
let pid_env = format!("{}", startup.pid);
|
||||||
let process_name_env = args.name.to_string();
|
let process_name_env = args.name.to_string();
|
||||||
let process_key_env = hex::encode(&init.key.0);
|
let process_key_env: String = init.key.into();
|
||||||
let (shell, args) = if cfg!(windows) {
|
let (shell, args) = if cfg!(windows) {
|
||||||
("cmd", ["/C", &args.command])
|
("cmd", ["/C", &args.command])
|
||||||
} else if cfg!(unix) {
|
} else if cfg!(unix) {
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,26 @@ impl ProcessKey {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Into<String> for ProcessKey {
|
||||||
|
fn into(self) -> String {
|
||||||
|
let mut out = String::new();
|
||||||
|
for i in self.0 {
|
||||||
|
out.push_str(&format!("{:02x}", i));
|
||||||
|
}
|
||||||
|
out
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<&str> for ProcessKey {
|
||||||
|
fn from(v: &str) -> ProcessKey {
|
||||||
|
let mut key = [0u8; 16];
|
||||||
|
for (src, dest) in v.as_bytes().chunks(2).zip(key.iter_mut()) {
|
||||||
|
*dest = u8::from_str_radix(core::str::from_utf8(src).unwrap(), 16).unwrap();
|
||||||
|
}
|
||||||
|
ProcessKey::new(key)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq)]
|
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||||
pub struct ThreadInit {}
|
pub struct ThreadInit {}
|
||||||
|
|
||||||
|
|
@ -226,7 +246,7 @@ pub fn create_process_post(
|
||||||
let server_env = format!("{}", xous_address());
|
let server_env = format!("{}", xous_address());
|
||||||
let pid_env = format!("{}", startup.pid);
|
let pid_env = format!("{}", startup.pid);
|
||||||
let process_name_env = args.name.to_string();
|
let process_name_env = args.name.to_string();
|
||||||
let process_key_env = hex::encode(&init.key.0);
|
let process_key_env: String = init.key.into();
|
||||||
let (shell, args) = if cfg!(windows) {
|
let (shell, args) = if cfg!(windows) {
|
||||||
("cmd", ["/C", &args.command])
|
("cmd", ["/C", &args.command])
|
||||||
} else if cfg!(unix) {
|
} else if cfg!(unix) {
|
||||||
|
|
@ -343,11 +363,7 @@ fn default_xous_address() -> SocketAddr {
|
||||||
|
|
||||||
fn default_process_key() -> ProcessKey {
|
fn default_process_key() -> ProcessKey {
|
||||||
std::env::var("XOUS_PROCESS_KEY")
|
std::env::var("XOUS_PROCESS_KEY")
|
||||||
.map(|s| {
|
.map(|s| s.as_str().into())
|
||||||
let mut base = ProcessKey([0u8; 16]);
|
|
||||||
hex::decode_to_slice(s, &mut base.0).unwrap();
|
|
||||||
base
|
|
||||||
})
|
|
||||||
.unwrap_or(ProcessKey([0u8; 16]))
|
.unwrap_or(ProcessKey([0u8; 16]))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -31,29 +31,8 @@ pub use locale::LANG;
|
||||||
#[cfg(feature = "processes-as-threads")]
|
#[cfg(feature = "processes-as-threads")]
|
||||||
pub use crate::arch::ProcessArgsAsThread;
|
pub use crate::arch::ProcessArgsAsThread;
|
||||||
|
|
||||||
#[cfg(any(target_os = "none", target_os = "xous"))]
|
|
||||||
pub fn init() {}
|
pub fn init() {}
|
||||||
|
|
||||||
#[cfg(not(any(target_os = "none", target_os = "xous")))]
|
|
||||||
pub fn init() {
|
|
||||||
use std::panic;
|
|
||||||
panic::set_hook(Box::new(|arg| {
|
|
||||||
println!("PANIC!");
|
|
||||||
println!("Details: {:?}", arg);
|
|
||||||
debug_here::debug_here!();
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Convert a four-letter string into a 32-bit int.
|
|
||||||
#[macro_export]
|
|
||||||
macro_rules! make_name {
|
|
||||||
($fcc:expr) => {{
|
|
||||||
let mut c: [u8; 4] = Default::default();
|
|
||||||
c.copy_from_slice($fcc.as_bytes());
|
|
||||||
u32::from_le_bytes(c) as usize
|
|
||||||
}};
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(not(target_os = "none"))]
|
#[cfg(not(target_os = "none"))]
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! maybe_main {
|
macro_rules! maybe_main {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue