Last active
December 12, 2015 01:39
-
-
Save daniel-fanjul-alcuten/4692778 to your computer and use it in GitHub Desktop.
building at Spotify
This file contains hidden or 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
alias xdebug='XRELEASE=0 && xstatus' | |
alias xrelease='XRELEASE=1 && xstatus' | |
alias xquiet='XVERBOSE=0 && xstatus' | |
alias xverbose='XVERBOSE=1 && xstatus' | |
alias xnoapk='XAPK=0 && xstatus' | |
alias xapk='XAPK=1 && xstatus' | |
if [ "$(uname)" = Darwin ]; then | |
XPROCS=$(sysctl -n hw.ncpu) | |
else | |
XPROCS=$(grep ^processor /proc/cpuinfo | wc -l) | |
fi | |
function xprocs() { | |
XPROCS="$1" && xstatus | |
} | |
function xstatus() { | |
echo "XRELEASE=$XRELEASE" | |
echo "XVERBOSE=$XVERBOSE" | |
echo "XAPK=$XAPK" | |
echo "XPROCS=$XPROCS" | |
} | |
function xconfig() { | |
if local dirname=$(basename "$PWD"); then | |
if [ "$dirname" == "android" ]; then | |
export ANDROID_SDK_FOLDER="$PWD"/.git/lib/adt-bundle-mac-x86_64 \ | |
ANDROID_TOOLCHAIN_FOLDER="$PWD"/.git/lib/android-ndk-r8d | |
export ANDROID_SDK="$ANDROID_SDK_FOLDER"/sdk \ | |
ANDROID_TOOLCHAIN="$ANDROID_TOOLCHAIN_FOLDER"/toolchains/here | |
fi | |
fi | |
} | |
function xmake() { | |
if local dirname=$(basename "$PWD"); then | |
if [ "$dirname" == "android" ]; then | |
local command="./scripts/setup-cmake-android.sh \"$ANDROID_SDK\" \"$ANDROID_TOOLCHAIN\"" | |
elif [ "$dirname" == "libspotify" ]; then | |
local command=":" | |
else | |
if local system=$(uname); then | |
if [ "$XRELEASE" = 1 ]; then | |
local config="--config Release -DCMAKE_BUILD_TYPE=Release" | |
else | |
local config="--config Debug -DCMAKE_BUILD_TYPE=Debug" | |
fi | |
if [ "$system" = Darwin ]; then | |
local xcode="-G Xcode" | |
fi | |
local command="mkdir -p build && cd build && cmake $config $xcode .." | |
fi | |
fi | |
fi && bash -c "set -x; $command" | |
} | |
function xopen() { | |
if local dirname=$(basename "$PWD"); then | |
if [ "$dirname" == "android" ]; then | |
local command="open .git/lib/adt-bundle-mac-x86_64/eclipse/Eclipse.app/" | |
elif [ "$dirname" == "client-iphone" ]; then | |
local command="open *.xcodeproj/" | |
else | |
local command="open build/*.xcodeproj/" | |
fi | |
fi && bash -c "set -x; $command" | |
} | |
function xemul() { | |
if local dirname=$(basename "$PWD"); then | |
if [ "$dirname" == "android" ]; then | |
# android create avd -c 512M -n testvm16 -p .git/lib/testvm16 -t "android-16" | |
local command="emulator -avd testvm16 &" | |
else | |
local command=":" | |
fi | |
fi && bash -c "set -x; $command" | |
} | |
function xbuild() { | |
if [ "$XRELEASE" = 1 ]; then | |
local xcode_config="-configuration Release" | |
local make_config="CMAKE_BUILD_TYPE=Release" | |
else | |
local xcode_config="-configuration Debug" | |
local make_config="CMAKE_BUILD_TYPE=Debug" | |
fi | |
if [ "$XVERBOSE" = 1 ]; then | |
local verbose="VERBOSE=1" | |
else | |
local verbose="" | |
fi | |
if local dirname=$(basename "$PWD"); then | |
if [ "$dirname" == "android" ]; then | |
local make_config="CMAKE_BUILD_TYPE=Release" | |
local command="make -C build -j $XPROCS $make_config $verbose" | |
if [ "$XAPK" = 1 ]; then | |
command="$command spotify_apk && adb -e install -r ./build/SpotifyAndroid-release.apk" | |
fi | |
elif [ "$dirname" == "client-iphone" ]; then | |
local command="xcodebuild -project *.xcodeproj build $xcode_config -sdk iphonesimulator6.0 -arch i386" | |
elif [ "$dirname" == "libspotify" ]; then | |
local command="make -j $XPROCS $make_config $verbose" | |
else | |
if local system=$(uname); then | |
if [ "$system" = Darwin ]; then | |
local command="cd build && xcodebuild -project *.xcodeproj $xcode_config build" | |
else | |
local command="cd build && make -j $XPROCS $make_config $verbose" | |
fi | |
fi | |
fi | |
fi && bash -c "set -x; $command" | |
} | |
function xtest() { | |
if local dirname=$(basename "$PWD"); then | |
if [ "$dirname" == "android" ]; then | |
local command=":" | |
elif [ "$dirname" == "client-iphone" ]; then | |
local command='ctest -C Debug' | |
elif [ "$dirname" == "libspotify" ]; then | |
local command=":" | |
else | |
local command='cd build && ctest -C Debug' | |
fi | |
fi && bash -c "set -x; $command" | |
} | |
function xo() { | |
xmake && xopen | |
} | |
function xb() { | |
xmake && xbuild | |
} | |
function xt() { | |
xb && xtest | |
} | |
function xc() { | |
git rsclean && git rsupdate | |
} | |
function xco() { | |
xc && xo | |
} | |
function xcb() { | |
xc && xb | |
} | |
function xct() { | |
xc && xt | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment