[sdk/kdesrc-build] /: Fix default value for "directory-layout" option

Andrew Shark null at kde.org
Tue Jan 9 07:53:18 GMT 2024


Git commit 642bdc2e326f8eae6cbc2a07bfe37fc1044952b9 by Andrew Shark.
Committed on 09/01/2024 at 08:52.
Pushed by ashark into branch 'master'.

Fix default value for "directory-layout" option

It was silently allowed to have unset "directory-layout" option value, that was treated as "metadata" value.

Previously, it defaulted to "metadata". Then commit 7fe7c940 (BUG: 461279) changed the default value in documentation to "flat", but not in the code.

This commit treats any incorrect value (not one of "flat", "invent", "metadata"), including empty string, as a "flat" value with warning.

Add the forgotten default BuildContext value, and add it in FirstRun.

M  +1    -1    data/kdesrc-buildrc.in
M  +2    -1    doc/conf-options-table.docbook
M  +1    -0    modules/ksb/BuildContext.pm
M  +2    -0    modules/ksb/FirstRun.pm
M  +11   -13   modules/ksb/Module.pm

https://invent.kde.org/sdk/kdesrc-build/-/commit/642bdc2e326f8eae6cbc2a07bfe37fc1044952b9

diff --git a/data/kdesrc-buildrc.in b/data/kdesrc-buildrc.in
index 72eef3af..62de3d1a 100644
--- a/data/kdesrc-buildrc.in
+++ b/data/kdesrc-buildrc.in
@@ -50,7 +50,7 @@ global
 
     # Use a flat folder layout under ~/kde/src and ~/kde/build
     # rather than nested directories
-    directory-layout flat
+    directory-layout %{directory-layout}
 
     # Use Ninja as cmake generator instead of gmake
     cmake-generator Kate - Ninja
diff --git a/doc/conf-options-table.docbook b/doc/conf-options-table.docbook
index 8c1a32e9..e74858b1 100644
--- a/doc/conf-options-table.docbook
+++ b/doc/conf-options-table.docbook
@@ -695,10 +695,11 @@ on also use that proxy server, if possible, by setting the
 <member>Type</member><member>String</member>
 <member>Valid values</member><member><userinput>flat</userinput>,
 <userinput>invent</userinput>, <userinput>metadata</userinput></member>
+<member>Default value</member><member>flat</member>
 </simplelist>
 <para>This option is used to configure the layout which &kdesrc-build; should use when
 creating source and build directories.</para>
-<para>The <userinput>flat</userinput> layout is the default value, and will group all modules
+<para>The <userinput>flat</userinput> layout will group all modules
 directly underneath the top level source and build directories. For example,
 <literal>source/extragear/network/telepathy/ktp-text-ui</literal> in the <userinput>metadata</userinput>
 layout would be <literal>source/ktp-text-ui</literal> using the <userinput>flat</userinput> layout
diff --git a/modules/ksb/BuildContext.pm b/modules/ksb/BuildContext.pm
index ce78ac60..808a89cf 100644
--- a/modules/ksb/BuildContext.pm
+++ b/modules/ksb/BuildContext.pm
@@ -154,6 +154,7 @@ our %defaultGlobalOptions = (
     "configure-flags"      => "",
     "custom-build-command" => '',
     "cxxflags"             => "-pipe",
+    "directory-layout"     => "flat",
     "dest-dir"             => '${MODULE}', # single quotes used on purpose!
     "do-not-compile"       => "",
     "http-proxy"           => '', # Proxy server to use for HTTP.
diff --git a/modules/ksb/FirstRun.pm b/modules/ksb/FirstRun.pm
index ee668e7f..28bb9833 100644
--- a/modules/ksb/FirstRun.pm
+++ b/modules/ksb/FirstRun.pm
@@ -312,6 +312,7 @@ DONE
     my $fill_placeholder = sub {
         my $option_name = shift;
         my $mode = shift;
+        $mode //= "";
 
         my $value = $gl->{$option_name};
         if ($mode eq "bool_to_str") {
@@ -331,6 +332,7 @@ DONE
     $fill_placeholder->("install-session-driver", "bool_to_str");
     $fill_placeholder->("install-environment-driver", "bool_to_str");
     $fill_placeholder->("stop-on-failure", "bool_to_str");
+    $fill_placeholder->("directory-layout");
     $fill_placeholder->("compile-commands-linking", "bool_to_str");
     $fill_placeholder->("compile-commands-export", "bool_to_str");
     $fill_placeholder->("generate-vscode-project-config", "bool_to_str");
diff --git a/modules/ksb/Module.pm b/modules/ksb/Module.pm
index 0dd11afc..e1665e8c 100644
--- a/modules/ksb/Module.pm
+++ b/modules/ksb/Module.pm
@@ -999,21 +999,19 @@ sub destDir ($self)
     my $layout = $self->getOption('directory-layout');
     if ($layout eq 'flat') {
         $basePath = $self->name();
+    } elsif ($layout eq 'invent') { # invent layout is the modern layout for proper KDE projects
+        $basePath = $self->getOption('#kde-repo-path', 'module');
+        $basePath ||= $self->name(); # Default if not provided in repo-metadata
+    } elsif ($layout eq 'metadata') {
+        $basePath = $self->getOption('#kde-project-path', 'module');
+        $basePath ||= $self->name(); # Default if not provided in repo-metadata
     } else {
-        # invent layout is the modern layout for proper KDE projects
-        if ($layout eq 'invent') {
-            $basePath = $self->getOption('#kde-repo-path', 'module');
-        } else {
-            if ($layout && $layout ne 'invent' && $layout ne 'metadata' &&
-                !$self->hasOption('#warned-invalid-directory-layout')) # avoid spamming
-            {
-                warning("Invalid b[directory-layout] value: $layout. Will use b[metadata] instead for b[$self]");
-                $self->setOption('#warned-invalid-directory-layout', 1);
-            }
-            $basePath = $self->getOption('#kde-project-path', 'module');
+        if (!$self->hasOption('#warned-invalid-directory-layout')) # avoid spamming
+        {
+            warning ("y[ * Invalid b[directory-layout]y[ value: \"$layout\". Will use b[flat]y[ instead for b[$self]");
+            $self->setOption('#warned-invalid-directory-layout', 1);
         }
-
-        $basePath ||= $self->name(); # Default if not provided in repo-metadata
+        $basePath = $self->name();
     }
 
     # Note the default dest-dir option is '${MODULE}' so this normally is used


More information about the kde-doc-english mailing list