Skip to content

Commit

Permalink
Merge branch 'release/0.6.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
kolesnick committed May 2, 2019
2 parents 41774a8 + 04a6984 commit 311bb55
Show file tree
Hide file tree
Showing 17 changed files with 595 additions and 61 deletions.
2 changes: 1 addition & 1 deletion nuspec/nuget/Cake.Unity.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<summary>Cake AddIn that extends Cake with ability to execute the Unity Editor as a command line utility.</summary>
<licenseUrl>https://github.com/cake-contrib/Cake.Unity/blob/master/LICENSE</licenseUrl>
<projectUrl>https://github.com/cake-contrib/Cake.Unity/</projectUrl>
<iconUrl>https://cdn.rawgit.com/cake-contrib/graphics/a5cf0f881c390650144b2243ae551d5b9f836196/png/cake-contrib-medium.png</iconUrl>
<iconUrl>https://cdn.jsdelivr.net/gh/cake-contrib/graphics/png/cake-contrib-medium.png</iconUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<copyright>Copyright (c) Cake Contributions 2014 - Present</copyright>
<tags>Cake, Script, Build, Unity</tags>
Expand Down
4 changes: 2 additions & 2 deletions setup.cake
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#load nuget:https://www.myget.org/F/cake-contrib/api/v2?package=Cake.Recipe&version=0.3.0-unstable0452&prerelease
#load nuget:?package=Cake.Recipe&version=1.0.0

Environment.SetVariableNames();

Expand All @@ -22,4 +22,4 @@ ToolSettings.SetToolSettings(context: Context,
testCoverageExcludeByAttribute: "*.ExcludeFromCodeCoverage*",
testCoverageExcludeByFile: "*/*Designer.cs;*/*.g.cs;*/*.g.i.cs");

Build.Run();
Build.RunDotNetCore();
16 changes: 2 additions & 14 deletions src/Cake.Unity.sln
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.28307.168
# Visual Studio Version 16
VisualStudioVersion = 16.0.28803.202
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Cake.Unity", "Cake.Unity\Cake.Unity.csproj", "{0222DDD2-3716-4E19-854F-EB36D04268D0}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Cake.Unity.Tests", "Cake.Unity.Tests\Cake.Unity.Tests.csproj", "{9AA57ADE-FA83-4162-9CAA-ED7C1219EED4}"
EndProject
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Cake.Unity.FSharp.Tests", "Cake.Unity.FSharp.Tests\Cake.Unity.FSharp.Tests.fsproj", "{240E476F-324F-4489-B7A9-98A8EBD28C2A}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -19,14 +15,6 @@ Global
{0222DDD2-3716-4E19-854F-EB36D04268D0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0222DDD2-3716-4E19-854F-EB36D04268D0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0222DDD2-3716-4E19-854F-EB36D04268D0}.Release|Any CPU.Build.0 = Release|Any CPU
{9AA57ADE-FA83-4162-9CAA-ED7C1219EED4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9AA57ADE-FA83-4162-9CAA-ED7C1219EED4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9AA57ADE-FA83-4162-9CAA-ED7C1219EED4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9AA57ADE-FA83-4162-9CAA-ED7C1219EED4}.Release|Any CPU.Build.0 = Release|Any CPU
{240E476F-324F-4489-B7A9-98A8EBD28C2A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{240E476F-324F-4489-B7A9-98A8EBD28C2A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{240E476F-324F-4489-B7A9-98A8EBD28C2A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{240E476F-324F-4489-B7A9-98A8EBD28C2A}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
39 changes: 39 additions & 0 deletions src/Cake.Unity/Arguments/AssetServerUpdate.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
namespace Cake.Unity.Arguments
{
public class AssetServerUpdate
{
public string IP { get; }
public int? Port { get; }
public string ProjectName { get; }
public string Username { get; }
public string Password { get; }
public string Revision { get; }

public AssetServerUpdate(string ip, string projectName, string userName, string password)
{
IP = ip;
ProjectName = projectName;
Username = userName;
Password = password;
}

public AssetServerUpdate(string ip, int port, string projectName, string userName, string password)
: this(ip, projectName, userName, password)
{
Port = port;
}

public AssetServerUpdate(string ip, string projectName, string userName, string password, string revision)
: this(ip, projectName, userName, password)
{
Revision = revision;
}

public AssetServerUpdate(string ip, int port, string projectName, string userName, string password, string revision)
: this(ip, projectName, userName, password)
{
Port = port;
Revision = revision;
}
}
}
12 changes: 12 additions & 0 deletions src/Cake.Unity/Arguments/DefaultPlatformTextureFormat.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
namespace Cake.Unity.Arguments
{
public enum DefaultPlatformTextureFormat
{
dxt,
pvrtc,
atc,
etc,
etc2,
astc
}
}
12 changes: 12 additions & 0 deletions src/Cake.Unity/Arguments/ExportPackage.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace Cake.Unity.Arguments
{
public class ExportPackage
{
public string[] AssetPaths { get; set; }
public string PackageName { get; set; }
}
}
21 changes: 21 additions & 0 deletions src/Cake.Unity/Arguments/ForceGLCore.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
namespace Cake.Unity.Arguments
{
public enum ForceGLCore
{
Auto = 0,
v32 = 32,
v33 = 33,
v40 = 40,
v41 = 41,
v42 = 42,
v43 = 43,
v44 = 44,
v45 = 45
}

internal static class ForceGLCoreExtension
{
public static string Render(this ForceGLCore version) =>
version == ForceGLCore.Auto ? "" : ((int) version).ToString();
}
}
16 changes: 16 additions & 0 deletions src/Cake.Unity/Arguments/ForceGLES.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
namespace Cake.Unity.Arguments
{
public enum ForceGLES
{
Auto = 0,
v30 = 30,
v31 = 31,
v32 = 32
}

internal static class ForceGLESExtension
{
public static string Render(this ForceGLES version) =>
version == ForceGLES.Auto ? "" : ((int)version).ToString();
}
}
9 changes: 9 additions & 0 deletions src/Cake.Unity/Arguments/StackTraceLogType.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace Cake.Unity.Arguments
{
public enum StackTraceLogType
{
None,
ScriptOnly,
Full
}
}
2 changes: 1 addition & 1 deletion src/Cake.Unity/Cake.Unity.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Cake.Core" Version="0.28.0" />
<PackageReference Include="Cake.Core" Version="0.33.0" PrivateAssets="All" />
<PackageReference Include="Microsoft.CSharp" Version="4.5.0" />
<PackageReference Include="System.ValueTuple" Version="4.5.0" />
</ItemGroup>
Expand Down
48 changes: 48 additions & 0 deletions src/Cake.Unity/SeekersOfEditors/OSXSeekerOfEditors.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
using System.Linq;
using System.Xml.Linq;
using Cake.Core;
using Cake.Core.Diagnostics;
using Cake.Core.IO;
using Cake.Unity.Version;

namespace Cake.Unity.SeekersOfEditors
{
internal class OSXSeekerOfEditors : SeekerOfEditors
{
public OSXSeekerOfEditors(ICakeEnvironment environment, IGlobber globber, ICakeLog log)
: base(environment, globber, log)
{ }

protected override string SearchPattern => "/Applications/**/Unity*.app/Contents/MacOS/Unity";

protected override UnityVersion DetermineVersion(FilePath editorPath)
{
log.Debug($"Determining version of Unity Editor at path {editorPath}...");

var version = UnityVersionFromInfoPlist(editorPath);

if (version == null)
{
log.Debug($"Can't find UnityVersion for {editorPath}");
return null;
}

var unityVersion = UnityVersion.Parse(version);

log.Debug($"Result Unity Editor version (full): {unityVersion}");
return unityVersion;
}

private static string UnityVersionFromInfoPlist(FilePath editorPath) =>
XElement
.Load(PlistPath(editorPath))
.Descendants()
.SkipWhile((element) => element.Value != "CFBundleVersion")
.Skip(1)
.FirstOrDefault()
?.Value;

private static string PlistPath(FilePath editorPath) =>
editorPath.FullPath.Replace("/MacOS/Unity", "/Info.plist");
}
}
59 changes: 59 additions & 0 deletions src/Cake.Unity/SeekersOfEditors/SeekerOfEditors.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Cake.Core;
using Cake.Core.Diagnostics;
using Cake.Core.IO;
using Cake.Unity.Version;

namespace Cake.Unity.SeekersOfEditors
{
internal abstract class SeekerOfEditors
{
protected readonly ICakeEnvironment environment;
private readonly IGlobber globber;
protected readonly ICakeLog log;

public static SeekerOfEditors GetSeeker(ICakeEnvironment environment, IGlobber globber, ICakeLog log)
{
if (environment.Platform.Family == PlatformFamily.Windows)
return new WindowsSeekerOfEditors(environment, globber, log);

if (environment.Platform.Family == PlatformFamily.OSX)
return new OSXSeekerOfEditors(environment, globber, log);

throw new NotSupportedException("Cannot locate Unity Editors. Only Windows and OSX platform is supported.");
}

protected SeekerOfEditors(ICakeEnvironment environment, IGlobber globber, ICakeLog log)
{
this.environment = environment;
this.globber = globber;
this.log = log;
}

public IReadOnlyCollection<UnityEditorDescriptor> Seek()
{
var searchPattern = SearchPattern;

log.Debug("Searching for available Unity Editors...");
log.Debug("Search pattern: {0}", searchPattern);
var candidates = globber.GetFiles(searchPattern).ToList();

log.Debug("Found {0} candidates.", candidates.Count);
log.Debug(string.Empty);

var editors =
from candidatePath in candidates
let version = DetermineVersion(candidatePath)
where version != null
select new UnityEditorDescriptor(version, candidatePath);

return editors.ToList();
}

protected abstract string SearchPattern { get; }

protected abstract UnityVersion DetermineVersion(FilePath editorPath);
}
}
Original file line number Diff line number Diff line change
@@ -1,50 +1,22 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics;
using System.Linq;
using Cake.Core;
using Cake.Core.Diagnostics;
using Cake.Core.IO;
using Cake.Unity.Version;

namespace Cake.Unity
namespace Cake.Unity.SeekersOfEditors
{
internal class SeekerOfEditors
internal class WindowsSeekerOfEditors : SeekerOfEditors
{
private readonly ICakeEnvironment environment;
private readonly IGlobber globber;
private readonly ICakeLog log;

public SeekerOfEditors(ICakeEnvironment environment, IGlobber globber, ICakeLog log)
{
this.environment = environment;
this.globber = globber;
this.log = log;
}
public WindowsSeekerOfEditors(ICakeEnvironment environment, IGlobber globber, ICakeLog log)
: base(environment, globber, log)
{ }

private string ProgramFiles => environment.GetSpecialPath(SpecialPath.ProgramFiles).FullPath;
protected override string SearchPattern => $"{ProgramFiles}/*Unity*/**/Editor/Unity.exe";

public IReadOnlyCollection<UnityEditorDescriptor> Seek()
{
var searchPattern = $"{ProgramFiles}/*Unity*/**/Editor/Unity.exe";

log.Debug("Searching for available Unity Editors...");
log.Debug("Search pattern: {0}", searchPattern);
var candidates = globber.GetFiles(searchPattern).ToList();

log.Debug("Found {0} candidates.", candidates.Count);
log.Debug(string.Empty);

var editors =
from candidatePath in candidates
let version = DetermineVersion(candidatePath)
where version != null
select new UnityEditorDescriptor(version, candidatePath);

return editors.ToList();
}

private UnityVersion DetermineVersion(FilePath editorPath)
protected override UnityVersion DetermineVersion(FilePath editorPath)
{
log.Debug("Determining version of Unity Editor at path {0}...", editorPath);

Expand Down
8 changes: 2 additions & 6 deletions src/Cake.Unity/UnityAliases.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using Cake.Core;
using Cake.Core.Annotations;
using Cake.Core.Diagnostics;
using Cake.Core.IO;
using Cake.Unity.Platforms;
using Cake.Unity.SeekersOfEditors;
using Cake.Unity.Version;
using static Cake.Core.PlatformFamily;
using static Cake.Unity.Version.UnityReleaseStage;

namespace Cake.Unity
Expand Down Expand Up @@ -334,9 +333,6 @@ select editor
[CakeNamespaceImport("Cake.Unity.Version")]
public static IReadOnlyCollection<UnityEditorDescriptor> FindUnityEditors(this ICakeContext context)
{
if (context.Environment.Platform.Family != Windows)
throw new NotSupportedException("Cannot locate Unity Editors. Only Windows platform is supported.");

if (unityEditorsCache != null)
{
context.Log.Debug("Already searched for Unity Editors. Using cached results.");
Expand All @@ -345,7 +341,7 @@ public static IReadOnlyCollection<UnityEditorDescriptor> FindUnityEditors(this I

return
unityEditorsCache =
new SeekerOfEditors(context.Environment, context.Globber, context.Log)
SeekerOfEditors.GetSeeker(context.Environment, context.Globber, context.Log)
.Seek();
}

Expand Down
Loading

0 comments on commit 311bb55

Please sign in to comment.