Commit 2a305b36 authored by Johan Ouwerkerk's avatar Johan Ouwerkerk
Browse files

feat: support organising cloned source directories according to the 'layout'...

feat: support organising cloned source directories according to the 'layout' of repositories on

Issues: #59
parent b6c37bb8
Pipeline #44521 passed with stage
in 2 minutes and 50 seconds
......@@ -2314,17 +2314,44 @@ on also use that proxy server, if possible, by setting the
<row id="conf-ignore-kde-structure">
<entry>Can't be overridden</entry>
<para>This option is deprecated and will be removed (again) in a future release.</para>
<para>Please use the <option><link linkend="conf-directory-layout">directory-layout</link></option>
instead, which offers more selectivity.</para>
<row id="conf-directory-layout">
<entry>Module setting overrides global</entry>
<entry><para>This option is used to store the source and the build files directly
in the name of the module. For example,
<entry><para>This option is used to configure the directory layout which &kdesrc-build; should
maintain when creating source and build directories.</para>
<para>Currently there are three possible values <userinput>metadata</userinput>,
<userinput>invent</userinput> and <userinput>flat</userinput></para>
<para>The <userinput>flat</userinput> layout will group all modules directly underneath the top level
source and build directories. For example,
This option is disabled by default. If you want to enable this option you need to set it
to <userinput>true</userinput>.</para>
<para>This option was introduced with &kdesrc-build; 1.16.</para>
<para>The <userinput>invent</userinput> layout creates a directory hierarchy mirroring the relative
paths of repositories on <ulink url=""></ulink>. For example
<literal>utilities/kate</literal>. This layout only affects KDE projects. It is a good choice for
people starting out with &kdesrc-build;.
<para>Finally, the <userinput>metadata</userinput> layout is the same as the old default
behaviour. This layout organises KDE projects according to the project paths specified in the
project metadata for these modules. This is a good choice if you want a directory layout which
tracks with certain KDE processes, but note that this path is therefore not always stable. As a
result, &kdesrc-build; may abandon an old copy of the repository and clone a new one for a project
due to changes in the project metadata.</para>
<para>By default the <userinput>metadata</userinput> layout will be used, to preserve backwards
compatibility for existing users of &kdesrc-build;.</para>
......@@ -81,7 +81,8 @@ our %defaultGlobalFlags = (
"delete-my-settings" => 0, # Should only be set from cmdline
"disable-agent-check" => 0, # If true we don't check on ssh-agent
"disable-snapshots" => 1, # 2016-07-31 Temp. disabled until fixed to supply snapshots
"ignore-kde-structure" => 0, # Whether to use kde dir structure like extragear/network
"ignore-kde-structure" => 0, # Whether to use kde dir structure like extragear/network. Deprecated as of late December 2020/January 2021
"directory-layout" => 'metadata', # Directory layout to use, can be 'flat', 'invent', 'metadata' (project path based hierarchy)
"include-dependencies" => 0, # 2019-08-31 Made negatable from cmdline (NB: false here but true in rcfile)
"install-after-build" => 1,
"install-environment-driver" => 1, # Setup ~/.config/kde-env-*.sh for login scripts
......@@ -957,12 +957,40 @@ sub destDir
my $destDir = $self->getOption('dest-dir');
my $basePath = "";
my $layout = $self->getOption('directory-layout');
if ($self->getOption('ignore-kde-structure')) {
# avoid spamming
if (!$self->getOption('#warned-deprecated-ignore-kde-structure')) {
warning("b[ignore-kde-structure] is deprecated, please use b[directory-layout] instead for b[$self]");
# no or equivalent layout configured, assume the user wants to use flat layout
if (!$layout || $layout eq 'flat') {
$layout = 'flat';
} else {
# avoid spamming
if (!$self->getOption('#warned-deprecated-ignore-kde-structure')) {
warning("Deprecated b[ignore-kde-structure] will be ignored in favour of b[directory-layout] for b[$self]");
# avoid spamming
$self->setOption('#warned-deprecated-ignore-kde-structure', 1);
if ($layout eq 'flat') {
$basePath = $self->name();
} else {
$basePath = shift // $self->getOption('#xml-full-path');
$basePath ||= $self->name(); # Default if not provided in repo-metadata
# invent layout only works for proper KDE projects, which have a kde:(.*).git pattern repository configured
if ($layout eq 'invent' && $self->getOption('repository') =~ m/kde:(.*)\.git/) {
$basePath = $1;
} else {
if (!$self->getOption('#warned-invalid-directory-layout') # avoid spamming
&& $layout ne 'invent' && $layout ne 'metadata') {
warning("Invalid b[directory-layout] value: $layout. Will use b[default] instead for b[$self]");
$self->setOption('#warned-invalid-directory-layout', 1);
$basePath = shift // $self->getOption('#xml-full-path');
$basePath ||= $self->name(); # Default if not provided in repo-metadata
$destDir =~ s/(\$\{MODULE})|(\$MODULE\b)/$basePath/g;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment