mirror of
https://github.com/spacedriveapp/spacedrive.git
synced 2025-12-11 20:15:30 +01:00
Colocate native code + reorganise (#589)
colocate native code + all rust in crates/
This commit is contained in:
parent
3a86b6c2d8
commit
9397aa617d
2
.gitignore
vendored
2
.gitignore
vendored
@ -68,3 +68,5 @@ playwright-report
|
||||
/sdserver_data
|
||||
.spacedrive
|
||||
dev.db-journal
|
||||
.build/
|
||||
.swiftpm
|
||||
|
||||
91
Cargo.lock
generated
91
Cargo.lock
generated
@ -5635,40 +5635,6 @@ dependencies = [
|
||||
"webp",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sd-core-android"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"jni 0.19.0",
|
||||
"sd-core-mobile",
|
||||
"tracing",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sd-core-ios"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"objc",
|
||||
"objc-foundation",
|
||||
"objc_id",
|
||||
"sd-core-mobile",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sd-core-mobile"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"futures",
|
||||
"once_cell",
|
||||
"openssl",
|
||||
"openssl-sys",
|
||||
"rspc",
|
||||
"sd-core",
|
||||
"serde_json",
|
||||
"tokio",
|
||||
"tracing",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sd-crypto"
|
||||
version = "0.0.0"
|
||||
@ -5695,6 +5661,13 @@ dependencies = [
|
||||
"zeroize",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sd-desktop-macos"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"swift-rs",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sd-ffmpeg"
|
||||
version = "0.1.0"
|
||||
@ -5718,6 +5691,47 @@ dependencies = [
|
||||
"tokio",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sd-macos"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"swift-rs",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sd-mobile-android"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"jni 0.19.0",
|
||||
"sd-mobile-core",
|
||||
"tracing",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sd-mobile-core"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"futures",
|
||||
"once_cell",
|
||||
"openssl",
|
||||
"openssl-sys",
|
||||
"rspc",
|
||||
"sd-core",
|
||||
"serde_json",
|
||||
"tokio",
|
||||
"tracing",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sd-mobile-ios"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"objc",
|
||||
"objc-foundation",
|
||||
"objc_id",
|
||||
"sd-mobile-core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sd-p2p"
|
||||
version = "0.1.0"
|
||||
@ -6223,9 +6237,9 @@ dependencies = [
|
||||
"rand 0.8.5",
|
||||
"rspc",
|
||||
"sd-core",
|
||||
"sd-desktop-macos",
|
||||
"serde",
|
||||
"server",
|
||||
"swift-rs",
|
||||
"tauri",
|
||||
"tauri-build",
|
||||
"tokio",
|
||||
@ -6540,10 +6554,11 @@ checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601"
|
||||
|
||||
[[package]]
|
||||
name = "swift-rs"
|
||||
version = "0.3.0"
|
||||
source = "git+https://github.com/Brendonovich/swift-rs.git?rev=833e29ba333f1dfe303eaa21de78c4f8c5a3f2ff#833e29ba333f1dfe303eaa21de78c4f8c5a3f2ff"
|
||||
version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dc903dccb086f72f6e93a12e149d84aceda2ad4b08647e14e0330a3bfea61e2b"
|
||||
dependencies = [
|
||||
"base64 0.13.1",
|
||||
"base64 0.21.0",
|
||||
"serde",
|
||||
"serde_json",
|
||||
]
|
||||
|
||||
@ -7,7 +7,8 @@ members = [
|
||||
# "crates/p2p/tunnel/utils",
|
||||
"apps/cli",
|
||||
"apps/desktop/src-tauri",
|
||||
"apps/mobile/rust/*",
|
||||
"apps/desktop/crates/*",
|
||||
"apps/mobile/crates/*",
|
||||
"apps/server",
|
||||
]
|
||||
|
||||
@ -32,7 +33,7 @@ rspc = { version = "0.1.2" }
|
||||
specta = { version = "0.0.6" }
|
||||
httpz = { version = "0.0.3" }
|
||||
|
||||
swift-rs = { git = "https://github.com/Brendonovich/swift-rs.git", rev = "833e29ba333f1dfe303eaa21de78c4f8c5a3f2ff" }
|
||||
swift-rs = { version = "1.0" }
|
||||
|
||||
tokio = { version = "1.25.0" }
|
||||
|
||||
@ -42,4 +43,4 @@ openssl-sys = { git = "https://github.com/spacedriveapp/rust-openssl", rev = "92
|
||||
|
||||
rspc = { git = "https://github.com/oscartbeaumont/rspc", rev = "c03872c0ba29d2429e9c059dfb235cdd03e15e8c" } # TODO: Move back to crates.io when new jsonrpc executor + `tokio::spawn` in the Tauri IPC plugin + upgraded Tauri version is released
|
||||
specta = { git = "https://github.com/oscartbeaumont/rspc", rev = "c03872c0ba29d2429e9c059dfb235cdd03e15e8c" }
|
||||
httpz = { git = "https://github.com/oscartbeaumont/httpz", rev = "a5185f2ed2fdefeb2f582dce38a692a1bf76d1d6" }
|
||||
httpz = { git = "https://github.com/oscartbeaumont/httpz", rev = "a5185f2ed2fdefeb2f582dce38a692a1bf76d1d6" }
|
||||
|
||||
12
apps/desktop/crates/macos/Cargo.toml
Normal file
12
apps/desktop/crates/macos/Cargo.toml
Normal file
@ -0,0 +1,12 @@
|
||||
[package]
|
||||
name = "sd-desktop-macos"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
swift-rs.workspace = true
|
||||
|
||||
[build-dependencies]
|
||||
swift-rs = { workspace = true, features = ["build"] }
|
||||
@ -6,8 +6,8 @@
|
||||
"repositoryURL": "https://github.com/brendonovich/swift-rs",
|
||||
"state": {
|
||||
"branch": null,
|
||||
"revision": "c3003bc0c28a6742d3da341b61887d8e072fda0a",
|
||||
"version": null
|
||||
"revision": "e30e6f539898248ab9387b0e21b79167729144b6",
|
||||
"version": "1.0.0"
|
||||
}
|
||||
}
|
||||
]
|
||||
@ -18,7 +18,7 @@ let package = Package(
|
||||
],
|
||||
dependencies: [
|
||||
// Dependencies declare other packages that this package depends on.
|
||||
.package(url: "https://github.com/brendonovich/swift-rs", revision: "c3003bc0c28a6742d3da341b61887d8e072fda0a"),
|
||||
.package(url: "https://github.com/brendonovich/swift-rs", from: "1.0.0"),
|
||||
],
|
||||
targets: [
|
||||
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
|
||||
@ -27,7 +27,7 @@ let package = Package(
|
||||
name: "sd-desktop-macos",
|
||||
dependencies: [
|
||||
.product(name: "SwiftRs", package: "swift-rs") ],
|
||||
path: "Sources"
|
||||
path: "src-swift"
|
||||
),
|
||||
]
|
||||
)
|
||||
5
apps/desktop/crates/macos/build.rs
Normal file
5
apps/desktop/crates/macos/build.rs
Normal file
@ -0,0 +1,5 @@
|
||||
fn main() {
|
||||
swift_rs::SwiftLinker::new("10.15")
|
||||
.with_package("sd-desktop-macos", "./")
|
||||
.link();
|
||||
}
|
||||
15
apps/desktop/crates/macos/src/lib.rs
Normal file
15
apps/desktop/crates/macos/src/lib.rs
Normal file
@ -0,0 +1,15 @@
|
||||
use swift_rs::*;
|
||||
|
||||
pub type NSObject = *mut std::ffi::c_void;
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub enum AppThemeType {
|
||||
Light = 0 as Int,
|
||||
Dark = 1 as Int,
|
||||
}
|
||||
|
||||
swift!(pub fn lock_app_theme(theme_type: Int));
|
||||
swift!(pub fn blur_window_background(window: &NSObject));
|
||||
swift!(pub fn set_titlebar_style(window: &NSObject, transparent: Bool, large: Bool));
|
||||
|
||||
swift!(pub fn reload_webview(webview: &NSObject));
|
||||
@ -7,7 +7,6 @@ license = ""
|
||||
repository = "https://github.com/spacedriveapp/spacedrive"
|
||||
default-run = "spacedrive"
|
||||
edition = "2021"
|
||||
build = "build.rs"
|
||||
|
||||
[dependencies]
|
||||
tauri = { version = "1.2.4", features = ["api-all", "linux-protocol-headers", "macos-private-api"] }
|
||||
@ -28,14 +27,11 @@ rand = "0.8.5"
|
||||
url = "2.1.1"
|
||||
|
||||
[target.'cfg(target_os = "macos")'.dependencies]
|
||||
swift-rs.workspace = true
|
||||
sd-desktop-macos.path = "../crates/macos"
|
||||
|
||||
[build-dependencies]
|
||||
tauri-build = { version = "1.1.1", features = [] }
|
||||
|
||||
[target.'cfg(target_os = "macos")'.build-dependencies]
|
||||
swift-rs = { workspace = true, features = ["build"] }
|
||||
|
||||
[features]
|
||||
default = ["custom-protocol"]
|
||||
custom-protocol = ["tauri/custom-protocol"]
|
||||
|
||||
@ -1,11 +1,3 @@
|
||||
fn main() {
|
||||
#[cfg(target_os = "macos")]
|
||||
{
|
||||
use swift_rs::build::{link_swift, link_swift_package};
|
||||
|
||||
link_swift("10.15"); // macOS Catalina. Earliest version that is officially supported by Apple.
|
||||
link_swift_package("sd-desktop-macos", "./native/macos/");
|
||||
}
|
||||
|
||||
tauri_build::build();
|
||||
}
|
||||
|
||||
@ -1,9 +0,0 @@
|
||||
.DS_Store
|
||||
/.build
|
||||
/Packages
|
||||
/*.xcodeproj
|
||||
xcuserdata/
|
||||
DerivedData/
|
||||
.swiftpm/config/registries.json
|
||||
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
|
||||
.netrc
|
||||
@ -1,7 +0,0 @@
|
||||
mod native;
|
||||
|
||||
mod window;
|
||||
pub use window::*;
|
||||
|
||||
mod webview;
|
||||
pub use webview::*;
|
||||
@ -1,3 +0,0 @@
|
||||
use std::ffi::c_void;
|
||||
|
||||
pub type NSObject = *mut c_void;
|
||||
@ -1,5 +0,0 @@
|
||||
use super::native::NSObject;
|
||||
|
||||
extern "C" {
|
||||
pub fn reload_webview(webview: &NSObject);
|
||||
}
|
||||
@ -1,15 +0,0 @@
|
||||
use super::native::NSObject;
|
||||
use swift_rs::*;
|
||||
|
||||
#[allow(unused)]
|
||||
extern "C" {
|
||||
pub fn lock_app_theme(theme_type: Int);
|
||||
pub fn blur_window_background(window: &NSObject);
|
||||
pub fn set_titlebar_style(window: &NSObject, transparent: Bool, large: Bool);
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub enum AppThemeType {
|
||||
Light = 0 as Int,
|
||||
Dark = 1 as Int,
|
||||
}
|
||||
@ -11,9 +11,6 @@ use tauri::{api::path, async_runtime::block_on, plugin::TauriPlugin, Manager, Ru
|
||||
use tokio::{task::block_in_place, time::sleep};
|
||||
use tracing::{debug, error};
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
mod macos;
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
mod app_linux;
|
||||
|
||||
@ -92,7 +89,7 @@ async fn main() -> tauri::Result<()> {
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
{
|
||||
use macos::*;
|
||||
use sd_desktop_macos::*;
|
||||
|
||||
let window = window.ns_window().unwrap();
|
||||
|
||||
|
||||
@ -108,9 +108,7 @@ pub(crate) fn handle_menu_event(event: WindowMenuEvent<Wry>) {
|
||||
event
|
||||
.window()
|
||||
.with_webview(|webview| {
|
||||
use crate::macos::reload_webview;
|
||||
|
||||
unsafe { reload_webview(&(webview.inner() as _)) };
|
||||
unsafe { sd_desktop_macos::reload_webview(&(webview.inner() as _)) };
|
||||
})
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
@ -6,8 +6,8 @@ import org.apache.tools.ant.taskdefs.condition.Os
|
||||
apply plugin: 'org.mozilla.rust-android-gradle.rust-android'
|
||||
|
||||
cargo {
|
||||
module = "../../rust/android"
|
||||
libname = "sd_core_android"
|
||||
module = "../../crates/android"
|
||||
libname = "sd_mobile_android"
|
||||
pythonCommand = 'python3'
|
||||
profile = 'release'
|
||||
targets = ["arm", "arm64", "x86", "x86_64"]
|
||||
|
||||
@ -28,7 +28,7 @@ public class SDCore extends ReactContextBaseJavaModule {
|
||||
}
|
||||
|
||||
static {
|
||||
System.loadLibrary("sd_core_android");
|
||||
System.loadLibrary("sd_mobile_android");
|
||||
}
|
||||
|
||||
// is exposed by Rust and is used to register the subscription
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
[package]
|
||||
name = "sd-core-android"
|
||||
name = "sd-mobile-android"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
rust-version = "1.64.0"
|
||||
@ -13,7 +13,7 @@ crate-type = ["cdylib"]
|
||||
jni = "0.19.0"
|
||||
|
||||
# Core mobile handling stuff
|
||||
sd-core-mobile = { path = "../mobile", features = ["android"] }
|
||||
sd-mobile-core = { path = "../core", features = ["android"] }
|
||||
|
||||
# Other
|
||||
tracing = "0.1.37"
|
||||
@ -5,7 +5,7 @@ use jni::{
|
||||
JNIEnv,
|
||||
};
|
||||
|
||||
use sd_core_mobile::*;
|
||||
use sd_mobile_core::*;
|
||||
|
||||
use tracing::error;
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
[package]
|
||||
name = "sd-core-mobile"
|
||||
name = "sd-mobile-core"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
rust-version = "1.64.0"
|
||||
@ -1,5 +1,5 @@
|
||||
[package]
|
||||
name = "sd-core-ios"
|
||||
name = "sd-mobile-ios"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
@ -11,13 +11,12 @@ rust-version = "1.64.0"
|
||||
# which are only available when linking against the app's ObjC
|
||||
crate-type = ["staticlib"]
|
||||
|
||||
[dependencies]
|
||||
# Core mobile handling stuff
|
||||
sd-mobile-core = { path = "../core" }
|
||||
|
||||
[target.'cfg(target_os = "ios")'.dependencies]
|
||||
# FFI
|
||||
objc = "0.2.7"
|
||||
objc_id = "0.1.1"
|
||||
objc-foundation = "0.1.1"
|
||||
|
||||
[dependencies]
|
||||
# Core mobile handling stuff
|
||||
sd-core-mobile = { path = "../mobile" }
|
||||
@ -10,7 +10,7 @@ use objc::{msg_send, runtime::Object, sel, sel_impl};
|
||||
use objc_foundation::{INSString, NSString};
|
||||
use objc_id::Id;
|
||||
|
||||
use sd_core_mobile::*;
|
||||
use sd_mobile_core::*;
|
||||
|
||||
extern "C" {
|
||||
fn get_data_directory() -> *const c_char;
|
||||
@ -420,13 +420,13 @@
|
||||
"$(inherited)",
|
||||
"-ObjC",
|
||||
"-lc++",
|
||||
"-lsd_core_ios-ios",
|
||||
"-lsd_mobile_ios-ios",
|
||||
);
|
||||
"OTHER_LDFLAGS[sdk=iphonesimulator*]" = (
|
||||
"$(inherited)",
|
||||
"-ObjC",
|
||||
"-lc++",
|
||||
"-lsd_core_ios-iossim",
|
||||
"-lsd_mobile_ios-iossim",
|
||||
);
|
||||
OTHER_SWIFT_FLAGS = "$(inherited) -D EXPO_CONFIGURATION_DEBUG";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.spacedrive.app;
|
||||
@ -515,13 +515,13 @@
|
||||
"$(inherited)",
|
||||
"-ObjC",
|
||||
"-lc++",
|
||||
"-lsd_core_ios-ios",
|
||||
"-lsd_mobile_ios-ios",
|
||||
);
|
||||
"OTHER_LDFLAGS[sdk=iphonesimulator*]" = (
|
||||
"$(inherited)",
|
||||
"-ObjC",
|
||||
"-lc++",
|
||||
"-lsd_core_ios-iossim",
|
||||
"-lsd_mobile_ios-iossim",
|
||||
);
|
||||
OTHER_SWIFT_FLAGS = "$(inherited) -D EXPO_CONFIGURATION_RELEASE";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.spacedrive.app;
|
||||
|
||||
@ -11,9 +11,9 @@ fi
|
||||
|
||||
if [[ $PLATFORM_NAME = "iphonesimulator" ]]
|
||||
then
|
||||
cargo build -p sd-core-ios --target aarch64-apple-ios-sim
|
||||
lipo -create -output $TARGET_DIRECTORY/libsd_core_ios-iossim.a $TARGET_DIRECTORY/aarch64-apple-ios-sim/debug/libsd_core_ios.a
|
||||
cargo build -p sd-mobile-ios --target aarch64-apple-ios-sim
|
||||
lipo -create -output $TARGET_DIRECTORY/libsd_mobile_ios-iossim.a $TARGET_DIRECTORY/aarch64-apple-ios-sim/debug/libsd_mobile_ios.a
|
||||
else
|
||||
cargo build -p sd-core-ios --target aarch64-apple-ios
|
||||
lipo -create -output $TARGET_DIRECTORY/libsd_core_ios-ios.a $TARGET_DIRECTORY/aarch64-apple-ios/debug/libsd_core_ios.a
|
||||
cargo build -p sd-mobile-ios --target aarch64-apple-ios
|
||||
lipo -create -output $TARGET_DIRECTORY/libsd_mobile_ios-ios.a $TARGET_DIRECTORY/aarch64-apple-ios/debug/libsd_mobile_ios.a
|
||||
fi
|
||||
|
||||
12
crates/macos/Cargo.toml
Normal file
12
crates/macos/Cargo.toml
Normal file
@ -0,0 +1,12 @@
|
||||
[package]
|
||||
name = "sd-macos"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
swift-rs.workspace = true
|
||||
|
||||
[build-dependencies]
|
||||
swift-rs = { workspace = true, features = ["build"] }
|
||||
@ -3,11 +3,11 @@
|
||||
"pins": [
|
||||
{
|
||||
"package": "SwiftRs",
|
||||
"repositoryURL": "https://github.com/Brendonovich/swift-rs",
|
||||
"repositoryURL": "https://github.com/brendonovich/swift-rs",
|
||||
"state": {
|
||||
"branch": null,
|
||||
"revision": "e47a9e8186f6e25be6fae40d3cc3c272abea63a2",
|
||||
"version": "0.3.0"
|
||||
"revision": "e30e6f539898248ab9387b0e21b79167729144b6",
|
||||
"version": "1.0.0"
|
||||
}
|
||||
}
|
||||
]
|
||||
@ -4,28 +4,28 @@
|
||||
import PackageDescription
|
||||
|
||||
let package = Package(
|
||||
name: "swift-lib",
|
||||
name: "sd-macos",
|
||||
platforms: [
|
||||
.macOS(.v11),
|
||||
],
|
||||
products: [
|
||||
// Products define the executables and libraries a package produces, and make them visible to other packages.
|
||||
.library(
|
||||
name: "swift-lib",
|
||||
name: "sd-macos",
|
||||
type: .static,
|
||||
targets: ["swift-lib"]),
|
||||
targets: ["sd-macos"]),
|
||||
],
|
||||
dependencies: [
|
||||
// Dependencies declare other packages that this package depends on.
|
||||
// .package(url: /* package url */, from: "1.0.0"),
|
||||
.package(url: "https://github.com/brendonovich/swift-rs", revision: "c3003bc0c28a6742d3da341b61887d8e072fda0a"),
|
||||
.package(url: "https://github.com/brendonovich/swift-rs", from: "1.0.0"),
|
||||
],
|
||||
targets: [
|
||||
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
|
||||
// Targets can depend on other targets in this package, and on products in packages this package depends on.
|
||||
.target(
|
||||
name: "swift-lib",
|
||||
dependencies: [.product(name: "SwiftRs", package: "SwiftRs")],
|
||||
path: "Sources")
|
||||
name: "sd-macos",
|
||||
dependencies: [.product(name: "SwiftRs", package: "swift-rs")],
|
||||
path: "src-swift")
|
||||
]
|
||||
)
|
||||
7
crates/macos/build.rs
Normal file
7
crates/macos/build.rs
Normal file
@ -0,0 +1,7 @@
|
||||
use swift_rs::SwiftLinker;
|
||||
|
||||
fn main() {
|
||||
SwiftLinker::new("10.15")
|
||||
.with_package("sd-macos", "./")
|
||||
.link()
|
||||
}
|
||||
@ -3,8 +3,8 @@ import AppKit
|
||||
import SwiftRs
|
||||
|
||||
@_cdecl("get_file_thumbnail_base64")
|
||||
public func getFileThumbnailBase64(path: UnsafePointer<SRString>) -> SRString {
|
||||
let path = path.to_string();
|
||||
public func getFileThumbnailBase64(path: SRString) -> SRString {
|
||||
let path = path.toString();
|
||||
|
||||
let image = NSWorkspace.shared.icon(forFile: path)
|
||||
let bitmap = NSBitmapImageRep(data: image.tiffRepresentation!)!.representation(using: .png, properties: [:])!
|
||||
@ -13,6 +13,14 @@ public func getFileThumbnailBase64(path: UnsafePointer<SRString>) -> SRString {
|
||||
}
|
||||
|
||||
class Volume: NSObject {
|
||||
var name: SRString
|
||||
var path: SRString
|
||||
var total_capacity: Int
|
||||
var available_capacity: Int
|
||||
var is_removable: Bool
|
||||
var is_ejectable: Bool
|
||||
var is_root_filesystem: Bool
|
||||
|
||||
internal init(name: String, path: String, total_capacity: Int, available_capacity: Int, is_removable: Bool, is_ejectable: Bool, is_root_filesystem: Bool) {
|
||||
self.name = SRString(name)
|
||||
self.path = SRString(path)
|
||||
@ -22,14 +30,6 @@ class Volume: NSObject {
|
||||
self.is_ejectable = is_ejectable
|
||||
self.is_root_filesystem = is_root_filesystem
|
||||
}
|
||||
|
||||
var name: SRString
|
||||
var path: SRString
|
||||
var total_capacity: Int
|
||||
var available_capacity: Int
|
||||
var is_removable: Bool
|
||||
var is_ejectable: Bool
|
||||
var is_root_filesystem: Bool
|
||||
}
|
||||
|
||||
@_cdecl("get_mounts")
|
||||
@ -69,8 +69,5 @@ public func getMounts() -> SRObjectArray {
|
||||
}
|
||||
}
|
||||
|
||||
return toRust(SRObjectArray(validMounts))
|
||||
return SRObjectArray(validMounts)
|
||||
}
|
||||
|
||||
|
||||
|
||||
15
crates/macos/src/lib.rs
Normal file
15
crates/macos/src/lib.rs
Normal file
@ -0,0 +1,15 @@
|
||||
use swift_rs::*;
|
||||
|
||||
#[repr(C)]
|
||||
pub struct Volume {
|
||||
name: SRString,
|
||||
path: SRString,
|
||||
total_capacity: Int,
|
||||
available_capacity: Int,
|
||||
is_removable: Bool,
|
||||
is_ejectable: Bool,
|
||||
is_root_filesystem: Bool,
|
||||
}
|
||||
|
||||
swift!(pub fn get_file_thumbnail_base64(name: &SRString) -> SRString);
|
||||
swift!(pub fn get_mounts() -> SRObjectArray<Volume>);
|
||||
7
packages/macos/.gitignore
vendored
7
packages/macos/.gitignore
vendored
@ -1,7 +0,0 @@
|
||||
.DS_Store
|
||||
/.build
|
||||
/Packages
|
||||
/*.xcodeproj
|
||||
xcuserdata/
|
||||
DerivedData/
|
||||
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
|
||||
@ -1,67 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "1300"
|
||||
version = "1.3">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
buildImplicitDependencies = "YES">
|
||||
<BuildActionEntries>
|
||||
<BuildActionEntry
|
||||
buildForTesting = "YES"
|
||||
buildForRunning = "YES"
|
||||
buildForProfiling = "YES"
|
||||
buildForArchiving = "YES"
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "swift-lib"
|
||||
BuildableName = "swift-lib"
|
||||
BlueprintName = "swift-lib"
|
||||
ReferencedContainer = "container:">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
</BuildActionEntries>
|
||||
</BuildAction>
|
||||
<TestAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES">
|
||||
<Testables>
|
||||
</Testables>
|
||||
</TestAction>
|
||||
<LaunchAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
launchStyle = "0"
|
||||
useCustomWorkingDirectory = "NO"
|
||||
ignoresPersistentStateOnLaunch = "NO"
|
||||
debugDocumentVersioning = "YES"
|
||||
debugServiceExtension = "internal"
|
||||
allowLocationSimulation = "YES">
|
||||
</LaunchAction>
|
||||
<ProfileAction
|
||||
buildConfiguration = "Release"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
savedToolIdentifier = ""
|
||||
useCustomWorkingDirectory = "NO"
|
||||
debugDocumentVersioning = "YES">
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "swift-lib"
|
||||
BuildableName = "swift-lib"
|
||||
BlueprintName = "swift-lib"
|
||||
ReferencedContainer = "container:">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
</ProfileAction>
|
||||
<AnalyzeAction
|
||||
buildConfiguration = "Debug">
|
||||
</AnalyzeAction>
|
||||
<ArchiveAction
|
||||
buildConfiguration = "Release"
|
||||
revealArchiveInOrganizer = "YES">
|
||||
</ArchiveAction>
|
||||
</Scheme>
|
||||
@ -1,18 +0,0 @@
|
||||
{
|
||||
"configurations" : [
|
||||
{
|
||||
"id" : "217668D6-0AB1-4124-9035-478908965985",
|
||||
"name" : "Configuration 1",
|
||||
"options" : {
|
||||
|
||||
}
|
||||
}
|
||||
],
|
||||
"defaultOptions" : {
|
||||
"testTimeoutsEnabled" : true
|
||||
},
|
||||
"testTargets" : [
|
||||
|
||||
],
|
||||
"version" : 1
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user