blob: cab447bfeddb3cd5757b7fec1abf8e6ba12c2bb1 [file] [log] [blame]
#!/bin/bash
# Exit on error and show the commands as they execute.
set -ex
# Ensure we get the full path of this script's directory.
PROGDIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
GPU_ROOT=$PROGDIR/..
BUILD_ROOT=`pwd`/build
# Detect if it's the linux build bot that cross compiles windows
HOST_OS=$(uname | tr A-Z a-z)
if [[ $HOST_OS == "linux" ]]; then
crosscompile_windows=1
CMAKE=$GPU_ROOT/../../../../../../../prebuilts/cmake/linux-x86/bin/cmake
NINJA=$GPU_ROOT/../../../../../../../prebuilts/ninja/linux-x86/ninja
else
crosscompile_windows=0
CMAKE=$GPU_ROOT/../../../../../../../prebuilts/cmake/darwin-x86/bin/cmake
NINJA=$GPU_ROOT/../../../../../../../prebuilts/ninja/darwin-x86/ninja
fi
# Defaults if not specified on the command line
BUILD_NUMBER="SNAPSHOT-"`date "+%Y-%m-%dT%H:%M:%S%z"`
DIST_DIR=$BUILD_ROOT/dist
function show_help {
# Turn off command echoing so the help message is readable.
set +x
echo "USAGE: "`basename $0`" [options]"
echo ""
echo " -b <name/number> Sets the build number (used for artifact naming)."
echo " -d <absolute path> Sets the distribution directory."
echo " -h Show this message."
}
while getopts "b:d:f:h?iwx" opt; do
case "$opt" in
b) BUILD_NUMBER=$OPTARG
;;
d) DIST_DIR=$OPTARG
;;
h|\?) show_help
exit 0
;;
esac
done
HOST_BUILD_DIR=$BUILD_ROOT/$HOST_OS
mkdir -p $HOST_BUILD_DIR
cd $HOST_BUILD_DIR
$CMAKE -GNinja -DBUILDBOT=ON -DCPACK_OUTPUT_FILE_PREFIX=$DIST_DIR -DCMAKE_MAKE_PROGRAM=$NINJA $GPU_ROOT
$NINJA package
if [ $crosscompile_windows -eq 1 ]; then
WINDOWS_BUILD_DIR=$BUILD_ROOT/windows
mkdir -p $WINDOWS_BUILD_DIR
cd $WINDOWS_BUILD_DIR
$CMAKE -GNinja -DCMAKE_SYSTEM_NAME=Windows -DBUILDBOT=ON -DCPACK_OUTPUT_FILE_PREFIX=$DIST_DIR -DCMAKE_MAKE_PROGRAM=$NINJA $GPU_ROOT
$NINJA package
fi