Skip to content

Commit

Permalink
Auto-detect architecture in build.sh.
Browse files Browse the repository at this point in the history
  • Loading branch information
tritao committed Oct 21, 2024
1 parent 166e45e commit 0387235
Showing 1 changed file with 30 additions and 6 deletions.
36 changes: 30 additions & 6 deletions build/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ platform=x64
vs=vs2022
configuration=Release
build_only=false
disable_tests=true
ci=false
target_framework=
verbosity=minimal
Expand All @@ -18,10 +19,6 @@ oshost=""
os=""
test=

if [[ $(uname -m) != *"64"* ]]; then
platform=x86
fi

build()
{
if [ $ci = true ]; then
Expand Down Expand Up @@ -67,10 +64,10 @@ generate()
fi

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

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

restore()
Expand Down Expand Up @@ -180,6 +177,29 @@ detect_os()
os=$oshost
}

detect_arch()
{
if [ "$oshost" = "linux" ] || [ "$oshost" = "macosx" ]; then
arch=$(uname -m)
if [ "$arch" = "x86_64" ]; then
platform="x64"
elif [ "$arch" = "arm64" ] || [ "$arch" = "aarch64" ]; then
platform="arm64"
else
echo "Unknown architecture: $arch"
fi
elif [ "$oshost" = "windows" ]; then
arch=$(echo $PROCESSOR_ARCHITECTURE)
if [ "$arch" = "AMD64" ]; then
platform="x64"
elif [ "$arch" = "ARM64" ]; then
platform="arm64"
else
echo "Unknown architecture: $arch"
fi
fi
}

find_msbuild()
{
if [ -x "$(command -v MSBuild.exe)" ]; then
Expand All @@ -191,6 +211,7 @@ find_msbuild()

cmd=$(tr '[:upper:]' '[:lower:]' <<< $1)
detect_os
detect_arch
download_premake

while [[ $# > 0 ]]; do
Expand Down Expand Up @@ -227,6 +248,9 @@ while [[ $# > 0 ]]; do
-build_only)
build_only=true
;;
-disable-tests)
disable_tests=true
;;
esac
shift
done
Expand Down

0 comments on commit 0387235

Please sign in to comment.