Skip to content

Commit

Permalink
wip: macOS build
Browse files Browse the repository at this point in the history
  • Loading branch information
arm64v8a committed Oct 22, 2022
1 parent c288d3e commit 38de968
Show file tree
Hide file tree
Showing 8 changed files with 88 additions and 17 deletions.
17 changes: 14 additions & 3 deletions .github/workflows/build-qv2ray-cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,30 @@ 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
[ ${{ matrix.cross_os }} == asset ] || GOOS=${{ matrix.cross_os }} GOARCH=${{ matrix.cross_arch }} ./libs/build_go.sh
[ ${{ 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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
17 changes: 12 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
)
Expand Down
18 changes: 18 additions & 0 deletions appdmg.json
Original file line number Diff line number Diff line change
@@ -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"
}
]
}
4 changes: 0 additions & 4 deletions cmake/nkr.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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 ()
9 changes: 5 additions & 4 deletions libs/deploy_macos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion main/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
38 changes: 38 additions & 0 deletions res/MacOSXBundleInfo.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>${MACOSX_BUNDLE_EXECUTABLE_NAME}</string>
<key>CFBundleGetInfoString</key>
<string>${MACOSX_BUNDLE_INFO_STRING}</string>
<key>CFBundleIconFile</key>
<string>${MACOSX_BUNDLE_ICON_FILE}</string>
<key>CFBundleIdentifier</key>
<string>${MACOSX_BUNDLE_GUI_IDENTIFIER}</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleLongVersionString</key>
<string>${MACOSX_BUNDLE_LONG_VERSION_STRING}</string>
<key>CFBundleName</key>
<string>${MACOSX_BUNDLE_BUNDLE_NAME}</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>${MACOSX_BUNDLE_SHORT_VERSION_STRING}</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>${MACOSX_BUNDLE_BUNDLE_VERSION}</string>
<key>CSResourcesFileMapped</key>
<true/>
<key>NSHumanReadableCopyright</key>
<string>${MACOSX_BUNDLE_COPYRIGHT}</string>
<key>NSPrincipalClass</key>
<string>NSApplication</string>
<key>NSHighResolutionCapable</key>
<string>True</string>
</dict>
</plist>
Binary file added res/nekoray.icns
Binary file not shown.

0 comments on commit 38de968

Please sign in to comment.