Jump to content

Guidelines and HOWTOs/Build from source/edk: Difference between revisions

From KDE Community Wiki
Elvis Angelaccio (talk | contribs)
Introduce edk documentation
 
Elvis Angelaccio (talk | contribs)
Update documentation
Line 24: Line 24:
mkdir ~/.config/edk
mkdir ~/.config/edk
cp edk/config.ini.example ~/.config/edk/config.ini
cp edk/config.ini.example ~/.config/edk/config.ini
# optional, if you want to customize your environment variables
cp edk/env.sh.example ~/config/edk/env.sh
cp edk/env.sh.example ~/config/edk/env.sh
</syntaxhighlight>
</syntaxhighlight>
Line 35: Line 36:
   edk
   edk


This is a shorthand for <code>edk b</code> with no additional arguments.
The script will perform the following operations:
The script will perform the following operations:


* Source whatever environment variables are exported in <code>$XDG_CONFIG_HOME/edk/env.sh</code>
* If <code>$XDG_CONFIG_HOME/edk/env.sh</code> exists, it will source whatever environment variables are exported in there.
* Build the CMake-based project found in <code>$(pwd)</code> in a <tt>build</tt> subdirectory
* Build the CMake-based project found in <code>$(pwd)</code>. Build files are written to a subdirectory of <code>$XDG_CACHE_HOME/edk</code>.
* Install the project in <code>$EDK</code>. This variable must be defined in <code>env.sh</code> so that <tt>edk</tt> can automatically pass the <code>-DCMAKE_INSTALL_PREFIX</code> argument to <tt>cmake</tt>.
* Install the project in <code>$EDK</code>. This variable defaults to <code>$XDG_DATA_HOME/edk</code>, but you can override it in <code>env.sh</code>.
* Run the project tests (if available)
* Run the project tests (if available).
 
=== Configure the project ===
 
<tt>edk</tt> will respect the options defined in the <code>[project]</code> section of the config file.
The value of the <code>project</code> key is defined in the following order:
 
# The value of the <code>-p</code> switch, for example <code>edk -p foo</code>
# The value of the <code>project</code> key in the <code>[global]</code> section of the config file
# The name of the directory <tt>edk</tt> was run from.
 
The value of this key is also used as the name of the build directory in <code>$XDG_CACHE_HOME/edk</code>.


=== Run the project ===
=== Run the project ===
Line 46: Line 59:
Once the project is built, you can run it with:
Once the project is built, you can run it with:


   edk -r
   edk r


This assumes that you have configured the <code>project</code> key in the <code>[global]</code> section of the config file. The value of this key is used as the name of the executable to run, unless you define an <code>executable</code> key in the <code>[project]</code> section.
This will execute whatever is defined in the <code>project</code> key, unless you define an <code>executable</code> key in the <code>[project]</code> section.
 
If you don't have the <tt>project</tt> key (or if you want to override it), you can use as alternative:
 
  edk -p foo -r


If you want to pass arguments to the project:
If you want to pass arguments to the project:


   edk -r --foo --bar=XXX
   edk r --foo --bar=XXX


=== Debug the project ===
=== Debug the project ===


Similarly to the -r option, it's also possible to run the project with a debugger (only gdb for now):
Similarly to the <code>r</code> subcommand, it's also possible to run the project with a debugger (only gdb for now):


   edk -d
   edk d


This will execute <code>gdb <executable></code>.
This will execute <code>gdb <executable></code>.
{{Note| The <tt>-r</tt> and <tt>-d</tt> options are mutually exclusive. }}


=== Clean build ===
=== Clean build ===


   edk -c
   edk b -c


This will delete the build directory before performing a new build.
This will delete the build directory before performing a new build.

Revision as of 19:25, 8 August 2016

edk is a Python script that can be used to easily build KDE projects. Once edk is properly installed and configured, building any KDE project is as easy as invoking edk from the git root of the project.

Motivations

You may be interested in edk if:

  • You are a new contributor looking for a simple development environment
  • You are a new contributor and you want to build just one application
  • You want to build KDE projects on top of an existing Plasma environment
  • You want to build KDE projects on top of a third party environment (e.g. Gnome or Unity)
  • You are tired to manually call cmake, make, make test, ...

How does it work?

edk is designed to just build, install and (optionally) "run" your project (as edk is primarily designed for applications with a single executable). You don't need to worry about setting up a development environment (besides installing edk itself).

edk is not a replacement of kdesrc-build. It doesn't download source code and it doesn't resolve dependencies (in fact, edk assumes that all build-dependencies are already satisfied). If you want to build the whole KDE stack, kdesrc-build is still the way to go.

Installation

git clone git://anongit.kde.org/scratch/elvisangelaccio/edk.git
# assuming that $HOME/bin is in your $PATH
ln -s $PWD/edk/edk.py $HOME/bin/edk
mkdir ~/.config/edk
cp edk/config.ini.example ~/.config/edk/config.ini
# optional, if you want to customize your environment variables
cp edk/env.sh.example ~/config/edk/env.sh

Note

You can replace ~/.config with $XDG_CONFIG_HOME, if you have this variable set


Usage

Build a project

From the git root of the project:

 edk

This is a shorthand for edk b with no additional arguments. The script will perform the following operations:

  • If $XDG_CONFIG_HOME/edk/env.sh exists, it will source whatever environment variables are exported in there.
  • Build the CMake-based project found in $(pwd). Build files are written to a subdirectory of $XDG_CACHE_HOME/edk.
  • Install the project in $EDK. This variable defaults to $XDG_DATA_HOME/edk, but you can override it in env.sh.
  • Run the project tests (if available).

Configure the project

edk will respect the options defined in the [project] section of the config file. The value of the project key is defined in the following order:

  1. The value of the -p switch, for example edk -p foo
  2. The value of the project key in the [global] section of the config file
  3. The name of the directory edk was run from.

The value of this key is also used as the name of the build directory in $XDG_CACHE_HOME/edk.

Run the project

Once the project is built, you can run it with:

 edk r

This will execute whatever is defined in the project key, unless you define an executable key in the [project] section.

If you want to pass arguments to the project:

 edk r --foo --bar=XXX

Debug the project

Similarly to the r subcommand, it's also possible to run the project with a debugger (only gdb for now):

 edk d

This will execute gdb <executable>.

Clean build

 edk b -c

This will delete the build directory before performing a new build.

Configuration

Build with Ninja

Add -GNinja in the cmake-options of your config.ini file (either in the [global] section on in a project-specific section).