From fa5f5f3eb7096bbe028bd3fcd6a3d2d7e9b9e6cf Mon Sep 17 00:00:00 2001 From: caesay Date: Mon, 25 Dec 2023 11:09:06 +0000 Subject: [PATCH] WIP prepare to restructure rust for xplat --- src/Rust/Cargo.lock | 46 +++----------- src/Rust/Cargo.toml | 61 +++++++++++-------- src/Rust/build.rs | 4 ++ src/Rust/src/platform/mod.rs | 11 ---- src/Rust/src/{ => shared}/bundle.rs | 0 src/Rust/src/{ => shared}/download.rs | 0 src/Rust/src/shared/mod.rs | 0 src/Rust/src/{ => shared}/util.rs | 0 .../unix/util.rs => shared/util_osx.rs} | 0 .../src/{platform => }/windows/dialogs.rs | 0 src/Rust/src/{platform => }/windows/mod.rs | 0 src/Rust/src/{ => windows}/runtimes.rs | 0 .../src/{platform => }/windows/self_delete.rs | 0 .../src/{platform => }/windows/shortcuts.rs | 0 src/Rust/src/{ => windows}/splash.rs | 0 src/Rust/src/{platform => }/windows/util.rs | 0 16 files changed, 47 insertions(+), 75 deletions(-) delete mode 100644 src/Rust/src/platform/mod.rs rename src/Rust/src/{ => shared}/bundle.rs (100%) rename src/Rust/src/{ => shared}/download.rs (100%) create mode 100644 src/Rust/src/shared/mod.rs rename src/Rust/src/{ => shared}/util.rs (100%) rename src/Rust/src/{platform/unix/util.rs => shared/util_osx.rs} (100%) rename src/Rust/src/{platform => }/windows/dialogs.rs (100%) rename src/Rust/src/{platform => }/windows/mod.rs (100%) rename src/Rust/src/{ => windows}/runtimes.rs (100%) rename src/Rust/src/{platform => }/windows/self_delete.rs (100%) rename src/Rust/src/{platform => }/windows/shortcuts.rs (100%) rename src/Rust/src/{ => windows}/splash.rs (100%) rename src/Rust/src/{platform => }/windows/util.rs (100%) diff --git a/src/Rust/Cargo.lock b/src/Rust/Cargo.lock index 033147a13..94abb4fe3 100644 --- a/src/Rust/Cargo.lock +++ b/src/Rust/Cargo.lock @@ -232,7 +232,6 @@ dependencies = [ "chrono", "clap", "codesign-verify", - "com", "derivative", "file-rotate", "fs_extra", @@ -286,37 +285,6 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" -[[package]] -name = "com" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a30a2b2a013da986dc5cc3eda3d19c0d59d53f835be1b2356eb8d00f000c793" -dependencies = [ - "com_macros", -] - -[[package]] -name = "com_macros" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7606b05842fea68ddcc89e8053b8860ebcb2a0ba8d6abfe3a148e5d5a8d3f0c1" -dependencies = [ - "com_macros_support", - "proc-macro2", - "syn 1.0.109", -] - -[[package]] -name = "com_macros_support" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97e9a6d20f4ac8830e309a455d7e9416e65c6af5a97c88c55fbb4c2012e107da" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "core-foundation" version = "0.9.4" @@ -353,9 +321,9 @@ dependencies = [ [[package]] name = "crossbeam-utils" -version = "0.8.17" +version = "0.8.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c06d96137f14f244c37f989d9fff8f95e6c18b918e71f36638f8c49112e4c78f" +checksum = "c3a430a770ebd84726f584a90ee7f020d28db52c6d02138900f22341f866d39c" dependencies = [ "cfg-if", ] @@ -740,9 +708,9 @@ checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" [[package]] name = "openssl" -version = "0.10.61" +version = "0.10.62" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b8419dc8cc6d866deb801274bba2e6f8f6108c1bb7fcc10ee5ab864931dbb45" +checksum = "8cde4d2d9200ad5909f8dac647e29482e07c3a35de8a13fce7c9c7747ad9f671" dependencies = [ "bitflags 2.4.1", "cfg-if", @@ -772,9 +740,9 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" [[package]] name = "openssl-sys" -version = "0.9.97" +version = "0.9.98" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3eaad34cdd97d81de97964fc7f29e2d104f483840d906ef56daa1912338460b" +checksum = "c1665caf8ab2dc9aef43d1c0023bd904633a6a05cb30b0ad59bec2ae986e57a7" dependencies = [ "cc", "libc", @@ -926,7 +894,7 @@ checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" [[package]] name = "remove_dir_all" version = "0.8.2" -source = "git+https://github.com/caesay/remove_dir_all.git#88a1afa25a1ec8960bfe74c5d2ef12515ab89ae6" +source = "git+https://github.com/caesay/remove_dir_all.git#f70d40ad7b6bb655a7a36268cd7cc5ea8e015c6d" dependencies = [ "cfg-if", "cvt", diff --git a/src/Rust/Cargo.toml b/src/Rust/Cargo.toml index 211671c3b..18c15868d 100644 --- a/src/Rust/Cargo.toml +++ b/src/Rust/Cargo.toml @@ -3,9 +3,13 @@ name = "clowd_squirrel" version = "0.0.0-local" edition = "2021" +[features] +windows_build = [] + [[bin]] name = "setup" path = "src/setup.rs" +required-features = ["windows_build"] [[bin]] name = "update" @@ -14,10 +18,12 @@ path = "src/update.rs" [[bin]] name = "testapp" path = "src/testapp.rs" +required-features = ["windows_build"] [[bin]] name = "stub" path = "src/stub.rs" +required-features = ["windows_build"] [profile.release] opt-level = "z" # optimize for size @@ -32,10 +38,33 @@ rpath = false # disable rpath [dependencies] anyhow = "1.0" -memmap2 = "0.9" pretty-bytes-rust = "0.3" -xml = "0.8" os_info = { git = "https://github.com/stanislav-tkach/os_info.git", branch = "master", default-features = false } # public releases don't yet have processor arch info +zip = { version = "0.6", default-features = false, features = ["deflate"] } +regex = "1.10" +rand = "0.8" +log = "0.4" +simplelog = "0.12" +clap = "4.4" +xml = "0.8" +semver = "1.0" +chrono = "0.4" +wait-timeout = "0.2" +lazy_static = "1.4" +strum = { version = "0.25", features = ["derive"] } +ureq = { version = "2.9", default-features = false, features = [ + "native-tls", + "gzip", +] } +native-tls = "0.2" +file-rotate = "0.7" +derivative = "2.2" +simple-stopwatch = "0.1.4" + +[target.'cfg(windows)'.dependencies] +fs_extra = "1.2" +glob = "0.3" +memmap2 = "0.9" winsafe = { git = "https://github.com/caesay/winsafe.git", branch = "cs/only-ipersistfile", features = [ "kernel", "version", @@ -45,18 +74,11 @@ winsafe = { git = "https://github.com/caesay/winsafe.git", branch = "cs/only-ipe "gui", "ole", ] } -zip = { version = "0.6", default-features = false, features = ["deflate"] } -regex = "1.10" -rand = "0.8" -log = "0.4" -simplelog = "0.12" -clap = "4.4" image = { version = "0.24", default-features = false, features = [ "gif", "jpeg", "png", ] } -fs_extra = "1.2" windows = { version = "0.52", default-features = false, features = [ "Win32_Foundation", "Win32_Security", @@ -74,26 +96,15 @@ windows-sys = { version = "0.52", default-features = false, features = [ "Wdk_System", "Wdk_System_Threading", ] } -semver = "1.0" -chrono = "0.4" -wait-timeout = "0.2" -lazy_static = "1.4" -strum = { version = "0.25", features = ["derive"] } -ureq = { version = "2.9", default-features = false, features = [ - "native-tls", - "gzip", +remove_dir_all = { git = "https://github.com/caesay/remove_dir_all.git", features = [ + "log", ] } -native-tls = "0.2" -file-rotate = "0.7" -derivative = "2.2" -remove_dir_all = { git = "https://github.com/caesay/remove_dir_all.git", features = ["log"] } -glob = "0.3" normpath = "1.0.1" codesign-verify = { git = "https://github.com/caesay/codesign-verify-rs.git" } -com = "0.2.0" widestring = "1.0.2" -simple-stopwatch="0.1.4" [build-dependencies] +semver = "1.0" + +[target.'cfg(windows)'.build-dependencies] winres = "0.1" -semver = "1.0" \ No newline at end of file diff --git a/src/Rust/build.rs b/src/Rust/build.rs index cd1a2a600..e6fce4601 100644 --- a/src/Rust/build.rs +++ b/src/Rust/build.rs @@ -1,7 +1,10 @@ +#![allow(unused_variables)] use semver; use std::process::Command; +#[cfg(target_os = "windows")] extern crate winres; + fn main() { let ver_output = Command::new("nbgv").args(&["get-version", "-v", "NuGetPackageVersion"]).output().expect("Failed to execute nbgv get-version"); let version = String::from_utf8(ver_output.stdout).expect("Unable to convert ngbv output to string"); @@ -12,6 +15,7 @@ fn main() { println!("cargo:rustc-env=NGBV_VERSION={}", version); + #[cfg(target_os = "windows")] let _ = winres::WindowsResource::new() .set_manifest_file("app.manifest") .set_version_info(winres::VersionInfo::PRODUCTVERSION, ver) diff --git a/src/Rust/src/platform/mod.rs b/src/Rust/src/platform/mod.rs deleted file mode 100644 index 4def1961c..000000000 --- a/src/Rust/src/platform/mod.rs +++ /dev/null @@ -1,11 +0,0 @@ -#[cfg(target_family = "windows")] -mod windows; - -#[cfg(target_family = "unix")] -mod unix; - -#[cfg(target_family = "windows")] -pub use windows::*; - -#[cfg(target_family = "unix")] -pub use unix::*; \ No newline at end of file diff --git a/src/Rust/src/bundle.rs b/src/Rust/src/shared/bundle.rs similarity index 100% rename from src/Rust/src/bundle.rs rename to src/Rust/src/shared/bundle.rs diff --git a/src/Rust/src/download.rs b/src/Rust/src/shared/download.rs similarity index 100% rename from src/Rust/src/download.rs rename to src/Rust/src/shared/download.rs diff --git a/src/Rust/src/shared/mod.rs b/src/Rust/src/shared/mod.rs new file mode 100644 index 000000000..e69de29bb diff --git a/src/Rust/src/util.rs b/src/Rust/src/shared/util.rs similarity index 100% rename from src/Rust/src/util.rs rename to src/Rust/src/shared/util.rs diff --git a/src/Rust/src/platform/unix/util.rs b/src/Rust/src/shared/util_osx.rs similarity index 100% rename from src/Rust/src/platform/unix/util.rs rename to src/Rust/src/shared/util_osx.rs diff --git a/src/Rust/src/platform/windows/dialogs.rs b/src/Rust/src/windows/dialogs.rs similarity index 100% rename from src/Rust/src/platform/windows/dialogs.rs rename to src/Rust/src/windows/dialogs.rs diff --git a/src/Rust/src/platform/windows/mod.rs b/src/Rust/src/windows/mod.rs similarity index 100% rename from src/Rust/src/platform/windows/mod.rs rename to src/Rust/src/windows/mod.rs diff --git a/src/Rust/src/runtimes.rs b/src/Rust/src/windows/runtimes.rs similarity index 100% rename from src/Rust/src/runtimes.rs rename to src/Rust/src/windows/runtimes.rs diff --git a/src/Rust/src/platform/windows/self_delete.rs b/src/Rust/src/windows/self_delete.rs similarity index 100% rename from src/Rust/src/platform/windows/self_delete.rs rename to src/Rust/src/windows/self_delete.rs diff --git a/src/Rust/src/platform/windows/shortcuts.rs b/src/Rust/src/windows/shortcuts.rs similarity index 100% rename from src/Rust/src/platform/windows/shortcuts.rs rename to src/Rust/src/windows/shortcuts.rs diff --git a/src/Rust/src/splash.rs b/src/Rust/src/windows/splash.rs similarity index 100% rename from src/Rust/src/splash.rs rename to src/Rust/src/windows/splash.rs diff --git a/src/Rust/src/platform/windows/util.rs b/src/Rust/src/windows/util.rs similarity index 100% rename from src/Rust/src/platform/windows/util.rs rename to src/Rust/src/windows/util.rs