2021-11-07 19:28:16 +00:00
|
|
|
# custom swift targets
|
2024-03-27 22:22:56 +00:00
|
|
|
bridge = join_paths(source_root, 'osdep/mac/app_bridge_objc.h')
|
2024-02-27 15:55:29 +00:00
|
|
|
header = join_paths(build_root, 'osdep/mac/swift.h')
|
|
|
|
module = join_paths(build_root, 'osdep/mac/swift.swiftmodule')
|
|
|
|
target = join_paths(build_root, 'osdep/mac/swift.o')
|
2021-11-07 19:28:16 +00:00
|
|
|
|
|
|
|
swift_flags = ['-frontend', '-c', '-sdk', macos_sdk_path,
|
|
|
|
'-enable-objc-interop', '-emit-objc-header', '-parse-as-library']
|
|
|
|
|
|
|
|
if swift_ver.version_compare('>=6.0')
|
|
|
|
swift_flags += ['-swift-version', '5']
|
|
|
|
endif
|
|
|
|
|
|
|
|
if get_option('debug')
|
|
|
|
swift_flags += '-g'
|
|
|
|
endif
|
|
|
|
|
|
|
|
if get_option('optimization') != '0'
|
|
|
|
swift_flags += '-O'
|
|
|
|
endif
|
|
|
|
|
2024-04-28 17:21:01 +00:00
|
|
|
if macos_11_features.allowed()
|
|
|
|
swift_flags += ['-D', 'HAVE_MACOS_11_FEATURES']
|
|
|
|
endif
|
|
|
|
|
|
|
|
if macos_12_features.allowed()
|
|
|
|
swift_flags += ['-D', 'HAVE_MACOS_12_FEATURES']
|
|
|
|
endif
|
|
|
|
|
2024-03-23 19:09:15 +00:00
|
|
|
if macos_cocoa_cb.allowed()
|
|
|
|
swift_flags += ['-D', 'HAVE_MACOS_COCOA_CB']
|
|
|
|
endif
|
|
|
|
|
2024-03-03 01:49:11 +00:00
|
|
|
if macos_touchbar.allowed()
|
|
|
|
swift_flags += ['-D', 'HAVE_MACOS_TOUCHBAR']
|
|
|
|
endif
|
|
|
|
|
2024-03-23 19:09:15 +00:00
|
|
|
if macos_media_player.allowed()
|
|
|
|
swift_flags += ['-D', 'HAVE_MACOS_MEDIA_PLAYER']
|
|
|
|
endif
|
|
|
|
|
2021-11-07 19:28:16 +00:00
|
|
|
extra_flags = get_option('swift-flags').split()
|
|
|
|
swift_flags += extra_flags
|
|
|
|
|
2024-02-27 15:55:29 +00:00
|
|
|
swift_compile = [swift_prog, swift_flags, '-module-name', 'swift',
|
2021-11-07 19:28:16 +00:00
|
|
|
'-emit-module-path', '@OUTPUT0@', '-import-objc-header', bridge,
|
|
|
|
'-emit-objc-header-path', '@OUTPUT1@', '-o', '@OUTPUT2@',
|
2023-11-27 20:58:38 +00:00
|
|
|
'@INPUT@', '-I.', '-I' + source_root,
|
|
|
|
'-I' + libplacebo.get_variable('includedir',
|
|
|
|
default_value: source_root / 'subprojects' / 'libplacebo' / 'src' / 'include')]
|
2021-11-07 19:28:16 +00:00
|
|
|
|
|
|
|
swift_targets = custom_target('swift_targets',
|
|
|
|
input: swift_sources,
|
2024-02-27 15:55:29 +00:00
|
|
|
output: ['swift.swiftmodule', 'swift.h', 'swift.o'],
|
2021-11-07 19:28:16 +00:00
|
|
|
command: swift_compile,
|
|
|
|
)
|
|
|
|
sources += swift_targets
|
|
|
|
|
|
|
|
swift_lib_dir_py = find_program(join_paths(tools_directory, 'macos-swift-lib-directory.py'))
|
|
|
|
swift_lib_dir = run_command(swift_lib_dir_py, swift_prog.full_path(), check: true).stdout()
|
|
|
|
message('Detected Swift library directory: ' + swift_lib_dir)
|
|
|
|
|
|
|
|
# linker flags
|
|
|
|
swift_link_flags = ['-L' + swift_lib_dir, '-Xlinker', '-rpath',
|
|
|
|
'-Xlinker', swift_lib_dir, '-rdynamic', '-Xlinker',
|
|
|
|
'-add_ast_path', '-Xlinker', module]
|
|
|
|
if swift_ver.version_compare('>=5.0')
|
|
|
|
swift_link_flags += ['-Xlinker', '-rpath', '-Xlinker',
|
|
|
|
'/usr/lib/swift', '-L/usr/lib/swift']
|
|
|
|
endif
|
|
|
|
add_project_link_arguments(swift_link_flags, language: ['c', 'objc'])
|