diff --git a/veilid-core/ios_build.sh b/veilid-core/ios_build.sh index a0d985e5..dad8d4b6 100755 --- a/veilid-core/ios_build.sh +++ b/veilid-core/ios_build.sh @@ -1,8 +1,8 @@ #!/bin/bash SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" - -CARGO_MANIFEST_PATH=$SCRIPTDIR/Cargo.toml +CARGO_MANIFEST_PATH=$(python -c "import os; print(os.path.realpath(\"$SCRIPTDIR/Cargo.toml\"))") +# echo CARGO_MANIFEST_PATH: $CARGO_MANIFEST_PATH if [ "$CONFIGURATION" == "Debug" ]; then EXTRA_CARGO_OPTIONS="$@" @@ -25,6 +25,8 @@ do echo Unsupported ARCH: $arch continue fi - env -i PATH=/usr/bin:/bin:/usr/local/bin:/opt/homebrew/bin ~/.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:$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/example/macos/Podfile.lock b/veilid-flutter/example/macos/Podfile.lock index e823c012..8e81c417 100644 --- a/veilid-flutter/example/macos/Podfile.lock +++ b/veilid-flutter/example/macos/Podfile.lock @@ -15,7 +15,7 @@ EXTERNAL SOURCES: SPEC CHECKSUMS: FlutterMacOS: 57701585bf7de1b3fc2bb61f6378d73bbdea8424 - veilid: 8d01491ca5ee1b58110c98f7778124c3ead89a7c + veilid: fd5957b2b4ff66a1dbeba0433afdce762d21d90c PODFILE CHECKSUM: 6eac6b3292e5142cfc23bdeb71848a40ec51c14c diff --git a/veilid-flutter/example/macos/Runner.xcodeproj/project.pbxproj b/veilid-flutter/example/macos/Runner.xcodeproj/project.pbxproj index d752c1ab..f719bbe5 100644 --- a/veilid-flutter/example/macos/Runner.xcodeproj/project.pbxproj +++ b/veilid-flutter/example/macos/Runner.xcodeproj/project.pbxproj @@ -26,6 +26,7 @@ 33CC10F32044A3C60003C045 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F22044A3C60003C045 /* Assets.xcassets */; }; 33CC10F62044A3C60003C045 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F42044A3C60003C045 /* MainMenu.xib */; }; 33CC11132044BFA00003C045 /* MainFlutterWindow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */; }; + 40BAB9F027A74B09000EC229 /* libveilid_flutter.dylib in Bundle Framework */ = {isa = PBXBuildFile; fileRef = 40BAB9EF27A74B09000EC229 /* libveilid_flutter.dylib */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; }; 8526E2FC060241577E5281A0 /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E89F2D855D7BDA4933E1A2EC /* Pods_Runner.framework */; }; /* End PBXBuildFile section */ @@ -46,6 +47,7 @@ dstPath = ""; dstSubfolderSpec = 10; files = ( + 40BAB9F027A74B09000EC229 /* libveilid_flutter.dylib in Bundle Framework */, ); name = "Bundle Framework"; runOnlyForDeploymentPostprocessing = 0; @@ -68,6 +70,7 @@ 33E51913231747F40026EE4D /* DebugProfile.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = DebugProfile.entitlements; sourceTree = ""; }; 33E51914231749380026EE4D /* Release.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.entitlements; path = Release.entitlements; sourceTree = ""; }; 33E5194F232828860026EE4D /* AppInfo.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = AppInfo.xcconfig; sourceTree = ""; }; + 40BAB9EF27A74B09000EC229 /* libveilid_flutter.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libveilid_flutter.dylib; path = ../../macos/lib/libveilid_flutter.dylib; sourceTree = ""; }; 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Release.xcconfig; sourceTree = ""; }; 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Debug.xcconfig; sourceTree = ""; }; B8606FB3C4AA619FC22C3115 /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = ""; }; @@ -101,6 +104,7 @@ 33CC10E42044A3C60003C045 = { isa = PBXGroup; children = ( + 40BAB9EF27A74B09000EC229 /* libveilid_flutter.dylib */, 33FAB671232836740065AC1E /* Runner */, 33CEB47122A05771004F2AC0 /* Flutter */, 33CC10EE2044A3C60003C045 /* Products */, @@ -159,7 +163,6 @@ 233B6A2BBF071AE96501823B /* Pods-Runner.release.xcconfig */, B8606FB3C4AA619FC22C3115 /* Pods-Runner.profile.xcconfig */, ); - name = Pods; path = Pods; sourceTree = ""; }; diff --git a/veilid-flutter/macos/.gitignore b/veilid-flutter/macos/.gitignore new file mode 100644 index 00000000..a65b4177 --- /dev/null +++ b/veilid-flutter/macos/.gitignore @@ -0,0 +1 @@ +lib diff --git a/veilid-flutter/macos/veilid.podspec b/veilid-flutter/macos/veilid.podspec index 6b277afe..a632b0a7 100644 --- a/veilid-flutter/macos/veilid.podspec +++ b/veilid-flutter/macos/veilid.podspec @@ -7,11 +7,11 @@ Pod::Spec.new do |s| s.version = '0.0.1' s.summary = 'Veilid Network' s.description = <<-DESC -Veilid Network +Veilid Network Plugin DESC - s.homepage = 'http://example.com' - s.license = { :file => '../LICENSE' } - s.author = { 'Your Company' => 'email@example.com' } + s.homepage = 'http://veilid.com' + s.license = 'LGPL-2.0-or-later OR MPL-2.0 OR (MIT AND BSD-3-Clause)' + s.author = { 'John Smith' => 'jsmith@example.com' } s.source = { :path => '.' } s.source_files = 'Classes/**/*' s.dependency 'FlutterMacOS' @@ -20,6 +20,26 @@ Veilid Network s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES' } s.swift_version = '5.0' - s.script_phase = { :name => 'Cargo Build', :script => '../rust/macos_build.sh', :execution_position => :before_compile } + s.script_phase = { + :name => 'Cargo Build', + :script => File.join(File.dirname(__dir__), 'rust', 'macos_build.sh'), + :execution_position => :before_compile, + :output_files => [ File.join(File.dirname(__dir__), 'lib', 'libveilid_flutter.dylib') ] + } + + # s.prepare_command = <<-CMD + # mkdir -p lib/Release/ + # cp /dev/null lib/Release/libveilid_flutter.dylib + # CMD + + # require 'json' + # require 'pathname' + # rust_dylib_absolute = File.join(File.dirname(JSON.parse(`cargo locate-project`)['root']), 'target', 'x86_64-apple-darwin', 'release', 'libveilid_flutter.dylib') + # rust_dylib_relative = Pathname.new(rust_dylib_absolute).relative_path_from(Pathname.new(Dir.pwd)).to_s + # require 'pp' + # print 'Rust dylib: ' + # pp rust_dylib_relative + # s.vendored_libraries = 'lib/Release/libveilid_flutter.dylib' + # s.libraries = [ 'veilid_flutter' ] end diff --git a/veilid-flutter/rust/ios_build.sh b/veilid-flutter/rust/ios_build.sh index eade03b7..6e5439a4 100755 --- a/veilid-flutter/rust/ios_build.sh +++ b/veilid-flutter/rust/ios_build.sh @@ -1,8 +1,8 @@ #!/bin/bash SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" - -CARGO_MANIFEST_PATH=$SCRIPTDIR/Cargo.toml +CARGO_MANIFEST_PATH=$(python -c "import os; print(os.path.realpath(\"$SCRIPTDIR/Cargo.toml\"))") +# echo CARGO_MANIFEST_PATH: $CARGO_MANIFEST_PATH if [ "$CONFIGURATION" == "Debug" ]; then EXTRA_CARGO_OPTIONS="$@" diff --git a/veilid-flutter/rust/macos_build.sh b/veilid-flutter/rust/macos_build.sh index c5e73d86..11efd509 100755 --- a/veilid-flutter/rust/macos_build.sh +++ b/veilid-flutter/rust/macos_build.sh @@ -1,15 +1,19 @@ #!/bin/bash SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" - -CARGO_MANIFEST_PATH=$SCRIPTDIR/Cargo.toml +CARGO_MANIFEST_PATH=$(python -c "import os; print(os.path.realpath(\"$SCRIPTDIR/Cargo.toml\"))") +TARGET_DIR=$(dirname `cargo locate-project --message-format plain`)/target +# echo CARGO_MANIFEST_PATH: $CARGO_MANIFEST_PATH if [ "$CONFIGURATION" == "Debug" ]; then EXTRA_CARGO_OPTIONS="$@" + RUST_CONFIGURATION="debug" else EXTRA_CARGO_OPTIONS="$@ --release" + RUST_CONFIGURATION="release" fi ARCHS=${ARCHS:=x86_64} +echo ARCHS: $ARCHS for arch in $ARCHS do if [ "$arch" == "arm64" ]; then @@ -28,5 +32,11 @@ do 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 + # xxx add to lipo list? done +OUTPUT_DIR=$SCRIPTDIR/../macos/lib +mkdir -p $OUTPUT_DIR +# xxx use lipo library? +cp $TARGET_DIR/x86_64-apple-darwin/$RUST_CONFIGURATION/libveilid_flutter.dylib $OUTPUT_DIR +