m (→Git Configuration) |
(→Git Configuration) |
||
| Line 11: | Line 11: | ||
== Git Configuration == | == Git Configuration == | ||
| − | + | KDE uses Git as its main source repository and revision control software which you need to configure before you can use it in KDE. You can find the recommended Git configuration for KDE on the [[Development/Git/Configuration|Git Configuration]] page. | |
| − | + | ||
| − | + | ||
| − | [ | + | |
| − | + | ||
| − | + | ||
== Path Configuration == | == Path Configuration == | ||
Contents |
Configuring your build environment is the single most important step in building KDE. A wrong decision or mistake here could at best mean you have to rebuild everything from scratch again, or at worst break your system KDE rendering your system unusable.
A lot of very important concepts will be discussed and it is important that you understand them before proceeding.
A set of configuration scripts and bash commands are provided as a recommended configuration when building KDE manually. If you use these as provided then your KDE build will be a lot easier and it will be easier for you to find support online. The one disadvantage to these scripts is that they hide important details from you which you may want to learn about, but the two methods are completely interchangeable so once you are comfortable building KDE using the scripts you can learn more by doing everything yourself.
It is recommended that you build KDE using your normal user account. In some circumstances you may want to build using a separate user account, such as if you are a KWin or Plasma developer wishing to test a full KDE session with compositing effects, but for most circumstances a simple way can be found for achieving the same aim while still running using your normal user account (e.g. Nested X using xypher).
KDE uses Git as its main source repository and revision control software which you need to configure before you can use it in KDE. You can find the recommended Git configuration for KDE on the Git Configuration page.
This section explains the different paths that need to be configured for building KDE. The following section will demonstrate a simple method for setting up the required paths.
The $KDE_SRC path environment variable defines where the KDE Build System can find the source files.
TODO: Decide how to do stable and unstable source branches in parallel. While Git supports having these in a single source clone to save disk space, it is sometimes nice to have separate clones to allow simultaneous parallel builds, and it takes less scripting to achieve. It's also conceptually closer to how svn works so seems preferable during the transition.
The $KDE_BUILD path environment variable defines where the KDE Build System will create the build files.
The KDE build system requires that your source and build files be in different directories (aka out-of-source builds). This keeps your source directories clean and simplifies management of your different build files. :
While for some simple build scenarios you could just create a "build" directory inside your 'source' directory (e.g. "kde/src/kdelibs/build"), this negates many of the advantages when used with a full KDE build. Instead clearly separate paths are recommended.
For example if we were building kdelibs we could have the following folders:
/home/myuser/kde/src/kdelibs /home/myuser/kde/build/kdelibs
If you plan to build multiple branches of KDE such as stable and unstable in parallel then you will need to add an extra level to the directory:
/home/myuser/kde/src/master/kdelibs /home/myuser/kde/src/4.6/kdelibs /home/myuser/kde/build/master/kdelibs /home/myuser/kde/build/4.6/kdelibs
The $KDEDIR path environment variable defines where the KDE Build System will install KDE.
It is strongly recommended for a development build that you do a user based install and not a root install, i.e. install your KDE build into a separate user folder and not into the system /usr folder. This provides a number of advantages:
That said, the build instructions provided are completely generic and will work for building a root system install if you configure your environment to do so, i.e. for Linux from Scratch or doing a root install in a virtual machine for testing or packaging purposes.
For the kdelibs example given above we would then have:
/home/myuser/kde/src/master/kdelibs /home/myuser/kde/src/4.6/kdelibs /home/myuser/kde/build/master/kdelibs /home/myuser/kde/build/4.6/kdelibs /home/myuser/kde/inst/master/kdelibs /home/myuser/kde/inst/4.6/kdelibs
The $KDEHOME path environment variable defines wat directory KDE will treat as your home folder, i.e. for stroing data writing config files to.
For the same reason as the Install Path, it is strongly recommended that you set your KDE Home Path to be different from your normal home folder.
For the kdelibs example given above we would then have:
/home/myuser/kde/src/master/kdelibs /home/myuser/kde/src/4.6/kdelibs /home/myuser/kde/build/master/kdelibs /home/myuser/kde/build/4.6/kdelibs /home/myuser/kde/inst/master/kdelibs /home/myuser/kde/inst/4.6/kdelibs /home/myuser/kde/home/master/kdelibs /home/myuser/kde/home/4.6/kdelibs
There are a number of other paths that are required, but these can all be automatically derived and created by the config script given below.
The example environment configuration script given below is for building KDE against your system Qt under your normal user account with an out-of-source build and installing into a user directory. By changing just four variables you can use the script to configure any KDE build environment you want.
It is recommended you create a separate script for each build environment you require. If you have separate source directories for each build then save the script into the root source directory with the name ".build-config" to allow the bash scripts in the next section to automatically load the config and create the required directories.
If you don't wish to use the bash scripts then you must manually create the required directories and manually execute the config script.
If you are building KDE using a dedicated user to run a full desktop session, then you should put this config into the users ~/.bashrc file.
export BASEDIR=~/kde
export BUILDNAME=master
export QTDIR=/usr
export KDE_SRC=$BASEDIR/src export KDE_BUILD=$BASEDIR/build export KDEDIR=$BASEDIR/inst/$BUILDNAME export KDEDIRS=$KDEDIR export KDEHOME=$BASEDIR/home/.$BUILDNAME export KDETMP=/tmp/$BUILDNAME-$USER export KDEVARTMP=/var/tmp/$BUILDNAME-$USER mkdir -p $KDETMP mkdir -p $KDEVARTMP
export QT_PLUGIN_PATH=$KDEDIR/lib/kde4/plugins
export KDE4_DBUS_INTERFACES_DIR=$KDEDIR/share/dbus-1/interfaces export PYTHON_SITE_PACKAGES_DIR=$KDEDIR/lib/python2.6/site-packages/PyKDE4
export PATH=$KDEDIR/bin:$PATH export LD_LIBRARY_PATH=$KDEDIR/lib:$LD_LIBRARY_PATH export PKG_CONFIG_PATH=$KDEDIR/lib/pkgconfig:$PKG_CONFIG_PATH
export CMAKE_PREFIX_PATH=$KDEDIR:$CMAKE_PREFIX_PATH export CMAKE_LIBRARY_PATH=$KDEDIR/lib:$CMAKE_LIBRARY_PATH export CMAKE_INCLUDE_PATH=$KDEDIR/include:$CMAKE_INCLUDE_PATH
unset XDG_DATA_DIRS unset XDG_CONFIG_DIRS
echo echo "*** Configured KDE Build Environment " $BUILDNAME " ***" echo echo "QTDIR=" $QTDIR echo "KDEDIR=" $KDEDIR echo "PATH=" $PATH echo
Save this script in an executable file called "findup" somewhere in your path, usually ~/bin/findup.
arg="$1" if test -z "$arg"; then exit 1; fi
while ! test -f "$arg"; do
cd .. if test "$PWD" = "/"; then exit 1 fi
done
echo $PWD/$arg
prepend() { [ -d "$2" ] && eval $1=\"$2\$\{$1:+':'\$$1\}\" && export $1 ; }
export KDE_COLOR_DEBUG=1 export QTEST_COLORED=1
export OBJ_REPLACEMENT="s#$KDE_SRC#$KDE_BUILD#"
alias make=makeobj
function cmakekde {
if test -n "$1"; then
# srcFolder is defined via command line argument
srcFolder="$1"
else
# get srcFolder for current dir
srcFolder=`pwd | sed -e s,$KDE_BUILD,$KDE_SRC,`
fi
# we are in the src folder, change to build directory
# Alternatively, we could just use makeobj in the commands below...
current=`pwd`
if [ "$srcFolder" = "$current" ]; then
cb
fi
# To disable tests, remove -DKDE4_BUILD_TESTS=TRUE
# To save disk space change "debugfull" to "debug"
cmake "$srcFolder" \
-DCMAKE_INSTALL_PREFIX=$KDEDIR \
-DKDE4_BUILD_TESTS=TRUE \
-DCMAKE_BUILD_TYPE=debugfull
# Comment out the following two lines to stop builds waiting after
# the configuration step, so that the user can check configure output
echo "Press <ENTER> to continue..."
read userinput
# Note: To speed up compiling, change 'make -j2' to 'make -jx',
# where x is your number of processors +1
nice make -j2 && make install
#Use this line instead if using icecream
#nice make CC=icecc -j6 && make install
RETURN=$?
cs
return ${RETURN}
}
function cd() {
if test -z "$1"; then builtin cd elif test -z "$2"; then builtin cd "$1" else builtin cd "$1" "$2" fi _f=`findup .build-config` if test -n "$_f" -a "$_lastf" != "$_f"; then echo "Loading $_f" _lastf="$_f" source "$_f" fi
}
function cb {
local dest
# Make sure build directory exists. mkdir -p "$KDE_BUILD"
# command line argument
if test -n "$1"; then
cd "$KDE_BUILD/$1"
return
fi
# substitute src dir with build dir
dest=`pwd | sed -e s,$KDE_SRC,$KDE_BUILD,`
if test ! -d "$dest"; then
# build directory does not exist, create
mkdir -p "$dest"
fi
cd "$dest"
}
function cs {
local dest current
# Make sure source directory exists. mkdir -p "$KDE_SRC"
# command line argument
if test -n "$1"; then
cd "$KDE_SRC/$1"
else
# substitute build dir with src dir
dest=`pwd | sed -e s,$KDE_BUILD,$KDE_SRC,`
current=`pwd`
if [ "$dest" = "$current" ]; then
cd "$KDE_SRC"
else
cd "$dest"
fi
fi
}
function _cs_scandir {
local base ext
base=$1
ext=$2
if [ -d $base ]; then
for d in `ls $base`; do
if [ -d $base/$d ]; then
dirs="$dirs $ext$d/"
fi
done
fi
}
function _cs() {
local cur dirs
_cs_scandir "$KDE_SRC"
_cs_scandir "$KDE_SRC/KDE" "KDE/"
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
COMPREPLY=( $(compgen -W "${dirs}" -- ${cur}) )
}
complete -F _cs cs
svndiff ()
{
svn diff "$*" | colordiff | less;
}