Skip to content

Commit 0387235

Browse files
committed
Auto-detect architecture in build.sh.
1 parent 166e45e commit 0387235

File tree

1 file changed

+30
-6
lines changed

1 file changed

+30
-6
lines changed

build/build.sh

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ platform=x64
55
vs=vs2022
66
configuration=Release
77
build_only=false
8+
disable_tests=true
89
ci=false
910
target_framework=
1011
verbosity=minimal
@@ -18,10 +19,6 @@ oshost=""
1819
os=""
1920
test=
2021

21-
if [[ $(uname -m) != *"64"* ]]; then
22-
platform=x86
23-
fi
24-
2522
build()
2623
{
2724
if [ $ci = true ]; then
@@ -67,10 +64,10 @@ generate()
6764
fi
6865

6966
if [ "$os" = "linux" ] || [ "$os" = "macosx" ]; then
70-
"$builddir/premake.sh" --file="$builddir/premake5.lua" gmake2 --os=$os --arch=$platform --configuration=$configuration --target-framework=$target_framework "$@"
67+
"$builddir/premake.sh" --file="$builddir/premake5.lua" gmake2 --os=$os --arch=$platform --configuration=$configuration --target-framework=$target_framework --disable-tests=$disable_tests "$@"
7168
fi
7269

73-
"$builddir/premake.sh" --file="$builddir/premake5.lua" $vs --os=$os --arch=$platform --configuration=$configuration --target-framework=$target_framework
70+
"$builddir/premake.sh" --file="$builddir/premake5.lua" $vs --os=$os --arch=$platform --configuration=$configuration --target-framework=$target_framework --disable-tests=$disable_tests
7471
}
7572

7673
restore()
@@ -180,6 +177,29 @@ detect_os()
180177
os=$oshost
181178
}
182179

180+
detect_arch()
181+
{
182+
if [ "$oshost" = "linux" ] || [ "$oshost" = "macosx" ]; then
183+
arch=$(uname -m)
184+
if [ "$arch" = "x86_64" ]; then
185+
platform="x64"
186+
elif [ "$arch" = "arm64" ] || [ "$arch" = "aarch64" ]; then
187+
platform="arm64"
188+
else
189+
echo "Unknown architecture: $arch"
190+
fi
191+
elif [ "$oshost" = "windows" ]; then
192+
arch=$(echo $PROCESSOR_ARCHITECTURE)
193+
if [ "$arch" = "AMD64" ]; then
194+
platform="x64"
195+
elif [ "$arch" = "ARM64" ]; then
196+
platform="arm64"
197+
else
198+
echo "Unknown architecture: $arch"
199+
fi
200+
fi
201+
}
202+
183203
find_msbuild()
184204
{
185205
if [ -x "$(command -v MSBuild.exe)" ]; then
@@ -191,6 +211,7 @@ find_msbuild()
191211

192212
cmd=$(tr '[:upper:]' '[:lower:]' <<< $1)
193213
detect_os
214+
detect_arch
194215
download_premake
195216

196217
while [[ $# > 0 ]]; do
@@ -227,6 +248,9 @@ while [[ $# > 0 ]]; do
227248
-build_only)
228249
build_only=true
229250
;;
251+
-disable-tests)
252+
disable_tests=true
253+
;;
230254
esac
231255
shift
232256
done

0 commit comments

Comments
 (0)