Git commit 66bff6dc56039cc75bcc64bc5a7c6fb38f9b1e82 by Andrew Shark.
Committed on 28/01/2024 at 07:28.
Pushed by ashark into branch 'master'.

Allow ignoring modules from global config

This will let users to constantly ignore specified modules in global section, 
so they do not need to pass it in command line each time.

Also, it will allow to ignore some defined modules that are not in any module 
set (for example, gpgme).

BUG: 472917

M  +2    -2    doc/conf-options-table.docbook
M  +3    -1    doc/supported-cmdline-params.docbook
M  +8    -1    modules/ksb/Application.pm
M  +13   -3    modules/ksb/BuildContext.pm

https://invent.kde.org/sdk/kdesrc-build/-/commit/66bff6dc56039cc75bcc64bc5a7c6fb38f9b1e82

diff --git a/doc/conf-options-table.docbook b/doc/conf-options-table.docbook
index 8722b1ae..ed52e6bc 100644
--- a/doc/conf-options-table.docbook
+++ b/doc/conf-options-table.docbook
@@ -1335,8 +1335,8 @@ installations. However this only works on build systems 
that support
 <member>Type</member><member>String</member>
 <member>Available since</member><member>1.16</member>
 </simplelist>
-<para>Currently can only be used in module-set, see <ulink
-url="https://bugs.kde.org/show_bug.cgi?id=472917";>Bug 472917</ulink>.</para>
+<para>This option can be used in global section and in module-sets.</para>
+<para>Note that when specified in global section, &cmd-ignore-modules; cmdline 
option does not override this, but instead appends.</para>
 <para>Modules named by this option, which would be chosen by &kdesrc-build;
 due to a <link linkend="conf-use-modules">use-modules</link> option, are
 instead skipped entirely. Use this option when you want to build an entire
diff --git a/doc/supported-cmdline-params.docbook 
b/doc/supported-cmdline-params.docbook
index 494a3363..7c4f8f31 100644
--- a/doc/supported-cmdline-params.docbook
+++ b/doc/supported-cmdline-params.docbook
@@ -53,7 +53,9 @@ Do not include the modules passed on the rest of the command 
line in the
 update/build process (this is useful if you want to build most of the modules
 in your <link linkend="configure-data">configuration file</link> and just skip
 a few).
-</para></listitem>
+</para>
+<para>Note that this option does not override <link 
linkend="conf-ignore-modules">ignore-modules</link> config option in global 
section. Instead, it appends it.</para>
+</listitem>
 </varlistentry>
 
 <varlistentry id="cmdline-run">
diff --git a/modules/ksb/Application.pm b/modules/ksb/Application.pm
index 7847092a..24459d07 100644
--- a/modules/ksb/Application.pm
+++ b/modules/ksb/Application.pm
@@ -264,7 +264,7 @@ EOF
     }
 
     # Convert list to hash for lookup
-    my %ignoredSelectors =
+    my %ignored_in_cmdline =
         map { $_, 1 } @{$opts->{'ignore-modules'}};
 
     my @startProgramAndArgs = @{$opts->{'start-program'}};
@@ -313,6 +313,13 @@ EOF
         _readConfigurationOptions($ctx, $fh, $cmdlineGlobalOptions, 
$deferredOptions);
     close $fh;
 
+    my %ignored_in_global_section =
+        map { $_, 1 } split(" ", $ctx->{options}->{"ignore-modules"});
+    $ctx->{options}->{"ignore-modules"} = "";
+
+    # For user convenience, cmdline ignored selectors would not override the 
config selectors. Instead, they will be merged.
+    my %ignoredSelectors = (%ignored_in_cmdline, %ignored_in_global_section);
+
     # Check if we're supposed to drop into an interactive shell instead.  If 
so,
     # here's the stop off point.
 
diff --git a/modules/ksb/BuildContext.pm b/modules/ksb/BuildContext.pm
index a7b0e15b..b247796f 100644
--- a/modules/ksb/BuildContext.pm
+++ b/modules/ksb/BuildContext.pm
@@ -795,13 +795,23 @@ sub getOption ($self, $key, $level = 'module')
     $self->ksb::OptionsBase::getOption($key);
 }
 
-# OVERRIDE: Overrides OptionsBase::setOption to handle some global-only 
options.
+# OVERRIDE
 sub setOption
 {
     my ($self, %options) = @_;
 
-    # Actually set options.
-    $self->SUPER::setOption(%options);
+    # Special case handling.
+    if (exists $options{'filter-out-phases'}) {
+        for my $phase (split(' ', $options{'filter-out-phases'})) {
+            $self->phases()->filterOutPhase($phase);
+        }
+        delete $options{'filter-out-phases'};
+    }
+
+    # Our immediate parent class Module overrides this, but we actually
+    # want the OptionsBase version to be used instead, because Module's 
version specifically checks for
+    # some options prohibited for it (such as "ignore-modules") but we may 
want such for BuildContext.
+    $self->ksb::OptionsBase::setOption(%options);
 
     # Automatically respond to various global option changes.
     while (my ($key, $value) = each %options) {

Reply via email to