mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-05 15:18:49 +00:00
build_odin.sh - fix build on darwin arm64
Done: - use ARCH variable properly - refactor have_which() to use POSIX compliant command - ref - use command instead of which for the same reason as above. - run shfmt for consistency.
This commit is contained in:
+13
-11
@@ -25,11 +25,11 @@ panic() {
|
|||||||
version() { echo "$@" | awk -F. '{ printf("%d%03d%03d%03d\n", $1,$2,$3,$4); }'; }
|
version() { echo "$@" | awk -F. '{ printf("%d%03d%03d%03d\n", $1,$2,$3,$4); }'; }
|
||||||
|
|
||||||
config_darwin() {
|
config_darwin() {
|
||||||
ARCH=$(uname -m)
|
local ARCH=$(uname -m)
|
||||||
: ${LLVM_CONFIG=llvm-config}
|
: ${LLVM_CONFIG=llvm-config}
|
||||||
|
|
||||||
# allow for arm only llvm's with version 13
|
# allow for arm only llvm's with version 13
|
||||||
if [ ARCH == arm64 ]; then
|
if [ "${ARCH}" == "arm64" ]; then
|
||||||
MIN_LLVM_VERSION=("13.0.0")
|
MIN_LLVM_VERSION=("13.0.0")
|
||||||
else
|
else
|
||||||
# allow for x86 / amd64 all llvm versions beginning from 11
|
# allow for x86 / amd64 all llvm versions beginning from 11
|
||||||
@@ -37,7 +37,7 @@ config_darwin() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [ $(version $($LLVM_CONFIG --version)) -lt $(version $MIN_LLVM_VERSION) ]; then
|
if [ $(version $($LLVM_CONFIG --version)) -lt $(version $MIN_LLVM_VERSION) ]; then
|
||||||
if [ ARCH == arm64 ]; then
|
if [ "${ARCH}" == "arm64" ]; then
|
||||||
panic "Requirement: llvm-config must be base version 13 for arm64"
|
panic "Requirement: llvm-config must be base version 13 for arm64"
|
||||||
else
|
else
|
||||||
panic "Requirement: llvm-config must be base version greater than 11 for amd64/x86"
|
panic "Requirement: llvm-config must be base version greater than 11 for amd64/x86"
|
||||||
@@ -59,11 +59,11 @@ config_freebsd() {
|
|||||||
: ${LLVM_CONFIG=}
|
: ${LLVM_CONFIG=}
|
||||||
|
|
||||||
if [ ! "$LLVM_CONFIG" ]; then
|
if [ ! "$LLVM_CONFIG" ]; then
|
||||||
if which llvm-config11 > /dev/null 2>&1; then
|
if [ -x "$(command -v llvm-config11)" ]; then
|
||||||
LLVM_CONFIG=llvm-config11
|
LLVM_CONFIG=llvm-config11
|
||||||
elif which llvm-config12 > /dev/null 2>&1; then
|
elif [ -x "$(command -v llvm-config12)" ]; then
|
||||||
LLVM_CONFIG=llvm-config12
|
LLVM_CONFIG=llvm-config12
|
||||||
elif which llvm-config13 > /dev/null 2>&1; then
|
elif [ -x "$(command -v llvm-config13)" ]; then
|
||||||
LLVM_CONFIG=llvm-config13
|
LLVM_CONFIG=llvm-config13
|
||||||
else
|
else
|
||||||
panic "Unable to find LLVM-config"
|
panic "Unable to find LLVM-config"
|
||||||
@@ -86,11 +86,11 @@ config_linux() {
|
|||||||
: ${LLVM_CONFIG=}
|
: ${LLVM_CONFIG=}
|
||||||
|
|
||||||
if [ ! "$LLVM_CONFIG" ]; then
|
if [ ! "$LLVM_CONFIG" ]; then
|
||||||
if which llvm-config > /dev/null 2>&1; then
|
if [ -x "$(command -v llvm-config)" ]; then
|
||||||
LLVM_CONFIG=llvm-config
|
LLVM_CONFIG=llvm-config
|
||||||
elif which llvm-config-11 > /dev/null 2>&1; then
|
elif [ -x "$(command -v llvm-config-11)" ]; then
|
||||||
LLVM_CONFIG=llvm-config-11
|
LLVM_CONFIG=llvm-config-11
|
||||||
elif which llvm-config-11-64 > /dev/null 2>&1; then
|
elif [ -x "$(command -v llvm-config-11-16)" ]; then
|
||||||
LLVM_CONFIG=llvm-config-11-64
|
LLVM_CONFIG=llvm-config-11-64
|
||||||
else
|
else
|
||||||
panic "Unable to find LLVM-config"
|
panic "Unable to find LLVM-config"
|
||||||
@@ -111,7 +111,7 @@ config_linux() {
|
|||||||
|
|
||||||
LDFLAGS="$LDFLAGS -ldl"
|
LDFLAGS="$LDFLAGS -ldl"
|
||||||
CXXFLAGS="$CXXFLAGS $($LLVM_CONFIG --cxxflags --ldflags)"
|
CXXFLAGS="$CXXFLAGS $($LLVM_CONFIG --cxxflags --ldflags)"
|
||||||
LDFLAGS="$LDFLAGS $($LLVM_CONFIG --libs core native --system-libs --libfiles) -Wl,-rpath=\$ORIGIN"
|
LDFLAGS="$LDFLAGS $($LLVM_CONFIG --libs core native --system-libs --libfiles) -Wl,-rpath=\$ORIGIN"
|
||||||
|
|
||||||
# Creates a copy of the llvm library in the build dir, this is meant to support compiler explorer.
|
# Creates a copy of the llvm library in the build dir, this is meant to support compiler explorer.
|
||||||
# The annoyance is that this copy can be cluttering the development folder. TODO: split staging folders
|
# The annoyance is that this copy can be cluttering the development folder. TODO: split staging folders
|
||||||
@@ -135,6 +135,7 @@ build_odin() {
|
|||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
panic "Build mode unsupported!"
|
panic "Build mode unsupported!"
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
set -x
|
set -x
|
||||||
@@ -147,7 +148,7 @@ run_demo() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
have_which() {
|
have_which() {
|
||||||
if ! which which > /dev/null 2>&1; then
|
if ! [ -x "$(command -v which)" ]; then
|
||||||
panic "Could not find \`which\`"
|
panic "Could not find \`which\`"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
@@ -169,6 +170,7 @@ FreeBSD)
|
|||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
panic "Platform unsupported!"
|
panic "Platform unsupported!"
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
if [[ $# -eq 0 ]]; then
|
if [[ $# -eq 0 ]]; then
|
||||||
|
|||||||
Reference in New Issue
Block a user