Skip to content

Commit d4f6265

Browse files
author
Stewart Miles
committed
Added support for Unity configured JDK Path.
Also, * Fixed VersionHandler build errors with Unity 5.5, due to the constantly changing BuildTarget enum. rather than requiring JAVA_HOME to be set in the Jar Resolver. * Fixed VersionHandler build when multiple versions of Unity are installed. BUG=33292471 Change-Id: Ie36ca053822db885a87eeeb4388e74acac9028f5
1 parent 66c36e1 commit d4f6265

24 files changed

+115
-68
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
# Version 1.2.7 - Dec 2, 2016
2+
## Bug Fixes
3+
* Fixed VersionHandler build errors with Unity 5.5, due to the constantly
4+
changing BuildTarget enum.
5+
* Added support for Unity configured JDK Path rather than requiring
6+
JAVA_HOME to be set in the Jar Resolver.
7+
18
# Version 1.2.6 - Nov 15, 2016
29
## Bug Fixes
310
* Fixed IOSResolver errors when iOS support is not installed.

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ project.ext {
138138
buildPath = file('build').absolutePath
139139
exportPath = file('build/plugin.unitypackage').absolutePath
140140
dllDir = 'Assets/PlayServicesResolver/Editor'
141-
pluginVersion = '1.2.6.0'
141+
pluginVersion = '1.2.7.0'
142142
currentPluginPath = file('.').absolutePath
143143
currentPluginBasename = 'play-services-resolver'
144144
currentPluginName = (currentPluginBasename + '-' + pluginVersion +

exploded/Assets/PlayServicesResolver/Editor.meta

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

exploded/Assets/PlayServicesResolver/Editor/Google.IOSResolver_v1.2.6.0.dll.meta renamed to exploded/Assets/PlayServicesResolver/Editor/Google.IOSResolver_v1.2.7.0.dll.meta

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

exploded/Assets/PlayServicesResolver/Editor/Google.JarResolver_v1.2.6.0.dll.meta renamed to exploded/Assets/PlayServicesResolver/Editor/Google.JarResolver_v1.2.7.0.dll.meta

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Binary file not shown.
Binary file not shown.

exploded/Assets/PlayServicesResolver/Editor/Google.VersionHandler_v1.2.6.0.dll.meta renamed to exploded/Assets/PlayServicesResolver/Editor/Google.VersionHandler_v1.2.7.0.dll.meta

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

exploded/Assets/PlayServicesResolver/Editor/play-services-resolver_v1.2.6.0.txt

Lines changed: 0 additions & 3 deletions
This file was deleted.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Assets/PlayServicesResolver/Editor/Google.IOSResolver_v1.2.7.0.dll
2+
Assets/PlayServicesResolver/Editor/Google.JarResolver_v1.2.7.0.dll
3+
Assets/PlayServicesResolver/Editor/Google.VersionHandler_v1.2.7.0.dll

exploded/Assets/PlayServicesResolver/Editor/play-services-resolver_v1.2.6.0.txt.meta renamed to exploded/Assets/PlayServicesResolver/Editor/play-services-resolver_v1.2.7.0.txt.meta

Lines changed: 1 addition & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
-41.8 KB
Binary file not shown.
44.5 KB
Binary file not shown.

plugin/Assets/PlayServicesResolver.meta

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

plugin/Assets/PlayServicesResolver/Editor.meta

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

plugin/Assets/PlayServicesResolver/Editor/Google.IOSResolver.dll.meta

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

plugin/Assets/PlayServicesResolver/Editor/Google.JarResolver.dll.meta

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

plugin/Assets/PlayServicesResolver/Editor/Google.VersionHandler.dll.meta

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

plugin/Assets/PlayServicesResolver/Editor/play-services-resolver.txt.meta

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

source/IOSResolver/IOSResolver.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@
4343
<HintPath>$(UnityHintPath)/UnityEngine.dll</HintPath>
4444
</Reference>
4545
<Reference Include="UnityEditor.iOS.Extensions.Xcode">
46-
<HintPath>$(UnityIosPath)/UnityEditor.iOS.Extensions.Xcode.dll</HintPath>
47-
<HintPath>$(UnityIosPath)/Unity.iOS.Extensions.Xcode.dll</HintPath>
46+
<HintPath Condition="Exists('$(UnityIosPath)/UnityEditor.iOS.Extensions.Xcode.dll')">$(UnityIosPath)/UnityEditor.iOS.Extensions.Xcode.dll</HintPath>
47+
<HintPath Condition="Exists('$(UnityIosPath)/Unity.iOS.Extensions.Xcode.dll')">$(UnityIosPath)/Unity.iOS.Extensions.Xcode.dll</HintPath>
4848
</Reference>
4949
<Reference Include="System" />
5050
<Reference Include="System.Core" />

source/PlayServicesResolver/src/DefaultResolver.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,8 @@ internal bool SupportsAarFiles
213213
/// <param name="toolName">Name of the tool to search for.</param>
214214
private string FindJavaTool(string javaTool)
215215
{
216-
string javaHome = Environment.GetEnvironmentVariable("JAVA_HOME");
216+
string javaHome = UnityEditor.EditorPrefs.GetString("JdkPath");
217+
javaHome = javaHome ?? Environment.GetEnvironmentVariable("JAVA_HOME");
217218
string toolPath;
218219
if (javaHome != null)
219220
{

source/VersionHandler/src/VersionHandler.cs

Lines changed: 86 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -82,39 +82,81 @@ public FilenameComponents(string filename) {
8282
private static string LABEL_PREFIX = "gvh_";
8383
// Initialized depending on the version of unity we are running against
8484
private static HashSet<BuildTarget> targetBlackList = null;
85+
// Initialized by parsing BuildTarget enumeration values from
86+
// BUILD_TARGET_NAME_TO_ENUM_NAME.
87+
private static Dictionary<string, BuildTarget>
88+
buildTargetNameToEnum = null;
8589

8690
/// <summary>
8791
/// Label which flags whether an asset is should be managed by this
8892
/// module.
8993
/// </summary>
9094
public static string ASSET_LABEL = "gvh";
9195

92-
// Map of build target names to BuildTarget enumeration values.
93-
static public Dictionary<string, BuildTarget>
94-
BUILD_TARGET_NAME_TO_ENUM = new Dictionary<string, BuildTarget> {
95-
{"osx", BuildTarget.StandaloneOSXUniversal},
96-
{"osxintel", BuildTarget.StandaloneOSXIntel},
97-
{"windows", BuildTarget.StandaloneWindows},
98-
{"ios", BuildTarget.iOS},
99-
{"ps3", BuildTarget.PS3},
100-
{"xbox360", BuildTarget.XBOX360},
101-
{"android", BuildTarget.Android},
102-
{"linux32", BuildTarget.StandaloneLinux},
103-
{"windows64", BuildTarget.StandaloneWindows64},
104-
{"webgl", BuildTarget.WebGL},
105-
{"linux64", BuildTarget.StandaloneLinux64},
106-
{"linux", BuildTarget.StandaloneLinuxUniversal},
107-
{"osxintel64", BuildTarget.StandaloneOSXIntel64},
108-
{"tizen", BuildTarget.Tizen},
109-
{"psp2", BuildTarget.PSP2},
110-
{"ps4", BuildTarget.PS4},
111-
{"xboxone", BuildTarget.XboxOne},
112-
{"samsungtv", BuildTarget.SamsungTV},
113-
{"nintendo3ds", BuildTarget.Nintendo3DS},
114-
{"wiiu", BuildTarget.WiiU},
115-
{"tvos", BuildTarget.tvOS},
96+
// Map of build target names to BuildTarget enumeration names.
97+
// We don't use BuildTarget enumeration values here as Unity has a
98+
// habit of removing unsupported ones from the API.
99+
static public Dictionary<string, string>
100+
BUILD_TARGET_NAME_TO_ENUM_NAME = new Dictionary<string, string> {
101+
{"osx", "StandaloneOSXUniversal"},
102+
{"osxintel", "StandaloneOSXIntel"},
103+
{"windows", "StandaloneWindows"},
104+
{"ios", "iOS"},
105+
{"ps3", "PS3"},
106+
{"xbox360", "XBOX360"},
107+
{"android", "Android"},
108+
{"linux32", "StandaloneLinux"},
109+
{"windows64", "StandaloneWindows64"},
110+
{"webgl", "WebGL"},
111+
{"linux64", "StandaloneLinux64"},
112+
{"linux", "StandaloneLinuxUniversal"},
113+
{"osxintel64", "StandaloneOSXIntel64"},
114+
{"tizen", "Tizen"},
115+
{"psp2", "PSP2"},
116+
{"ps4", "PS4"},
117+
{"xboxone", "XboxOne"},
118+
{"samsungtv", "SamsungTV"},
119+
{"nintendo3ds", "Nintendo3DS"},
120+
{"wiiu", "WiiU"},
121+
{"tvos", "tvOS"},
116122
};
117123

124+
/// <summary>
125+
/// Get a set of build target names mapped to supported BuildTarget
126+
/// enumeration values.
127+
/// </summary>
128+
internal static Dictionary<string, BuildTarget> GetBuildTargetNameToEnum() {
129+
if (buildTargetNameToEnum == null) {
130+
var targetBlackList = GetBlackList();
131+
buildTargetNameToEnum =
132+
new Dictionary<string, BuildTarget>();
133+
foreach (var targetNameEnumName in
134+
BUILD_TARGET_NAME_TO_ENUM_NAME) {
135+
// Attempt to parse the build target name.
136+
// ArgumentException, OverflowException or
137+
// TypeInitializationException
138+
// will be thrown if the build target is no longer
139+
// supported.
140+
BuildTarget target;
141+
try {
142+
target = (BuildTarget)Enum.Parse(
143+
typeof(BuildTarget), targetNameEnumName.Value);
144+
} catch (ArgumentException) {
145+
continue;
146+
} catch (OverflowException) {
147+
continue;
148+
} catch (TypeInitializationException) {
149+
continue;
150+
}
151+
if (!targetBlackList.Contains(target)) {
152+
buildTargetNameToEnum[targetNameEnumName.Key] =
153+
target;
154+
}
155+
}
156+
}
157+
return buildTargetNameToEnum;
158+
}
159+
118160
// Returns the major/minor version of the unity environment we are running in
119161
// as a float so it can be compared numerically.
120162
static float GetUnityVersionMajorMinor() {
@@ -133,6 +175,11 @@ static float GetUnityVersionMajorMinor() {
133175

134176
// Returns a hashset containing blacklisted build targets for the current
135177
// unity environment.
178+
// We need to maintain a seperate blacklist as Unity occasionally
179+
// removes BuildTarget display names but does not remove the enumeration
180+
// values associated with the names. This causes a fatal error in
181+
// PluginImporter.GetCompatibleWithPlatform() when provided with a
182+
// BuildTarget that no longer has a display name.
136183
static HashSet<BuildTarget> GetBlackList() {
137184
if (targetBlackList == null) {
138185
targetBlackList = new HashSet<BuildTarget>();
@@ -144,11 +191,6 @@ static HashSet<BuildTarget> GetBlackList() {
144191
return targetBlackList;
145192
}
146193

147-
// Returns true if the given target is supported by the current environment.
148-
internal static bool IsTargetSupportedByUnity(BuildTarget target) {
149-
return !GetBlackList().Contains(target);
150-
}
151-
152194
/// <summary>
153195
/// Name of the file use to construct this object.
154196
/// </summary>
@@ -285,11 +327,11 @@ public bool GetEditorEnabled() {
285327
/// </returns>
286328
public HashSet<BuildTarget> GetBuildTargets() {
287329
HashSet<BuildTarget> buildTargetSet = new HashSet<BuildTarget>();
330+
var buildTargetToEnum = GetBuildTargetNameToEnum();
288331
if (targets != null) {
289332
foreach (string target in targets) {
290333
BuildTarget buildTarget;
291-
if (BUILD_TARGET_NAME_TO_ENUM.TryGetValue(
292-
target, out buildTarget)) {
334+
if (buildTargetToEnum.TryGetValue(target, out buildTarget)) {
293335
buildTargetSet.Add(buildTarget);
294336
} else if (!target.Equals("editor")) {
295337
UnityEngine.Debug.LogError(
@@ -577,23 +619,21 @@ public bool EnableMostRecentPlugins() {
577619
modifiedThisVersion = true;
578620
}
579621
foreach (BuildTarget target in
580-
FileMetadata.BUILD_TARGET_NAME_TO_ENUM.Values) {
581-
if (FileMetadata.IsTargetSupportedByUnity(target)) {
582-
bool enabled = selectedTargets != null &&
583-
selectedTargets.Contains(target);
584-
try {
585-
if (pluginImporter.GetCompatibleWithPlatform(target) !=
586-
enabled) {
587-
pluginImporter.SetCompatibleWithPlatform(
588-
target, enabled);
589-
modifiedThisVersion = true;
590-
}
591-
}
592-
catch(Exception e) {
593-
UnityEngine.Debug.LogWarning(
594-
"Unexpected error enumerating targets: " + e.Message);
622+
FileMetadata.GetBuildTargetNameToEnum().Values) {
623+
bool enabled = selectedTargets != null &&
624+
selectedTargets.Contains(target);
625+
try {
626+
if (pluginImporter.GetCompatibleWithPlatform(target) !=
627+
enabled) {
628+
pluginImporter.SetCompatibleWithPlatform(
629+
target, enabled);
630+
modifiedThisVersion = true;
595631
}
596632
}
633+
catch(Exception e) {
634+
UnityEngine.Debug.LogWarning(
635+
"Unexpected error enumerating targets: " + e.Message);
636+
}
597637
}
598638
if (modifiedThisVersion) {
599639
pluginImporter.SaveAndReimport();

0 commit comments

Comments
 (0)