Build MacOS executables as bundles

This commit is contained in:
Lars Toenning
2023-11-21 19:51:51 +01:00
parent 6f29139d97
commit 662ae094b4
10 changed files with 85 additions and 29 deletions

View File

@@ -117,7 +117,7 @@ if(SWIFT_USE_CRASHPAD)
endif() endif()
if(APPLE) if(APPLE)
set(CMAKE_INSTALL_RPATH @loader_path/../lib) set(CMAKE_INSTALL_RPATH @loader_path/../../../../lib)
elseif(UNIX) elseif(UNIX)
set(CMAKE_INSTALL_RPATH \$ORIGIN/../lib) set(CMAKE_INSTALL_RPATH \$ORIGIN/../lib)
endif() endif()

View File

@@ -384,11 +384,14 @@ class MacOSBuilder(Builder):
return True return True
def _strip_debug(self): def _strip_debug(self):
bundle_files = [
"bin/swiftcore.app/Contents/MacOS/swiftcore",
"bin/swiftdata.app/Contents/MacOS/swiftdata",
"bin/swiftguistd.app/Contents/MacOS/swiftguistd",
"bin/swiftlauncher.app/Contents/MacOS/swiftlauncher",
]
files = [ files = [
"bin/swiftcore",
"bin/swiftdata",
"bin/swiftguistd",
"bin/swiftlauncher",
"lib/libcore.dylib", "lib/libcore.dylib",
"lib/libgui.dylib", "lib/libgui.dylib",
"lib/libinput.dylib", "lib/libinput.dylib",
@@ -405,6 +408,11 @@ class MacOSBuilder(Builder):
"xswiftbus/64/mac.xpl", "xswiftbus/64/mac.xpl",
] ]
dist_path = path.join(self._get_swift_source_path(), "dist") dist_path = path.join(self._get_swift_source_path(), "dist")
# Put output of bundle files directly in bin folder
for file in bundle_files:
subprocess.check_call(["dsymutil", path.join(dist_path, file), "-o", path.join(dist_path, "bin", file.split("/")[-1] + ".dSYM")], env=dict(os.environ))
for file in files: for file in files:
subprocess.check_call(["dsymutil", path.join(dist_path, file)], env=dict(os.environ)) subprocess.check_call(["dsymutil", path.join(dist_path, file)], env=dict(os.environ))

View File

@@ -22,10 +22,22 @@ target_link_libraries(swiftcore
core core
) )
if(APPLE)
set_target_properties(swiftcore PROPERTIES MACOSX_BUNDLE TRUE)
set_target_properties(swiftcore PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/Info.plist)
set(RESOURCE_FILES swiftcore.icns qt.conf)
target_sources(swiftcore PRIVATE ${RESOURCE_FILES})
set_target_properties(swiftcore PROPERTIES RESOURCE "${RESOURCE_FILES}")
endif()
add_dependencies(swiftcore resources) add_dependencies(swiftcore resources)
if(WIN32) if(WIN32)
add_dependencies(swiftcore copy_externals_to_build_dir) add_dependencies(swiftcore copy_externals_to_build_dir)
endif() endif()
install(TARGETS swiftcore) if(APPLE)
install(TARGETS swiftcore BUNDLE DESTINATION bin)
else()
install(TARGETS swiftcore)
endif()

View File

@@ -7,19 +7,19 @@
<key>CFBundleDisplayName</key> <key>CFBundleDisplayName</key>
<string>swift core</string> <string>swift core</string>
<key>CFBundleExecutable</key> <key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string> <string>swiftcore</string>
<key>CFBundleGetInfoString</key> <key>CFBundleGetInfoString</key>
<string>swift project - free and open source pilot client</string> <string>swift project - free and open source pilot client</string>
<key>CFBundleIconFile</key> <key>CFBundleIconFile</key>
<string>${ASSETCATALOG_COMPILER_APPICON_NAME}</string> <string>swiftcore.icns</string>
<key>CFBundleIdentifier</key> <key>CFBundleIdentifier</key>
<string>${PRODUCT_BUNDLE_IDENTIFIER}</string> <string>org.swift-project.swiftcore</string>
<key>CFBundlePackageType</key> <key>CFBundlePackageType</key>
<string>APPL</string> <string>APPL</string>
<key>CFBundleSignature</key> <key>CFBundleSignature</key>
<string>${QMAKE_PKGINFO_TYPEINFO}</string> <string>????</string>
<key>LSMinimumSystemVersion</key> <key>LSMinimumSystemVersion</key>
<string>${MACOSX_DEPLOYMENT_TARGET}</string> <string>10.13</string>
<key>NSPrincipalClass</key> <key>NSPrincipalClass</key>
<string>NSApplication</string> <string>NSApplication</string>
<key>NSSupportsAutomaticGraphicsSwitching</key> <key>NSSupportsAutomaticGraphicsSwitching</key>

View File

@@ -23,10 +23,22 @@ target_link_libraries(swiftdata
core core
) )
if(APPLE)
set_target_properties(swiftdata PROPERTIES MACOSX_BUNDLE TRUE)
set_target_properties(swiftdata PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/Info.plist)
set(RESOURCE_FILES swiftdata.icns qt.conf)
target_sources(swiftdata PRIVATE ${RESOURCE_FILES})
set_target_properties(swiftdata PROPERTIES RESOURCE "${RESOURCE_FILES}")
endif()
add_dependencies(swiftdata resources) add_dependencies(swiftdata resources)
if(WIN32) if(WIN32)
add_dependencies(swiftdata copy_externals_to_build_dir) add_dependencies(swiftdata copy_externals_to_build_dir)
endif() endif()
install(TARGETS swiftdata) if(APPLE)
install(TARGETS swiftdata BUNDLE DESTINATION bin)
else()
install(TARGETS swiftdata)
endif()

View File

@@ -7,19 +7,19 @@
<key>CFBundleDisplayName</key> <key>CFBundleDisplayName</key>
<string>swift data</string> <string>swift data</string>
<key>CFBundleExecutable</key> <key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string> <string>swiftdata</string>
<key>CFBundleGetInfoString</key> <key>CFBundleGetInfoString</key>
<string>swift project - free and open source pilot client</string> <string>swift project - free and open source pilot client</string>
<key>CFBundleIconFile</key> <key>CFBundleIconFile</key>
<string>${ASSETCATALOG_COMPILER_APPICON_NAME}</string> <string>swiftdata.icns</string>
<key>CFBundleIdentifier</key> <key>CFBundleIdentifier</key>
<string>${PRODUCT_BUNDLE_IDENTIFIER}</string> <string>org.swift-project.swiftdata</string>
<key>CFBundlePackageType</key> <key>CFBundlePackageType</key>
<string>APPL</string> <string>APPL</string>
<key>CFBundleSignature</key> <key>CFBundleSignature</key>
<string>${QMAKE_PKGINFO_TYPEINFO}</string> <string>????</string>
<key>LSMinimumSystemVersion</key> <key>LSMinimumSystemVersion</key>
<string>${MACOSX_DEPLOYMENT_TARGET}</string> <string>10.13</string>
<key>NSPrincipalClass</key> <key>NSPrincipalClass</key>
<string>NSApplication</string> <string>NSApplication</string>
<key>NSSupportsAutomaticGraphicsSwitching</key> <key>NSSupportsAutomaticGraphicsSwitching</key>

View File

@@ -28,10 +28,22 @@ target_link_libraries(swiftguistd
sound sound
) )
if(APPLE)
set_target_properties(swiftguistd PROPERTIES MACOSX_BUNDLE TRUE)
set_target_properties(swiftguistd PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/Info.plist)
set(RESOURCE_FILES swift.icns qt.conf)
target_sources(swiftguistd PRIVATE ${RESOURCE_FILES})
set_target_properties(swiftguistd PROPERTIES RESOURCE "${RESOURCE_FILES}")
endif()
add_dependencies(swiftguistd resources) add_dependencies(swiftguistd resources)
if(WIN32) if(WIN32)
add_dependencies(swiftguistd copy_externals_to_build_dir) add_dependencies(swiftguistd copy_externals_to_build_dir)
endif() endif()
install(TARGETS swiftguistd) if(APPLE)
install(TARGETS swiftguistd BUNDLE DESTINATION bin)
else()
install(TARGETS swiftguistd)
endif()

View File

@@ -7,19 +7,19 @@
<key>CFBundleDisplayName</key> <key>CFBundleDisplayName</key>
<string>swift gui</string> <string>swift gui</string>
<key>CFBundleExecutable</key> <key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string> <string>swiftguistd</string>
<key>CFBundleGetInfoString</key> <key>CFBundleGetInfoString</key>
<string>swift project - free and open source pilot client</string> <string>swift project - free and open source pilot client</string>
<key>CFBundleIconFile</key> <key>CFBundleIconFile</key>
<string>${ASSETCATALOG_COMPILER_APPICON_NAME}</string> <string>swift.icns</string>
<key>CFBundleIdentifier</key> <key>CFBundleIdentifier</key>
<string>${PRODUCT_BUNDLE_IDENTIFIER}</string> <string>org.swift-project.swiftguistd</string>
<key>CFBundlePackageType</key> <key>CFBundlePackageType</key>
<string>APPL</string> <string>APPL</string>
<key>CFBundleSignature</key> <key>CFBundleSignature</key>
<string>${QMAKE_PKGINFO_TYPEINFO}</string> <string>????</string>
<key>LSMinimumSystemVersion</key> <key>LSMinimumSystemVersion</key>
<string>${MACOSX_DEPLOYMENT_TARGET}</string> <string>10.13</string>
<key>NSPrincipalClass</key> <key>NSPrincipalClass</key>
<string>NSApplication</string> <string>NSApplication</string>
<key>NSSupportsAutomaticGraphicsSwitching</key> <key>NSSupportsAutomaticGraphicsSwitching</key>

View File

@@ -23,10 +23,22 @@ target_link_libraries(swiftlauncher
core core
) )
if(APPLE)
set_target_properties(swiftlauncher PROPERTIES MACOSX_BUNDLE TRUE)
set_target_properties(swiftlauncher PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/Info.plist)
set(RESOURCE_FILES swiftlauncher.icns qt.conf)
target_sources(swiftlauncher PRIVATE ${RESOURCE_FILES})
set_target_properties(swiftlauncher PROPERTIES RESOURCE "${RESOURCE_FILES}")
endif()
add_dependencies(swiftlauncher resources) add_dependencies(swiftlauncher resources)
if(WIN32) if(WIN32)
add_dependencies(swiftlauncher copy_externals_to_build_dir) add_dependencies(swiftlauncher copy_externals_to_build_dir)
endif() endif()
install(TARGETS swiftlauncher) if(APPLE)
install(TARGETS swiftlauncher BUNDLE DESTINATION bin)
else()
install(TARGETS swiftlauncher)
endif()

View File

@@ -7,19 +7,19 @@
<key>CFBundleDisplayName</key> <key>CFBundleDisplayName</key>
<string>swift launcher</string> <string>swift launcher</string>
<key>CFBundleExecutable</key> <key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string> <string>swiftlauncher</string>
<key>CFBundleGetInfoString</key> <key>CFBundleGetInfoString</key>
<string>swift project - free and open source pilot client</string> <string>swift project - free and open source pilot client</string>
<key>CFBundleIconFile</key> <key>CFBundleIconFile</key>
<string>${ASSETCATALOG_COMPILER_APPICON_NAME}</string> <string>swiftlauncher.icns</string>
<key>CFBundleIdentifier</key> <key>CFBundleIdentifier</key>
<string>${PRODUCT_BUNDLE_IDENTIFIER}</string> <string>org.swift-project.swiftlauncher</string>
<key>CFBundlePackageType</key> <key>CFBundlePackageType</key>
<string>APPL</string> <string>APPL</string>
<key>CFBundleSignature</key> <key>CFBundleSignature</key>
<string>${QMAKE_PKGINFO_TYPEINFO}</string> <string>????</string>
<key>LSMinimumSystemVersion</key> <key>LSMinimumSystemVersion</key>
<string>${MACOSX_DEPLOYMENT_TARGET}</string> <string>10.13</string>
<key>NSPrincipalClass</key> <key>NSPrincipalClass</key>
<string>NSApplication</string> <string>NSApplication</string>
<key>NSSupportsAutomaticGraphicsSwitching</key> <key>NSSupportsAutomaticGraphicsSwitching</key>