Skip to content

Commit 8a8e059

Browse files
authored
Merge pull request #540 from googlesamples/feature/tag_tvos_libs
Update export_unity_package.py with the ability to handle tvOS build targets.
2 parents 3387fc2 + 841ab8c commit 8a8e059

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

source/ExportUnityPackage/export_unity_package.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@
7272
# platforms including the editor.
7373
# * Android
7474
# * iOS
75+
# * tvOS
7576
"platforms": ["Editor", "Standalone", "Android", "iOS"],
7677
7778
# CPUs supported by standalone or editor platforms when the
@@ -404,6 +405,12 @@
404405
[("CompileFlags", None),
405406
("FrameworkDependencies", None)]))])
406407

408+
DEFAULT_PLATFORM_SETTINGS_DISABLED_TVOS = collections.OrderedDict(
409+
PLATFORM_SETTINGS_DISABLED +
410+
[("settings", collections.OrderedDict(
411+
[("CompileFlags", None),
412+
("FrameworkDependencies", None)]))])
413+
407414
PLUGIN_IMPORTER_METADATA_TEMPLATE = collections.OrderedDict(
408415
[("PluginImporter", collections.OrderedDict(
409416
[("serializedVersion", 1),
@@ -441,6 +448,8 @@
441448
DEFAULT_PLATFORM_SETTINGS_DISABLED)),
442449
("iOS", copy.deepcopy(
443450
DEFAULT_PLATFORM_SETTINGS_DISABLED_IOS)),
451+
("tvOS", copy.deepcopy(
452+
DEFAULT_PLATFORM_SETTINGS_DISABLED_TVOS)),
444453
]))
445454
] + DEFAULT_IMPORTER_DATA))
446455
])
@@ -465,6 +474,7 @@
465474
"Win64": "Standalone",
466475
"WindowsStoreApps": "Windows Store Apps",
467476
"iOS": "iPhone",
477+
"tvOS": "tvOS",
468478
}
469479

470480
# Alias for standalone platforms specified by the keys of
@@ -1755,6 +1765,7 @@ def importer_metadata(self):
17551765
elif importer_type == "PluginImporter":
17561766
platforms = set(safe_dict_get_value(
17571767
self._json, "platforms", default_value=["Editor", "Android", "iOS",
1768+
"tvOS",
17581769
STANDALONE_PLATFORM_ALIAS]))
17591770
cpu_string = safe_dict_get_value(self._json, "cpu",
17601771
default_value="AnyCPU")

source/ExportUnityPackage/export_unity_package_test.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1678,6 +1678,7 @@ def test_apply_any_platform_selection_serializationv1(self):
16781678
del platform_data["Win64"]
16791679
del platform_data["WindowsStoreApps"]
16801680
del platform_data["iOS"]
1681+
del platform_data["tvOS"]
16811682

16821683
expected_metadata = copy.deepcopy(
16831684
export_unity_package.PLUGIN_IMPORTER_METADATA_TEMPLATE)
@@ -1697,6 +1698,7 @@ def test_apply_any_platform_selection_serializationv1(self):
16971698
platform_data["Win64"]["enabled"] = 1
16981699
platform_data["WindowsStoreApps"]["enabled"] = 1
16991700
platform_data["iOS"]["enabled"] = 1
1701+
platform_data["tvOS"]["enabled"] = 1
17001702

17011703
all_platforms_enabled = (
17021704
export_unity_package.Asset.apply_any_platform_selection(
@@ -2051,6 +2053,15 @@ def test_importer_metadata_ios_only(self):
20512053
self.package, {"importer": "PluginImporter",
20522054
"platforms": ["iOS"]}).importer_metadata)
20532055

2056+
def test_importer_metadata_tvos_only(self):
2057+
"""Create metadata that only targets tvOS."""
2058+
self.plugin_metadata["PluginImporter"]["platformData"]["tvOS"]["enabled"] = 1
2059+
self.assertEqual(
2060+
self.plugin_metadata,
2061+
export_unity_package.AssetConfiguration(
2062+
self.package, {"importer": "PluginImporter",
2063+
"platforms": ["tvOS"]}).importer_metadata)
2064+
20542065
def test_importer_metadata_standalone_invalid_cpu(self):
20552066
"""Create metadata with an invalid CPU."""
20562067
with self.assertRaises(export_unity_package.ProjectConfigurationError):

0 commit comments

Comments
 (0)