Last active
April 28, 2017 15:20
-
-
Save djmott/c098cedbfd55b63f388e1694883f0052 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
_set_target_toolchain(){ | |
local target="$1" | |
local toolchain_dir="$2" | |
local bindir="$2" | |
[ -d "$bindir/bin" ] && bindir="$toolchain_dir/bin" | |
export PATH=$bindir:$PATH | |
unset ADDR2LINE AR AS CXX CC CPP ELFEDIT GXX GCOV GDB GPROF LD LDD NM OBJCOPY OBJDUMP POPULATE RANLIB READELF SIZE STRINGS STRIP | |
[ -f "$bindir/$target-addr2line" ] && export ADDR2LINE=$target-addr2line | |
[ -f "$bindir/$target-ar" ] && export AR=$target-ar | |
[ -f "$bindir/$target-as" ] && export AS=$target-as | |
[ -f "$bindir/$target-c++" ] && export CXX=$target-c++ | |
[ -f "$bindir/$target-gcc" ] && export CC=$target-gcc | |
[ -f "$bindir/$target-cpp" ] && export CPP=$target-cpp | |
[ -f "$bindir/$target-elfedit" ] && export ELFEDIT=$target-elfedit | |
[ -f "$bindir/$target-g++" ] && export GXX=$target-g++ | |
[ -f "$bindir/$target-gcov" ] && export GCOV=$target-gcov | |
[ -f "$bindir/$target-gdb" ] && export GDB=$target-gdb | |
[ -f "$bindir/$target-gprof" ] && export GPROF=$target-gprof | |
[ -f "$bindir/$target-ld" ] && export LD=$target-ld | |
[ -f "$bindir/$target-ldd" ] && export LDD=$target-ldd | |
[ -f "$bindir/$target-nm" ] && export NM=$target-nm | |
[ -f "$bindir/$target-objcopy" ] && export OBJCOPY=$target-objcopy | |
[ -f "$bindir/$target-objdump" ] && export OBJDUMP=$target-objdump | |
[ -f "$bindir/$target-populate" ] && export POPULATE=$target-populate | |
[ -f "$bindir/$target-ranlib" ] && export RANLIB=$target-ranlib | |
[ -f "$bindir/$target-readelf" ] && export READELF=$target-readelf | |
[ -f "$bindir/$target-size" ] && export SIZE=$target-size | |
[ -f "$bindir/$target-strings" ] && export STRINGS=$target-strings | |
[ -f "$bindir/$target-strip" ] && export STRIP=$target-strip | |
} | |
toolchain_names=("default" "armv8" "mingw32" "mingw64" "xpc") | |
toolchain_targets=("" "" "" "x86_64-w64-mingw32" "x86_64-xpc-linux-gnu") | |
toolchain_dirs=("" "" "" "/src/toolchains/linux/mingw" "/src/toolchains/linux/xpc") | |
export SYSTOOLCHAIN=${SYSTOOLCHAIN:-"default"} | |
for ((i=0 ; i<${#toolchain_names[@]}; i++)){ | |
if [ "${SYSTOOLCHAIN}" == "${toolchain_names[i]}" ]; then | |
_set_target_toolchain "${toolchain_targets[i]}" "${toolchain_dirs[i]}" | |
break | |
fi | |
} | |
toolchain(){ | |
if [ "0" == "$#" ]; then | |
echo "" | |
echo "Available toolchains: " | |
for ((i=0 ; i<${#toolchain_names[@]}; i++)){ | |
echo " ${toolchain_names[i]}" | |
} | |
echo "Current toolchain: $SYSTOOLCHAIN" | |
echo "" | |
return 0 | |
fi | |
for ((i=0 ; i<${#toolchain_names[@]}; i++)){ | |
if [ "${1}" == "${toolchain_names[i]}" ]; then | |
export SYSTOOLCHAIN="$1" | |
exec bash --login | |
fi | |
} | |
echo "Invalid toolchain: $1" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment