diff --git a/.github/workflows/dev-build.yml b/.github/workflows/dev-build.yml index 55ee73c18b..d868de8411 100644 --- a/.github/workflows/dev-build.yml +++ b/.github/workflows/dev-build.yml @@ -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 diff --git a/.github/workflows/release-maa.yml b/.github/workflows/release-maa.yml index 68563e702c..80b3528e37 100644 --- a/.github/workflows/release-maa.yml +++ b/.github/workflows/release-maa.yml @@ -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 diff --git a/.gitmodules b/.gitmodules index 358c602a99..70db001202 100644 --- a/.gitmodules +++ b/.gitmodules @@ -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 diff --git a/3rdparty/VisionOCR b/3rdparty/VisionOCR index cd18ce5e00..67991c4c0c 160000 --- a/3rdparty/VisionOCR +++ b/3rdparty/VisionOCR @@ -1 +1 @@ -Subproject commit cd18ce5e00e40436b5b207beab4ff0cdb8e7b74e +Subproject commit 67991c4c0c191f3e74bcdcbc0537d730ef9f028f diff --git a/CMakeLists.txt b/CMakeLists.txt index 992d9b3883..d249113765 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) diff --git a/include/AsstCaller.h b/include/AsstCaller.h index 1343ac147c..435002cbe4 100644 --- a/include/AsstCaller.h +++ b/include/AsstCaller.h @@ -2,16 +2,26 @@ #include "AsstPort.h" +#ifndef __cplusplus +#include +#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); diff --git a/include/module.modulemap b/include/module.modulemap new file mode 100644 index 0000000000..0fe3104227 --- /dev/null +++ b/include/module.modulemap @@ -0,0 +1,8 @@ +module MeoAssistant { + umbrella header "AsstCaller.h" + export * + link framework "Accelerate" + link framework "OpenCL" + link framework "Vision" + link "c++" +} diff --git a/src/MeoAsstMac b/src/MeoAsstMac new file mode 160000 index 0000000000..f689d735c6 --- /dev/null +++ b/src/MeoAsstMac @@ -0,0 +1 @@ +Subproject commit f689d735c6ec1346180fff12aba471d7df126992