From 02c0d065ef7470bc1429f69e790bbf325676fef0 Mon Sep 17 00:00:00 2001 From: John Smith Date: Mon, 10 Jan 2022 22:36:54 -0500 Subject: [PATCH] updates and aarch64-unknown-linux-gnu build in earthly --- .cargo/config.toml | 7 ++ Cargo.lock | 95 ++++++++------- Earthfile | 29 +++-- external/keyring-manager | 2 +- veilid-cli/Cargo.toml | 6 +- veilid-cli/src/main.rs | 15 +-- veilid-core/Cargo.toml | 4 +- .../utils/network_interfaces/netlink.rs | 2 +- veilid-server/Cargo.toml | 6 +- veilid-server/src/unix.rs | 108 ++++++++++-------- 10 files changed, 149 insertions(+), 125 deletions(-) create mode 100644 .cargo/config.toml diff --git a/.cargo/config.toml b/.cargo/config.toml new file mode 100644 index 00000000..6bda8e4a --- /dev/null +++ b/.cargo/config.toml @@ -0,0 +1,7 @@ +[target.aarch64-unknown-linux-gnu] +# ar = "aarch64-linux-gnu-ar" +linker = "aarch64-linux-gnu-gcc" + +[target.aarch64-linux-android] +#ar = "$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android-ar" +linker = "$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android-clang" \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock index b19ac206..9977b279 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -116,15 +116,6 @@ dependencies = [ "log", ] -[[package]] -name = "ansi_term" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2" -dependencies = [ - "winapi", -] - [[package]] name = "anyhow" version = "1.0.52" @@ -686,13 +677,24 @@ version = "2.34.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c" dependencies = [ - "ansi_term", + "bitflags", + "textwrap 0.11.0", + "unicode-width", +] + +[[package]] +name = "clap" +version = "3.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1957aa4a5fb388f0a0a73ce7556c5b42025b874e5cdc2c670775e346e97adec0" +dependencies = [ "atty", "bitflags", - "strsim 0.8.0", - "textwrap", - "unicode-width", - "vec_map", + "indexmap", + "os_str_bytes", + "strsim", + "termcolor", + "textwrap 0.14.2", ] [[package]] @@ -830,7 +832,7 @@ checksum = "1604dafd25fba2fe2d5895a9da139f8dc9b319a5fe5354ca137cbbce4e178d10" dependencies = [ "atty", "cast", - "clap", + "clap 2.34.0", "criterion-plot", "csv", "itertools", @@ -1103,7 +1105,7 @@ dependencies = [ "ident_case", "proc-macro2", "quote", - "strsim 0.10.0", + "strsim", "syn", ] @@ -1144,15 +1146,6 @@ dependencies = [ "generic-array", ] -[[package]] -name = "directories" -version = "3.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e69600ff1703123957937708eb27f7a564e48885c537782722ed0ba3189ce1d7" -dependencies = [ - "dirs-sys", -] - [[package]] name = "directories" version = "4.0.1" @@ -1836,11 +1829,11 @@ dependencies = [ "android_logger", "backtrace", "byteorder", - "cfg-if 0.1.10", - "clap", + "cfg-if 1.0.0", + "clap 3.0.6", "core-foundation 0.9.2", "core-foundation-sys 0.8.3", - "directories 4.0.1", + "directories", "fs4", "jni", "keychain-services", @@ -1848,14 +1841,13 @@ dependencies = [ "log", "ndk", "ndk-glue", - "owning_ref", "rpassword", "secret-service", "security-framework", "security-framework-sys", "serde 1.0.133", "serde_cbor", - "serial_test 0.4.0", + "serial_test 0.5.1", "simplelog", "snailquote", "tempfile", @@ -2444,6 +2436,15 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" +[[package]] +name = "os_str_bytes" +version = "6.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e22443d1643a904602595ba1cd8f7d896afe56d26712531c5ff73a15b2fbf64" +dependencies = [ + "memchr", +] + [[package]] name = "owning_ref" version = "0.4.1" @@ -3422,12 +3423,6 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" -[[package]] -name = "strsim" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" - [[package]] name = "strsim" version = "0.10.0" @@ -3522,6 +3517,12 @@ dependencies = [ "unicode-width", ] +[[package]] +name = "textwrap" +version = "0.14.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0066c8d12af8b5acd21e00547c3797fde4e8677254a7ee429176ccebbe93dd80" + [[package]] name = "thiserror" version = "1.0.30" @@ -3760,12 +3761,6 @@ version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" -[[package]] -name = "vec_map" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" - [[package]] name = "veilid-cli" version = "0.1.0" @@ -3777,14 +3772,14 @@ dependencies = [ "capnp", "capnp-rpc", "capnpc", - "cfg-if 0.1.10", - "clap", + "cfg-if 1.0.0", + "clap 3.0.6", "config 0.10.1", "crossbeam-channel", "cursive", "cursive-flexi-logger-view", "cursive_buffered_backend", - "directories 3.0.2", + "directories", "flexi_logger", "futures", "log", @@ -3813,7 +3808,7 @@ dependencies = [ "bugsalot", "capnp", "capnpc", - "cfg-if 0.1.10", + "cfg-if 1.0.0", "chacha20poly1305", "chrono", "config 0.11.0", @@ -3821,7 +3816,7 @@ dependencies = [ "curve25519-dalek-ng", "data-encoding", "digest", - "directories 3.0.2", + "directories", "ed25519-dalek", "futures-util", "generic-array", @@ -3884,12 +3879,12 @@ dependencies = [ "capnp", "capnp-rpc", "capnpc", - "cfg-if 0.1.10", - "clap", + "cfg-if 1.0.0", + "clap 3.0.6", "config 0.11.0", "ctrlc", "daemonize", - "directories 3.0.2", + "directories", "failure", "futures", "lazy_static", diff --git a/Earthfile b/Earthfile index 65727888..a36089f6 100644 --- a/Earthfile +++ b/Earthfile @@ -12,13 +12,19 @@ deps-base: RUN apt-get install -y software-properties-common RUN add-apt-repository -y ppa:deadsnakes/ppa RUN apt-get -y update - RUN apt-get install -y iproute2 curl build-essential cmake libssl-dev openssl file git pkg-config python3.8 python3.8-distutils python3.8-dev libdbus-1-dev libdbus-glib-1-dev libgirepository1.0-dev libcairo2-dev + RUN apt-get install -y iproute2 curl build-essential cmake libssl-dev openssl file git pkg-config python3.8 python3.8-distutils python3.8-dev libdbus-1-dev libdbus-glib-1-dev libgirepository1.0-dev libcairo2-dev RUN apt-get remove -y python3.5 RUN curl https://bootstrap.pypa.io/get-pip.py | python3.8 +# Install Cap'n Proto +deps-capnp: + FROM +deps-base + COPY scripts/earthly/install_capnproto.sh / + RUN /bin/bash /install_capnproto.sh; rm /install_capnproto.sh + # Install Rust deps-rust: - FROM +deps-base + FROM +deps-capnp ENV RUSTUP_HOME=/usr/local/rustup ENV CARGO_HOME=/usr/local/cargo ENV PATH=/usr/local/cargo/bin:$PATH @@ -37,21 +43,20 @@ deps-rust: # WASM RUN rustup target add wasm32-unknown-unknown -# Install Cap'n Proto -deps-capnp: +# Install cross-platform tooling +deps-cross: FROM +deps-rust - COPY scripts/earthly/install_capnproto.sh / - RUN /bin/bash /install_capnproto.sh; rm /install_capnproto.sh + RUN apt-get install -y gcc-aarch64-linux-gnu + # Install stub secrets daemon for keyring tests deps-secretsd: - FROM +deps-capnp + FROM +deps-cross COPY scripts/earthly/secretsd /secretsd RUN pip install -r /secretsd/requirements.txt RUN pip install keyring RUN cp /secretsd/dbus/org.freedesktop.secrets.service /usr/share/dbus-1/services/org.freedesktop.secrets.service - # Clean up the apt cache to save space deps: FROM +deps-secretsd @@ -78,6 +83,10 @@ build-linux-arm64: SAVE ARTIFACT ./target/aarch64-unknown-linux-gnu AS LOCAL ./target/artifacts/aarch64-unknown-linux-gnu # Unit tests -unit-test: +unit-tests-linux-amd64: FROM +code - RUN cargo test --release + RUN cargo test --target x86_64-unknown-linux-gnu --release + +unit-tests-linux-arm64: + FROM +code + RUN cargo test --target aarch64-unknown-linux-gnu --release diff --git a/external/keyring-manager b/external/keyring-manager index 3713e105..935ca957 160000 --- a/external/keyring-manager +++ b/external/keyring-manager @@ -1 +1 @@ -Subproject commit 3713e10599c6078e058aab785ef46594420dc11b +Subproject commit 935ca957d7e223ef560a0b20b656730a325e0ba7 diff --git a/veilid-cli/Cargo.toml b/veilid-cli/Cargo.toml index 3bc60607..c0dbaed0 100644 --- a/veilid-cli/Cargo.toml +++ b/veilid-cli/Cargo.toml @@ -20,14 +20,14 @@ cursive_buffered_backend = { path = "../external/cursive_buffered_backend" } # cursive_tree_view = "0.6.0" # cursive_table_view = "0.12.0" # cursive-tabs = "0.5.0" -clap = "^2.33.2" -directories = "^3" +clap = "^3" +directories = "^4" log = "^0.4" futures = "^0.3" serde = "^1.0.122" serde_derive = "^1.0.122" parking_lot = "^0.11" -cfg-if = "^0.1" +cfg-if = "^1" capnp = "^0.14" capnp-rpc = "^0.14" config = { version = "0.10.1", features = ["yaml"] } diff --git a/veilid-cli/src/main.rs b/veilid-cli/src/main.rs index 41874b7e..27792912 100644 --- a/veilid-cli/src/main.rs +++ b/veilid-cli/src/main.rs @@ -3,7 +3,7 @@ use anyhow::*; use async_std::prelude::*; -use clap::{App, Arg}; +use clap::{App, Arg, ColorChoice}; use flexi_logger::*; use log::*; use std::ffi::OsStr; @@ -22,31 +22,32 @@ pub mod veilid_client_capnp { fn parse_command_line(default_config_path: &OsStr) -> Result { let matches = App::new("veilid-cli") .version("0.1") + .color(ColorChoice::Auto) .about("Veilid Console Client") .arg( - Arg::with_name("address") + Arg::new("address") .required(false) .help("Address to connect to"), ) .arg( - Arg::with_name("debug") + Arg::new("debug") .long("debug") .help("Turn on debug logging"), ) .arg( - Arg::with_name("wait-for-debug") + Arg::new("wait-for-debug") .long("wait-for-debug") .help("Wait for debugger to attach"), ) .arg( - Arg::with_name("trace") + Arg::new("trace") .long("trace") .conflicts_with("debug") .help("Turn on trace logging"), ) .arg( - Arg::with_name("config-file") - .short("c") + Arg::new("config-file") + .short('c') .takes_value(true) .value_name("FILE") .default_value_os(default_config_path) diff --git a/veilid-core/Cargo.toml b/veilid-core/Cargo.toml index 1cd06d85..8cad1983 100644 --- a/veilid-core/Cargo.toml +++ b/veilid-core/Cargo.toml @@ -18,7 +18,7 @@ capnp = { version = "^0", default_features = false } rust-fsm = "^0" static_assertions = "^1" log = "^0" -cfg-if = "^0" +cfg-if = "^1" anyhow = "^1" thiserror = "^1" @@ -31,7 +31,7 @@ serde-big-array = "^0" futures-util = { version = "^0", default_features = false, features = ["alloc"] } parking_lot = "^0" lazy_static = "^1" -directories = "^3" +directories = "^4" once_cell = "^1" ed25519-dalek = { version = "^1", default_features = false, features = ["alloc", "u64_backend"] } diff --git a/veilid-core/src/intf/native/utils/network_interfaces/netlink.rs b/veilid-core/src/intf/native/utils/network_interfaces/netlink.rs index a98b8644..7f698934 100644 --- a/veilid-core/src/intf/native/utils/network_interfaces/netlink.rs +++ b/veilid-core/src/intf/native/utils/network_interfaces/netlink.rs @@ -21,7 +21,7 @@ use tools::*; fn get_interface_name(index: u32) -> Result { let mut ifnamebuf = [0u8; (IF_NAMESIZE + 1)]; cfg_if! { - if #[cfg(all(target_os = "android", any(target_arch = "arm", target_arch = "aarch64")))] { + if #[cfg(all(any(target_os = "android", target_os="linux"), any(target_arch = "arm", target_arch = "aarch64")))] { if unsafe { if_indextoname(index, ifnamebuf.as_mut_ptr()) }.is_null() { return Err("if_indextoname returned null".to_owned()); } diff --git a/veilid-server/Cargo.toml b/veilid-server/Cargo.toml index 5924994f..15006e54 100644 --- a/veilid-server/Cargo.toml +++ b/veilid-server/Cargo.toml @@ -13,17 +13,17 @@ path = "src/main.rs" [dependencies] log = "^0" simplelog = { version = "^0", features = ["test"] } -clap = "^2" +clap = "^3" async-std = { version = "^1", features = ["unstable"] } async-tungstenite = { version = "^0", features = ["async-std-runtime", "async-tls"] } veilid-core = { path = "../veilid-core" } -directories = "^3" +directories = "^4" capnp = "^0" parking_lot = "^0" capnp-rpc = "^0" config = { version = "^0", features = ["yaml"] } failure = "^0" -cfg-if = "^0" +cfg-if = "^1" serde = "^1" serde_derive = "^1" serde_yaml = "^0" diff --git a/veilid-server/src/unix.rs b/veilid-server/src/unix.rs index fb4718d5..85f59193 100644 --- a/veilid-server/src/unix.rs +++ b/veilid-server/src/unix.rs @@ -17,73 +17,82 @@ use std::time::{Duration, Instant}; use veilid_core::xx::SingleShotEventual; fn parse_command_line(default_config_path: &OsStr) -> Result { + let matches = App::new("veilid-server") .version("0.1") .about("Veilid Server") + .color(clap::ColorChoice::Auto) .arg( - Arg::with_name("daemon") + Arg::new("daemon") .long("daemon") - .short("d") + .short('d') .help("Run in daemon mode in the background"), ) .arg( - Arg::with_name("subnode_index") - .long("subnode_index") - .takes_value(true) - .help("Run as an extra daemon on the same machine for testing purposes, specify a number greater than zero to offset the listening ports"), - ) - .arg( - Arg::with_name("debug") - .long("debug") - .help("Turn on debug logging on the terminal"), - ) - .arg( - Arg::with_name("trace") - .long("trace") - .conflicts_with("debug") - .help("Turn on trace logging on the terminal"), - ) - .arg( - Arg::with_name("generate-id") - .long("generate-id") - .help("Only generate a new node id and print it"), - ) - .arg( - Arg::with_name("config-file") - .short("c") + Arg::new("config-file") + .short('c') .long("config-file") .takes_value(true) .value_name("FILE") .default_value_os(default_config_path) .help("Specify a configuration file to use"), - ) - .arg( - Arg::with_name("dump-config") - .long("dump-config") - .help("Instead of running the server, print the configuration it would use to the console"), - ) - .arg( - Arg::with_name("bootstrap") - .long("bootstrap") - .takes_value(true) - .value_name("BOOTSTRAP_LIST") - .help("Specify a list of bootstrap servers to use"), - ) - .arg( - Arg::with_name("attach") + ).arg( + Arg::new("attach") .long("attach") .takes_value(true) .value_name("BOOL") .possible_values(&["false", "true"]) .help("Automatically attach the server to the Veilid network"), ) - ; - #[cfg(debug_assertions)] - let matches = matches.arg( - Arg::with_name("wait-for-debug") - .long("wait-for-debug") - .help("Wait for debugger to attach"), - ); + // Dev options + .arg( + Arg::new("debug") + .long("debug") + .help("Turn on debug logging on the terminal"), + ) + .arg( + Arg::new("trace") + .long("trace") + .conflicts_with("debug") + .help("Turn on trace logging on the terminal"), + ) + .arg( + Arg::new("subnode_index") + .long("subnode_index") + .takes_value(true) + .help("Run as an extra daemon on the same machine for testing purposes, specify a number greater than zero to offset the listening ports"), + ) + .arg( + Arg::new("generate-dht-key") + .long("generate-dht-key") + .help("Only generate a new dht key and print it"), + ) + + .arg( + Arg::new("dump-config") + .long("dump-config") + .help("Instead of running the server, print the configuration it would use to the console"), + ) + .arg( + Arg::new("bootstrap") + .long("bootstrap") + .takes_value(true) + .value_name("BOOTSTRAP_LIST") + .help("Specify a list of bootstrap servers to use"), + ) + .arg( + Arg::new("local") + .long("local") + .help("Enable local peer scope") + ); + + #[cfg(debug_assertions)] + let matches = matches.arg( + Arg::new("wait-for-debug") + .long("wait-for-debug") + .help("Wait for debugger to attach"), + ); + Ok(matches.get_matches()) } @@ -163,6 +172,9 @@ pub async fn main() -> Result<(), String> { if matches.is_present("attach") { settingsrw.auto_attach = !matches!(matches.value_of("attach"), Some("true")); } + if matches.is_present("local") { + settingsrw.core.network.enable_local_peer_scope = true; + } if matches.occurrences_of("bootstrap") != 0 { let bootstrap = match matches.value_of("bootstrap") { Some(x) => {