diff --git a/.github/workflows/build-qv2ray-cmake.yml b/.github/workflows/build-qv2ray-cmake.yml index c655893..23d5ab8 100644 --- a/.github/workflows/build-qv2ray-cmake.yml +++ b/.github/workflows/build-qv2ray-cmake.yml @@ -23,12 +23,22 @@ jobs: steps: - name: Checking out sources uses: actions/checkout@v2 + - name: Go Status + run: git ls-files go | xargs cat | sha1sum > go_status + - name: Cache Common Download + id: cache-common + uses: actions/cache@v3 + with: + path: artifacts.tgz + key: CommonCache-${{ matrix.cross_os }}-${{ matrix.cross_arch }}-${{ hashFiles('libs/*.sh', 'go_status') }} - name: Install Golang + if: steps.cache-common.outputs.cache-hit != 'true' uses: actions/setup-go@v2 with: stable: false go-version: 1.19.2 - name: Build golang parts + if: steps.cache-common.outputs.cache-hit != 'true' shell: bash run: | [ ${{ matrix.cross_os }} == asset ] || ./libs/get_source.sh @@ -36,6 +46,7 @@ jobs: [ ${{ matrix.cross_os }} == asset ] || exit 0 ./libs/build_asset.sh - name: Tar files + if: steps.cache-common.outputs.cache-hit != 'true' run: tar czvf artifacts.tgz ./deployment - name: Uploading Artifact uses: actions/upload-artifact@master @@ -45,7 +56,7 @@ jobs: build-cpp: strategy: matrix: - platform: [ windows-2022, ubuntu-20.04, macos-11 ] + platform: [ windows-2022, ubuntu-20.04, macos-10.15 ] arch: [ x64 ] qt_version: [ 5.15.2 ] fail-fast: false @@ -68,7 +79,7 @@ jobs: toolset: 14.2 arch: ${{ matrix.arch }} - name: Download Artifacts - if: matrix.platform == 'macos-11' + if: matrix.platform == 'macos-10.15' uses: actions/download-artifact@v3 with: path: download-artifact @@ -127,7 +138,7 @@ jobs: ./libs/deploy_linux64.sh - name: macOS - ${{ matrix.qt_version }} - Generate MakeFile and Build shell: bash - if: matrix.platform == 'macos-11' + if: matrix.platform == 'macos-10.15' run: | mkdir build cd build diff --git a/CMakeLists.txt b/CMakeLists.txt index 7770671..54ace94 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -31,8 +31,8 @@ if (NKR_CROSS) endif () if (NKR_PACKAGE OR NKR_PACKAGE_MACOS) - message("[add_compile_definitions] NKR_PACKAGE") - add_compile_definitions(NKR_PACKAGE) + message("[add_compile_definitions] NKR_CPP_USE_APPDATA") + add_compile_definitions(NKR_CPP_USE_APPDATA) endif () # Windows @@ -257,10 +257,17 @@ target_link_libraries(nekoray PRIVATE ${PLATFORM_FUCKING_LIBRARIES} ) +set(MACOSX_ICON ${CMAKE_SOURCE_DIR}/res/nekoray.icns) + +if (APPLE) + target_sources(nekoray PRIVATE ${MACOSX_ICON}) +endif () + set_target_properties(nekoray PROPERTIES - MACOSX_BUNDLE_GUI_IDENTIFIER my.example.com - MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION} - MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR} + MACOSX_BUNDLE_ICON_FILE "nekoray.icns" + RESOURCE ${MACOSX_ICON} + MACOSX_BUNDLE_INFO_PLIST ${CMAKE_SOURCE_DIR}/res/MacOSXBundleInfo.plist + MACOSX_BUNDLE_GUI_IDENTIFIER moe.nekoray.macosx MACOSX_BUNDLE TRUE WIN32_EXECUTABLE TRUE ) diff --git a/appdmg.json b/appdmg.json new file mode 100644 index 0000000..d7f1a40 --- /dev/null +++ b/appdmg.json @@ -0,0 +1,18 @@ +{ + "title": "nekoray", + "icon": "res/nekoray.icns", + "contents": [ + { + "x": 448, + "y": 344, + "type": "link", + "path": "/Applications" + }, + { + "x": 192, + "y": 344, + "type": "file", + "path": "build/nekoray.app" + } + ] +} \ No newline at end of file diff --git a/cmake/nkr.cmake b/cmake/nkr.cmake index 6ae6652..68ec1fd 100644 --- a/cmake/nkr.cmake +++ b/cmake/nkr.cmake @@ -4,7 +4,3 @@ add_compile_definitions(NKR_VERSION=\"${NKR_VERSION}\") # Debug set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DNKR_DEBUG") - -if (NKR_USE_APPDATA) - add_compile_definitions(NKR_USE_APPDATA) -endif () diff --git a/libs/deploy_macos.sh b/libs/deploy_macos.sh index 3a3f135..c661d11 100755 --- a/libs/deploy_macos.sh +++ b/libs/deploy_macos.sh @@ -19,10 +19,11 @@ mv deployment/assets/* deployment/macos-$ARCH mv deployment/macos-$ARCH/* $BUILD/nekoray.app/Contents/MacOS popd -#### deploy qt & DLL runtime => dmg #### +#### deploy qt & DLL runtime => .app #### pushd $BUILD -macdeployqt nekoray.app -dmg -verbose=3 +macdeployqt nekoray.app -verbose=3 popd -#### copy dmg #### -cp $BUILD/*.dmg $DEST +#### pack dmg ### +sudo npm install -g appdmg +appdmg appdmg.json $DEST/nekoray.dmg diff --git a/main/main.cpp b/main/main.cpp index d00e2f7..ab63ead 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -50,7 +50,7 @@ int main(int argc, char *argv[]) { auto args = QApplication::arguments(); if (args.contains("-many")) NekoRay::dataStore->flag_many = true; if (args.contains("-appdata")) NekoRay::dataStore->flag_use_appdata = true; -#ifdef NKR_PACKAGE +#ifdef NKR_CPP_USE_APPDATA NekoRay::dataStore->flag_use_appdata = true; #endif diff --git a/res/MacOSXBundleInfo.plist b/res/MacOSXBundleInfo.plist new file mode 100644 index 0000000..e06b17e --- /dev/null +++ b/res/MacOSXBundleInfo.plist @@ -0,0 +1,38 @@ + + + + + CFBundleDevelopmentRegion + English + CFBundleExecutable + ${MACOSX_BUNDLE_EXECUTABLE_NAME} + CFBundleGetInfoString + ${MACOSX_BUNDLE_INFO_STRING} + CFBundleIconFile + ${MACOSX_BUNDLE_ICON_FILE} + CFBundleIdentifier + ${MACOSX_BUNDLE_GUI_IDENTIFIER} + CFBundleInfoDictionaryVersion + 6.0 + CFBundleLongVersionString + ${MACOSX_BUNDLE_LONG_VERSION_STRING} + CFBundleName + ${MACOSX_BUNDLE_BUNDLE_NAME} + CFBundlePackageType + APPL + CFBundleShortVersionString + ${MACOSX_BUNDLE_SHORT_VERSION_STRING} + CFBundleSignature + ???? + CFBundleVersion + ${MACOSX_BUNDLE_BUNDLE_VERSION} + CSResourcesFileMapped + + NSHumanReadableCopyright + ${MACOSX_BUNDLE_COPYRIGHT} + NSPrincipalClass + NSApplication + NSHighResolutionCapable + True + + diff --git a/res/nekoray.icns b/res/nekoray.icns new file mode 100644 index 0000000..18c4bfc Binary files /dev/null and b/res/nekoray.icns differ