Skip to content

Commit

Permalink
Remove appdmg dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
tresf committed May 12, 2024
1 parent 78d4fee commit 756ee24
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 37 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,6 @@ jobs:
- name: Install dependencies
run: |
brew bundle install --verbose
npm update -g npm
npm install --location=global appdmg
env:
HOMEBREW_NO_AUTO_UPDATE: 1
HOMEBREW_NO_INSTALL_UPGRADE: 1
Expand Down
19 changes: 12 additions & 7 deletions cmake/apple/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,25 @@ SET(MACOSX_BUNDLE_DMG_TITLE "${MACOSX_BUNDLE_BUNDLE_NAME} ${MACOSX_B
STRING(SUBSTRING "${MACOSX_BUNDLE_DMG_TITLE}" 0 27 MACOSX_BUNDLE_DMG_TITLE)

CONFIGURE_FILE("lmms.plist.in" "${CMAKE_BINARY_DIR}/Info.plist")
CONFIGURE_FILE("install_apple.sh.in" "${CMAKE_BINARY_DIR}/install_apple.sh" @ONLY)
CONFIGURE_FILE("package_apple.json.in" "${CMAKE_BINARY_DIR}/package_apple.json" @ONLY)

# Generators "Bundle" and "DragNDrop" don't support macdeployqt, use "External" instead
CONFIGURE_FILE("package_apple.sh.in" "${CMAKE_BINARY_DIR}/package_apple.sh" @ONLY)
CONFIGURE_FILE("appdmg.json.in" "${CMAKE_BINARY_DIR}/appdmg.json" @ONLY)

# CPack vars
set(CPACK_GENERATOR "External" PARENT_SCOPE)
set(CPACK_GENERATOR "DragNDrop" PARENT_SCOPE)
# Strip causes missing symbols on macOS
set(CPACK_STRIP_FILES false PARENT_SCOPE)
set(CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}-${VERSION}" PARENT_SCOPE)
# Creates a staging directory to create our bundle from
set(CPACK_EXTERNAL_ENABLE_STAGING true PARENT_SCOPE)
set(CPACK_POST_BUILD_SCRIPTS "${CMAKE_CURRENT_SOURCE_DIR}/CPackApple.cmake" PARENT_SCOPE)
set(CPACK_PRE_BUILD_SCRIPTS "${CMAKE_CURRENT_SOURCE_DIR}/CPackApple.cmake" PARENT_SCOPE)
set(CPACK_DMG_VOLUME_NAME "${CMAKE_BINARY_DIR}/${CMAKE_PROJECT_NAME}-${VERSION}-mac${APPLE_OS_VER}.dmg" PARENT_SCOPE)
# tiff file is multi-resource (1x & 2x) created programatically using convert
set(CPACK_DMG_BACKGROUND_IMAGE "${CMAKE_BINARY_DIR}/dmg_branding.tiff" PARENT_SCOPE)
# DS_Store contains the Finder layout
# this file can be recreated using appdmg: Copy .DS_Store from the root of the DMG file
set(CPACK_DMG_DS_STORE "${CMAKE_SOURCE_DIR}/cmake/apple/DS_Store" PARENT_SCOPE)
unset(CPACK_RESOURCE_FILE_LICENSE PARENT_SCOPE)

# Additional vars otherwise unexposed to CPack
set(CPACK_DMG_BACKGROUND_PNGS "${CMAKE_SOURCE_DIR}/cmake/apple/*.png" PARENT_SCOPE)
set(CPACK_BINARY_DIR "${CMAKE_BINARY_DIR}" PARENT_SCOPE)
set(CPACK_DMG_FILE "${CMAKE_BINARY_DIR}/${CMAKE_PROJECT_NAME}-${VERSION}-mac${APPLE_OS_VER}.dmg" PARENT_SCOPE)
15 changes: 5 additions & 10 deletions cmake/apple/CPackApple.cmake
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
# Create LMMS.app bundle using install_apple.sh
# Create LMMS.app bundle using package_apple.sh
# TODO: Port this script to CMake
execute_process(COMMAND chmod u+x ${CPACK_BINARY_DIR}/install_apple.sh)
execute_process(COMMAND chmod u+x ${CPACK_BINARY_DIR}/package_apple.sh)
execute_process(COMMAND ${CPACK_BINARY_DIR}/install_apple.sh ${CPACK_TEMPORARY_INSTALL_DIRECTORY} RESULT_VARIABLE EXIT_CODE)
if(NOT EXIT_CODE EQUAL 0)
message(FATAL_ERROR "Execution of install_apple.sh failed")
message(FATAL_ERROR "Execution of package_apple.sh failed")
endif()

# Create DMG
message("Generating DMG")
# REMOVE_RECURSE supresses missing file warnings
file(REMOVE_RECURSE "${CPACK_DMG_FILE}")
execute_process(
COMMAND appdmg "${CPACK_BINARY_DIR}/package_apple.json" "${CPACK_DMG_FILE}"
)
# Create tiff from two pngs
execute_process(COMMAND convert "${CPACK_DMG_BACKGROUND_PNGS}" "${CPACK_DMG_BACKGROUND_IMAGE}")
Binary file added cmake/apple/DS_Store
Binary file not shown.
File renamed without changes.
32 changes: 14 additions & 18 deletions cmake/apple/install_apple.sh.in → cmake/apple/package_apple.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,9 @@

set -e

# Place to create ".app" bundle
APP="@CMAKE_BINARY_DIR@/@PROJECT_NAME_UCASE@.app"

MSG_COLOR='\x1B[1;36m'
COLOR_RESET='\x1B[0m'
APP="$1/@PROJECT_NAME_UCASE@.app"
echo -e "$MSG_COLOR\n\nCreating App Bundle \"$APP\"...$COLOR_RESET"

qtpath="$(dirname "@QT_QMAKE_EXECUTABLE@")"
Expand All @@ -28,30 +26,31 @@ else
echo "Provided directory '$1' does not exist"
fi

# Remove any old .app bundles
rm -Rf "$APP"

# Create .app bundle containing contents from CPack's "External" install directory
mkdir -p "$APP/Contents/MacOS"
mkdir -p "$APP/Contents/Frameworks"
mkdir -p "$APP/Contents/Resources"
cd "$1"
cp -R ./* "$APP/Contents"
cp "@CMAKE_BINARY_DIR@/Info.plist" "$APP/Contents/"
cp "@CMAKE_SOURCE_DIR@/cmake/apple/"*.icns "$APP/Contents/Resources/"
for file in *; do
if [ $(basename $file) != "@PROJECT_NAME_UCASE@.app" ]; then
mv "$file" "$APP/Contents/"
fi
done


cp "@CMAKE_BINARY_DIR@/Info.plist" "$APP/Contents/" # TODO: MOVE TO INSTALL
cp "@CMAKE_SOURCE_DIR@/cmake/apple/"*.icns "$APP/Contents/Resources/" # TODO: MOVE TO INSTALL

# Make all libraries writable for macdeployqt
cd "$APP"
find . -type f -print0 | xargs -0 chmod u+w

lmmsbin="MacOS/@CMAKE_PROJECT_NAME@"
zynbin="MacOS/RemoteZynAddSubFx"

# Move lmms binary
mv "$APP/Contents/bin/@CMAKE_PROJECT_NAME@" "$APP/Contents/$lmmsbin"
mv "$APP/Contents/bin/@CMAKE_PROJECT_NAME@" "$APP/Contents/MacOS/@CMAKE_PROJECT_NAME@"
rm -rf "$APP/bin"

# Fix zyn linking
mv "$APP/Contents/lib/lmms/RemoteZynAddSubFx" "$APP/Contents/$zynbin"
mv "$APP/Contents/lib/lmms/RemoteZynAddSubFx" "$APP/Contents/MacOS/RemoteZynAddSubFx"

# Replace @rpath with @loader_path for Carla
# See also plugins/CarlaBase/CMakeLists.txt
Expand All @@ -65,7 +64,7 @@ install_name_tool -change @rpath/libcarlabase.dylib \
"$APP/Contents/lib/lmms/libcarlarack.so"

# Link lmms binary
_executables="${_executables} -executable=$APP/Contents/$zynbin"
_executables="${_executables} -executable=$APP/Contents/MacOS/RemoteZynAddSubFx"

# Build a list of shared objects in target/lib/lmms
for file in "$APP/Contents/lib/lmms/"*.so; do
Expand Down Expand Up @@ -105,9 +104,6 @@ for file in "$APP/Contents/lib/lmms/"libcarla*; do
done
done

# Cleanup
rm -rf "$APP/Contents/bin"

# Codesign
codesign --force --deep --sign - "$APP"

Expand Down

0 comments on commit 756ee24

Please sign in to comment.