more
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
TARGET=$1
|
||||
|
||||
if [[ -z "$TARGET" ]]; then
|
||||
echo "Missing TARGET (Mac or iOS)"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "=== Mac Build Starting ==="
|
||||
echo "Target: $TARGET"
|
||||
|
||||
UNITY_VERSION="2022.3.62f1"
|
||||
UNITY_ROOT="/Applications/Unity/Hub/Editor"
|
||||
UNITY_EXE="$UNITY_ROOT/$UNITY_VERSION/Unity.app/Contents/MacOS/Unity"
|
||||
|
||||
if [[ ! -f "$UNITY_EXE" ]]; then
|
||||
echo "Unity not installed at $UNITY_EXE"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
case "$TARGET" in
|
||||
Mac)
|
||||
METHOD="BuildScript.Mac"
|
||||
;;
|
||||
iOS)
|
||||
METHOD="BuildScript.iOS"
|
||||
;;
|
||||
*)
|
||||
echo "Unknown target: $TARGET"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
"$UNITY_EXE" \
|
||||
-batchmode \
|
||||
-nographics \
|
||||
-quit \
|
||||
-projectPath "$(pwd)" \
|
||||
-executeMethod $METHOD \
|
||||
-logFile -
|
||||
|
||||
echo "=== Build SUCCESS: $TARGET ==="
|
||||
@@ -1,45 +0,0 @@
|
||||
param(
|
||||
[Parameter(Mandatory = $true)]
|
||||
[string]$Target
|
||||
)
|
||||
|
||||
Write-Host "============================="
|
||||
Write-Host "Unity Build Starting"
|
||||
Write-Host "Target: $Target"
|
||||
Write-Host "============================="
|
||||
|
||||
if ([string]::IsNullOrWhiteSpace($Target)) {
|
||||
throw "ERROR: Target was empty. TeamCity did not pass unity.target correctly."
|
||||
}
|
||||
|
||||
$config = Get-Content ".\ci\toolchain.json" | ConvertFrom-Json
|
||||
|
||||
if (-not $config.targets.$Target) {
|
||||
throw "Unknown build target: $Target"
|
||||
}
|
||||
|
||||
$t = $config.targets.$Target
|
||||
|
||||
$UnityExe = Join-Path $config.unityRoot "$($config.unityVersion)\Editor\Unity.exe"
|
||||
|
||||
if (!(Test-Path $UnityExe)) {
|
||||
throw "Unity not installed at expected path: $UnityExe"
|
||||
}
|
||||
|
||||
Write-Host "Using Unity: $UnityExe"
|
||||
Write-Host "Executing method: $($t.method)"
|
||||
Write-Host "Output: $($t.outputPath)"
|
||||
|
||||
& $UnityExe `
|
||||
-batchmode `
|
||||
-nographics `
|
||||
-quit `
|
||||
-projectPath $PWD `
|
||||
-executeMethod $t.method `
|
||||
-logFile -
|
||||
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
throw "Unity build FAILED for target: $Target"
|
||||
}
|
||||
|
||||
Write-Host "Build SUCCESS: $Target"
|
||||
@@ -0,0 +1,53 @@
|
||||
param(
|
||||
[Parameter(Mandatory = $true)]
|
||||
[ValidateSet("Windows","Android")]
|
||||
[string]$Target
|
||||
)
|
||||
|
||||
Write-Host "=== Windows Build Starting ==="
|
||||
Write-Host "Target: $Target"
|
||||
|
||||
$config = Get-Content ".\ci\toolchain.json" | ConvertFrom-Json
|
||||
|
||||
$unityVersion = $config.unityVersion
|
||||
$unityRoot = $config.windows.unityRoot
|
||||
|
||||
$unityExe = Join-Path $unityRoot "$unityVersion\Editor\Unity.exe"
|
||||
|
||||
if (!(Test-Path $unityExe)) {
|
||||
throw "Unity not installed: $unityExe"
|
||||
}
|
||||
|
||||
# ----------------------------
|
||||
# Toolchain setup (Windows agent)
|
||||
# ----------------------------
|
||||
|
||||
Write-Host "Ensuring toolchain (Unity + Android SDK/JDK/NDK)..."
|
||||
|
||||
# NOTE: In real setups you either:
|
||||
# - rely on Unity Hub installs, OR
|
||||
# - preinstalled cached toolchain
|
||||
# This script assumes preinstalled Hub-managed tools.
|
||||
|
||||
# ----------------------------
|
||||
# Select Unity method
|
||||
# ----------------------------
|
||||
|
||||
$method = switch ($Target) {
|
||||
"Windows" { "BuildScript.Windows" }
|
||||
"Android" { "BuildScript.Android" }
|
||||
}
|
||||
|
||||
& $unityExe `
|
||||
-batchmode `
|
||||
-nographics `
|
||||
-quit `
|
||||
-projectPath $PWD `
|
||||
-executeMethod $method `
|
||||
-logFile -
|
||||
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
throw "Build failed: $Target"
|
||||
}
|
||||
|
||||
Write-Host "=== Build SUCCESS: $Target ==="
|
||||
@@ -1,22 +0,0 @@
|
||||
param(
|
||||
[string]$ConfigPath = ".\ci\toolchain.json"
|
||||
)
|
||||
|
||||
$config = Get-Content $ConfigPath | ConvertFrom-Json
|
||||
|
||||
$UnityVersion = $config.unityVersion
|
||||
$UnityExe = Join-Path $config.unityRoot "$UnityVersion\Editor\Unity.exe"
|
||||
|
||||
Write-Host "Checking Unity $UnityVersion..."
|
||||
|
||||
if (!(Test-Path $UnityExe)) {
|
||||
throw "Unity version not installed: $UnityVersion"
|
||||
}
|
||||
|
||||
Write-Host "Unity found: $UnityExe"
|
||||
|
||||
# expose for later steps
|
||||
$env:UNITY_VERSION = $UnityVersion
|
||||
$env:UNITY_EXE = $UnityExe
|
||||
|
||||
return $UnityExe
|
||||
+16
-12
@@ -1,18 +1,22 @@
|
||||
{
|
||||
"unityVersion": "2022.3.62f1",
|
||||
"unityRoot": "C:\\Program Files\\Unity\\Hub\\Editor",
|
||||
|
||||
"targets": {
|
||||
"Windows": {
|
||||
"method": "BuildScript.Windows",
|
||||
"outputPath": "Builds/Windows/Game.exe",
|
||||
"buildTarget": "StandaloneWindows64"
|
||||
},
|
||||
"windows": {
|
||||
"unityRoot": "C:\\Program Files\\Unity\\Hub\\Editor",
|
||||
"modules": [
|
||||
"android",
|
||||
"android-sdk-ndk-tools",
|
||||
"android-open-jdk",
|
||||
"windows-il2cpp"
|
||||
]
|
||||
},
|
||||
|
||||
"Android": {
|
||||
"method": "BuildScript.Android",
|
||||
"outputPath": "Builds/Android/Game.aab",
|
||||
"buildTarget": "Android"
|
||||
}
|
||||
"mac": {
|
||||
"unityRoot": "/Applications/Unity/Hub/Editor",
|
||||
"modules": [
|
||||
"ios-il2cpp",
|
||||
"mac-mono",
|
||||
"android"
|
||||
]
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user