Skip to content

Commit cb60f3b

Browse files
authored
Add premake support for ARM-based macOS (#1958)
This upgrades to premake 5.0.0-beta8, which is the first version that provides ARM64-based binaries for macOS.
1 parent 42ccd59 commit cb60f3b

File tree

1 file changed

+27
-9
lines changed

1 file changed

+27
-9
lines changed

build/build.sh

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#!/usr/bin/env bash
22
set -e
33
builddir=$(cd "$(dirname "$0")"; pwd)
4-
platform=x64
54
vs=vs2022
65
configuration=DebugOpt
76
build_only=false
@@ -18,8 +17,17 @@ oshost=""
1817
os=""
1918
test=
2019

21-
if [[ $(uname -m) != *"64"* ]]; then
20+
_machine=$(uname -m)
21+
22+
if [[ $_machine == "arm64" ]]; then
23+
platform="arm64"
24+
elif [[ $_machine == "x86_64" ]]; then
25+
platform="x64"
26+
elif [[ $_machine == "i686" ]]; then
2227
platform=x86
28+
else
29+
echo "Unsupported machine type: ${_machine}"
30+
exit 1
2331
fi
2432

2533
build()
@@ -103,7 +111,7 @@ test()
103111
}
104112

105113
clean()
106-
{
114+
{
107115
rm -rf "$objdir"
108116
rm -rf "$gendir"
109117
rm -rf "$bindir"
@@ -125,14 +133,22 @@ download_premake()
125133

126134
if ! [ -f "$premake_path" ]; then
127135
echo "Downloading and unpacking Premake..."
128-
premake_version=5.0.0-beta2
136+
unpack_filename=$premake_filename
137+
if [ $oshost = "macosx" ]; then
138+
# macOS needs a newer premake version which has arm64 (Apple Silicon) support
139+
premake_version=5.0.0-beta8
140+
else
141+
# Other systems need an older premake that still works on Ubuntu 22.04
142+
premake_version=5.0.0-beta2
143+
unpack_filename=./${premake_filename}
144+
fi
129145
premake_archive=premake-$premake_version-$oshost.$premake_archive_ext
130146
premake_url=https://github.com/premake/premake-core/releases/download/v$premake_version/$premake_archive
131147
curl -L -O $premake_url
132148
if [ $oshost = "windows" ]; then
133149
unzip $premake_archive $premake_filename -d "$premake_dir"
134150
else
135-
tar -xf $premake_archive -C "$premake_dir" ./$premake_filename
151+
tar -xf $premake_archive -C "$premake_dir" $unpack_filename
136152
fi
137153
chmod +x "$premake_path"
138154
rm $premake_archive
@@ -161,7 +177,9 @@ package_llvm()
161177

162178
detect_os()
163179
{
164-
case "$(uname -s)" in
180+
local _system=$(uname -s)
181+
182+
case "${_system}" in
165183
Darwin)
166184
oshost=macosx
167185
;;
@@ -172,7 +190,7 @@ detect_os()
172190
oshost=windows
173191
;;
174192
*)
175-
echo "Unsupported platform"
193+
echo "Unsupported platform: ${_system}"
176194
exit 1
177195
;;
178196
esac
@@ -202,7 +220,7 @@ while [[ $# > 0 ]]; do
202220
-configuration)
203221
configuration=$2
204222
shift
205-
;;
223+
;;
206224
-platform)
207225
platform=$2
208226
shift
@@ -240,7 +258,7 @@ case "$cmd" in
240258
;;
241259
generate_config)
242260
generate_config
243-
;;
261+
;;
244262
prepack)
245263
prepack
246264
;;

0 commit comments

Comments
 (0)