Skip to content

Commit e5f9ed5

Browse files
committed
Add basic support for tvOS
1 parent 88c045b commit e5f9ed5

File tree

12 files changed

+232
-10
lines changed

12 files changed

+232
-10
lines changed

modules/xcode/tests/test_xcode_project.lua

+171
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,19 @@
256256
end
257257

258258

259+
function suite.PBXFileReference_ListsTVOSWindowedTarget()
260+
_TARGET_OS = "tvos"
261+
kind "WindowedApp"
262+
prepare()
263+
xcode.PBXFileReference(tr)
264+
test.capture [[
265+
/* Begin PBXFileReference section */
266+
E5FB9875FD0E33A7ED2A2EB5 /* MyProject.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; name = MyProject.app; path = MyProject.app; sourceTree = BUILT_PRODUCTS_DIR; };
267+
/* End PBXFileReference section */
268+
]]
269+
end
270+
271+
259272
function suite.PBXFileReference_ListsStaticLibTarget()
260273
kind "StaticLib"
261274
prepare()
@@ -281,6 +294,19 @@
281294
end
282295

283296

297+
function suite.PBXFileReference_ListsTVOSStaticLibTarget()
298+
_TARGET_OS = "tvos"
299+
kind "StaticLib"
300+
prepare()
301+
xcode.PBXFileReference(tr)
302+
test.capture [[
303+
/* Begin PBXFileReference section */
304+
FDCF31ACF735331EEAD08FEC /* libMyProject.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; name = libMyProject.a; path = libMyProject.a; sourceTree = BUILT_PRODUCTS_DIR; };
305+
/* End PBXFileReference section */
306+
]]
307+
end
308+
309+
284310
function suite.PBXFileReference_ListsSharedLibTarget()
285311
kind "SharedLib"
286312
prepare()
@@ -306,6 +332,19 @@
306332
end
307333

308334

335+
function suite.PBXFileReference_ListsTVOSSharedLibTarget()
336+
_TARGET_OS = "tvos"
337+
kind "SharedLib"
338+
prepare()
339+
xcode.PBXFileReference(tr)
340+
test.capture [[
341+
/* Begin PBXFileReference section */
342+
2781AF7F7E0F19F156882DBF /* libMyProject.dylib */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.dylib"; includeInIndex = 0; name = libMyProject.dylib; path = libMyProject.dylib; sourceTree = BUILT_PRODUCTS_DIR; };
343+
/* End PBXFileReference section */
344+
]]
345+
end
346+
347+
309348
function suite.PBXFileReference_ListsOSXBundleTarget()
310349
kind "SharedLib"
311350
sharedlibtype "OSXBundle"
@@ -332,6 +371,19 @@
332371
]]
333372
end
334373

374+
function suite.PBXFileReference_ListsTVOSOSXBundleTarget()
375+
_TARGET_OS = "tvos"
376+
kind "SharedLib"
377+
sharedlibtype "OSXBundle"
378+
prepare()
379+
xcode.PBXFileReference(tr)
380+
test.capture [[
381+
/* Begin PBXFileReference section */
382+
8AD066EE75BC8CE0BDA2552E /* MyProject.bundle */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; name = MyProject.bundle; path = MyProject.bundle; sourceTree = BUILT_PRODUCTS_DIR; };
383+
/* End PBXFileReference section */
384+
]]
385+
end
386+
335387
function suite.PBXFileReference_ListsXCTestTarget()
336388
kind "SharedLib"
337389
sharedlibtype "XCTest"
@@ -357,6 +409,19 @@
357409
]]
358410
end
359411

412+
function suite.PBXFileReference_ListsTVOSXCTestTarget()
413+
_TARGET_OS = "tvos"
414+
kind "SharedLib"
415+
sharedlibtype "XCTest"
416+
prepare()
417+
xcode.PBXFileReference(tr)
418+
test.capture [[
419+
/* Begin PBXFileReference section */
420+
F573990FE05FBF012845874F /* MyProject.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; name = MyProject.xctest; path = MyProject.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
421+
/* End PBXFileReference section */
422+
]]
423+
end
424+
360425
function suite.PBXFileReference_ListsOSXFrameworkTarget()
361426
kind "SharedLib"
362427
sharedlibtype "OSXFramework"
@@ -384,6 +449,19 @@
384449
end
385450

386451

452+
function suite.PBXFileReference_ListsTVOSOSXFrameworkTarget()
453+
_TARGET_OS = "tvos"
454+
kind "SharedLib"
455+
sharedlibtype "OSXFramework"
456+
prepare()
457+
xcode.PBXFileReference(tr)
458+
test.capture [[
459+
/* Begin PBXFileReference section */
460+
2D914F2255CC07D43D679562 /* MyProject.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; name = MyProject.framework; path = MyProject.framework; sourceTree = BUILT_PRODUCTS_DIR; };
461+
/* End PBXFileReference section */
462+
]]
463+
end
464+
387465

388466
function suite.PBXFileReference_ListsSourceFiles()
389467
files { "source.c" }
@@ -2238,6 +2316,99 @@
22382316
]]
22392317
end
22402318

2319+
function suite.XCBuildConfigurationTarget_OnTVOS()
2320+
_TARGET_OS = "tvos"
2321+
prepare()
2322+
xcode.XCBuildConfiguration_Target(tr, tr.products.children[1], tr.configs[1])
2323+
test.capture [[
2324+
FDC4CBFB4635B02D8AD4823B /* Debug */ = {
2325+
isa = XCBuildConfiguration;
2326+
buildSettings = {
2327+
ALWAYS_SEARCH_USER_PATHS = NO;
2328+
"CODE_SIGN_IDENTITY[sdk=appletvos*]" = "Apple Developer";
2329+
CONFIGURATION_BUILD_DIR = bin/Debug;
2330+
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
2331+
GCC_DYNAMIC_NO_PIC = NO;
2332+
INSTALL_PATH = /usr/local/bin;
2333+
PRODUCT_NAME = MyProject;
2334+
SDKROOT = appletvos;
2335+
};
2336+
name = Debug;
2337+
};
2338+
]]
2339+
end
2340+
2341+
function suite.XCBuildConfigurationTarget_OnTVOSMinVersion()
2342+
_TARGET_OS = "tvos"
2343+
systemversion "8.3"
2344+
prepare()
2345+
xcode.XCBuildConfiguration_Target(tr, tr.products.children[1], tr.configs[1])
2346+
test.capture [[
2347+
FDC4CBFB4635B02D8AD4823B /* Debug */ = {
2348+
isa = XCBuildConfiguration;
2349+
buildSettings = {
2350+
ALWAYS_SEARCH_USER_PATHS = NO;
2351+
"CODE_SIGN_IDENTITY[sdk=appletvos*]" = "Apple Developer";
2352+
CONFIGURATION_BUILD_DIR = bin/Debug;
2353+
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
2354+
GCC_DYNAMIC_NO_PIC = NO;
2355+
INSTALL_PATH = /usr/local/bin;
2356+
PRODUCT_NAME = MyProject;
2357+
SDKROOT = appletvos;
2358+
TVOS_DEPLOYMENT_TARGET = 8.3;
2359+
};
2360+
name = Debug;
2361+
};
2362+
]]
2363+
end
2364+
2365+
function suite.XCBuildConfigurationTarget_OnTVOSMinMaxVersion()
2366+
_TARGET_OS = "tvos"
2367+
systemversion "8.3:9.1"
2368+
prepare()
2369+
xcode.XCBuildConfiguration_Target(tr, tr.products.children[1], tr.configs[1])
2370+
test.capture [[
2371+
FDC4CBFB4635B02D8AD4823B /* Debug */ = {
2372+
isa = XCBuildConfiguration;
2373+
buildSettings = {
2374+
ALWAYS_SEARCH_USER_PATHS = NO;
2375+
"CODE_SIGN_IDENTITY[sdk=appletvos*]" = "Apple Developer";
2376+
CONFIGURATION_BUILD_DIR = bin/Debug;
2377+
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
2378+
GCC_DYNAMIC_NO_PIC = NO;
2379+
INSTALL_PATH = /usr/local/bin;
2380+
PRODUCT_NAME = MyProject;
2381+
SDKROOT = appletvos;
2382+
TVOS_DEPLOYMENT_TARGET = 8.3;
2383+
};
2384+
name = Debug;
2385+
};
2386+
]]
2387+
end
2388+
2389+
function suite.XCBuildConfigurationTarget_OnTVOSCodeSigningIdentity()
2390+
_TARGET_OS = "tvos"
2391+
xcodecodesigningidentity "Premake Developers"
2392+
prepare()
2393+
xcode.XCBuildConfiguration_Target(tr, tr.products.children[1], tr.configs[1])
2394+
test.capture [[
2395+
FDC4CBFB4635B02D8AD4823B /* Debug */ = {
2396+
isa = XCBuildConfiguration;
2397+
buildSettings = {
2398+
ALWAYS_SEARCH_USER_PATHS = NO;
2399+
"CODE_SIGN_IDENTITY[sdk=appletvos*]" = "Premake Developers";
2400+
CONFIGURATION_BUILD_DIR = bin/Debug;
2401+
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
2402+
GCC_DYNAMIC_NO_PIC = NO;
2403+
INSTALL_PATH = /usr/local/bin;
2404+
PRODUCT_NAME = MyProject;
2405+
SDKROOT = appletvos;
2406+
};
2407+
name = Debug;
2408+
};
2409+
]]
2410+
end
2411+
22412412

22422413
---------------------------------------------------------------------------
22432414
-- XCBuildConfiguration_Project tests

modules/xcode/xcode_common.lua

+9
Original file line numberDiff line numberDiff line change
@@ -1341,6 +1341,15 @@
13411341
if family then
13421342
settings['TARGETED_DEVICE_FAMILY'] = family
13431343
end
1344+
elseif os.istarget(p.TVOS) then
1345+
settings['SDKROOT'] = 'appletvos'
1346+
1347+
settings['CODE_SIGN_IDENTITY[sdk=appletvos*]'] = cfg.xcodecodesigningidentity or 'Apple Developer'
1348+
1349+
local minOSVersion = project.systemversion(cfg)
1350+
if minOSVersion ~= nil then
1351+
settings['TVOS_DEPLOYMENT_TARGET'] = minOSVersion
1352+
end
13441353
else
13451354
local minOSVersion = project.systemversion(cfg)
13461355
if minOSVersion ~= nil then

src/_premake_init.lua

+2
Original file line numberDiff line numberDiff line change
@@ -855,6 +855,7 @@
855855
"linux",
856856
"macosx",
857857
"solaris",
858+
"tvos",
858859
"uwp",
859860
"wii",
860861
"windows",
@@ -1306,6 +1307,7 @@
13061307
{ "linux", "Linux" },
13071308
{ "macosx", "Apple Mac OS X" },
13081309
{ "solaris", "Solaris" },
1310+
{ "tvos", "tvOS" },
13091311
{ "uwp", "Microsoft Universal Windows Platform"},
13101312
{ "windows", "Microsoft Windows" },
13111313
}

src/base/_foundation.lua

+1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
premake.ANDROID = "android"
3737
premake.EMSCRIPTEN = "emscripten"
3838
premake.IOS = "ios"
39+
premake.TVOS = "tvos"
3940
premake.LINUX = "linux"
4041
premake.MACOSX = "macosx"
4142
premake.MAKEFILE = "Makefile"

src/base/os.lua

+1
Original file line numberDiff line numberDiff line change
@@ -834,6 +834,7 @@
834834
["linux"] = { "linux", "posix", "desktop" },
835835
["macosx"] = { "macosx", "darwin", "posix", "desktop" },
836836
["solaris"] = { "solaris", "posix", "desktop" },
837+
["tvos"] = { "tvos", "darwin", "posix", "mobile" },
837838
["uwp"] = { "uwp", "windows", "desktop" },
838839
["windows"] = { "windows", "win32", "desktop" },
839840
}

src/tools/clang.lua

+7-2
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,15 @@
9595
function clang.getsystemversionflags(cfg)
9696
local flags = {}
9797

98-
if cfg.system == p.MACOSX or cfg.system == p.IOS then
98+
if cfg.system == p.MACOSX or cfg.system == p.IOS or cfg.system == p.TVOS then
9999
local minVersion = p.project.systemversion(cfg)
100100
if minVersion ~= nil then
101-
local name = iif(cfg.system == p.MACOSX, "macosx", "iphoneos")
101+
local name = "macosx"
102+
if cfg.system == p.IOS then
103+
name = "iphoneos"
104+
elseif cfg.system == p.TVOS then
105+
name = "appletvos"
106+
end
102107
table.insert (flags, "-m" .. name .. "-version-min=" .. p.project.systemversion(cfg))
103108
end
104109
end

tests/config/test_targetinfo.lua

+3-3
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@
220220

221221

222222
--
223-
-- Bundle path should be set for macOS/iOS cocoa bundle.
223+
-- Bundle path should be set for macOS/iOS/tvOS cocoa bundle.
224224
--
225225

226226
function suite.bundlepathSet_onMacSharedLibOSXBundle()
@@ -232,7 +232,7 @@
232232
end
233233

234234
--
235-
-- Bundle path should be set for macOS/iOS cocoa unit test bundle.
235+
-- Bundle path should be set for macOS/iOS/tvOS cocoa unit test bundle.
236236
--
237237

238238
function suite.bundlepathSet_onMacSharedLibXCTest()
@@ -245,7 +245,7 @@
245245

246246

247247
--
248-
-- Bundle path should be set for macOS/iOS framework.
248+
-- Bundle path should be set for macOS/iOS/tvOS framework.
249249
--
250250

251251
function suite.bundlepathSet_onMacSharedLibOSXFramework()

tests/tools/test_clang.lua

+18
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,24 @@
9090
test.contains({ "-miphoneos-version-min=5.0" }, clang.getcxxflags(cfg))
9191
end
9292

93+
--
94+
-- Check tvOS deployment target flags
95+
--
96+
97+
function suite.cflags_tvos_systemversion()
98+
system "tvOS"
99+
systemversion "12.1"
100+
prepare()
101+
test.contains({ "-mappletvos-version-min=12.1" }, clang.getcflags(cfg))
102+
end
103+
104+
function suite.cxxflags_tvos_systemversion()
105+
system "tvOS"
106+
systemversion "5.0"
107+
prepare()
108+
test.contains({ "-mappletvos-version-min=5.0" }, clang.getcxxflags(cfg))
109+
end
110+
93111
--
94112
-- Check handling of openmp.
95113
--

tests/tools/test_gcc.lua

+7
Original file line numberDiff line numberDiff line change
@@ -838,6 +838,13 @@
838838
test.contains("-F/Library/Frameworks", gcc.getincludedirs(cfg, {}, {}, cfg.frameworkdirs))
839839
end
840840

841+
function suite.includeDirs_tvos_onFrameworkDirs()
842+
system "tvOS"
843+
frameworkdirs { "/Library/Frameworks" }
844+
prepare()
845+
test.contains("-F/Library/Frameworks", gcc.getincludedirs(cfg, {}, {}, cfg.frameworkdirs))
846+
end
847+
841848

842849
--
843850
-- Check handling of linker flag.

website/docs/os/os.getSystemTags.md

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ and meta tags like `posix`, `darwin`, `desktop` and `mobile` tags.
1515
| linux | linux, posix, desktop |
1616
| macosx | macosx, darwin, posix, desktop |
1717
| solaris | solaris, posix, desktop |
18+
| tvos | tvos, darwin, posix, mobile |
1819
| uwp | uwp, windows, desktop |
1920
| windows | windows, win32, desktop |
2021

website/docs/system.md

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ If no system is specified, Premake will identify and target the current operatin
1919
* linux
2020
* macosx
2121
* solaris
22+
* tvos
2223
* uwp
2324
* wii
2425
* windows

0 commit comments

Comments
 (0)