Skip to content

Commit ab760af

Browse files
authored
Merge pull request #6 from Unity-Technologies/processes
Fix schedulers for running processes, clean up tasks, and more
2 parents d6fbf47 + eff8642 commit ab760af

File tree

121 files changed

+7912
-1957
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

121 files changed

+7912
-1957
lines changed

LICENSE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
MIT License
22

33
Copyright (c) 2019 Unity Technologies
4-
Copyright (c) 2019 Andreia Gaita
4+
Copyright (c) 2016-2019 Andreia Gaita
55
Copyright (c) 2016-2018 GitHub
66

77
Permission is hereby granted, free of charge, to any person obtaining a copy

README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# About the Tasks package
2+
3+
Unity.Editor.Tasks is a TPL-based (Task Parallel Library, or System.Threading.Tasks) task management library.
4+
5+
This repository is a subset of the functionality in [Git for Unity](https://github.com/Unity-Technologies/Git-for-Unity) repository, specifically the `Threading`, `OutputProcessors`, `Tasks`, `Process` and `IO` directories, as well as various helper classes found in [](https://github.com/Unity-Technologies/Git-for-Unity/tree/master/src/com.unity.git.api/Api).
6+
7+
It's been split up for easier testing and consumption by the Git package and any other packages, libraries or apps that wish to use it.
8+
9+
10+
11+
## The History
12+
13+
This library was originally written because Unity's old Mono C# profile/compilers did not support TPL and async/await, the Git client really needs to run on controlled background threads with some sort of exclusive locking mechanism, without the uncertainty of explicit async/await calls, and I really didn't have the time or the inclination to teach modern .NET developers how to code for an ancient Mono version.
14+
15+
The next best thing was to code modern .NET and use a version of the TPL library backported to .NET 3.5 (the highest that Unity's old mono supports) to have it running in Unity 5.6 and up. The nice thing about modern .NET is that it's pretty much all syntactic sugar. Ancient Mono versions can run the code just fine, they just can't compile it.
16+
17+
These days, Unity supports modern .NET and can compile all this code just fine, so this library no longer ships with .NET 3.5 support, but it still maintains its separation from Unity - the projects don't reference Unity, and any Unity integration code in this library is behind a `#if UNITY_EDITOR` define, so you can safely consume the nuget packages in any .NET environment, and Unity-specific functionality will only be available when you consume this library as a package in a Unity project.
18+
19+
## License
20+
21+
**[MIT](LICENSE)**
22+
23+
Copyright (c) 2019 Unity Technologies
24+
Copyright (c) 2016-2019 Andreia Gaita
25+
Copyright (c) 2016-2018 GitHub

Unity.Editor.Tasks.sln

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "helpers", "helpers", "{93CD
1313
EndProject
1414
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestBase", "tests\Helpers\TestBase\TestBase.csproj", "{93F4BC16-1A50-4DB1-8FA3-78FCDB54B365}"
1515
EndProject
16+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Helper.CommandLine", "tests\Helpers\Helper.CommandLine\Helper.CommandLine.csproj", "{9A8F0974-A7AE-433B-8C49-5DBD30B0E479}"
17+
EndProject
1618
Global
1719
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1820
Debug|Any CPU = Debug|Any CPU
@@ -31,13 +33,18 @@ Global
3133
{93F4BC16-1A50-4DB1-8FA3-78FCDB54B365}.Debug|Any CPU.Build.0 = Debug|Any CPU
3234
{93F4BC16-1A50-4DB1-8FA3-78FCDB54B365}.Release|Any CPU.ActiveCfg = Release|Any CPU
3335
{93F4BC16-1A50-4DB1-8FA3-78FCDB54B365}.Release|Any CPU.Build.0 = Release|Any CPU
36+
{9A8F0974-A7AE-433B-8C49-5DBD30B0E479}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
37+
{9A8F0974-A7AE-433B-8C49-5DBD30B0E479}.Debug|Any CPU.Build.0 = Debug|Any CPU
38+
{9A8F0974-A7AE-433B-8C49-5DBD30B0E479}.Release|Any CPU.ActiveCfg = Release|Any CPU
39+
{9A8F0974-A7AE-433B-8C49-5DBD30B0E479}.Release|Any CPU.Build.0 = Release|Any CPU
3440
EndGlobalSection
3541
GlobalSection(SolutionProperties) = preSolution
3642
HideSolutionNode = FALSE
3743
EndGlobalSection
3844
GlobalSection(NestedProjects) = preSolution
3945
{452FEC2C-09AD-4FB5-965C-29D1FB872A4E} = {13E9D517-C9FB-4DBE-B4B2-10748698E27E}
4046
{93F4BC16-1A50-4DB1-8FA3-78FCDB54B365} = {93CD1CE7-1B0E-47A0-ADC3-F30702D65605}
47+
{9A8F0974-A7AE-433B-8C49-5DBD30B0E479} = {93CD1CE7-1B0E-47A0-ADC3-F30702D65605}
4148
EndGlobalSection
4249
GlobalSection(ExtensibilityGlobals) = postSolution
4350
SolutionGuid = {11F9BFE4-27A0-4CCF-A3C1-3683D75126A6}

common/packaging.targets

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,21 @@
66
<Import Project="packageversionfiles.targets" />
77

88
<ItemGroup>
9-
<PackageReference Include="SpoiledCat.MSBuild.Tasks.FileUpdate" Version="1.0.13" PrivateAssets="All" IncludeAssets="runtime; build; native; contentfiles; analyzers" />
9+
<PackageReference Include="SpoiledCat.MSBuild.Tasks.FileUpdate" Version="1.0.13" PrivateAssets="All" IncludeAssets="runtime; build; native; contentfiles; analyzers" Private="false" />
10+
1011
</ItemGroup>
1112

13+
<Target Name="PreventMSBuildSDKCopyLocal" AfterTargets="ResolveReferences">
14+
<ItemGroup>
15+
<ReferenceCopyLocalPaths Remove="@(ReferenceCopyLocalPaths)" Condition="
16+
$([System.String]::new('%(ReferenceCopyLocalPaths.NuGetPackageId)').StartsWith('Microsoft.Build')) or
17+
$([System.String]::new('%(ReferenceCopyLocalPaths.NuGetPackageId)').StartsWith('Microsoft.Win32')) or
18+
$([System.String]::new('%(ReferenceCopyLocalPaths.NuGetPackageId)').StartsWith('System.Collections.Immutable')) or
19+
$([System.String]::new('%(ReferenceCopyLocalPaths.NuGetPackageId)').StartsWith('System.Text'))
20+
" />
21+
</ItemGroup>
22+
</Target>
23+
1224
<!-- Assemble all sources into a folder called (PackageName) -->
1325
<Target Name="EnumeratePackageFiles" Returns="@(SourcesToCopy)">
1426
<CreateItem
@@ -40,9 +52,9 @@
4052
Condition=" '$(TargetFramework)' == 'net471' " >
4153

4254
<PropertyGroup>
43-
<NpmVersion Condition=" '$(NpmVersionSuffix)' == '' ">$(NuGetPackageVersion)</NpmVersion>
44-
<NpmVersion Condition=" '$(NpmVersionSuffix)' != '' and '$(PublicRelease)' != 'true'">$(BuildVersionSimple)$(NpmVersionSuffix)-g$(GitCommitIdShort)</NpmVersion>
45-
<NpmVersion Condition=" '$(NpmVersionSuffix)' != '' and '$(PublicRelease)' == 'true'">$(NuGetPackageVersion)$(NpmVersionSuffix)</NpmVersion>
55+
<NeedsSuffix Condition="'$(PublicRelease)' != 'true' and '$(NpmVersionSuffix)' != '' and !$(NuGetPackageVersion.Contains('$(NpmVersionSuffix)'))">true</NeedsSuffix>
56+
<NpmVersion Condition=" '$(NeedsSuffix)' != 'true' ">$(NuGetPackageVersion)</NpmVersion>
57+
<NpmVersion Condition=" '$(NeedsSuffix)' == 'true'">$(BuildVersionSimple)$(NpmVersionSuffix)-g$(GitCommitIdShort)</NpmVersion>
4658
</PropertyGroup>
4759

4860
<FileUpdate
@@ -139,9 +151,9 @@
139151
Condition="Exists('$(PackageSourceRoot)\Tests') and '$(TargetFramework)' == 'net471' " >
140152

141153
<PropertyGroup>
142-
<NpmVersion Condition=" '$(NpmVersionSuffix)' == '' ">$(NuGetPackageVersion)</NpmVersion>
143-
<NpmVersion Condition=" '$(NpmVersionSuffix)' != '' and '$(PublicRelease)' != 'true'">$(BuildVersionSimple)$(NpmVersionSuffix)-g$(GitCommitIdShort)</NpmVersion>
144-
<NpmVersion Condition=" '$(NpmVersionSuffix)' != '' and '$(PublicRelease)' == 'true'">$(NuGetPackageVersion)$(NpmVersionSuffix)</NpmVersion>
154+
<NeedsSuffix Condition="'$(PublicRelease)' != 'true' and '$(NpmVersionSuffix)' != '' and !$(NuGetPackageVersion.Contains('$(NpmVersionSuffix)'))">true</NeedsSuffix>
155+
<NpmVersion Condition=" '$(NeedsSuffix)' != 'true' ">$(NuGetPackageVersion)</NpmVersion>
156+
<NpmVersion Condition=" '$(NeedsSuffix)' == 'true'">$(BuildVersionSimple)$(NpmVersionSuffix)-g$(GitCommitIdShort)</NpmVersion>
145157
</PropertyGroup>
146158

147159
<FileUpdate
@@ -162,6 +174,12 @@
162174
Regex="&quot;directory&quot;: &quot;.*&quot;"
163175
ReplacementText="&quot;directory&quot;: &quot;src/$(PackageName)/Tests&quot;" />
164176

177+
<FileUpdate
178+
Files="$(PublishTo)$(PackageTestName)\package.json"
179+
Regex="&quot;revision&quot;: &quot;.*&quot;"
180+
ReplacementText="&quot;revision&quot;: &quot;$(GitCommitId)&quot;"
181+
Encoding="utf-8-without-bom" />
182+
165183
</Target>
166184

167185
</Project>

common/unityreferences.targets

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33

4-
<PropertyGroup Condition=" '$([System.IO.Path]::GetFileName($(MSBuildProjectDirectory)))' == 'Editor' ">
5-
<DefineConstants>UNITY_EDITOR</DefineConstants>
6-
</PropertyGroup>
7-
84
<ItemGroup>
95
<None Remove="**\*.meta;*.DotSettings;*.ncrunch*;**\*.asmdef;bin\**;obj\**;LICENSE.md;version.json;package.json" />
106
</ItemGroup>
@@ -91,10 +87,12 @@
9187
<Reference Include="UnityEditor">
9288
<HintPath>$(UnityDir)Managed\UnityEditor.dll</HintPath>
9389
<Private>False</Private>
90+
<PrivateAssets>all</PrivateAssets>
9491
</Reference>
9592
<Reference Include="UnityEngine">
9693
<HintPath>$(UnityDir)Managed\UnityEngine.dll</HintPath>
9794
<Private>False</Private>
95+
<PrivateAssets>all</PrivateAssets>
9896
</Reference>
9997

10098
<Reference Condition="$(MSBuildProjectName.EndsWith('Tests'))" Include="UnityEditor.TestRunner">

extras/com.unity.editor.tasks/Tests/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
"repository" : {
1313
"type" : "git",
1414
"url": "ssh://git@github.com/Unity-Technologies/com.unity.editor.tasks.git",
15-
"directory": ""
15+
"directory": "",
16+
"revision": ""
1617
},
1718
"dependencies": {
1819
"com.unity.editor.tasks": "0.0.0-placeholder"

pack.cmd

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,4 +55,6 @@ dotnet pack --no-restore --no-build -c %CONFIGURATION% %PUBLIC%
5555

5656
if "x%UPM%"=="x1" (
5757
call powershell scripts/Pack-Upm.ps1
58+
) else (
59+
call powershell scripts/Pack-Npm.ps1
5860
)

pack.sh

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,41 @@ fi
5757
dotnet pack --no-build --no-restore -c $CONFIGURATION $PUBLIC
5858

5959
if [[ x"$UPM" == x"1" ]]; then
60-
powershell scripts/Pack-Upm.ps1
60+
powershell scripts/Pack-Npm.ps1
61+
else
62+
srcdir="$DIR/build/packages"
63+
targetdir="$DIR/upm-ci~/packages"
64+
mkdir -p $targetdir
65+
rm -f $targetdir/*
66+
67+
cat >$targetdir/packages.json <<EOL
68+
{
69+
EOL
70+
71+
pushd $srcdir
72+
count=0
73+
for j in `ls -d *`; do
74+
echo $j
75+
pushd $j
76+
tgz="$(npm pack -q)"
77+
mv -f $tgz $targetdir/$tgz
78+
cp package.json $targetdir/$tgz.json
79+
popd
80+
81+
comma=""
82+
if [[ x"$count" == x"1" ]]; then comma=","; fi
83+
json="$(cat $targetdir/$tgz.json)"
84+
cat >>$targetdir/packages.json <<EOL
85+
${comma}
86+
"${tgz}": ${json}
87+
EOL
88+
89+
count=1
90+
done
91+
popd
92+
93+
cat >>$targetdir/packages.json <<EOL
94+
}
95+
EOL
6196
fi
6297
popd >/dev/null 2>&1

scripts/Pack-Npm.ps1

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
[CmdletBinding()]
2+
Param(
3+
[switch]
4+
$Trace = $false
5+
)
6+
7+
Set-StrictMode -Version Latest
8+
if ($Trace) {
9+
Set-PSDebug -Trace 1
10+
}
11+
12+
. $PSScriptRoot\helpers.ps1 | out-null
13+
14+
$srcDir = Join-Path $rootDirectory 'build\packages'
15+
$targetDir = Join-Path $rootDirectory 'upm-ci~\packages'
16+
17+
Remove-Item "$targetDir\*"
18+
New-Item -itemtype Directory -Path $targetDir -Force -ErrorAction SilentlyContinue
19+
20+
Get-ChildItem -Directory $srcDir | % {
21+
Write-Output "Packing $($_.Name)"
22+
23+
try {
24+
Push-Location (Join-Path $srcDir $_.Name)
25+
$package = Invoke-Command -Fatal { & npm pack -qf }
26+
$package = "$package".Trim()
27+
$tgt = Join-Path $targetDir $package
28+
Move-Item $package $tgt -Force
29+
Copy-Item "package.json" (Join-Path $targetDir "$package.json") -Force
30+
} finally {
31+
Pop-Location
32+
}
33+
}
34+
35+
Write-Output "Writing packages.json"
36+
37+
try {
38+
Push-Location $targetDir
39+
40+
$file = "packages.json"
41+
$count = 0
42+
43+
Set-Content $file "{"
44+
45+
Get-ChildItem "*.tgz" | % {
46+
if ($count -gt 0) {
47+
Add-Content $file ","
48+
}
49+
$json = Get-Content "$($_.Name).json"
50+
Add-Content $file """$($_.Name)"": "
51+
Add-Content $file $json
52+
$count = $count + 1
53+
}
54+
55+
Add-Content $file "}"
56+
57+
} finally {
58+
Pop-Location
59+
}

src/Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project>
22
<PropertyGroup>
33
<LangVersion>7.3</LangVersion>
4-
<GenerateDocumentationFile>false</GenerateDocumentationFile>
4+
<GenerateDocumentationFile>true</GenerateDocumentationFile>
55

66
<RepoRoot>$([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)..\'))</RepoRoot>
77
<RepoBuildPath>$(RepoRoot)build\</RepoBuildPath>

0 commit comments

Comments
 (0)