[waf] add support for watchOS and watchSimulator
authorPaul Brossier <piem@piem.org>
Tue, 18 Nov 2025 10:12:46 +0000 (11:12 +0100)
committerPaul Brossier <piem@piem.org>
Tue, 18 Nov 2025 11:50:30 +0000 (12:50 +0100)
wscript

diff --git a/wscript b/wscript
index aeebaf6..715e612 100644 (file)
--- a/wscript
+++ b/wscript
@@ -258,11 +258,14 @@ def configure(ctx):
             ctx.msg('Checking for Accelerate framework', 'no (disabled)',
                     color = 'YELLOW')
 
-    if target_platform in [ 'ios', 'iosimulator', 'watchos', 'watchsimulator' ]:
+    if target_platform in [ 'ios', 'iosimulator', 'watchos', 'watchsimulator',
+                            'tvos', 'tvsimulator' ]:
         if target_platform in ['ios', 'iosimulator']:
             MINSDKVER="16.4"
         elif target_platform in ['watchos', 'watchsimulator']:
             MINSDKVER="8.0"
+        elif target_platform in ['tvos', 'tvsimulator']:
+            MINSDKVER="9.0"
         xcodeslct_output = subprocess.check_output (['xcode-select', '--print-path'])
         XCODEPATH = xcodeslct_output.decode(sys.stdout.encoding).strip()
         if target_platform == 'ios':
@@ -273,6 +276,10 @@ def configure(ctx):
             SDKNAME = "WatchOS"
         elif target_platform == 'watchsimulator':
             SDKNAME = "WatchSimulator"
+        elif target_platform == 'tvos':
+            SDKNAME = "AppleTVOS"
+        elif target_platform == 'tvsimulator':
+            SDKNAME = "AppleTVSimulator"
         else:
             raise ctx.errors.ConfigurationError ("Error: unknown target platform '"
                 + target_platform + "'")
@@ -314,6 +321,20 @@ def configure(ctx):
             ctx.env.LINKFLAGS += ['-arch', 'arm64']
             ctx.env.CFLAGS += [ '-mwatchsimulator-version-min=' + MINSDKVER ]
             ctx.env.LINKFLAGS += [ '-mwatchsimulator-version-min=' + MINSDKVER ]
+        elif target_platform == 'tvos':
+            ctx.env.CFLAGS += [ '-arch', 'arm64' ]
+            ctx.env.CFLAGS += [ '-arch', 'arm64e' ]
+            ctx.env.LINKFLAGS += ['-arch', 'arm64']
+            ctx.env.LINKFLAGS += ['-arch', 'arm64e']
+            ctx.env.CFLAGS += [ '-mtvos-version-min=' + MINSDKVER ]
+            ctx.env.LINKFLAGS += [ '-mtvos-version-min=' + MINSDKVER ]
+        elif target_platform == 'tvsimulator':
+            ctx.env.CFLAGS += [ '-arch', 'x86_64' ]
+            ctx.env.CFLAGS += [ '-arch', 'arm64' ]
+            ctx.env.LINKFLAGS += ['-arch', 'x86_64']
+            ctx.env.LINKFLAGS += ['-arch', 'arm64']
+            ctx.env.CFLAGS += [ '-mtvos-simulator-version-min=' + MINSDKVER ]
+            ctx.env.LINKFLAGS += [ '-mtvos-simulator-version-min=' + MINSDKVER ]
         ctx.env.CFLAGS += [ '-isysroot' , SDKROOT]
         ctx.env.LINKFLAGS += [ '-isysroot' , SDKROOT]
 
@@ -579,7 +600,8 @@ def build(bld):
     bld.recurse('src')
 
     # add sub directories
-    if bld.env['DEST_OS'] not in ['ios', 'iosimulator', 'watchos', 'watchsimulator', 'android']:
+    if bld.env['DEST_OS'] not in ['ios', 'iosimulator', 'watchos', 'watchsimulator',
+                'tvos', 'tvsimulator', 'android']:
         if bld.env['DEST_OS']=='emscripten' and not bld.options.testcmd:
             bld.options.testcmd = 'node %s'
         if bld.options.enable_examples: