11param
22(
33 [Switch ]$Archive ,
4- [String ]$BlockedSolutions ,
4+ [String ]$BlockList ,
55 [Switch ]$Clean ,
66 [String ]$Configuration = " Release" ,
77 [Switch ]$Help
88)
99
1010$work = $pwd
11- $blockedSolutionsList = $BlockedSolutions .Split (" ;" );
11+ $blockList = $BlockList .Split (" ;" );
1212$artifactsDir = [System.IO.Directory ]::CreateDirectory([System.IO.Path ]::Combine($work , " Artifacts" ))
1313
1414if ($Help )
@@ -17,8 +17,8 @@ if ($Help)
1717 Write-Host
1818 Write-Host " Parameters:"
1919 Write-Host " -Archive - archives the build artifacts."
20- Write-Host " -BlockedSolutions - semi-colon separated list of solutions not to build."
21- Write-Host " -Clean - clean the solutions before building."
20+ Write-Host " -BlockList - semi-colon separated list of projects not to build."
21+ Write-Host " -Clean - clean the projects before building."
2222 Write-Host " -Configuration [name] - build with a specific configuration."
2323 Write-Host " -Help - display help."
2424 exit
@@ -42,16 +42,26 @@ function GetProjectProperty([String]$in_projectPath, [String]$in_propertyName)
4242 return & msbuild / NoLogo / p:Configuration= " ${Configuration} " - getProperty:" ${in_propertyName} " " ${in_projectPath} "
4343}
4444
45+ function IsDependency ([String ]$in_path )
46+ {
47+ return $in_path.Contains (" Dependencies" )
48+ }
49+
4550function BuildSolutions ([String ]$in_root )
4651{
4752 $root = [System.IO.Path ]::Combine($work , $in_root )
4853
4954 foreach ($solutionPath in [System.IO.Directory ]::EnumerateFiles($root , " *.sln" , [System.IO.SearchOption ]::AllDirectories))
5055 {
56+ if (IsDependency($solutionPath ))
57+ {
58+ continue
59+ }
60+
5161 $solutionDir = Split-Path $solutionPath
5262 $solutionName = [System.IO.Path ]::GetFileNameWithoutExtension($solutionPath )
5363
54- if ($blockedSolutionsList .Contains ($solutionName ))
64+ if ($blockList .Contains ($solutionName ))
5565 {
5666 continue
5767 }
@@ -81,7 +91,7 @@ function BuildSolutions([String]$in_root)
8191 foreach ($projectPath in $projects )
8292 {
8393 $projectDir = GetProjectProperty $projectPath " ProjectDir"
84- $projectName = GetProjectProperty $projectPath " ProjectName"
94+ $projectName = ( GetProjectProperty $projectPath " ProjectName" ).Replace( " " , " " )
8595 $binDir = [System.IO.Path ]::Combine($projectDir , " bin" )
8696
8797 foreach ($platformDir in [System.IO.Directory ]::EnumerateDirectories($binDir ))
@@ -107,7 +117,6 @@ function BuildSolutions([String]$in_root)
107117 Write-Host " * Cannot archive project binaries." - ForegroundColor DarkRed
108118 Write-Host " * Directory not found: ${targetDir} " - ForegroundColor DarkRed
109119 Write-Host (" ***********************" + ' *' * $targetDir.Length ) - ForegroundColor DarkRed
110-
111120 exit -1
112121 }
113122
@@ -123,4 +132,66 @@ function BuildSolutions([String]$in_root)
123132 }
124133}
125134
135+ function BuildMakefiles ([String ]$in_root )
136+ {
137+ $root = [System.IO.Path ]::Combine($work , $in_root )
138+
139+ foreach ($makefilePath in [System.IO.Directory ]::EnumerateFiles($root , " Makefile" , [System.IO.SearchOption ]::AllDirectories))
140+ {
141+ if (IsDependency($makefilePath ))
142+ {
143+ continue
144+ }
145+
146+ $makefileDir = Split-Path $makefilePath
147+ $projectName = [System.IO.Path ]::GetFileName($makefileDir )
148+
149+ if ($blockList.Contains ($projectName ))
150+ {
151+ continue
152+ }
153+
154+ $args = @ ()
155+
156+ if ($Clean )
157+ {
158+ $args += " clean"
159+ }
160+
161+ $args += " all"
162+
163+ Write-Host
164+ Write-Host (" **************" + ' *' * $makefilePath.Length ) - ForegroundColor DarkGreen
165+ Write-Host " * Makefile: ${makefilePath} *" - ForegroundColor DarkGreen
166+ Write-Host (" **************" + ' *' * $makefilePath.Length ) - ForegroundColor DarkGreen
167+
168+ & make - C " ${makefileDir} " @args
169+
170+ if ($Archive )
171+ {
172+ $projectNameSafe = $projectName.Replace (" " , " " )
173+ $binDir = [System.IO.Path ]::Combine($makefileDir , " bin" )
174+ $targetName = " ${projectNameSafe} -${Configuration} .zip"
175+
176+ if (! [System.IO.Directory ]::Exists($binDir ))
177+ {
178+ Write-Host
179+ Write-Host (" ***********************" + ' *' * $binDir.Length ) - ForegroundColor DarkRed
180+ Write-Host " * Cannot archive project binaries." - ForegroundColor DarkRed
181+ Write-Host " * Directory not found: ${binDir} " - ForegroundColor DarkRed
182+ Write-Host (" ***********************" + ' *' * $binDir.Length ) - ForegroundColor DarkRed
183+ exit -1
184+ }
185+
186+ $artifactRootDir = [System.IO.Directory ]::CreateDirectory([System.IO.Path ]::Combine($artifactsDir.FullName , $in_root , $projectName ))
187+ $artifactTargetPath = [System.IO.Path ]::Combine($artifactRootDir.FullName , $targetName )
188+
189+ cd $binDir
190+ Compress-Archive - Force * $artifactTargetPath
191+ cd $work
192+ }
193+ }
194+ }
195+
126196BuildSolutions(" Games" )
197+ BuildMakefiles(" Games/Zelda 64 Recompiled/Majora's Mask" )
0 commit comments