forked from microsoft/glTF-SDK
-
Notifications
You must be signed in to change notification settings - Fork 0
/
macinit.ps1
119 lines (101 loc) · 3.37 KB
/
macinit.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
<#
.SYNOPSIS
Setup the xcode workspace for building on MacOS.
This should be run after every git pull or clean and should be safe to run any time.
.DESCRIPTION
Fetches NuGet packages and updates any configuration required for the xcode workspace to load and build.
Could go so far as to update or generate the xcode projects if needed.
.EXAMPLE
macosini.ps1
#>
[CmdletBinding()]
param(
[switch]$Clean,
[switch]$NoMacOS,
[switch]$NoIOS,
[switch]$NoSimulator,
[switch]$NoUnitTests
)
$ErrorActionPreference = "stop"
if ($NoUnitTests) {$ENABLE_UNIT_TESTS = "OFF"} else {$ENABLE_UNIT_TESTS = "ON"}
function CleanFiles()
{
Remove-Item "$PSScriptRoot/Build/packages" -Recurse -Force -ErrorAction Ignore | Write-Host
Remove-Item "$PSScriptRoot/Built" -Recurse -Force -ErrorAction Ignore | Write-Host
}
function RestoreNuGet()
{
Write-Host "Restoring NuGet packages"
&"$PSScriptRoot/XPlatScripts/NuGet.macOS/NuGetRestore.ps1" -XCodeConfigFile "$PSScriptRoot/Built/Int/XCode.xcconfig" -PackagesDirectory "$PSScriptRoot/Build/packages" -PackagesConfigRoot "$PSScriptRoot/Build/macOSPackageRoot" -NugetConfigSource "$PSScriptRoot/NuGet.Config"
}
function GenerateSpectreVersion()
{
Write-Host "Generating SpectreVersionInternal.h"
&"$PSScriptRoot/Build/Scripts/VersionGeneratorAndModifier.ps1" -sourceDirectory $PSScriptRoot -Exclude "$PSScriptRoot/Build/packages;$PSScriptRoot/Build/NuGet/FBX" -ModifyCoAppPackages false -ModifyNuGetPackages false -ModifyWindowsStoreApps false -WriteVersionHeader true
}
function GenerateProjectsMacOS()
{
Write-Host "Generate MacOS Projects"
New-Item -Path "$PSScriptRoot/Built/Int" -Name cmake_macos -ItemType Directory -Force | Out-Null
Push-Location "$PSScriptRoot/Built/Int/cmake_macos" | Out-Null
try
{
cmake -G Xcode ../../.. -DENABLE_UNIT_TESTS="$ENABLE_UNIT_TESTS" | Write-Host
}
finally
{
Pop-Location | Out-Null
}
}
function GenerateProjectsIOS()
{
Write-Host "Generate iOS Projects"
New-Item -Path "$PSScriptRoot/Built/Int" -Name cmake_ios -ItemType Directory -Force | Out-Null
Push-Location "$PSScriptRoot/Built/Int/cmake_ios" | Out-Null
try
{
cmake -G Xcode ../../.. -DCMAKE_TOOLCHAIN_FILE="$PSScriptRoot/Build/CMake/ios.toolchain.cmake" -DIOS_PLATFORM=OS -DIOS_DEPLOYMENT_TARGET="9.0" -DENABLE_UNIT_TESTS="$ENABLE_UNIT_TESTS" | Write-Host
}
finally
{
Pop-Location | Out-Null
}
}
function GenerateProjectsIOSSimulator()
{
Write-Host "Generate iOS Simulator Projects"
New-Item -Path "$PSScriptRoot/Built/Int" -Name cmake_ios_simulator -ItemType Directory -Force | Out-Null
Push-Location "$PSScriptRoot/Built/Int/cmake_ios_simulator" | Out-Null
try
{
cmake -G Xcode ../../.. -DCMAKE_TOOLCHAIN_FILE="$PSScriptRoot/Build/CMake/ios.toolchain.cmake" -DIOS_PLATFORM=SIMULATOR64 -DIOS_DEPLOYMENT_TARGET="9.0" -DENABLE_UNIT_TESTS="$ENABLE_UNIT_TESTS" | Write-Host
}
finally
{
Pop-Location | Out-Null
}
}
function Main()
{
if ($Clean)
{
CleanFiles
}
RestoreNuGet
GenerateSpectreVersion
if (!$NoMacOS)
{
GenerateProjectsMacOS
}
if (!$NoIOS)
{
GenerateProjectsIOS
}
if (!$NoSimulator)
{
GenerateProjectsIOSSimulator
}
}
Main