Skip to content

Commit

Permalink
Merge branch 'release/0.9.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
kolesnick committed May 17, 2022
2 parents 8e56327 + f2979af commit 4c11fcb
Show file tree
Hide file tree
Showing 10 changed files with 91 additions and 8 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
[Bb]uild/
*.sln.ide/
/src/.vs
/src/.idea

# Build related
tools/**
Expand Down
3 changes: 0 additions & 3 deletions nuspec/nuget/Cake.Unity.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,5 @@
<file src="netstandard2.0/Cake.Unity.dll" target="lib/netstandard2.0" />
<file src="netstandard2.0/Cake.Unity.pdb" target="lib/netstandard2.0" />
<file src="netstandard2.0/Cake.Unity.xml" target="lib/netstandard2.0" />
<file src="net46/Cake.Unity.dll" target="lib/net46" />
<file src="net46/Cake.Unity.pdb" target="lib/net46" />
<file src="net46/Cake.Unity.xml" target="lib/net46" />
</files>
</package>
3 changes: 3 additions & 0 deletions src/Cake.Unity.FSharp.Tests/Cake.Unity.FSharp.Tests.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
<TargetFramework>netcoreapp3.1</TargetFramework>
<IsPackable>false</IsPackable>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<RootNamespace>Cake.Unity.Tests</RootNamespace>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Cake.Core" Version="1.0.0" />
<PackageReference Include="Cake.Testing" Version="1.0.0" />
<PackageReference Include="FSharp.Interop.Dynamic" Version="4.0.3.130" />
<PackageReference Include="FsUnit" Version="3.4.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.10.0" />
Expand All @@ -18,6 +20,7 @@
<Compile Include="InfoPlistParserTests.fs" />
<Compile Include="UnityEditorArgumentsTests.fs" />
<Compile Include="UnityVersionTests.fs" />
<Compile Include="OSXSeekerOfEditorsTests.fs" />
</ItemGroup>

<ItemGroup>
Expand Down
28 changes: 28 additions & 0 deletions src/Cake.Unity.FSharp.Tests/OSXSeekerOfEditorsTests.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
module Cake.Unity.Tests.OSXSeekerOfEditorsTests

open Cake.Core
open Cake.Core.IO
open NUnit.Framework
open Cake.Unity.SeekersOfEditors
open Cake.Testing
open System.Runtime.InteropServices

let seek (seeker : OSXSeekerOfEditors) = seeker.Seek ()
let runningOnWindows = RuntimeInformation.IsOSPlatform OSPlatform.Windows

[<Test>]
let ``seek should not fail on real file system`` () =

if runningOnWindows then
Assert.Inconclusive ()

else
let environment = FakeEnvironment PlatformFamily.OSX
let fileSystem = FileSystem ()
let globber = Globber (fileSystem, environment)
let log = FakeLog ()

(environment, globber, log, fileSystem)
|> OSXSeekerOfEditors
|> seek
|> ignore
2 changes: 2 additions & 0 deletions src/Cake.Unity.sln.DotSettings
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:Boolean x:Key="/Default/UserDictionary/Words/=globber/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
3 changes: 3 additions & 0 deletions src/Cake.Unity/AssemblyAttributes.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
using System.Runtime.CompilerServices;

[assembly: InternalsVisibleTo("Cake.Unity.FSharp.Tests")]
2 changes: 1 addition & 1 deletion src/Cake.Unity/Cake.Unity.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard2.0;net46</TargetFrameworks>
<TargetFramework>netstandard2.0</TargetFramework>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<NoWarn>1591;1573</NoWarn>
Expand Down
48 changes: 48 additions & 0 deletions src/Cake.Unity/SeekersOfEditors/LinuxSeekerOfEditors.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
using Cake.Core;
using Cake.Core.Diagnostics;
using Cake.Core.IO;
using Cake.Unity.Version;
using System.Text.RegularExpressions;

namespace Cake.Unity.SeekersOfEditors
{
internal class LinuxSeekerOfEditors : SeekerOfEditors
{
private readonly IFileSystem fileSystem;
private readonly Regex VersionRegex = new Regex("(?<major>\\d+)\\.(?<minor>\\d+)\\.(?<patch>\\d+)(?<branch>\\w)(?<build>\\d+)");

public LinuxSeekerOfEditors(ICakeEnvironment environment, IGlobber globber, ICakeLog log, IFileSystem fileSystem)
: base(environment, globber, log)
{
this.fileSystem = fileSystem;
}

protected override string[] SearchPatterns => new[] {
"/home/*/Unity/Hub/Editor/*/Editor/Unity"
};

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

var versionMatch = VersionRegex.Match(editorPath.FullPath);

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

var major = int.Parse(versionMatch.Groups["major"].Value);
var minor = int.Parse(versionMatch.Groups["minor"].Value);
var patch = int.Parse(versionMatch.Groups["patch"].Value);
var branch = char.Parse(versionMatch.Groups["branch"].Value);
var build = int.Parse(versionMatch.Groups["build"].Value);

var unityVersion = new UnityVersion(major, minor, patch, branch, build);

log.Debug($"Result Unity Editor version (full): {unityVersion}");
return unityVersion;
}
}
}
4 changes: 1 addition & 3 deletions src/Cake.Unity/SeekersOfEditors/OSXSeekerOfEditors.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Xml.Linq;
using Cake.Core;
using Cake.Core.Diagnostics;
using Cake.Core.IO;
using Cake.Unity.Version;

[assembly: InternalsVisibleTo("Cake.Unity.FSharp.Tests")]
namespace Cake.Unity.SeekersOfEditors
{
internal class OSXSeekerOfEditors : SeekerOfEditors
Expand All @@ -20,7 +18,7 @@ public OSXSeekerOfEditors(ICakeEnvironment environment, IGlobber globber, ICakeL
this.fileSystem = fileSystem;
}

protected override string[] SearchPatterns => new[] {"/Applications/**/Unity*.app/Contents/MacOS/Unity"};
protected override string[] SearchPatterns => new[] {"/Applications/Unity/Hub/Editor/*/Unity.app/Contents/MacOS/Unity"};

protected override UnityVersion DetermineVersion(FilePath editorPath)
{
Expand Down
5 changes: 4 additions & 1 deletion src/Cake.Unity/SeekersOfEditors/SeekerOfEditors.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ public static SeekerOfEditors GetSeeker(ICakeEnvironment environment, IGlobber g
if (environment.Platform.Family == PlatformFamily.OSX)
return new OSXSeekerOfEditors(environment, globber, log, fileSystem);

throw new NotSupportedException("Cannot locate Unity Editors. Only Windows and OSX platform is supported.");
if (environment.Platform.Family == PlatformFamily.Linux)
return new LinuxSeekerOfEditors(environment, globber, log, fileSystem);

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

protected SeekerOfEditors(ICakeEnvironment environment, IGlobber globber, ICakeLog log)
Expand Down

0 comments on commit 4c11fcb

Please sign in to comment.