ci: More macOS bundle fixes

This commit is contained in:
Luke Street 2022-06-13 17:05:28 -04:00
parent 30802a447f
commit f0936a7fb0
5 changed files with 86 additions and 18 deletions

View File

@ -175,7 +175,7 @@ jobs:
build/install/debug.tar.* build/install/debug.tar.*
build-ios: build-ios:
name: Build iOS name: Build iOS (AppleClang arm64)
runs-on: macos-11 runs-on: macos-11
steps: steps:
@ -195,10 +195,21 @@ jobs:
run: cmake --preset ios-default run: cmake --preset ios-default
- name: Build - name: Build
run: cmake --build --preset ios-default run: cmake --build --preset ios-default --target install
- name: Generate IPA
run: ci/build-ipa.sh
- name: Upload artifacts
uses: actions/upload-artifact@v2
with:
name: metaforce-${{env.METAFORCE_VERSION}}-ios-appleclang-arm64
path: |
build/install/Metaforce.ipa
build/install/debug.tar.*
build-tvos: build-tvos:
name: Build tvOS name: Build tvOS (AppleClang arm64)
runs-on: macos-11 runs-on: macos-11
steps: steps:
@ -218,7 +229,18 @@ jobs:
run: cmake --preset tvos-default run: cmake --preset tvos-default
- name: Build - name: Build
run: cmake --build --preset tvos-default run: cmake --build --preset tvos-default --target install
- name: Generate IPA
run: ci/build-ipa.sh
- name: Upload artifacts
uses: actions/upload-artifact@v2
with:
name: metaforce-${{env.METAFORCE_VERSION}}-tvos-appleclang-arm64
path: |
build/install/Metaforce.ipa
build/install/debug.tar.*
build-windows: build-windows:
name: Build Windows (${{matrix.name}} x86_64) name: Build Windows (${{matrix.name}} x86_64)
@ -302,7 +324,7 @@ jobs:
- name: Upload artifacts - name: Upload artifacts
uses: actions/upload-artifact@v2 uses: actions/upload-artifact@v2
with: with:
name: metaforce-${{env.METAFORCE_VERSION}}-win32-clang-x86_64 name: metaforce-${{env.METAFORCE_VERSION}}-win32-${{matrix.preset}}-x86_64
path: | path: |
${{env.BUILD_DIR}}/install/*.exe ${{env.BUILD_DIR}}/install/*.exe
${{env.BUILD_DIR}}/install/debug.7z ${{env.BUILD_DIR}}/install/debug.7z

View File

@ -372,6 +372,29 @@ add_subdirectory(gbalink EXCLUDE_FROM_ALL)
configure_file(${CMAKE_SOURCE_DIR}/version.h.in ${CMAKE_BINARY_DIR}/version.h) configure_file(${CMAKE_SOURCE_DIR}/version.h.in ${CMAKE_BINARY_DIR}/version.h)
# Packaging logic # Packaging logic
function(get_target_output_name target result_var)
get_target_property(output_name ${target} OUTPUT_NAME)
if (output_name STREQUAL "output_name-NOTFOUND")
set(${result_var} "${target}" PARENT_SCOPE)
else ()
set(${result_var} "${output_name}" PARENT_SCOPE)
endif ()
endfunction()
function(get_target_prefix target result_var)
set(${result_var} "" PARENT_SCOPE)
if (APPLE)
# Have to recreate some bundle logic here, since CMake can't tell us
get_target_property(is_bundle ${target} MACOSX_BUNDLE)
if (is_bundle)
get_target_output_name(${target} output_name)
if (CMAKE_SYSTEM_NAME STREQUAL Darwin)
set(${result_var} "${output_name}.app/Contents/MacOS/" PARENT_SCOPE)
else ()
set(${result_var} "${output_name}.app/" PARENT_SCOPE)
endif ()
endif ()
endif ()
endfunction()
list(APPEND BINARY_TARGETS metaforce) list(APPEND BINARY_TARGETS metaforce)
set(EXTRA_TARGETS "") set(EXTRA_TARGETS "")
if (TARGET crashpad_handler) if (TARGET crashpad_handler)
@ -380,20 +403,26 @@ endif ()
set(BIN_PREFIX "${CMAKE_INSTALL_PREFIX}") set(BIN_PREFIX "${CMAKE_INSTALL_PREFIX}")
install(TARGETS ${BINARY_TARGETS} ${EXTRA_TARGETS} DESTINATION ${BIN_PREFIX}) install(TARGETS ${BINARY_TARGETS} ${EXTRA_TARGETS} DESTINATION ${BIN_PREFIX})
if (CMAKE_BUILD_TYPE STREQUAL Debug OR CMAKE_BUILD_TYPE STREQUAL RelWithDebInfo) if (CMAKE_BUILD_TYPE STREQUAL Debug OR CMAKE_BUILD_TYPE STREQUAL RelWithDebInfo)
foreach (target IN LISTS BINARY_TARGETS) set(DEBUG_FILES_LIST "")
foreach (target IN LISTS BINARY_TARGETS EXTRA_TARGETS)
get_target_output_name(${target} output_name)
if (WIN32) if (WIN32)
install(FILES $<TARGET_PDB_FILE:${target}> DESTINATION ${BIN_PREFIX} OPTIONAL) install(FILES $<TARGET_PDB_FILE:${target}> DESTINATION ${BIN_PREFIX} OPTIONAL)
elseif (APPLE) elseif (APPLE)
get_target_prefix(${target} target_prefix)
install(CODE "execute_process(WORKING_DIRECTORY \"${BIN_PREFIX}\" COMMAND rm -fr \"$<TARGET_FILE_NAME:${target}>.dSYM\")") install(CODE "execute_process(WORKING_DIRECTORY \"${BIN_PREFIX}\" COMMAND rm -fr \"$<TARGET_FILE_NAME:${target}>.dSYM\")")
install(CODE "execute_process(WORKING_DIRECTORY \"${BIN_PREFIX}\" COMMAND dsymutil \"$<TARGET_FILE:${target}>\")") install(CODE "execute_process(WORKING_DIRECTORY \"${BIN_PREFIX}\" COMMAND dsymutil \"${target_prefix}$<TARGET_FILE_NAME:${target}>\")")
install(CODE "execute_process(WORKING_DIRECTORY \"${BIN_PREFIX}\" COMMAND strip -S \"$<TARGET_FILE:${target}>\")") install(CODE "execute_process(WORKING_DIRECTORY \"${BIN_PREFIX}\" COMMAND strip -S \"${target_prefix}$<TARGET_FILE_NAME:${target}>\")")
install(CODE "execute_process(WORKING_DIRECTORY \"${BIN_PREFIX}\" COMMAND mv \"$<TARGET_FILE:${target}>.dSYM\" .)") if (NOT target_prefix STREQUAL "")
install(CODE "execute_process(WORKING_DIRECTORY \"${BIN_PREFIX}\" COMMAND mv \"${target_prefix}$<TARGET_FILE_NAME:${target}>.dSYM\" .)")
endif ()
elseif (UNIX) elseif (UNIX)
install(CODE "execute_process(WORKING_DIRECTORY \"${BIN_PREFIX}\" COMMAND objcopy --only-keep-debug ${target} ${target}.dbg)") get_target_prefix(${target} target_prefix)
install(CODE "execute_process(WORKING_DIRECTORY \"${BIN_PREFIX}\" COMMAND objcopy --strip-debug --add-gnu-debuglink=${target}.dbg ${target})") install(CODE "execute_process(WORKING_DIRECTORY \"${BIN_PREFIX}\" COMMAND objcopy --only-keep-debug \"${target_prefix}$<TARGET_FILE_NAME:${target}>\" \"${target_prefix}$<TARGET_FILE_NAME:${target}>.dbg\")")
install(CODE "execute_process(WORKING_DIRECTORY \"${BIN_PREFIX}\" COMMAND objcopy --strip-debug --add-gnu-debuglink=$<TARGET_FILE_NAME:${target}>.dbg \"${target_prefix}$<TARGET_FILE_NAME:${target}>\")")
endif () endif ()
list(APPEND DEBUG_FILES_LIST "${output_name}")
endforeach () endforeach ()
set(DEBUG_FILES_LIST ${BINARY_TARGETS})
if (WIN32) if (WIN32)
list(TRANSFORM DEBUG_FILES_LIST APPEND ".pdb") list(TRANSFORM DEBUG_FILES_LIST APPEND ".pdb")
list(JOIN DEBUG_FILES_LIST " " DEBUG_FILES) list(JOIN DEBUG_FILES_LIST " " DEBUG_FILES)
@ -408,3 +437,13 @@ if (CMAKE_BUILD_TYPE STREQUAL Debug OR CMAKE_BUILD_TYPE STREQUAL RelWithDebInfo)
install(CODE "execute_process(WORKING_DIRECTORY \"${BIN_PREFIX}\" COMMAND tar -I \"xz -9 -T0\" -cvf \"${CMAKE_INSTALL_PREFIX}/debug.tar.xz\" ${DEBUG_FILES})") install(CODE "execute_process(WORKING_DIRECTORY \"${BIN_PREFIX}\" COMMAND tar -I \"xz -9 -T0\" -cvf \"${CMAKE_INSTALL_PREFIX}/debug.tar.xz\" ${DEBUG_FILES})")
endif () endif ()
endif () endif ()
foreach (target IN LISTS BINARY_TARGETS)
get_target_prefix(${target} target_prefix)
foreach (extra_target IN LISTS EXTRA_TARGETS)
get_target_prefix(${extra_target} extra_prefix)
if (NOT "${target_prefix}" STREQUAL "${extra_prefix}")
# Copy extra target to target prefix
install(CODE "execute_process(WORKING_DIRECTORY \"${BIN_PREFIX}\" COMMAND cp \"${extra_prefix}$<TARGET_FILE_NAME:${extra_target}>\" \"${target_prefix}$<TARGET_FILE_NAME:${extra_target}>\")")
endif ()
endforeach ()
endforeach ()

View File

@ -244,7 +244,6 @@ if (APPLE)
elseif (IOS) elseif (IOS)
set(RESOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/platforms/ios) set(RESOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/platforms/ios)
set(INFO_PLIST ${RESOURCE_DIR}/Info.plist.in) set(INFO_PLIST ${RESOURCE_DIR}/Info.plist.in)
message("Using INFO_PLIST ${INFO_PLIST}")
file(GLOB_RECURSE RESOURCE_FILES "${RESOURCE_DIR}/Base.lproj/*") file(GLOB_RECURSE RESOURCE_FILES "${RESOURCE_DIR}/Base.lproj/*")
list(APPEND RESOURCE_FILES list(APPEND RESOURCE_FILES
${RESOURCE_DIR}/Assets.car ${RESOURCE_DIR}/Assets.car
@ -255,7 +254,7 @@ if (APPLE)
set(INFO_PLIST ${RESOURCE_DIR}/Info.plist.in) set(INFO_PLIST ${RESOURCE_DIR}/Info.plist.in)
set(RESOURCE_FILES ${RESOURCE_DIR}/mainicon.icns) set(RESOURCE_FILES ${RESOURCE_DIR}/mainicon.icns)
endif () endif ()
target_sources(metaforce PRIVATE ${INFO_PLIST} ${RESOURCE_FILES}) target_sources(metaforce PRIVATE ${RESOURCE_FILES})
# Add to resources, preserving directory structure # Add to resources, preserving directory structure
foreach (FILE ${RESOURCE_FILES}) foreach (FILE ${RESOURCE_FILES})
file(RELATIVE_PATH NEW_FILE "${RESOURCE_DIR}" ${FILE}) file(RELATIVE_PATH NEW_FILE "${RESOURCE_DIR}" ${FILE})
@ -268,9 +267,10 @@ if (APPLE)
MACOSX_BUNDLE TRUE MACOSX_BUNDLE TRUE
MACOSX_BUNDLE_INFO_PLIST ${INFO_PLIST} MACOSX_BUNDLE_INFO_PLIST ${INFO_PLIST}
MACOSX_BUNDLE_BUNDLE_NAME Metaforce MACOSX_BUNDLE_BUNDLE_NAME Metaforce
MACOSX_BUNDLE_GUI_IDENTIFIER dev.test.metaforce MACOSX_BUNDLE_GUI_IDENTIFIER com.axiodl.Metaforce
MACOSX_BUNDLE_BUNDLE_VERSION "${METAFORCE_VERSION_STRING}" MACOSX_BUNDLE_BUNDLE_VERSION "${METAFORCE_VERSION_STRING}"
MACOSX_BUNDLE_SHORT_VERSION_STRING "${METAFORCE_SHORT_VERSION_STRING}" MACOSX_BUNDLE_SHORT_VERSION_STRING "${METAFORCE_SHORT_VERSION_STRING}"
OUTPUT_NAME Metaforce
) )
endif () endif ()
if (WINDOWS_STORE) if (WINDOWS_STORE)

View File

@ -1,8 +1,8 @@
#!/bin/bash -ex #!/bin/bash -ex
cd build/install cd build/install
for i in metaforce crashpad_handler; do for i in Metaforce crashpad_handler; do
codesign --timestamp --options runtime -s "$CODESIGN_IDENT" metaforce.app/Contents/MacOS/$i codesign --timestamp --options runtime -s "$CODESIGN_IDENT" Metaforce.app/Contents/MacOS/$i
done done
create-dmg metaforce.app --identity="$CODESIGN_IDENT" . create-dmg Metaforce.app --identity="$CODESIGN_IDENT" .
xcrun altool -t osx -f *.dmg --primary-bundle-id com.axiodl.Metaforce \ xcrun altool -t osx -f *.dmg --primary-bundle-id com.axiodl.Metaforce \
--notarize-app -u "$ASC_USERNAME" -p "$ASC_PASSWORD" --team-id "$ASC_TEAM_ID" --notarize-app -u "$ASC_USERNAME" -p "$ASC_PASSWORD" --team-id "$ASC_TEAM_ID"

7
ci/build-ipa.sh Executable file
View File

@ -0,0 +1,7 @@
#!/bin/bash -ex
cd build/install
rm -fr Payload
mkdir Payload
cp -r Metaforce.app Payload
zip -r Metaforce.zip Payload
mv Metaforce.zip Metaforce.ipa