#!/bin/bash # Auxiliary script for semi-automated building of OCCT for iOS platform. # Script should be placed into root of OCCT repository, edited with paths # to CMake and 3rd-parties. # https://dev.opencascade.org/ # FreeType should be specified as mandatory dependency # (should be manually build or taken from earlier builds). # https://www.opencascade.com/content/3rd-party-components # CMake toolchain definition should be cloned from the following git repository: # https://github.com/leetal/ios-cmake # CMake can be downloaded from official site: # https://cmake.org/download/ # go to the script directory aScriptPath=${BASH_SOURCE%/*} if [ -d "$aScriptPath" ]; then cd "$aScriptPath"; fi aScriptPath="$PWD" aCasSrc=$aScriptPath aNbJobs="$(getconf _NPROCESSORS_ONLN)" PATH=/Applications/CMake.app/Contents/bin:$PATH aToolchain=$HOME/Develop/3rdparty-ios/ios-cmake.git/ios.toolchain.cmake # paths to pre-built 3rd-parties aFreeType=$HOME/Develop/3rdparty-ios/freetype-2.7.1-ios # build stages to perform toSimulator=0 toCMake=1 toClean=1 toMake=1 toInstall=1 toPack=1 export MACOSX_DEPLOYMENT_TARGET= export IPHONEOS_DEPLOYMENT_TARGET=8.0 anAbi=arm64 aPlatform=OS64 aPlatformAndCompiler=ios-$anAbi-clang if [[ $toSimulator == 1 ]]; then anAbi=x86_64 aPlatform=SIMULATOR64 aPlatformAndCompiler=ios-simulator64-clang fi aWorkDir=work/${aPlatformAndCompiler}-make aDestDir=$aCasSrc/work/$aPlatformAndCompiler aLogFile=$aCasSrc/build-${aPlatformAndCompiler}.log # include some information about OCCT into archive echo \> VERSION.html git status >> VERSION.html git log -n 100 >> VERSION.html echo \>> VERSION.html mkdir -p $aWorkDir rm -f $aLogFile pushd $aWorkDir aTimeZERO=$SECONDS set -o pipefail function logDuration { if [[ $1 == 1 ]]; then aDur=$(($4 - $3)) echo $2 time: $aDur sec>> $aLogFile fi } # (re)generate Make files if [[ $toCMake == 1 ]]; then echo Configuring OCCT for iOS... cmake -G "Unix Makefiles" \ -D CMAKE_TOOLCHAIN_FILE:FILEPATH="$aToolchain" \ -D PLATFORM:STRING="$aPlatform" \ -D ARCHS:STRING="$anAbi" \ -D IOS_DEPLOYMENT_TARGET:STRING="$IPHONEOS_DEPLOYMENT_TARGET" \ -D ENABLE_VISIBILITY:BOOL="TRUE" \ -D CMAKE_C_USE_RESPONSE_FILE_FOR_OBJECTS:BOOL="OFF" \ -D CMAKE_CXX_USE_RESPONSE_FILE_FOR_OBJECTS:BOOL="OFF" \ -D CMAKE_BUILD_TYPE:STRING="Release" \ -D BUILD_LIBRARY_TYPE:STRING="Static" \ -D INSTALL_DIR:PATH="$aDestDir" \ -D INSTALL_DIR_INCLUDE:STRING="inc" \ -D INSTALL_DIR_LIB:STRING="lib" \ -D INSTALL_DIR_RESOURCE:STRING="src" \ -D INSTALL_NAME_DIR:STRING="@executable_path/../Frameworks" \ -D 3RDPARTY_FREETYPE_DIR:PATH="$aFreeType" \ -D 3RDPARTY_FREETYPE_INCLUDE_DIR_freetype2:FILEPATH="$aFreeType/include" \ -D 3RDPARTY_FREETYPE_INCLUDE_DIR_ft2build:FILEPATH="$aFreeType/include" \ -D 3RDPARTY_FREETYPE_LIBRARY_DIR:PATH="$aFreeType/lib" \ -D USE_FREEIMAGE:BOOL="OFF" \ -D BUILD_MODULE_Draw:BOOL="OFF" \ "$aCasSrc" 2>&1 | tee -a $aLogFile aResult=$?; if [[ $aResult != 0 ]]; then exit $aResult; fi fi aTimeGEN=$SECONDS logDuration $toCMake "Generation" $aTimeZERO $aTimeGEN # clean up from previous build if [[ $toClean == 1 ]]; then make clean fi # build the project if [[ $toMake == 1 ]]; then echo Building... make -j $aNbJobs 2>&1 | tee -a $aLogFile aResult=$?; if [[ $aResult != 0 ]]; then exit $aResult; fi fi aTimeBUILD=$SECONDS logDuration $toMake "Building" $aTimeGEN $aTimeBUILD logDuration $toMake "Total building" $aTimeZERO $aTimeBUILD # install the project if [[ $toInstall == 1 ]]; then echo Installing into $aCasSrc/work/$aPlatformAndCompiler... make install 2>&1 | tee -a $aLogFile cp -f $aCasSrc/VERSION.html $aDestDir/VERSION.html fi aTimeINSTALL=$SECONDS logDuration $toInstall "Install" $aTimeBUILD $aTimeINSTALL # create an archive if [[ $toPack == 1 ]]; then anArchName=occt-$aPlatformAndCompiler.tar.bz2 echo Creating an archive $aCasSrc/work/$anArchName... rm $aCasSrc/work/$aPlatformAndCompiler/../$anArchName &>/dev/null pushd $aCasSrc/work/$aPlatformAndCompiler tar -jcf $aCasSrc/work/$aPlatformAndCompiler/../$anArchName * popd fi aTimePACK=$SECONDS logDuration $toPack "Packing archive" $aTimeINSTALL $aTimePACK # finished DURATION=$(($aTimePACK - $aTimeZERO)) echo Total time: $DURATION sec logDuration 1 "Total" $aTimeZERO $aTimePACK popd