Aleks 10 лет назад
Родитель
Сommit
c5460c8b5c
2 измененных файлов с 78 добавлено и 1 удалено
  1. 1 1
      include/bx/platform.h
  2. 77 0
      scripts/toolchain.lua

+ 1 - 1
include/bx/platform.h

@@ -169,7 +169,7 @@
 #elif defined(__linux__)
 #	undef  BX_PLATFORM_LINUX
 #	define BX_PLATFORM_LINUX 1
-#elif defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__)
+#elif defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) || defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__)
 #	undef  BX_PLATFORM_IOS
 #	define BX_PLATFORM_IOS 1
 #elif defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__)

+ 77 - 0
scripts/toolchain.lua

@@ -25,6 +25,8 @@ function toolchain(_buildDir, _libDir)
 			{ "linux-arm-gcc",  "Linux (ARM, GCC compiler)"  },
 			{ "ios-arm",        "iOS - ARM"                  },
 			{ "ios-simulator",  "iOS - Simulator"            },
+			{ "tvOS-arm",       "tvOS - ARM"                 },
+			{ "tvOS-simulator", "tvOS - Simulator"           },
 			{ "mingw-gcc",      "MinGW"                      },
 			{ "mingw-clang",    "MinGW (clang compiler)"     },
 			{ "nacl",           "Native Client"              },
@@ -62,6 +64,7 @@ function toolchain(_buildDir, _libDir)
 		allowed = {
 			{ "osx", "OSX" },
 			{ "ios", "iOS" },
+			{ "tvos", "tvOS" },
 		}
 	}
 
@@ -77,6 +80,12 @@ function toolchain(_buildDir, _libDir)
 		description = "Set iOS target version (default: 8.0).",
 	}
 
+	newoption {
+		trigger = "with-tvos",
+		value   = "#",
+		description = "Set tvOS target version (default: 9.0).",
+	}
+
 	-- Avoid error when invoking genie --help.
 	if (_ACTION == nil) then return false end
 
@@ -96,6 +105,11 @@ function toolchain(_buildDir, _libDir)
 		iosPlatform = _OPTIONS["with-ios"]
 	end
 
+	local tvosPlatform = ""
+	if _OPTIONS["with-tvos"] then
+		tvosPlatform = _OPTIONS["with-tvos"]
+	end
+
 	if _ACTION == "gmake" then
 
 		if nil == _OPTIONS["gcc"] then
@@ -167,6 +181,18 @@ function toolchain(_buildDir, _libDir)
 			premake.gcc.ar  = "ar"
 			location (path.join(_buildDir, "projects", _ACTION .. "-ios-simulator"))
 
+		elseif "tvos-arm" == _OPTIONS["gcc"] then
+			premake.gcc.cc  = "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang"
+			premake.gcc.cxx = "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++"
+			premake.gcc.ar  = "ar"
+			location (path.join(_buildDir, "projects", _ACTION .. "-tvos-arm"))
+
+		elseif "tvos-simulator" == _OPTIONS["gcc"] then
+			premake.gcc.cc  = "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang"
+			premake.gcc.cxx = "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++"
+			premake.gcc.ar  = "ar"
+			location (path.join(_buildDir, "projects", _ACTION .. "-tvos-simulator"))
+
 		elseif "linux-gcc" == _OPTIONS["gcc"] then
 			location (path.join(_buildDir, "projects", _ACTION .. "-linux"))
 
@@ -343,6 +369,10 @@ function toolchain(_buildDir, _libDir)
 		elseif "ios" == _OPTIONS["xcode"] then
 			premake.xcode.toolset = "iphoneos"
 			location (path.join(_buildDir, "projects", _ACTION .. "-ios"))
+
+		elseif "tvos" == _OPTIONS["xcode"] then
+			premake.xcode.toolset = "appletvos"
+			location (path.join(_buildDir, "projects", _ACTION .. "-tvos"))
 		end
 	end
 
@@ -911,6 +941,53 @@ function toolchain(_buildDir, _libDir)
 			"--sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator" ..iosPlatform .. ".sdk",
 		}
 
+	configuration { "tvos*" }
+		linkoptions {
+			"-lc++",
+		}
+		buildoptions {
+			"-Wfatal-errors",
+			"-Wunused-value",
+			"-Wundef",
+		}
+		includedirs { path.join(bxDir, "include/compat/ios") }
+
+	configuration { "tvos-arm" }
+		targetdir (path.join(_buildDir, "tvos-arm/bin"))
+		objdir (path.join(_buildDir, "tvos-arm/obj"))
+		libdirs { path.join(_libDir, "lib/tvos-arm") }
+		linkoptions {
+			"-mtvos-version-min=9.0",
+			"-arch arm64",
+			"--sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS" ..tvosPlatform .. ".sdk",
+			"-L/Applications/Xcode.app/Contents/Developer/Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS" ..tvosPlatform .. ".sdk/usr/lib/system",
+			"-F/Applications/Xcode.app/Contents/Developer/Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS" ..tvosPlatform .. ".sdk/System/Library/Frameworks",
+			"-F/Applications/Xcode.app/Contents/Developer/Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS" ..tvosPlatform .. ".sdk/System/Library/PrivateFrameworks",
+		}
+		buildoptions {
+			"-mtvos-version-min=9.0",
+			"-arch arm64",
+			"--sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS" ..tvosPlatform .. ".sdk",
+		}
+
+	configuration { "tvos-simulator" }
+		targetdir (path.join(_buildDir, "tvos-simulator/bin"))
+		objdir (path.join(_buildDir, "tvos-simulator/obj"))
+		libdirs { path.join(_libDir, "lib/tvos-simulator") }
+		linkoptions {
+			"-mtvos-simulator-version-min=9.0",
+			"-arch i386",
+			"--sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/AppleTVSimulator.platform/Developer/SDKs/AppleTVSimulator" ..tvosPlatform .. ".sdk",
+			"-L/Applications/Xcode.app/Contents/Developer/Platforms/AppleTVSimulator.platform/Developer/SDKs/AppleTVSimulator" ..tvosPlatform .. ".sdk/usr/lib/system",
+			"-F/Applications/Xcode.app/Contents/Developer/Platforms/AppleTVSimulator.platform/Developer/SDKs/AppleTVSimulator" ..tvosPlatform .. ".sdk/System/Library/Frameworks",
+			"-F/Applications/Xcode.app/Contents/Developer/Platforms/AppleTVSimulator.platform/Developer/SDKs/AppleTVSimulator" ..tvosPlatform .. ".sdk/System/Library/PrivateFrameworks",
+		}
+		buildoptions {
+			"-mtvos-simulator-version-min=9.0",
+			"-arch i386",
+			"--sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/AppleTVSimulator.platform/Developer/SDKs/AppleTVSimulator" ..tvosPlatform .. ".sdk",
+		}
+
 	configuration { "ps4" }
 		targetdir (path.join(_buildDir, "ps4/bin"))
 		objdir (path.join(_buildDir, "ps4/obj"))