From e796f74d3d4da55b9dae3472595b8f4028f7dda4 Mon Sep 17 00:00:00 2001 From: Hanh Date: Sat, 17 Dec 2022 15:01:28 +0800 Subject: [PATCH] Universal MacOS build --- .github/workflows/build-mac.yml | 18 +++++++---- Makefile.toml | 45 ++++++++++++++++++++++++++ macos/Runner.xcodeproj/project.pbxproj | 14 ++++---- 3 files changed, 63 insertions(+), 14 deletions(-) diff --git a/.github/workflows/build-mac.yml b/.github/workflows/build-mac.yml index 74eb286..773c6f8 100644 --- a/.github/workflows/build-mac.yml +++ b/.github/workflows/build-mac.yml @@ -1,4 +1,4 @@ -name: Build and Release MacOS +name: Build and Release MacOS Universal on: workflow_dispatch: @@ -20,10 +20,14 @@ jobs: curl https://download.z.cash/downloads/sapling-output.params --output $HOME/.zcash-params/sapling-output.params curl https://download.z.cash/downloads/sapling-spend.params --output $HOME/.zcash-params/sapling-spend.params - - name: Build dylib - run: | - cargo install cargo-make - cargo make flatpak + - name: rustup + run: rustup target add aarch64-apple-darwin + + - name: install make + run: cargo install cargo-make + + - name: build lib + run: cargo make macos - name: wget flutter run: | @@ -41,11 +45,11 @@ jobs: - name: Build DMG run: | npm install -g appdmg - (cd misc;appdmg app.json ../ywallet.dmg) + (cd misc;appdmg app.json ../ywallet-universal.dmg) - name: Release uses: softprops/action-gh-release@v1 if: startsWith(github.ref, 'refs/tags/v') with: files: | - ./ywallet.dmg + ./ywallet-universal.dmg diff --git a/Makefile.toml b/Makefile.toml index f2220b6..5eb33d2 100644 --- a/Makefile.toml +++ b/Makefile.toml @@ -297,9 +297,54 @@ args = [ "--features=dart_ffi" ] +[tasks.mac-build-release] +private = true +command = "cargo" +args = [ + "build", + "--target=x86_64-apple-darwin", + "--release", + "--features=dart_ffi" +] + +[tasks.m1-build-release] +private = true +command = "cargo" +args = [ + "build", + "--target=aarch64-apple-darwin", + "--release", + "--features=dart_ffi" +] + [tasks.flatpak] dependencies = [ "setup-crate-type-android", "desktop-build-release", "restore-crate-type" ] + +[tasks.macos] +dependencies = [ + "setup-crate-type-android", + "mac-build-release", + "m1-build-release", + "restore-crate-type", + "post-macos" +] + +[tasks.post-macos] +script_runner = "@duckscript" +condition = { platforms = ["mac"] } +script = [ + "mkdir ${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/target/universal/release", + """ + exec /usr/bin/lipo ${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/target/x86_64-apple-darwin/release/libwarp_api_ffi.dylib \ + ${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/target/aarch64-apple-darwin/release/libwarp_api_ffi.dylib \ + -output ${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/target/universal/release/libwarp_api_ffi.dylib -create + """, + """ + cp ${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/native/${CARGO_MAKE_CRATE_CURRENT_WORKSPACE_MEMBER}/binding.h \ + ${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/packages/warp_api_ffi/ios/Classes/binding.h + """, +] diff --git a/macos/Runner.xcodeproj/project.pbxproj b/macos/Runner.xcodeproj/project.pbxproj index f02663d..d2894f9 100644 --- a/macos/Runner.xcodeproj/project.pbxproj +++ b/macos/Runner.xcodeproj/project.pbxproj @@ -71,7 +71,7 @@ 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 = ""; }; 3ABAA4F74E9B840322C571A2 /* 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 = ""; }; - 3B7C926528AE6FF000777DAD /* libwarp_api_ffi.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libwarp_api_ffi.dylib; path = ../target/release/libwarp_api_ffi.dylib; sourceTree = ""; }; + 3B7C926528AE6FF000777DAD /* libwarp_api_ffi.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libwarp_api_ffi.dylib; path = ../target/universal/release/libwarp_api_ffi.dylib; sourceTree = ""; }; 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Release.xcconfig; sourceTree = ""; }; 8D0D09BA27FFDEBE0DB78C1C /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Debug.xcconfig; sourceTree = ""; }; @@ -424,13 +424,13 @@ CODE_SIGN_ENTITLEMENTS = Runner/DebugProfile.entitlements; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 300; + CURRENT_PROJECT_VERSION = 327; INFOPLIST_FILE = Runner/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/../Frameworks", ); - MARKETING_VERSION = 1.2.16; + MARKETING_VERSION = 1.2.17; PRODUCT_BUNDLE_IDENTIFIER = me.hanh.ywallet; PROVISIONING_PROFILE_SPECIFIER = ""; STRIP_STYLE = "non-global"; @@ -554,13 +554,13 @@ CODE_SIGN_ENTITLEMENTS = Runner/DebugProfile.entitlements; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 300; + CURRENT_PROJECT_VERSION = 327; INFOPLIST_FILE = Runner/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/../Frameworks", ); - MARKETING_VERSION = 1.2.16; + MARKETING_VERSION = 1.2.17; PRODUCT_BUNDLE_IDENTIFIER = me.hanh.ywallet; PROVISIONING_PROFILE_SPECIFIER = ""; STRIP_STYLE = "non-global"; @@ -578,13 +578,13 @@ CODE_SIGN_ENTITLEMENTS = Runner/Release.entitlements; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 300; + CURRENT_PROJECT_VERSION = 327; INFOPLIST_FILE = Runner/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/../Frameworks", ); - MARKETING_VERSION = 1.2.16; + MARKETING_VERSION = 1.2.17; PRODUCT_BUNDLE_IDENTIFIER = me.hanh.ywallet; PROVISIONING_PROFILE_SPECIFIER = ""; STRIP_STYLE = "non-global";