From a17c8bad641d1686c13d7bd22fe31a6382cc1b16 Mon Sep 17 00:00:00 2001 From: John Smith Date: Sat, 29 Jan 2022 23:23:50 -0500 Subject: [PATCH] macos work --- Cargo.lock | 8 ++++---- veilid-flutter/lib/bridge_generated.dart | 12 ++++++------ veilid-flutter/rust/build.rs | 2 +- veilid-flutter/rust/ios_build.sh | 6 +++--- veilid-flutter/rust/macos_build.sh | 7 ++++--- veilid-flutter/rust/src/bridge_generated.rs | 18 ------------------ veilid-flutter/setup_flutter.sh | 15 +++++++++++++-- 7 files changed, 31 insertions(+), 37 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 61d617ee..c089b224 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3216,9 +3216,9 @@ dependencies = [ [[package]] name = "security-framework" -version = "2.5.0" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d09d3c15d814eda1d6a836f2f2b56a6abc1446c8a34351cb3180d3db92ffe4ce" +checksum = "3fed7948b6c68acbb6e20c334f55ad635dc0f75506963de4464289fbd3b051ac" dependencies = [ "bitflags", "core-foundation 0.9.2", @@ -3229,9 +3229,9 @@ dependencies = [ [[package]] name = "security-framework-sys" -version = "2.5.0" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e90dd10c41c6bfc633da6e0c659bd25d31e0791e5974ac42970267d59eba87f7" +checksum = "a57321bf8bc2362081b2599912d2961fe899c0efadf1b4b2f8d48b3e253bb96c" dependencies = [ "core-foundation-sys 0.8.3", "libc", diff --git a/veilid-flutter/lib/bridge_generated.dart b/veilid-flutter/lib/bridge_generated.dart index 12f5c309..44aacaa7 100644 --- a/veilid-flutter/lib/bridge_generated.dart +++ b/veilid-flutter/lib/bridge_generated.dart @@ -213,8 +213,8 @@ class VeilidFlutterImpl extends FlutterRustBridgeBase Stream startupVeilidCore( {required VeilidConfig config, dynamic hint}) => executeStream(FlutterRustBridgeTask( - callFfi: (port) => inner.wire_startup_veilid_core( - port, _api2wire_box_autoadd_veilid_config(config)), + callFfi: (port_) => inner.wire_startup_veilid_core( + port_, _api2wire_box_autoadd_veilid_config(config)), parseSuccessData: _wire2api_veilid_update, constMeta: const FlutterRustBridgeTaskConstMeta( debugName: "startup_veilid_core", @@ -226,7 +226,7 @@ class VeilidFlutterImpl extends FlutterRustBridgeBase Future getVeilidState({dynamic hint}) => executeNormal(FlutterRustBridgeTask( - callFfi: (port) => inner.wire_get_veilid_state(port), + callFfi: (port_) => inner.wire_get_veilid_state(port_), parseSuccessData: _wire2api_veilid_state, constMeta: const FlutterRustBridgeTaskConstMeta( debugName: "get_veilid_state", @@ -238,7 +238,7 @@ class VeilidFlutterImpl extends FlutterRustBridgeBase Future shutdownVeilidCore({dynamic hint}) => executeNormal(FlutterRustBridgeTask( - callFfi: (port) => inner.wire_shutdown_veilid_core(port), + callFfi: (port_) => inner.wire_shutdown_veilid_core(port_), parseSuccessData: _wire2api_unit, constMeta: const FlutterRustBridgeTaskConstMeta( debugName: "shutdown_veilid_core", @@ -250,7 +250,7 @@ class VeilidFlutterImpl extends FlutterRustBridgeBase Future veilidVersionString({dynamic hint}) => executeNormal(FlutterRustBridgeTask( - callFfi: (port) => inner.wire_veilid_version_string(port), + callFfi: (port_) => inner.wire_veilid_version_string(port_), parseSuccessData: _wire2api_String, constMeta: const FlutterRustBridgeTaskConstMeta( debugName: "veilid_version_string", @@ -262,7 +262,7 @@ class VeilidFlutterImpl extends FlutterRustBridgeBase Future veilidVersion({dynamic hint}) => executeNormal(FlutterRustBridgeTask( - callFfi: (port) => inner.wire_veilid_version(port), + callFfi: (port_) => inner.wire_veilid_version(port_), parseSuccessData: _wire2api_veilid_version, constMeta: const FlutterRustBridgeTaskConstMeta( debugName: "veilid_version", diff --git a/veilid-flutter/rust/build.rs b/veilid-flutter/rust/build.rs index 9f5a4f8d..4bc856ab 100644 --- a/veilid-flutter/rust/build.rs +++ b/veilid-flutter/rust/build.rs @@ -31,7 +31,7 @@ fn resolve_llvm_path() -> Option { } else if #[cfg(target_os="macos")] { // build host is mac - ["/opt/homebrew/opt/llvm", "/usr/local/homebrew/opt/llvm"].iter().map(Path::new).find_map(|p| if p.exists() { Some(p.to_owned()) } else { None } ) + ["/usr/local/opt/llvm", "/opt/homebrew/opt/llvm", ].iter().map(Path::new).find_map(|p| if p.exists() { Some(p.to_owned()) } else { None } ) } else { // anywhere else, just use the default paths None diff --git a/veilid-flutter/rust/ios_build.sh b/veilid-flutter/rust/ios_build.sh index 80fd1297..eade03b7 100755 --- a/veilid-flutter/rust/ios_build.sh +++ b/veilid-flutter/rust/ios_build.sh @@ -16,7 +16,6 @@ do echo arm64 CARGO_TARGET=aarch64-apple-ios CARGO_TOOLCHAIN=+ios-arm64-1.57.0 - #CARGO_TOOLCHAIN= elif [ "$arch" == "x86_64" ]; then echo x86_64 CARGO_TARGET=x86_64-apple-ios @@ -25,8 +24,9 @@ do echo Unsupported ARCH: $arch continue fi - HOMEBREW_DIR=$(dirname `which brew`) FLUTTER_DIR=$(dirname `which flutter`) - env -i PATH=/usr/bin:/bin:/usr/local/bin:$HOMEBREW_DIR:$FLUTTER_DIR ~/.cargo/bin/cargo $CARGO_TOOLCHAIN build $EXTRA_CARGO_OPTIONS --target $CARGO_TARGET --manifest-path $CARGO_MANIFEST_PATH + HOMEBREW_DIR=$(dirname `which brew`) + CARGO_DIR=$(dirname `which cargo`) + env -i PATH=/usr/bin:/bin:/usr/local/bin:$HOMEBREW_DIR:$FLUTTER_DIR:$CARGO_DIR HOME="$HOME" USER="$USER" cargo $CARGO_TOOLCHAIN build $EXTRA_CARGO_OPTIONS --target $CARGO_TARGET --manifest-path $CARGO_MANIFEST_PATH done diff --git a/veilid-flutter/rust/macos_build.sh b/veilid-flutter/rust/macos_build.sh index 324faac4..c5e73d86 100755 --- a/veilid-flutter/rust/macos_build.sh +++ b/veilid-flutter/rust/macos_build.sh @@ -9,7 +9,7 @@ if [ "$CONFIGURATION" == "Debug" ]; then else EXTRA_CARGO_OPTIONS="$@ --release" fi -ARCHS=${ARCHS:=arm64} +ARCHS=${ARCHS:=x86_64} for arch in $ARCHS do if [ "$arch" == "arm64" ]; then @@ -24,8 +24,9 @@ do echo Unsupported ARCH: $arch continue fi - HOMEBREW_DIR=$(dirname `which brew`) FLUTTER_DIR=$(dirname `which flutter`) - env -i PATH=/usr/bin:/bin:/usr/local/bin:$HOMEBREW_DIR:$FLUTTER_DIR ~/.cargo/bin/cargo $CARGO_TOOLCHAIN build $EXTRA_CARGO_OPTIONS --target $CARGO_TARGET --manifest-path $CARGO_MANIFEST_PATH + HOMEBREW_DIR=$(dirname `which brew`) + CARGO_DIR=$(dirname `which cargo`) + env -i PATH=/usr/bin:/bin:/usr/local/bin:$HOMEBREW_DIR:$FLUTTER_DIR:$CARGO_DIR HOME="$HOME" USER="$USER" cargo $CARGO_TOOLCHAIN build $EXTRA_CARGO_OPTIONS --target $CARGO_TARGET --manifest-path $CARGO_MANIFEST_PATH done diff --git a/veilid-flutter/rust/src/bridge_generated.rs b/veilid-flutter/rust/src/bridge_generated.rs index 3fd8758d..bbb888f6 100644 --- a/veilid-flutter/rust/src/bridge_generated.rs +++ b/veilid-flutter/rust/src/bridge_generated.rs @@ -532,21 +532,3 @@ pub extern "C" fn free_WireSyncReturnStruct(val: support::WireSyncReturnStruct) let _ = support::vec_from_leak_ptr(val.ptr, val.len); } } - - // ----------- DUMMY CODE FOR BINDGEN ---------- - - // copied from: allo-isolate - pub type DartPort = i64; - pub type DartPostCObjectFnType = unsafe extern "C" fn(port_id: DartPort, message: *mut std::ffi::c_void) -> bool; - #[no_mangle] pub unsafe extern "C" fn store_dart_post_cobject(ptr: DartPostCObjectFnType) { panic!("dummy code") } - - // copied from: frb_rust::support.rs - #[repr(C)] - pub struct WireSyncReturnStruct { - pub ptr: *mut u8, - pub len: i32, - pub success: bool, - } - - // --------------------------------------------- - \ No newline at end of file diff --git a/veilid-flutter/setup_flutter.sh b/veilid-flutter/setup_flutter.sh index b8ab4610..ae41edc2 100755 --- a/veilid-flutter/setup_flutter.sh +++ b/veilid-flutter/setup_flutter.sh @@ -62,12 +62,23 @@ if [ "$OS" == "linux" ]; then flutter config --enable-linux-desktop --enable-android elif [ "$OS" == "macos" ]; then + + # ensure x86_64 homebrew is installed + if [ -f /usr/local/bin/brew ] &> /dev/null; then + echo '[X] x86_64 homebrew is available' + else + echo 'x86_64 homebrew is not available, run this:' + echo 'arch -x86_64 zsh' + echo '/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"' + exit 1 + fi + # ensure packages are installed if [ "$BREW_USER" == "" ]; then - BREW_USER=`ls -lad /opt/homebrew/. | cut -d\ -f4` + BREW_USER=`ls -lad /usr/local/bin/. | cut -d\ -f4` echo "Must sudo to homebrew user \"$BREW_USER\" to install LLVM package:" fi - sudo -H -u $BREW_USER brew install llvm + sudo -H -u $BREW_USER arch -x86_64 /usr/local/bin/brew install llvm echo "Must sudo to root to install CocoaPods gem:" sudo arch -x86_64 gem install ffi sudo arch -x86_64 gem install cocoapods