File indexing completed on 2024-11-10 04:05:17

0001 #!/bin/bash
0002 #
0003 #  SPDX-License-Identifier: GPL-3.0-or-later
0004 #
0005 
0006 # Halt on errors and be verbose about what we are doing
0007 set -e
0008 set -x
0009 
0010 # Read in our parameters
0011 export BUILD_PREFIX=$1
0012 export KRITA_SOURCES=$2
0013 export KRITA_BRANDING="${3}"
0014 
0015 # qjsonparser, used to add metadata to the plugins needs to work in a en_US.UTF-8 environment.
0016 # That's not always the case, so make sure it is
0017 export LC_ALL=en_US.UTF-8
0018 export LANG=en_us.UTF-8
0019 
0020 # We want to use $prefix/deps/usr/ for all our dependencies
0021 export DEPS_INSTALL_PREFIX=$BUILD_PREFIX/deps/usr
0022 export DOWNLOADS_DIR=$BUILD_PREFIX/downloads/
0023 
0024 # Setup variables needed to help everything find what we build
0025 export LD_LIBRARY_PATH=$DEPS_INSTALL_PREFIX/lib:$LD_LIBRARY_PATH
0026 export PATH=$DEPS_INSTALL_PREFIX/bin:$PATH
0027 export PKG_CONFIG_PATH=$DEPS_INSTALL_PREFIX/share/pkgconfig:$DEPS_INSTALL_PREFIX/lib/pkgconfig:/usr/lib/pkgconfig:$PKG_CONFIG_PATH
0028 export CMAKE_PREFIX_PATH=$DEPS_INSTALL_PREFIX:$CMAKE_PREFIX_PATH
0029 # https://docs.python.org/3.10/using/cmdline.html#envvar-PYTHONHOME
0030 export PYTHONPATH=$DEPS_INSTALL_PREFIX/sip
0031 export PYTHONHOME=$DEPS_INSTALL_PREFIX
0032 
0033 source ${KRITA_SOURCES}/packaging/linux/appimage/override_compiler.sh.inc
0034 
0035 cd $KRITA_SOURCES
0036 
0037 if [ -z "${KRITA_BRANDING}" ]; then
0038     # determine the channel for branding
0039     if [ "${JOB_NAME}" == "Krita_Nightly_Appimage_Build" ]; then
0040         KRITA_BRANDING="Next"
0041     elif [ "${JOB_NAME}" == "Krita_Stable_Appimage_Build" ]; then
0042         KRITA_BRANDING="Plus"
0043     else
0044         KRITA_BRANDING=""
0045     fi
0046 fi
0047 
0048 BUILD_TYPE="Release"
0049 
0050 # Make sure our build directory exists
0051 if [ ! -d $BUILD_PREFIX/krita-build/ ] ; then
0052     mkdir -p $BUILD_PREFIX/krita-build/
0053 fi
0054 
0055 # Now switch to it
0056 cd $BUILD_PREFIX/krita-build/
0057 
0058 # Determine how many CPUs we have
0059 CPU_COUNT=`grep -c processor /proc/cpuinfo`
0060 
0061 if [ $CPU_COUNT -gt 2 ]; then
0062     let "jobs = ${CPU_COUNT} - 2"
0063     CPU_COUNT=$jobs
0064 fi
0065 
0066 # Configure Krita
0067 cmake $KRITA_SOURCES \
0068     -DCMAKE_INSTALL_PREFIX:PATH=$BUILD_PREFIX/krita.appdir/usr \
0069     -DDEFINE_NO_DEPRECATED=1 \
0070     -DCMAKE_BUILD_TYPE=${BUILD_TYPE} \
0071     -DFOUNDATION_BUILD=1 \
0072     -DHIDE_SAFE_ASSERTS=ON \
0073     -DBUILD_TESTING=FALSE \
0074     -DKRITA_ENABLE_PCH=off \
0075     -DPYQT_SIP_DIR_OVERRIDE=$DEPS_INSTALL_PREFIX/share/sip/ \
0076     -DHAVE_MEMORY_LEAK_TRACKER=FALSE \
0077     -DBRANDING="${KRITA_BRANDING}"
0078 
0079 # Build and Install Krita (ready for the next phase)
0080 cmake --build . --target install --parallel $CPU_COUNT
0081 
0082 # We add Krita's AppImage location for plugins (GMic)
0083 export PLUGINS_INSTALL_PREFIX=$BUILD_PREFIX/krita.appdir/usr
0084 
0085 # Setup variables needed to help everything find what we build
0086 ARCH=`dpkg --print-architecture`
0087 export LD_LIBRARY_PATH=$PLUGINS_INSTALL_PREFIX/lib:$LD_LIBRARY_PATH
0088 export CMAKE_PREFIX_PATH=$PLUGINS_INSTALL_PREFIX:$CMAKE_PREFIX_PATH
0089 
0090 # Make sure our build directory exists
0091 if [ ! -d $BUILD_PREFIX/plugins-build/ ] ; then
0092     mkdir -p $BUILD_PREFIX/plugins-build/
0093 fi
0094 
0095 # The 3rdparty dependency handling in Krita also requires the install directory to be pre-created
0096 if [ ! -d $DOWNLOADS_DIR ] ; then
0097     mkdir -p $DOWNLOADS_DIR
0098 fi
0099 
0100 # Switch to our build directory as we're basically ready to start building...
0101 cd $BUILD_PREFIX/plugins-build/
0102 
0103 # Configure the dependencies for building
0104 cmake $KRITA_SOURCES/3rdparty_plugins \
0105     -DCMAKE_INSTALL_PREFIX=$PLUGINS_INSTALL_PREFIX \
0106     -DINSTALL_ROOT=$PLUGINS_INSTALL_PREFIX \
0107     -DEXTERNALS_DOWNLOAD_DIR=$DOWNLOADS_DIR \
0108     -DSUBMAKE_JOBS=$CPU_COUNT
0109 
0110 # Now start building everything we need, in the appropriate order
0111 cmake --build . --target ext_gmic --parallel $CPU_COUNT