Skip to content

Commit

Permalink
Build MacOS executables as bundles
Browse files Browse the repository at this point in the history
  • Loading branch information
ltoenning committed Nov 21, 2023
1 parent 29b05b7 commit aede5cb
Show file tree
Hide file tree
Showing 10 changed files with 85 additions and 29 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ if(SWIFT_USE_CRASHPAD)
endif()

if(APPLE)
set(CMAKE_INSTALL_RPATH @loader_path/../lib)
set(CMAKE_INSTALL_RPATH @loader_path/../../../../lib)
elseif(UNIX)
set(CMAKE_INSTALL_RPATH \$ORIGIN/../lib)
endif()
Expand Down
16 changes: 12 additions & 4 deletions scripts/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -384,11 +384,14 @@ def _should_create_symbols(self):
return True

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 = [
"bin/swiftcore",
"bin/swiftdata",
"bin/swiftguistd",
"bin/swiftlauncher",
"lib/libcore.dylib",
"lib/libgui.dylib",
"lib/libinput.dylib",
Expand All @@ -405,6 +408,11 @@ def _strip_debug(self):
"xswiftbus/64/mac.xpl",
]
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:
subprocess.check_call(["dsymutil", path.join(dist_path, file)], env=dict(os.environ))

Expand Down
14 changes: 13 additions & 1 deletion src/swiftcore/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,22 @@ target_link_libraries(swiftcore
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)

if(WIN32)
add_dependencies(swiftcore copy_externals_to_build_dir)
endif()

install(TARGETS swiftcore)
if(APPLE)
install(TARGETS swiftcore BUNDLE DESTINATION bin)
else()
install(TARGETS swiftcore)
endif()
10 changes: 5 additions & 5 deletions src/swiftcore/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@
<key>CFBundleDisplayName</key>
<string>swift core</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<string>swiftcore</string>
<key>CFBundleGetInfoString</key>
<string>swift project - free and open source pilot client</string>
<key>CFBundleIconFile</key>
<string>${ASSETCATALOG_COMPILER_APPICON_NAME}</string>
<string>swiftcore.icns</string>
<key>CFBundleIdentifier</key>
<string>${PRODUCT_BUNDLE_IDENTIFIER}</string>
<string>org.swift-project.swiftcore</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleSignature</key>
<string>${QMAKE_PKGINFO_TYPEINFO}</string>
<string>????</string>
<key>LSMinimumSystemVersion</key>
<string>${MACOSX_DEPLOYMENT_TARGET}</string>
<string>10.13</string>
<key>NSPrincipalClass</key>
<string>NSApplication</string>
<key>NSSupportsAutomaticGraphicsSwitching</key>
Expand Down
14 changes: 13 additions & 1 deletion src/swiftdata/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,22 @@ target_link_libraries(swiftdata
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)

if(WIN32)
add_dependencies(swiftdata copy_externals_to_build_dir)
endif()

install(TARGETS swiftdata)
if(APPLE)
install(TARGETS swiftdata BUNDLE DESTINATION bin)
else()
install(TARGETS swiftdata)
endif()
10 changes: 5 additions & 5 deletions src/swiftdata/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@
<key>CFBundleDisplayName</key>
<string>swift data</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<string>swiftdata</string>
<key>CFBundleGetInfoString</key>
<string>swift project - free and open source pilot client</string>
<key>CFBundleIconFile</key>
<string>${ASSETCATALOG_COMPILER_APPICON_NAME}</string>
<string>swiftdata.icns</string>
<key>CFBundleIdentifier</key>
<string>${PRODUCT_BUNDLE_IDENTIFIER}</string>
<string>org.swift-project.swiftdata</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleSignature</key>
<string>${QMAKE_PKGINFO_TYPEINFO}</string>
<string>????</string>
<key>LSMinimumSystemVersion</key>
<string>${MACOSX_DEPLOYMENT_TARGET}</string>
<string>10.13</string>
<key>NSPrincipalClass</key>
<string>NSApplication</string>
<key>NSSupportsAutomaticGraphicsSwitching</key>
Expand Down
14 changes: 13 additions & 1 deletion src/swiftguistandard/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,22 @@ target_link_libraries(swiftguistd
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)

if(WIN32)
add_dependencies(swiftguistd copy_externals_to_build_dir)
endif()

install(TARGETS swiftguistd)
if(APPLE)
install(TARGETS swiftguistd BUNDLE DESTINATION bin)
else()
install(TARGETS swiftguistd)
endif()
10 changes: 5 additions & 5 deletions src/swiftguistandard/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@
<key>CFBundleDisplayName</key>
<string>swift gui</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<string>swiftguistd</string>
<key>CFBundleGetInfoString</key>
<string>swift project - free and open source pilot client</string>
<key>CFBundleIconFile</key>
<string>${ASSETCATALOG_COMPILER_APPICON_NAME}</string>
<string>swift.icns</string>
<key>CFBundleIdentifier</key>
<string>${PRODUCT_BUNDLE_IDENTIFIER}</string>
<string>org.swift-project.swiftguistd</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleSignature</key>
<string>${QMAKE_PKGINFO_TYPEINFO}</string>
<string>????</string>
<key>LSMinimumSystemVersion</key>
<string>${MACOSX_DEPLOYMENT_TARGET}</string>
<string>10.13</string>
<key>NSPrincipalClass</key>
<string>NSApplication</string>
<key>NSSupportsAutomaticGraphicsSwitching</key>
Expand Down
14 changes: 13 additions & 1 deletion src/swiftlauncher/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,22 @@ target_link_libraries(swiftlauncher
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)

if(WIN32)
add_dependencies(swiftlauncher copy_externals_to_build_dir)
endif()

install(TARGETS swiftlauncher)
if(APPLE)
install(TARGETS swiftlauncher BUNDLE DESTINATION bin)
else()
install(TARGETS swiftlauncher)
endif()
10 changes: 5 additions & 5 deletions src/swiftlauncher/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@
<key>CFBundleDisplayName</key>
<string>swift launcher</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<string>swiftlauncher</string>
<key>CFBundleGetInfoString</key>
<string>swift project - free and open source pilot client</string>
<key>CFBundleIconFile</key>
<string>${ASSETCATALOG_COMPILER_APPICON_NAME}</string>
<string>swiftlauncher.icns</string>
<key>CFBundleIdentifier</key>
<string>${PRODUCT_BUNDLE_IDENTIFIER}</string>
<string>org.swift-project.swiftlauncher</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleSignature</key>
<string>${QMAKE_PKGINFO_TYPEINFO}</string>
<string>????</string>
<key>LSMinimumSystemVersion</key>
<string>${MACOSX_DEPLOYMENT_TARGET}</string>
<string>10.13</string>
<key>NSPrincipalClass</key>
<string>NSApplication</string>
<key>NSSupportsAutomaticGraphicsSwitching</key>
Expand Down

0 comments on commit aede5cb

Please sign in to comment.