meson: disable swift when cocoa not available or disabled

it doesn't make sense to build the swift parts without cocoa because
the swift bridge would be missing and it's impossible to interact
with the swift parts from obj-c, swift depends on cocoa/appkit/etc, and
the cocoa main function/main loop is missing making anything
cocoa/appkit/GUI crash on use.

like this it is possible to build mpv on macOS without cocoa, it will
fallback to the unix main function and mpv can run in 'headless' mode,
eg you can use it from CLI, it won't spawn any App icon/menu/etc, and
you can use everything that isn't related to cocoa/appkit/GUI like audio
playback. anything other will make mpv segfault, for example sdl2 and
its vo, since it tries to spawn a window.
This commit is contained in:
der richter authored and Kacper Michajłow committed 2025-09-15 03:59:55 +02:00
1 parent b4151d4449
commit af4e4fed44
1 file changed
+6 -2
+6 -2
View File
@@ -1526,7 +1526,11 @@ if macos_sdk_version != '0.0'
add_project_link_arguments(objc_link_flags, language: ['c', 'objc'])
endif
xcrun = find_program('xcrun', required: get_option('swift-build').require(darwin))
swift = get_option('swift-build').require(
darwin and features['cocoa'],
error_message: 'cocoa was not found',
)
xcrun = find_program('xcrun', required: swift)
swift_ver = '0.0'
if xcrun.found()
swift_prog = find_program(run_command(xcrun, '-find', 'swiftc', check: true).stdout().strip())
@@ -1544,7 +1548,7 @@ sys.stdout.write(swift_ver)
endif
swift = get_option('swift-build').require(
darwin and macos_sdk_version.version_compare('>= 10.15') and swift_ver.version_compare('>= 4.1'),
swift.allowed() and macos_sdk_version.version_compare('>= 10.15') and swift_ver.version_compare('>= 4.1'),
error_message: 'A suitable macos sdk version or swift version could not be found!',
)
features += {'swift': swift.allowed()}