forked from microsoft/lib3mf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBuildMacOSiOSNuGet.ps1
126 lines (104 loc) · 2.61 KB
/
BuildMacOSiOSNuGet.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
120
121
122
123
124
125
126
<#
.SYNOPSIS
Build the MacOS, iOS, and iOS Simulator projects
.DESCRIPTION
Build the MacOS, iOS, and iOS Simulator projects as they were generated by GenerateMacOSiOS.ps1
.EXAMPLE
BuildMacOSiOSNuGet.ps1
#>
[CmdletBinding()]
param(
[switch]$NoNuGet,
[switch]$NoMacOS,
[switch]$NoIOS,
[switch]$NoSimulator,
[switch]$NoDebug,
[switch]$NoRelease
)
$MACOS_OUTPUT_FOLDER = "macos"
$IOS_OUTPUT_FOLDER = "ios"
$IOS_SIMULATOR_OUTPUT_FOLDER = "ios_simulator"
function BuildProject($path)
{
Write-Host "Build XCode Project"
Push-Location "$path"
try
{
if (!$NoDebug)
{
cmake --build . --target lib3MF_s --config Debug
}
if (!$NoRelease)
{
cmake --build . --target lib3MF_s --config Release
}
}
finally
{
Pop-Location
}
}
function GenerateNuGetMacOS()
{
nuget pack $PSScriptRoot/../build/macos/nuget/macos/lib3mf.macos.nuspec -OutputDirectory $PSScriptRoot/../build/nuget
}
function GenerateNuGetIOS()
{
nuget pack $PSScriptRoot/../build/ios/nuget/ios/lib3mf.ios.nuspec -OutputDirectory $PSScriptRoot/../build/nuget
}
function StripSymbols()
{
Param
(
$Paths
)
Write-Host "`n****** Strip Debug Symbols - Start ******`n"
foreach($path in $Paths)
{
Write-Host "`tSearching path: $($path)"
$files = Get-ChildItem -Path $path -Recurse -File -Filter '*.a'
foreach($file in $files)
{
Write-Host "`t`tStripping symbols: $($file.Name)"
strip -S $file.FullName
}
}
Write-Host "`n****** Strip Debug Symbols - Finish ******`n"
}
function Main()
{
if (!$NoMacOS)
{
BuildProject $PSScriptRoot/../build/$MACOS_OUTPUT_FOLDER
}
if (!$NoIOS)
{
BuildProject $PSScriptRoot/../build/$IOS_OUTPUT_FOLDER
}
if (!$NoSimulator)
{
BuildProject $PSScriptRoot/../build/$IOS_SIMULATOR_OUTPUT_FOLDER
}
if (!$NoNuGet)
{
if (!$NoMacOS)
{
$MacPaths = (
"${ENV:BUILD_SOURCESDIRECTORY}\build\macos\Debug"
)
StripSymbols $MacPaths
GenerateNuGetMacOS
}
# Only generate the iOS NuGet package if we built both IOS and Simulator
if (!$NoIOS -and !$NoSimulator)
{
$IOSPaths = (
"${ENV:BUILD_SOURCESDIRECTORY}\build\ios\Debug-iphoneos",
"${ENV:BUILD_SOURCESDIRECTORY}\build\ios_simulator\Debug-iphonesimulator"
)
StripSymbols $IOSPaths
GenerateNuGetIOS
}
}
}
Main