summaryrefslogtreecommitdiffstats
path: root/wscript_build.py
diff options
context:
space:
mode:
Diffstat (limited to 'wscript_build.py')
-rw-r--r--wscript_build.py37
1 files changed, 37 insertions, 0 deletions
diff --git a/wscript_build.py b/wscript_build.py
index b2d61cf0be..78db131beb 100644
--- a/wscript_build.py
+++ b/wscript_build.py
@@ -139,6 +139,42 @@ def build(ctx):
ctx(features = "ebml_header", target = "ebml_types.h")
ctx(features = "ebml_definitions", target = "ebml_defs.c")
+ def swift(task):
+ src = ' '.join([x.abspath() for x in task.inputs])
+ bridge = ctx.path.find_node("osdep/macOS_swift_bridge.h")
+ tgt = task.outputs[0].abspath()
+ header = task.outputs[1].abspath()
+ module = task.outputs[2].abspath()
+
+ cmd = ('%s %s -module-name macOS_swift -emit-module-path %s '
+ '-import-objc-header %s -emit-objc-header-path %s -o %s %s '
+ '-I. -I..') % (ctx.env.SWIFT, ctx.env.SWIFT_FLAGS, module,
+ bridge, header, tgt, src)
+ return task.exec_command(cmd)
+
+ if ctx.dependency_satisfied('macos-cocoa-cb'):
+ swift_source = [
+ ( "video/out/cocoa_cb_common.swift" ),
+ ( "video/out/cocoa-cb/window.swift" ),
+ ( "video/out/cocoa-cb/events_view.swift" ),
+ ( "video/out/cocoa-cb/video_layer.swift" ),
+ ( "osdep/macOS_mpv_helper.swift" )
+ ]
+
+ ctx(
+ rule = swift,
+ source = ctx.filtered_sources(swift_source),
+ target = ('osdep/macOS_swift.o '
+ 'osdep/macOS_swift.h '
+ 'osdep/macOS_swift.swiftmodule'),
+ before = 'c',
+ )
+
+ ctx.env.append_value('LINKFLAGS', [
+ '-Xlinker', '-add_ast_path',
+ '-Xlinker', '%s' % ctx.path.find_resource("osdep/macOS_swift.swiftmodule")
+ ])
+
if ctx.dependency_satisfied('cplayer'):
main_fn_c = ctx.pick_first_matching_dep([
( "osdep/main-fn-cocoa.c", "cocoa" ),
@@ -552,6 +588,7 @@ def build(ctx):
target = "mpv",
source = main_fn_c,
use = ctx.dependencies_use() + ['objects'],
+ add_object = "osdep/macOS_swift.o",
includes = _all_includes(ctx),
features = "c cprogram" + (" syms" if syms else ""),
export_symbols_def = "libmpv/mpv.def", # for syms=True