Skip to content

Commit ed09579

Browse files
authored
Merge pull request #27 from UniToolsTeam/bix/nre-onvalidate
0.1.2-preview
2 parents 9d3c01c + 60142d7 commit ed09579

File tree

11 files changed

+169
-6
lines changed

11 files changed

+169
-6
lines changed

BuildScripts/Unity-Hub/build.bat

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
@echo off
2+
echo TODO CallPSHere

BuildScripts/Unity-Hub/build.bat.meta

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

BuildScripts/Unity-Hub/build.ps1

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
Write-Output "PowerShell $($PSVersionTable.PSEdition) version $($PSVersionTable.PSVersion)"
2+
#The default quit timeout is 300 seconds (5 mins). The full build process could take more time, that's why we set this value bigger
3+
$QuitTimeout=86400
4+
#Define the project path
5+
$ProjectPath=$(pwd)
6+
#Parse UnityVersion from the version file
7+
$UnityVersion = Get-Content "$ProjectPath/ProjectSettings/ProjectVersion.txt" -Raw
8+
$UnityVersion = $UnityVersion -split " "
9+
$UnityVersion = $UnityVersion[1]
10+
$UnityVersion = $UnityVersion -split "\n"
11+
$UnityVersion = $UnityVersion[0]
12+
$UnityVersion = $UnityVersion.Trim()
13+
#Create a path to the Unity Folder
14+
$UnityPath="$Env:Programfiles\Unity\Hub\Editor\$UnityVersion\Editor\Unity.exe"
15+
#Path to log file
16+
$BuildLog="PipelineResults.log"
17+
18+
19+
# Remove previous Editor.log.
20+
Remove-Item "$BuildLog" -Recurse -ErrorAction Ignore
21+
# Start the Unity process in background thread.
22+
Start-Process -FilePath "$UnityPath" -ArgumentList "-quit -quitTimeout $QuitTimeout -batchmode -projectPath $ProjectPath -executeMethod UniTools.Build.BatchModeBuilder.Execute -logFile $BuildLog $args"
23+
# Wait for Editor.log to be created.
24+
while (!(Test-Path "$BuildLog")) {
25+
Start-Sleep -m 10
26+
}
27+
# Output Editor.log until Unity is done.
28+
Get-Content -Path "$BuildLog" -Tail 1 -Wait | Where-Object {
29+
Write-Host $_
30+
31+
if ($_ -match "Application will terminate with return code") {
32+
[int]$exitCode = $_.Substring($_.get_Length()-1)
33+
Write-Host "Exit code is: "
34+
Write-Host $exitCode
35+
exit $exitCode
36+
}
37+
}

BuildScripts/Unity-Hub/build.ps1.meta

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

BuildScripts/Unity-Hub/build.sh

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,28 @@
55
QUIT_TIMEOUT=86400
66
#This is a current project directory.
77
PROJECT_PATH=$(pwd)
8-
#Parse the Unity version from the ProjectVersion.txt file
9-
UNITY_VERSION=$(awk '{ print $2 ; exit}' "$PROJECT_PATH/ProjectSettings/ProjectVersion.txt")
10-
#Path to the Unity Editor executable
11-
UNITY_PATH="/Applications/Unity/Hub/Editor/$UNITY_VERSION/Unity.app/Contents/MacOS/Unity"
12-
#Execute unity in batchmode with desire configuration
8+
9+
#Checking if the Unity Path was delivered with from CLI
10+
UNITY_PATH="$1"
11+
if [ -f "$UNITY_PATH" ]
12+
then
13+
echo "The Unity Editor is found at Path $UNITY_PATH from CLI"
14+
else
15+
echo "Unity path is not assigned from the CLI. Going to generate it based on the project version"
16+
#Parse the Unity version from the ProjectVersion.txt file
17+
UNITY_VERSION=$(awk '{ print $2 ; exit}' "$PROJECT_PATH/ProjectSettings/ProjectVersion.txt")
18+
if [[ "$OSTYPE" == "darwin"* ]]
19+
then
20+
echo "The platform is OSX"
21+
#Path to the Unity Editor executable
22+
UNITY_PATH="/Applications/Unity/Hub/Editor/$UNITY_VERSION/Unity.app/Contents/MacOS/Unity"
23+
else
24+
echo "This is Windows. Should be Windows :)"
25+
UNITY_PATH="C:/Program Files/Unity/Hub/Editor/$UNITY_VERSION/Editor/Unity.exe"
26+
fi
27+
fi
28+
29+
echo "Unity path is $UNITY_PATH"
1330

1431
$UNITY_PATH -quit -quitTimeout $QUIT_TIMEOUT -batchmode -projectPath $PROJECT_PATH -executeMethod UniTools.Build.BatchModeBuilder.Execute -logFile - "$@"
1532

BuildScripts/Unity-Hub/unity.ps1

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
Write-Output "PowerShell $($PSVersionTable.PSEdition) version $($PSVersionTable.PSVersion)"
2+
#The default quit timeout is 300 seconds (5 mins). The full build process could take more time, that's why we set this value bigger
3+
$QuitTimeout=86400
4+
#Define the project path
5+
$ProjectPath=$(pwd)
6+
#Parse UnityVersion from the version file
7+
$UnityVersion = Get-Content "$ProjectPath/ProjectSettings/ProjectVersion.txt" -Raw
8+
$UnityVersion = $UnityVersion -split " "
9+
$UnityVersion = $UnityVersion[1]
10+
$UnityVersion = $UnityVersion -split "\n"
11+
$UnityVersion = $UnityVersion[0]
12+
$UnityVersion = $UnityVersion.Trim()
13+
#Create a path to the Unity Folder
14+
$UnityPath="$Env:Programfiles\Unity\Hub\Editor\$UnityVersion\Editor\Unity.exe"
15+
#Path to log file
16+
$BuildLog="PipelineResults.log"
17+
18+
19+
# Remove previous Editor.log.
20+
Remove-Item "$BuildLog" -Recurse -ErrorAction Ignore
21+
# Start the Unity process in background thread.
22+
Start-Process -FilePath "$UnityPath" -ArgumentList "-quit -quitTimeout $QuitTimeout -batchmode -projectPath $ProjectPath -executeMethod UniTools.Build.BatchModeBuilder.Execute -logFile $BuildLog $args"
23+
# Wait for Editor.log to be created.
24+
while (!(Test-Path "$BuildLog")) {
25+
Start-Sleep -m 10
26+
}
27+
# Output Editor.log until Unity is done.
28+
Get-Content -Path "$BuildLog" -Tail 1 -Wait | Where-Object {
29+
Write-Host $_
30+
31+
if ($_ -match "Application will terminate with return code") {
32+
[int]$exitCode = $_.Substring($_.get_Length()-1)
33+
Write-Host "Exit code is: "
34+
Write-Host $exitCode
35+
exit $exitCode
36+
}
37+
}

BuildScripts/Unity-Hub/unity.ps1.meta

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

BuildScripts/Unity-Hub/unity.sh

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/usr/bin/env bash
2+
#This script is usefull to run Unity CLI commands
3+
4+
#Read a Unity Version as a first arg (can be empty) in this case the version will be defined from the Project settings.
5+
UNITY_VERSION="$1"
6+
#Build Unity Path according to the OS
7+
if [[ "$OSTYPE" == "darwin"* ]]
8+
then
9+
echo "The platform is OSX"
10+
#Path to the Unity Editor executable
11+
UNITY_PATH="/Applications/Unity/Hub/Editor/$UNITY_VERSION/Unity.app/Contents/MacOS/Unity"
12+
else
13+
echo "This is Windows. Should be Windows :)"
14+
UNITY_PATH="C:/Program Files/Unity/Hub/Editor/$UNITY_VERSION/Editor/Unity.exe"
15+
fi
16+
#Checking if the Unity Path
17+
echo "Checking if Unity is available at path $UNITY_PATH"
18+
if [ -f "$UNITY_PATH" ]
19+
then
20+
echo "The Unity Editor is found at Path $UNITY_PATH"
21+
else
22+
echo "Unity is not found. Going to generate it based on the project version"
23+
#This is a current project directory.
24+
PROJECT_PATH=$(pwd)
25+
#Parse the Unity version from the ProjectVersion.txt file
26+
UNITY_VERSION=$(awk '{ print $2 ; exit}' "$PROJECT_PATH/ProjectSettings/ProjectVersion.txt")
27+
if [[ "$OSTYPE" == "darwin"* ]]
28+
then
29+
echo "The platform is OSX"
30+
#Path to the Unity Editor executable
31+
UNITY_PATH="/Applications/Unity/Hub/Editor/$UNITY_VERSION/Unity.app/Contents/MacOS/Unity"
32+
else
33+
echo "This is Windows. Should be Windows :)"
34+
UNITY_PATH="C:/Program Files/Unity/Hub/Editor/$UNITY_VERSION/Editor/Unity.exe"
35+
fi
36+
fi
37+
38+
echo "Unity path is $UNITY_PATH"
39+
40+
#Execute the command
41+
"$UNITY_PATH" "$@"

BuildScripts/Unity-Hub/unity.sh.meta

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

Editor/Core/Pipelines/BuildPipeline.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ private void OnValidate()
3030
foreach (PipelineStep step in m_steps)
3131
{
3232
if (step == null) continue;
33+
if (step.Step == null) continue;
3334

3435
if (step.Skip)
3536
{

0 commit comments

Comments
 (0)