Skip to content

Commit a20594c

Browse files
updated post build for macos arch
1 parent a4f2cf2 commit a20594c

File tree

2 files changed

+63
-32
lines changed

2 files changed

+63
-32
lines changed

CMakeLists.txt

+12-3
Original file line numberDiff line numberDiff line change
@@ -107,15 +107,24 @@ add_custom_target (AssembleContent ALL
107107
DEPENDS BuildLauncher
108108
)
109109

110+
111+
set (SYSTEM_NAME ${CMAKE_SYSTEM_NAME})
112+
if ((${CMAKE_SYSTEM_NAME} STREQUAL "Windows") OR (${CMAKE_SYSTEM_NAME} STREQUAL "Linux"))
113+
set (SYSTEM_ARCHITECTURE "x64")
114+
elseif (${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
115+
if (MACOSX_ARCHITECTURE_ARM64)
116+
set (SYSTEM_ARCHITECTURE "osx-arm64")
117+
else ()
118+
set (SYSTEM_ARCHITECTURE "osx-x64")
119+
endif ()
120+
endif ()
110121
add_custom_command (TARGET AssembleContent
111122
POST_BUILD
112-
COMMAND pwsh ${CMAKE_CURRENT_SOURCE_DIR}/Scripts/PostBuild.ps1 -Configurations $<IF:$<CONFIG:Debug>,Debug,Release> $<$<BOOL:${LAUNCHER_ONLY}>:-LauncherOnly>
123+
COMMAND pwsh ${CMAKE_CURRENT_SOURCE_DIR}/Scripts/PostBuild.ps1 -SystemName ${SYSTEM_NAME} -Archtectures ${SYSTEM_ARCHITECTURE} -Configurations $<IF:$<CONFIG:Debug>,Debug,Release> $<$<BOOL:${LAUNCHER_ONLY}>:-LauncherOnly>
113124
)
114125

115126
# Copying Examples dir
116127
#
117128
if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/Examples/projectConfig.json)
118129
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/Examples/projectConfig.json DESTINATION ${CMAKE_BINARY_DIR}/Examples)
119130
endif ()
120-
121-

Scripts/PostBuild.ps1

+51-29
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,14 @@
2323
#Requires -PSEdition Core
2424

2525
param (
26+
[Parameter(HelpMessage="SystemName type to build, default to Windows")]
27+
[ValidateSet('Windows', 'Darwin', 'Linux')]
28+
[string[]] $SystemName = 'Windows',
29+
30+
[Parameter(HelpMessage="Architecture type to build, default to x64")]
31+
[ValidateSet('x64', 'arm64', 'osx-x64', 'osx-arm64')]
32+
[string[]] $Architectures = 'x64',
33+
2634
[Parameter(HelpMessage="Configuration type to build, default to Debug")]
2735
[ValidateSet('Debug', 'Release')]
2836
[string[]] $Configurations = 'Debug',
@@ -33,23 +41,10 @@ param (
3341

3442
$ErrorActionPreference = "Stop"
3543

36-
# Check the system name
37-
if ($IsLinux) {
38-
$SystemName = "Linux"
39-
}
40-
elseif ($IsMacOS) {
41-
$SystemName = "Darwin"
42-
}
43-
elseif ($IsWindows) {
44-
$SystemName = "Windows"
45-
}else{
46-
throw 'The OS is not supported'
47-
}
48-
4944
[string]$RepoRoot = [IO.Path]::Combine($PSScriptRoot, "..")
50-
[string]$OuputBuildDirectory = If($IsWindows) {
51-
[IO.Path]::Combine($RepoRoot, "Result.Windows.x64.MultiConfig")
52-
} Else {
45+
[string]$OuputBuildDirectory = If($IsWindows) {
46+
[IO.Path]::Combine($RepoRoot, "Result.Windows.x64.MultiConfig")
47+
} Else {
5348
[IO.Path]::Combine($RepoRoot, "Result.$SystemName.x64.$Configurations")
5449
}
5550

@@ -63,26 +58,53 @@ $ContentsToProcess = @(
6358
Name = "Resources"
6459
IsDirectory = $true
6560
Contents = @(
66-
67-
if ($IsWindows) {
68-
@{ From = "$RepoRoot\Resources\Shaders"; To = "$OuputBuildDirectory\Tetragrama\src\$Configurations\Shaders"}
69-
@{ From = "$RepoRoot\Resources\Editor\Settings"; To = "$OuputBuildDirectory\Tetragrama\src\$Configurations\Settings"}
70-
}
71-
elseif ($IsMacOS) {
72-
@{ From = "$RepoRoot\Resources\Shaders"; To = "$OuputBuildDirectory\Tetragrama\src\$Configurations\Shaders"}
73-
@{ From = "$RepoRoot\Resources\Editor\Settings"; To = "$OuputBuildDirectory\Tetragrama\src\$Configurations\Settings"}
74-
}
75-
else {
76-
@{ From = "$RepoRoot\Resources\Shaders"; To = "$OuputBuildDirectory\Tetragrama\src\Shaders"}
77-
@{ From = "$RepoRoot\Resources\Editor\Settings"; To = "$OuputBuildDirectory\Tetragrama\src\Settings"}
61+
switch ($SystemName) {
62+
"Windows" {
63+
@{ From = "$RepoRoot\Resources\Shaders"; To = "$OuputBuildDirectory\Tetragrama\src\$Configurations\Shaders"}
64+
@{ From = "$RepoRoot\Resources\Editor\Settings"; To = "$OuputBuildDirectory\Tetragrama\src\$Configurations\Settings"}
65+
}
66+
"Darwin" {
67+
@{ From = "$RepoRoot\Resources\Shaders"; To = "$OuputBuildDirectory\Tetragrama\src\$Configurations\Shaders"}
68+
@{ From = "$RepoRoot\Resources\Editor\Settings"; To = "$OuputBuildDirectory\Tetragrama\src\$Configurations\Settings"}
69+
}
70+
"Linux" {
71+
@{ From = "$RepoRoot\Resources\Shaders"; To = "$OuputBuildDirectory\Tetragrama\src\Shaders"}
72+
@{ From = "$RepoRoot\Resources\Editor\Settings"; To = "$OuputBuildDirectory\Tetragrama\src\Settings"}
73+
}
74+
Default {
75+
throw 'This system is not supported'
76+
}
7877
}
7978
)
8079
},
8180
@{
8281
Name = "Tetragrama"
8382
IsDirectory = $true
8483
Contents = @(
85-
@{ From = "$OuputBuildDirectory\Tetragrama\src\$Configurations"; To = "$OuputBuildDirectory\Panzerfaust\$Configurations\net6.0\Editor"}
84+
switch ($SystemName) {
85+
"Windows" {
86+
@{ From = "$OuputBuildDirectory\Tetragrama\src\$Configurations"; To = "$OuputBuildDirectory\Panzerfaust\$Configurations\net6.0\Editor"}
87+
}
88+
"Darwin" {
89+
switch ($Architectures) {
90+
"osx-x64" {
91+
@{ From = "$OuputBuildDirectory\Tetragrama\src\$Configurations"; To = "$OuputBuildDirectory\Panzerfaust\$Configurations\net6.0\$Architectures\Editor"}
92+
}
93+
"osx-arm64" {
94+
@{ From = "$OuputBuildDirectory\Tetragrama\src\$Configurations"; To = "$OuputBuildDirectory\Panzerfaust\$Configurations\net6.0\$Architectures\Editor"}
95+
}
96+
Default {
97+
throw 'This architecture is not supported'
98+
}
99+
}
100+
}
101+
"Linux" {
102+
@{ From = "$OuputBuildDirectory\Tetragrama\src\$Configurations"; To = "$OuputBuildDirectory\Panzerfaust\$Configurations\net6.0\Editor"}
103+
}
104+
Default {
105+
throw 'This system is not supported'
106+
}
107+
}
86108
)
87109
}
88110
)

0 commit comments

Comments
 (0)