Compare commits

...

1 Commits

Author SHA1 Message Date
Hao Guan
c6c75dea26 feat: App for macOS 2022-10-13 23:29:46 +10:00
8 changed files with 156 additions and 11 deletions

View File

@@ -71,5 +71,35 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/upload-artifact@v1
with:
name: artifacts
name: MaaBundle-x64-Windows
path: artifacts
macos-latest:
name: macos-latest
runs-on: macos-12
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
- name: Cache Homebrew
uses: actions/cache@v3
with:
path: $(brew --prefix)
key: ${{ runner.os }}-homebrew-${{ hashFiles('.config/brew/Brewfile') }}
- name: Install Dependencies
run: |
brew update --preinstall
brew install ninja range-v3
- name: Configure MeoAssistant
run: |
mkdir build && cd build
cmake .. -GNinja -DBUILD_XCFRAMEWORK=ON -DBUILD_UNIVERSAL=ON
- name: Build libMeoAssistant
run: cmake --build build
- name: Build MeoAsstMac
working-directory: src/MeoAsstMac
run: xcodebuild ARCHS="arm64 x86_64" CODE_SIGN_IDENTITY="-" DEVELOPMENT_TEAM="-" ONLY_ACTIVE_ARCH=NO -derivedDataPath DerivedData -project MeoAsstMac.xcodeproj -scheme MeoAsstMac
- uses: actions/upload-artifact@v1
with:
name: MaaBundle-darwin
path: src/MeoAsstMac/DerivedData/Build/Products/Debug

View File

@@ -41,5 +41,82 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/upload-artifact@v1
with:
name: artifacts
name: MaaBundle-x64-Windows
path: artifacts
macos-latest:
name: macos-latest
runs-on: macos-12
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
- name: 'Install Developer ID Certificate'
uses: apple-actions/import-codesign-certs@v1
with:
p12-file-base64: ${{ secrets.HGUANDL_SIGN_CERT_P12 }}
p12-password: ${{ secrets.HGUANDL_SIGN_CERT_PASSWD }}
- name: Cache Homebrew
uses: actions/cache@v3
with:
path: $(brew --prefix)
key: ${{ runner.os }}-homebrew-${{ hashFiles('.config/brew/Brewfile') }}
- name: Install Dependencies
run: |
brew update --preinstall
brew install ninja range-v3 create-dmg
- name: Configure MeoAssistant
run: |
mkdir build && cd build
cmake .. -GNinja -DCMAKE_BUILD_TYPE=Release -DBUILD_XCFRAMEWORK=ON -DBUILD_UNIVERSAL=ON
- name: Build libMeoAssistant
run: cmake --build build
- name: Build MeoAsstMac
working-directory: src/MeoAsstMac
run: xcodebuild -project MeoAsstMac.xcodeproj -scheme MeoAsstMac archive -archivePath MeoAsstMac.xcarchive -configuration Release
- name: Export MeoAsstMac
working-directory: src/MeoAsstMac
run: xcodebuild -exportArchive -archivePath MeoAsstMac.xcarchive -exportOptionsPlist ExportOptions.plist -exportPath Export
- name: Create disk image
working-directory: src/MeoAsstMac
run: create-dmg --background dmg-bkg.png --window-size 500 300 --icon-size 128 --icon MeoAsstMac.app 0 120 --hide-extension MeoAsstMac.app --app-drop-link 270 120 MeoAsstMac.dmg Export/MeoAsstMac.app
- name: Upload disk image
uses: actions/upload-artifact@v1
with:
name: MaaBundle-darwin
path: src/MeoAsstMac/MeoAsstMac.dmg
macos-release:
name: macos-release
runs-on: macos-12
needs: [windows-latest, macos-latest]
steps:
- name: 'Setup tag information'
run: |
GIT_TAG=${GITHUB_REF#refs/*/}
echo "GIT_TAG=${GIT_TAG}" >> $GITHUB_ENV
echo "APP_DMG=MaaBundle-darwin-${GIT_TAG}.dmg" >> $GITHUB_ENV
- name: Download artifacts
uses: actions/download-artifact@v3
with:
name: MaaBundle-darwin
- name: 'Verify image'
run: |
mv MeoAsstMac.dmg $APP_DMG
hdiutil verify $APP_DMG
- name: 'Notarize image'
env:
NOTARY_USER: ${{ secrets.HGUANDL_NOTARY_AAPL_ID }}
NOTARY_PASSWD: ${{ secrets.HGUANDL_NOTARY_PASSWD }}
NOTARY_TEAM: ${{ secrets.HGUANDL_SIGN_IDENTITY }}
run: |
xcrun notarytool submit --apple-id "$NOTARY_USER" --password "$NOTARY_PASSWD" --team-id "$NOTARY_TEAM" --wait $APP_DMG
xcrun stapler staple $APP_DMG
- name: Upload image to release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: '${{ github.workspace }}/${{ env.APP_DMG }}'
file_glob: false
tag: ${{ env.GIT_TAG }}
overwrite: true

5
.gitmodules vendored
View File

@@ -3,4 +3,7 @@
url = https://github.com/MaaAssistantArknights/MaaTestSet.git
[submodule "3rdparty/VisionOCR"]
path = 3rdparty/VisionOCR
url = https://github.com/hguandl/VisionOCR.git
url = https://github.com/MaaAssistantArknights/VisionOCR.git
[submodule "src/MeoAsstMac"]
path = src/MeoAsstMac
url = https://github.com/MaaAssistantArknights/MeoAsstMac.git

View File

@@ -6,6 +6,12 @@ if (NOT CMAKE_BUILD_TYPE)
endif ()
option(BUILD_TEST "build a demo" OFF)
option(BUILD_XCFRAMEWORK "build xcframework for macOS app" OFF)
option(BUILD_UNIVERSAL "build both arm64 and x86_64 on macOS" OFF)
if (BUILD_UNIVERSAL)
set(CMAKE_OSX_ARCHITECTURES "arm64;x86_64")
endif ()
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
@@ -42,10 +48,6 @@ if (MSVC)
target_link_libraries(MeoAssistant ws2_32 ${OpenCV} ${PaddleOCR_LIB} ${ZLIB})
target_include_directories(MeoAssistant PRIVATE 3rdparty/include)
else ()
find_package(OpenCV REQUIRED)
target_include_directories(MeoAssistant PRIVATE ${OpenCV_INCLUDE_DIRS})
target_link_libraries(MeoAssistant ${OpenCV_LIBS})
find_package(ZLIB REQUIRED)
target_include_directories(MeoAssistant PRIVATE ${ZLIB_INCLUDE_DIRS})
target_link_libraries(MeoAssistant ${ZLIB_LIBRARY})
@@ -59,11 +61,13 @@ else ()
add_subdirectory(3rdparty/VisionOCR)
target_link_libraries(MeoAssistant
vnocr
"-framework CoreFoundation"
"-framework CoreGraphics"
"-framework Vision"
"-framework Accelerate"
)
else ()
find_package(OpenCV REQUIRED)
target_include_directories(MeoAssistant PRIVATE ${OpenCV_INCLUDE_DIRS})
target_link_libraries(MeoAssistant ${OpenCV_LIBS})
target_link_libraries(MeoAssistant ppocr paddle_inference protobuf cryptopp gflags glog utf8proc xxhash iomp5 mkldnn mklml_intel)
endif (APPLE)
@@ -74,3 +78,15 @@ if (BUILD_TEST)
add_executable(test tools/TestCaller/main.cpp)
target_link_libraries(test MeoAssistant)
endif (BUILD_TEST)
if (BUILD_XCFRAMEWORK)
add_custom_command(OUTPUT MeoAssistant.xcframework
COMMAND rm -rf MeoAssistant.xcframework
COMMAND xcodebuild -create-xcframework -library libMeoAssistant.dylib -headers ${PROJECT_SOURCE_DIR}/include -output MeoAssistant.xcframework
DEPENDS MeoAssistant
)
add_custom_target(MaaXCFramework ALL
DEPENDS MeoAssistant MeoAssistant.xcframework
)
endif (BUILD_XCFRAMEWORK)

View File

@@ -2,16 +2,26 @@
#include "AsstPort.h"
#ifndef __cplusplus
#include <stdbool.h>
#endif
#ifdef __cplusplus
namespace asst
{
class Assistant;
}
#endif
#ifdef __cplusplus
extern "C"
{
#endif
#ifdef __cplusplus
typedef asst::Assistant* AsstHandle;
#else
typedef void* AsstHandle;
#endif
typedef int TaskId;
typedef void(ASST_CALL* AsstApiCallback)(int msg, const char* detail_json, void* custom_arg);

8
include/module.modulemap Normal file
View File

@@ -0,0 +1,8 @@
module MeoAssistant {
umbrella header "AsstCaller.h"
export *
link framework "Accelerate"
link framework "OpenCL"
link framework "Vision"
link "c++"
}

1
src/MeoAsstMac Submodule

Submodule src/MeoAsstMac added at f689d735c6