2013-05-13 15:18:18 +08:00
#!/bin/bash
2016-09-01 16:25:47 +08:00
2013-05-13 15:18:18 +08:00
# exit this script if any commmand fails
set -e
DIR = " $( cd " $( dirname " ${ BASH_SOURCE [0] } " ) " && pwd ) "
2021-05-18 16:40:30 +08:00
ADXE_ROOT = " $DIR " /../..
2017-01-19 13:55:14 +08:00
CPU_CORES = 4
2013-05-13 15:18:18 +08:00
2018-10-19 18:10:54 +08:00
function do_retry( )
{
cmd = $@
retry_times = 5
retry_wait = 3
c = 0
while [ $c -lt $(( retry_times+1)) ] ; do
c = $(( c+1))
echo " Executing \" $cmd \", try $c "
$cmd && return $?
if [ ! $c -eq $retry_times ] ; then
echo " Command failed, will retry in $retry_wait secs "
sleep $retry_wait
else
echo "Command failed, giving up."
return 1
fi
done
}
2016-09-01 16:25:47 +08:00
function build_linux( )
{
2021-05-15 01:00:20 +08:00
# source ../environment.sh
2021-05-18 16:40:30 +08:00
cd $ADXE_ROOT
2019-11-29 10:02:03 +08:00
set -x
2020-08-24 16:26:12 +08:00
cmake . -G "Unix Makefiles" -Bbuild -DCMAKE_BUILD_TYPE= Release
2020-09-25 11:07:56 +08:00
cmake --build build --target cpp-tests -- -j ` nproc`
2019-11-29 10:02:03 +08:00
set +x
2016-09-01 16:25:47 +08:00
}
2020-09-25 11:07:56 +08:00
function build_osx( )
2018-07-29 23:23:40 +08:00
{
2018-09-25 11:16:04 +08:00
NUM_OF_CORES = ` getconf _NPROCESSORS_ONLN`
2019-11-15 10:24:38 +08:00
2021-05-18 16:40:30 +08:00
cd $ADXE_ROOT
2020-08-24 16:26:12 +08:00
mkdir -p build
2021-07-09 10:35:57 +08:00
cmake -S . -B build -GXcode -DBUILD_EXTENSION_IMGUIEXT= ON -DBUILD_DEP_ALSOFT= ON
2020-09-21 22:10:50 +08:00
cmake --build build --config Release --target cpp-tests -- -quiet
2021-12-30 17:47:01 +08:00
2018-07-29 23:23:40 +08:00
exit 0
}
2020-09-25 11:07:56 +08:00
function build_ios( )
2018-07-29 23:23:40 +08:00
{
2018-09-25 11:16:04 +08:00
NUM_OF_CORES = ` getconf _NPROCESSORS_ONLN`
2021-05-18 16:40:30 +08:00
cd $ADXE_ROOT
2020-08-24 16:26:12 +08:00
2021-07-09 10:35:57 +08:00
cmake -S . -B build -GXcode -DCMAKE_TOOLCHAIN_FILE= cmake/ios.mini.cmake -DCMAKE_OSX_ARCHITECTURES= x86_64 -DBUILD_DEP_ALSOFT= ON
2020-02-07 20:59:22 +08:00
# cmake .. -GXcode -DCMAKE_TOOLCHAIN_FILE=../cmake/ios.toolchain.cmake -DCMAKE_SYSTEM_NAME=iOS -DPLATFORM=OS -DENABLE_ARC=0 # too much logs on console when "cmake --build ."
2020-08-24 16:26:12 +08:00
cmake --build build --config Release --target cpp-tests -- -quiet -jobs $NUM_OF_CORES -destination "platform=iOS Simulator,name=iPhone Retina (4-inch)"
2019-11-29 10:02:03 +08:00
2018-07-29 23:23:40 +08:00
exit 0
}
2020-09-25 11:07:56 +08:00
function build_android( )
2018-09-17 11:54:39 +08:00
{
2022-01-28 15:01:42 +08:00
# print jdk detail
echo " JAVA_HOME= $JAVA_HOME "
java -version
2018-09-17 11:54:39 +08:00
# Build all samples
echo "Building Android samples ..."
source ../environment.sh
2022-01-08 00:08:12 +08:00
# build fairygui-tests
pushd $ADXE_ROOT /tests/fairygui-tests/proj.android
do_retry ./gradlew assembleRelease -PPROP_BUILD_TYPE= cmake -PPROP_APP_ABI= $BUILD_ARCH --parallel --info
popd
2018-09-17 11:54:39 +08:00
# build cpp-tests
2021-05-18 16:40:30 +08:00
pushd $ADXE_ROOT /tests/cpp-tests/proj.android
2020-11-09 17:53:23 +08:00
2021-06-05 01:22:33 +08:00
do_retry ./gradlew assembleRelease -PPROP_BUILD_TYPE= cmake -PPROP_APP_ABI= $BUILD_ARCH --parallel --info
2018-09-17 11:54:39 +08:00
popd
}
2021-07-09 10:35:57 +08:00
function run_build( )
2016-09-01 16:25:47 +08:00
{
2021-07-09 10:35:57 +08:00
echo "Building..."
2019-03-25 10:08:49 +08:00
2020-09-25 11:07:56 +08:00
if [ $BUILD_TARGET = = 'osx' ] ; then
2019-11-29 10:02:03 +08:00
set -x
2020-09-25 11:07:56 +08:00
build_osx
2019-03-25 10:08:49 +08:00
exit 0
fi
2020-09-25 11:07:56 +08:00
if [ $BUILD_TARGET = = 'ios' ] ; then
2019-11-29 10:02:03 +08:00
set -x
2020-09-25 11:07:56 +08:00
build_ios
2019-03-25 10:08:49 +08:00
exit 0
fi
2016-09-01 16:25:47 +08:00
# linux
if [ $BUILD_TARGET = = 'linux' ] ; then
build_linux
2014-03-10 18:13:39 +08:00
fi
2016-09-01 16:25:47 +08:00
2018-09-17 11:54:39 +08:00
# android
2020-09-25 11:07:56 +08:00
if [ $BUILD_TARGET = = 'android' ] ; then
build_android
2018-09-17 11:54:39 +08:00
fi
2016-09-01 16:25:47 +08:00
}
2013-06-25 01:41:48 +08:00
2021-07-09 10:35:57 +08:00
run_build