Shorter build times

Peter Kümmel syntheticpp at gmx.net
Wed Mar 28 07:11:38 BST 2007


Hi,

here an idea to speed up compilation
by factor 3 to 4.

When working on KDE one does not work
on all projects and files at the same time,
which means, most files will not be touched,
and they could be build with the
KDE4_ENABLE_FINAL flag.

The problem using KDE4_ENABLE_FINAL is that
the projects with the touched files have to
rebuild completely on each change.
(With KDE4_ENABLE_FINAL a file is generated
which includes all cpp files.)

The idea of attached patch is to manually
exclude some files from the generated
all-in-one file.
When a developer don't wanna compile the
complete project after changing a file
he edits the generated include-all
file in his local build tree.

So it is possible to a build with a speedup
of factor 3 to 4 and to work on some files
without waiting ages on each change, best
of both worlds.

How it works:
the new macro KDE4_CREATE_MERGED_FILES creates
two files, one file which contains all untouched
files and one all touched. By default the file
with the touched files is 'empty', no code is
included (like using KDE4_ENABLE_FINAL).

Moving one file from the const to the touched file
works by commenting out a macro definition and a
include (because the dependency scan of cmake is
macro insensible).

For instance, kgzipfilter.cpp is a untouched file and
kfilterbase.cpp is a touched file:

allinone_const.C (in the build tree):

#define kgzipfilter___ASSUME_CONST
#if defined(kgzipfilter___ASSUME_CONST) && !defined(DONT_INCLUDE_CONST_FILES)
#include "kgzipfilter.cpp"
#endif

//#define kfilterbase___ASSUME_CONST
#if defined(kfilterbase___ASSUME_CONST) && !defined(DONT_INCLUDE_CONST_FILES)
//#include "kfilterbase.cpp"
#endif



allinone_touched.C (in the build tree):

// touched files

// look for non-const files
#define DONT_INCLUDE_CONST_FILES
#include "kdecore_allinone_const.C"


#ifndef kgzipfilter___ASSUME_CONST
#include "kgzipfilter.cpp"
#endif

#ifndef kfilterbase___ASSUME_CONST
#include "kfilterbase.cpp"
#endif



Enable it with the option -Dmerge_files=1.


Hope it saves some minutes of the rare
developer time.


Peter





-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: merge_file.patch
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20070328/a5ce13a6/attachment.ksh>


More information about the kde-core-devel mailing list