Centerlink (Talk | contribs) (Preliminary and still partly Finnish translation.) |
Centerlink (Talk | contribs) m (Still translating part of text.) |
||
| Line 114: | Line 114: | ||
==== CMake ja alihakemistot ==== | ==== CMake ja alihakemistot ==== | ||
| − | cd 4/kdelibs/kio/kio ; make => | + | cd 4/kdelibs/kio/kio ; make => mitään ei tapahdu, Makefile on äitihakemistossa. |
| − | + | Huolehdi, että editorisi käyttää sen sijaan käärinskriptiä | |
<code bash> | <code bash> | ||
#!/bin/sh | #!/bin/sh | ||
| Line 139: | Line 139: | ||
</code> | </code> | ||
| − | + | Hae tämä skripti: http://web.davidfaure.fr/scripts/makefromemacs. | |
==== CMake ja riippuvaisuudet ==== | ==== CMake ja riippuvaisuudet ==== | ||
touch kdecore/kapplication.h | touch kdecore/kapplication.h | ||
cd kdeui ; make | cd kdeui ; make | ||
| − | => | + | => kääntää ensin kohteen kdecore |
touch kdecore/kapplication.h | touch kdecore/kapplication.h | ||
cd kdeui ; make kdeui/fast | cd kdeui ; make kdeui/fast | ||
| − | => | + | => kääntää uudelleen vain kohteen kdeui |
make install/fast | make install/fast | ||
| − | + | Mutta huomaa, että normaalitila (ilman /fast) on myös hyödyllinen muissa tapauksissa: | |
| − | + | Esimerkiksi muokkaat | |
kdelibs/kio/kio/kdirmodel.cpp | kdelibs/kio/kio/kdirmodel.cpp | ||
| − | + | ja teet sille yksikkötestin | |
kdelibs/kio/tests/kdirmodeltest.cpp | kdelibs/kio/tests/kdirmodeltest.cpp | ||
| − | + | Silloin, jos haluat kääntää uudelleen sekä libkio että yksikkötestin, anna vain käsky "make kdirmodeltest" hakemistosta kdelibs/kio/tests. | |
=== KDE 4-ympäristömuuttujien luettelo === | === KDE 4-ympäristömuuttujien luettelo === | ||
| − | + | Tämä luettelee kaikki ympäristömuuttujat, jotka sinun pitäisi asettaa esimerkiksi tiedostossa $KDESRC/4/.my-setup | |
==== Qt ==== | ==== Qt ==== | ||
| Line 203: | Line 203: | ||
</code> | </code> | ||
| − | {{warning| | + | {{warning|Älä koskaan poista tiedostoa CMakeCache.txt ja kirjoita sitten komentoa make; suorita aina cmake uudelleen oikeilla valitsimilla CMakeCache.txt-tiedoston poistamisen jälkeen.}} |
===Käyttäen kdesvn-build=== | ===Käyttäen kdesvn-build=== | ||
Contents |
Languages: عربي | Asturianu | Català | Česky | Kaszëbsczi | Dansk | Deutsch | English | Esperanto | Español | Eesti | فارسی | Suomi | Français | Galego | Italiano | 日本語 | 한국어 | Norwegian | Polski | Português Brasileiro | Română | Русский | Svenska | Slovenčina | Slovenščina | српски | Türkçe | Tiếng Việt | Українська | 简体中文 | 繁體中文
| Tutorial Series | Getting Started |
| Previous | Getting Started/Build/KDE4 |
| What's Next | n/a |
| Further Reading | Alkuperäisen esittelyn tekijä: David Faure |
Time is precious. This tutorial shares David Faure's collected wisdom for how to get the most of our time and effort by saving on both using some simple scripts and techniques while developing KDE 4.
If you really want to use a separate account for development, see here.
But to save time and avoid many problems, it is strongly recommended to do it all from your usual user. All you need is an easy way to switch between environments. You go to ~/kde/src/4, you want to be in the kde4 environment, right?
To do this, paste http://web.davidfaure.fr/scripts/cd_function into your .zshrc or .bashrc, and download http://web.davidfaure.fr/scripts/findup somewhere in your $PATH (for instance into $HOME/bin or /usr/local/bin).
This way, whenever you enter a directory, it will look up a .my-setup file and source it (it also looks up in parent directories until it finds one, and it doesn't source the same one twice in a row).
Set up all the environment variables that are specific to kde4 (they will be detailed later on in this page) into that ~/kde/src/4/.my-setup file, and do the same for other environments (kde3, and anywhere you need project-specific environment variables...)
For Qt, by habit from the Qt3 times and to save time by avoiding "make install" after a change, I recommend using one directory for source, builds and install. This is done by configuring Qt with --prefix=$PWD. This isn't mandatory though.
Qt-Path: ~/qt/4/qt-copy
It was convenient in kde3, it is mandatory in kde4: you need to use out-of-source builds, i.e. separate build and source directories. It makes it very easy to rebuild from scratch, removing all generated files - even old ones that "make clean" wouldn't remove. It is easier to look at the source files (grep, ls etc.). It allows multiple build trees with different settings, e.g. debug and release.
Thus source modules for kde4 are checked out in ~/kde/src/4/ and building happens in ~/kde/build/4/.
If you use bash, take a look at this .bashrc. It is an example bash config which sets all KDE4 environment variables and some helper functions. You can also look at these scripts which are based on the above .bashrc.
The steps below describe some of these features as well as giving alternative and additional functions.
Read further about compiling a KDE module.
To easily swap from build and source folder back and forth, you can use cs and cb functions that work like the following:
pwd
~/kde/src/4/kdebase
cb && pwd
~/kde/build/4/kdebase # note that this folder is created if it does not exist
cs && pwd
~/kde/src/4/kdebase
A number of kde-related scripts will have to be able to do the same. Simply do: export OBJ_REPLACEMENT='s#/kde/src/#/kde/build/#' This allows the makeobj script from kdesdk to switch from src to build. If you also do: alias make=makeobj then you can simply type make from the source dir and it will be able to build. This is also very useful in editors - if your vi or emacs uses makeobj as the make command, you can compile with a single key press.
In addition, for fast navigation to other directories, it is very convenient to be able to type "cs 4/kdelibs" in order to go to ~/src/4/kdelibs, from anywhere. For instance, you could be in ~/kde/src/4/kdebase/workspace/kcontrol and now you decide to look at kdecore... No need to type a long series of "../.." or to restart from the top. You can just type cs 4/kdelibs/kdecore.
This is doable via the two functions cs and cb defined in the .bashrc.
The following code will enable you to use cd similar to cs described above:
export CDPATH=.:~/kde/src
The advantage, when using zsh, is that completion even works. Try cd 4/kdemul and press Tab, it will complete to 4/kdemultimedia, no matter where you currently are. Doesn't work in bash though - but surely you're using zsh by now, aren't you? :)
The minimal cs and cb aliases (same as above but without support for arguments) are: alias cb='cd `pwd | sed -e s,/kde/src/,/kde/build/,`' alias cs='cd `pwd | sed -e s,/kde/build/,/kde/src/,`'
Going back to the previous directory easily can be done with zsh. Set this in .zshrc:
setopt AUTO_PUSHD
alias p=popd
and then you can type "p" to pop back to the directory where you were last,
as many times as needed (type "dirs -v" to see the stack of previous directories).
Here you can find more CMake information.
cd 4/kdelibs/kio/kio ; make => mitään ei tapahdu, Makefile on äitihakemistossa.
Huolehdi, että editorisi käyttää sen sijaan käärinskriptiä
if test "$1" = "-k"; then shift; fi cmake_in_parent=0 if test -f CMakeLists.txt; then
if ! grep -q kde4_add CMakeLists.txt; then
cmake_in_parent=1
cd ..
fi
fi if test $# -gt 0; then
arg="$1"
if test "$arg" != install -a $cmake_in_parent -eq 1; then
arg=`basename $PWD`/"$arg"
fi
fi
jvalue=1 echo "calling makeobj -j $jvalue $arg" makeobj -j $jvalue $arg
Hae tämä skripti: http://web.davidfaure.fr/scripts/makefromemacs.
touch kdecore/kapplication.h cd kdeui ; make
=> kääntää ensin kohteen kdecore
touch kdecore/kapplication.h cd kdeui ; make kdeui/fast
=> kääntää uudelleen vain kohteen kdeui
make install/fast
Mutta huomaa, että normaalitila (ilman /fast) on myös hyödyllinen muissa tapauksissa: Esimerkiksi muokkaat
kdelibs/kio/kio/kdirmodel.cpp
ja teet sille yksikkötestin
kdelibs/kio/tests/kdirmodeltest.cpp
Silloin, jos haluat kääntää uudelleen sekä libkio että yksikkötestin, anna vain käsky "make kdirmodeltest" hakemistosta kdelibs/kio/tests.
Tämä luettelee kaikki ympäristömuuttujat, jotka sinun pitäisi asettaa esimerkiksi tiedostossa $KDESRC/4/.my-setup
export QTDIR=/d/qt/4/qt-copy
export PATH=$QTDIR/bin:$PATH
export LD_LIBRARY_PATH=$QTDIR/lib:$LD_LIBRARY_PATH
export PKG_CONFIG_PATH=$QTDIR/lib:$PKG_CONFIG_PATH
export KDEDIR=/d/kde/inst/kde4
export PATH=$KDEDIR/bin:$PATH
export LD_LIBRARY_PATH=$KDEDIR/lib:$LD_LIBRARY_PATH
export QT_PLUGIN_PATH=$KDEDIR/lib/kde4/plugins
export KDEDIRS=$KDEDIR
export KDEHOME=$HOME/.kde4
export QTEST_COLORED=1
export KDE_COLOR_DEBUG=1
If you use the aforementioned ~/.bashrc it is very convenient to compile a KDE module (it is required to already have aquired the source code, e.g. via SVN. see Using Subversion with KDE):
cs KDE/kdebase
cmakekde
Else you'll have to do the following:
mkdir -p ~/build/KDE/kdebase && cd ~/build/KDE/kdebase
cmake -DKDE4_BUILD_TESTS=TRUE -DCMAKE_BUILD_TYPE=debugfull \
-DCMAKE_INSTALL_PREFIX=~/kde ~/src/KDE/kdebase
make
| Warning |
|---|
| Älä koskaan poista tiedostoa CMakeCache.txt ja kirjoita sitten komentoa make; suorita aina cmake uudelleen oikeilla valitsimilla CMakeCache.txt-tiedoston poistamisen jälkeen. |
kdesvn-build is an all-in-one script: it handles the checking-out or updating from subversion, running cmake, make, make install, and storing all output in log files.
Copy kdesvn-buildrc-sample to $KDE_SRC/.kdesvn-buildrc, then edit it. Global options:
Per-module options:
module qt-copy # kdesvn-build sets the prefix to $qtdir configure-flags [....] apply-qt-patches true make-options -j3 sub-src sub-tools end module module kdelibs make-options -DKDE4_BUILD_TESTS=TRUE -DCMAKE_BUILD_TYPE=debugfull end module
Xephyr -screen 1240x768 -ac :4 & export DISPLAY=:4 sh -x startkde 2>&1 | tee kde4.log
>./list-kde4-binaries /d/kde/inst/kde4/bin/kwin, pid 6756 /d/kde/inst/kde4/bin/kpersonalizer, pid 6757
>./kill-kde4-binaries Killing /d/kde/inst/kde4/bin/kwin, pid 6756 Killing /d/kde/inst/kde4/bin/kpersonalizer, pid 6757
You can get the scripts list-kde4-binaries and kill-kde4-binaries from http://web.davidfaure.fr/scripts/