Skip to content

Commit cce405a

Browse files
committed
Support tvOS
1 parent fe43537 commit cce405a

8 files changed

+65
-11
lines changed

cmake/CMakeLists.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -1812,8 +1812,8 @@ if (onnxruntime_USE_WINML)
18121812
endif() # if (onnxruntime_USE_WINML)
18131813

18141814
if (onnxruntime_BUILD_SHARED_LIB OR onnxruntime_BUILD_APPLE_FRAMEWORK)
1815-
if (onnxruntime_BUILD_APPLE_FRAMEWORK AND NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin|iOS|visionOS")
1816-
message(FATAL_ERROR "onnxruntime_BUILD_APPLE_FRAMEWORK can only be enabled for macOS or iOS or visionOS.")
1815+
if (onnxruntime_BUILD_APPLE_FRAMEWORK AND NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin|iOS|visionOS|tvOS")
1816+
message(FATAL_ERROR "onnxruntime_BUILD_APPLE_FRAMEWORK can only be enabled for macOS or iOS or visionOS or tvOS.")
18171817
endif()
18181818
list(APPEND ONNXRUNTIME_CMAKE_FILES onnxruntime)
18191819
endif()

cmake/adjust_global_compile_flags.cmake

+2-2
Original file line numberDiff line numberDiff line change
@@ -178,9 +178,9 @@ if (onnxruntime_CROSS_COMPILING)
178178
endif()
179179
endif()
180180

181-
# Mark symbols to be invisible, for macOS/iOS/visionOS target only
181+
# Mark symbols to be invisible, for macOS/iOS/visionOS/tvOS target only
182182
# Due to many dependencies have different symbol visibility settings, set global compile flags here.
183-
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin|iOS|visionOS")
183+
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin|iOS|visionOS|tvOS")
184184
foreach(flags CMAKE_CXX_FLAGS CMAKE_OBJC_FLAGS CMAKE_OBJCXX_FLAGS)
185185
string(APPEND ${flags} " -fvisibility=hidden -fvisibility-inlines-hidden")
186186
endforeach()

cmake/onnxruntime_providers_cpu.cmake

+1-1
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ set_target_properties(onnxruntime_providers PROPERTIES LINKER_LANGUAGE CXX)
217217
set_target_properties(onnxruntime_providers PROPERTIES FOLDER "ONNXRuntime")
218218

219219
if (NOT onnxruntime_MINIMAL_BUILD AND NOT onnxruntime_EXTENDED_MINIMAL_BUILD
220-
AND NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin|iOS|visionOS"
220+
AND NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin|iOS|visionOS|tvOS"
221221
AND NOT CMAKE_SYSTEM_NAME STREQUAL "Android"
222222
AND NOT CMAKE_SYSTEM_NAME STREQUAL "Emscripten")
223223
file(GLOB onnxruntime_providers_shared_cc_srcs CONFIGURE_DEPENDS

cmake/onnxruntime_python.cmake

+1-1
Original file line numberDiff line numberDiff line change
@@ -725,7 +725,7 @@ if (onnxruntime_ENABLE_EXTERNAL_CUSTOM_OP_SCHEMAS)
725725
endif()
726726

727727
if (NOT onnxruntime_MINIMAL_BUILD AND NOT onnxruntime_EXTENDED_MINIMAL_BUILD
728-
AND NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin|iOS|visionOS"
728+
AND NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin|iOS|visionOS|tvOS"
729729
AND NOT CMAKE_SYSTEM_NAME STREQUAL "Android"
730730
AND NOT onnxruntime_USE_ROCM
731731
AND NOT CMAKE_SYSTEM_NAME STREQUAL "Emscripten")
+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Copyright (c) Microsoft Corporation. All rights reserved.
2+
# Licensed under the MIT License.
3+
4+
set(CMAKE_SYSTEM_NAME tvOS)
5+
set(CMAKE_SYSTEM_PROCESSOR arm64)
6+
7+
if (NOT DEFINED CMAKE_XCODE_ATTRIBUTE_DEVELOPMENT_TEAM AND NOT DEFINED CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY)
8+
set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_ALLOWED NO)
9+
endif()
10+
11+
SET(CMAKE_XCODE_ATTRIBUTE_CLANG_ENABLE_MODULES "YES")
12+
SET(CMAKE_XCODE_ATTRIBUTE_CLANG_ENABLE_OBJC_ARC "YES")

cmake/onnxruntime_unittests.cmake

+1-1
Original file line numberDiff line numberDiff line change
@@ -1843,7 +1843,7 @@ endif()
18431843

18441844
# limit to only test on windows first, due to a runtime path issue on linux
18451845
if (NOT onnxruntime_MINIMAL_BUILD AND NOT onnxruntime_EXTENDED_MINIMAL_BUILD
1846-
AND NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin|iOS|visionOS"
1846+
AND NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin|iOS|visionOS|tvOS"
18471847
AND NOT CMAKE_SYSTEM_NAME STREQUAL "Android"
18481848
AND NOT CMAKE_SYSTEM_NAME STREQUAL "Emscripten"
18491849
AND NOT onnxruntime_USE_ROCM)

tools/ci_build/build.py

+16-4
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,7 @@ def convert_arg_line_to_args(self, arg_line):
433433
platform_group = parser.add_mutually_exclusive_group()
434434
platform_group.add_argument("--ios", action="store_true", help="build for ios")
435435
platform_group.add_argument("--visionos", action="store_true", help="build for visionOS")
436+
platform_group.add_argument("--tvos", action="store_true", help="build for tvOS")
436437
platform_group.add_argument(
437438
"--macos",
438439
choices=["MacOSX", "Catalyst"],
@@ -452,6 +453,11 @@ def convert_arg_line_to_args(self, arg_line):
452453
default="",
453454
help="Path to visionos toolchain file, or cmake/onnxruntime_visionos.toolchain.cmake will be used",
454455
)
456+
parser.add_argument(
457+
"--tvos_toolchain_file",
458+
default="",
459+
help="Path to tvos toolchain file, or cmake/onnxruntime_tvos.toolchain.cmake will be used",
460+
)
455461
parser.add_argument(
456462
"--xcode_code_signing_team_id", default="", help="The development team ID used for code signing in Xcode"
457463
)
@@ -945,7 +951,7 @@ def use_dev_mode(args):
945951
return False
946952
if args.use_armnn:
947953
return False
948-
if (args.ios or args.visionos) and is_macOS():
954+
if (args.ios or args.visionos or args.tvos) and is_macOS():
949955
return False
950956
SYSTEM_COLLECTIONURI = os.getenv("SYSTEM_COLLECTIONURI") # noqa: N806
951957
if SYSTEM_COLLECTIONURI and SYSTEM_COLLECTIONURI != "https://dev.azure.com/onnxruntime/":
@@ -1617,12 +1623,12 @@ def generate_build_tree(
16171623
if args.use_snpe:
16181624
cmake_args += ["-Donnxruntime_USE_SNPE=ON"]
16191625

1620-
if args.macos or args.ios or args.visionos:
1626+
if args.macos or args.ios or args.visionos or args.tvos:
16211627
# Note: Xcode CMake generator doesn't have a good support for Mac Catalyst yet.
16221628
if args.macos == "Catalyst" and args.cmake_generator == "Xcode":
16231629
raise BuildError("Xcode CMake generator ('--cmake_generator Xcode') doesn't support Mac Catalyst build.")
16241630

1625-
if (args.ios or args.visionos or args.macos == "MacOSX") and not args.cmake_generator == "Xcode":
1631+
if (args.ios or args.visionos or args.tvos or args.macos == "MacOSX") and not args.cmake_generator == "Xcode":
16261632
raise BuildError(
16271633
"iOS/MacOS framework build requires use of the Xcode CMake generator ('--cmake_generator Xcode')."
16281634
)
@@ -1682,6 +1688,12 @@ def generate_build_tree(
16821688
),
16831689
"-Donnxruntime_ENABLE_CPUINFO=OFF",
16841690
]
1691+
if args.tvos:
1692+
cmake_args += [
1693+
"-DCMAKE_SYSTEM_NAME=tvOS",
1694+
"-DCMAKE_TOOLCHAIN_FILE="
1695+
+ (args.tvos_toolchain_file if args.tvos_toolchain_file else "../cmake/onnxruntime_tvos.toolchain.cmake"),
1696+
]
16851697

16861698
if args.build_wasm:
16871699
if not args.use_vcpkg:
@@ -3144,7 +3156,7 @@ def main():
31443156

31453157
if is_macOS():
31463158
if (
3147-
not (args.ios or args.visionos)
3159+
not (args.ios or args.visionos or args.tvos)
31483160
and args.macos != "Catalyst"
31493161
and not args.android
31503162
and args.osx_arch == "arm64"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"build_osx_archs": {
3+
"appletvos": [
4+
"arm64"
5+
],
6+
"appletvsimulator": [
7+
"arm64",
8+
"x86_64"
9+
]
10+
},
11+
"build_params": {
12+
"base": [
13+
"--parallel",
14+
"--build_apple_framework",
15+
"--use_coreml",
16+
"--skip_tests",
17+
"--cmake_extra_defines=onnxruntime_BUILD_UNIT_TESTS=OFF"
18+
],
19+
"appletvos": [
20+
"--tvos",
21+
"--use_xcode",
22+
"--apple_deploy_target=13.0"
23+
],
24+
"appletvsimulator": [
25+
"--tvos",
26+
"--use_xcode",
27+
"--apple_deploy_target=13.0"
28+
]
29+
}
30+
}

0 commit comments

Comments
 (0)