[sdk/kdesrc-build] /: Support phase selection individually for modules and module-sets
Andrew Shark
null at kde.org
Sun Jan 28 21:29:06 GMT 2024
Git commit d8104fa8e9defa5b25f7eab538a7b0f2fc652e1d by Andrew Shark.
Committed on 28/01/2024 at 21:24.
Pushed by ashark into branch 'master'.
Support phase selection individually for modules and module-sets
Previously we could only select phases globally from command line. They were applied to all modules.
Sometimes user want to control phase selection for individual module.
The clone is happening from the remote/origin by default. This becomes a problem when user is working with a local branch that is not presented in remote. For example, user may not have a developer account, or just does not want to upload his work even in work/user branch yet.
He just wants kdesrc-build to not touch the sources of that module (while the other modules still be updated), and does not want to exclude module from build phase.
Let's say user wants to work with `kio`, and testing it with `ark`.
Previously, user could achieve this task by running `kdesrc-build` several times. Different quirks were needed. Example:
- `kdesrc-build ark --include-dependencies` - build ark with dependencies (including kio) as normal
- `...` - make changes to the kio project
- `kdesrc-build kio --no-src --no-include-dependencies`
- `kdesrc-build ark --include-dependencies --ignore-modules kio`
After this commit user can specify the `no-src` option for the `kio` module, and then just run `kdesrc-build ark --include-dependencies`. The `kio` will not be updated in this process, but will not be excluded from build phase.
BUG: 354796
M +88 -14 doc/conf-options-table.docbook
M +2 -1 modules/ksb/Application.pm
M +0 -1 modules/ksb/BuildContext.pm
M +13 -9 modules/ksb/Cmdline.pm
M +47 -1 modules/ksb/Module.pm
https://invent.kde.org/sdk/kdesrc-build/-/commit/d8104fa8e9defa5b25f7eab538a7b0f2fc652e1d
diff --git a/doc/conf-options-table.docbook b/doc/conf-options-table.docbook
index ed52e6bc..63adbf01 100644
--- a/doc/conf-options-table.docbook
+++ b/doc/conf-options-table.docbook
@@ -1038,20 +1038,6 @@ end options
</entry>
</row>
-<row id="conf-no-src">
-<entry><link linkend="conf-no-src">no-src</link></entry>
-<entry>
-<simplelist type='horiz' columns='2'>
-<member>Type</member><member>Boolean</member>
-<member>Default value</member><member>False</member>
-</simplelist>
-<para>If this option is set to true then &kdesrc-build; will not update the
-source code for the module automatically. It will still try to build the
-module if it normally would have tried anyways.</para>
-<para>Related command-line option: <xref linkend="cmdline-no-src"/></para>
-</entry>
-</row>
-
<row id="conf-override-build-system">
<entry><link linkend="conf-override-build-system">override-build-system</link></entry>
<entry>
@@ -1314,6 +1300,94 @@ installations. However this only works on build systems that support
</tgroup>
</table>
+<table id="options-phase-selection-table">
+<para>These options do not require any value (except "filter-out-phases"). They are applied if they are presented in a section.</para>
+<title>Phase selection options</title>
+<tgroup cols="2">
+
+<thead>
+<row>
+<entry>Option name</entry>
+<entry>Scope</entry>
+<entry>Description</entry>
+</row>
+</thead>
+<tbody>
+
+<row id="conf-no-src">
+<entry><link linkend="conf-no-src">no-src</link></entry>
+<entry><simplelist type='vert'><member>global</member><member>module</member><member>module-set</member><member>options</member></simplelist></entry>
+<entry>
+<para>Remove <emphasis>update</emphasis> phase. The other phases that were presented will still be processed.</para>
+<para>Related command-line option: <xref linkend="cmdline-no-src"/></para>
+</entry>
+</row>
+
+<row id="conf-no-install">
+<entry><link linkend="conf-no-install">no-install</link></entry>
+<entry><simplelist type='vert'><member>global</member><member>module</member><member>module-set</member><member>options</member></simplelist></entry>
+<entry>
+<para>Remove <emphasis>install</emphasis> phase. The other phases that were presented will still be processed.</para>
+<para>Related command-line option: <xref linkend="cmdline-no-install"/></para>
+</entry>
+</row>
+
+<row id="conf-no-tests">
+<entry><link linkend="conf-no-tests">no-tests</link></entry>
+<entry><simplelist type='vert'><member>global</member><member>module</member><member>module-set</member><member>options</member></simplelist></entry>
+<entry>
+<para>Remove <emphasis>test</emphasis> phase. The other phases that were presented will still be processed.</para>
+<para>Related command-line option: --no-tests</para>
+</entry>
+</row>
+
+<row id="conf-no-build">
+<entry><link linkend="conf-no-build">no-build</link></entry>
+<entry><simplelist type='vert'><member>global</member><member>module</member><member>module-set</member><member>options</member></simplelist></entry>
+<entry>
+<para>Remove <emphasis>build</emphasis> phase. The other phases that were presented will still be processed.</para>
+<para>Related command-line option: <xref linkend="cmdline-no-build"/></para>
+</entry>
+</row>
+
+<row id="conf-build-only">
+<entry><link linkend="conf-build-only">build-only</link></entry>
+<entry><simplelist type='vert'><member>global</member><member>module</member><member>module-set</member><member>options</member></simplelist></entry>
+<entry>
+<para>If had <emphasis>build</emphasis> phase, remove any other phases. Otherwise, remove all phases.</para>
+<para>Related command-line option: <xref linkend="cmdline-build-only"/></para>
+</entry>
+</row>
+
+<row id="conf-install-only">
+<entry><link linkend="conf-install-only">install-only</link></entry>
+<entry><simplelist type='vert'><member>global</member><member>module</member><member>module-set</member><member>options</member></simplelist></entry>
+<entry>
+<para>If had <emphasis>install</emphasis> phase, remove any other phases. Otherwise, remove all phases.</para>
+<para>Related command-line option: <xref linkend="cmdline-install-only"/></para>
+</entry>
+</row>
+
+<row id="conf-uninstall">
+<entry><link linkend="conf-uninstall">uninstall</link></entry>
+<entry><simplelist type='vert'><member>global</member><member>module</member><member>module-set</member><member>options</member></simplelist></entry>
+<entry>
+<para>If had <emphasis>uninstall</emphasis> phase, remove any other phases. Otherwise, remove all phases.</para>
+<para>Related command-line option: --uninstall</para>
+</entry>
+</row>
+
+<row id="conf-filter-out-phases">
+<entry><link linkend="conf-filter-out-phases">filter-out-phases</link></entry>
+<entry><simplelist type='vert'><member>global</member><member>module</member><member>module-set</member><member>options</member></simplelist></entry>
+<entry>
+<para>Remove those phases that are listed (space separated) in this option. The other phases that were presented will still be processed.</para>
+</entry>
+</row>
+
+</tbody>
+</tgroup>
+</table>
<table id="options-module-set-table">
<title>Module-set and global scope options</title>
diff --git a/modules/ksb/Application.pm b/modules/ksb/Application.pm
index 24459d07..3d33a988 100644
--- a/modules/ksb/Application.pm
+++ b/modules/ksb/Application.pm
@@ -951,7 +951,8 @@ sub _parseModuleOptions ($ctx, $fileReader, $module, $endRE=undef)
_markModuleSource($module, $fileReader->currentFilename() . ":$.");
$module->setOption('#entry_num', $moduleID++);
- my @all_possible_options = sort keys %{$ctx->{build_options}->{global}};
+ my @phase_changing_options_canonical = map { my $element = $_; $element =~ s/\|.*//; $element } @ksb::Cmdline::phase_changing_options;
+ my @all_possible_options = sort keys %{$ctx->{build_options}->{global}}, @phase_changing_options_canonical;
# Read in each option
while (($_ = _readNextLogicalLine($fileReader)) && ($_ !~ $endRE))
diff --git a/modules/ksb/BuildContext.pm b/modules/ksb/BuildContext.pm
index b247796f..65697eec 100644
--- a/modules/ksb/BuildContext.pm
+++ b/modules/ksb/BuildContext.pm
@@ -113,7 +113,6 @@ my %GlobalOptions_with_extra_specifier = (
"colorful-output" => 1,
"ignore-modules" => "",
"niceness" => "10", # todo convert to int?
- "no-src" => "",
"pretend" => "",
"refresh-build" => "",
);
diff --git a/modules/ksb/Cmdline.pm b/modules/ksb/Cmdline.pm
index 8c7a6dba..055676b8 100644
--- a/modules/ksb/Cmdline.pm
+++ b/modules/ksb/Cmdline.pm
@@ -413,23 +413,30 @@ sub _showOptionsSpecifiersAndExit
exit;
}
+our @phase_changing_options = (
+ 'build-only',
+ 'install-only',
+ 'no-build',
+ 'no-install',
+ 'no-src|S',
+ 'no-tests',
+ 'src-only|s',
+ 'uninstall',
+);
+
+
# Return option specifiers ready to be fed into GetOptionsFromArray
sub _supportedOptions
{
# See https://perldoc.perl.org/5.005/Getopt::Long for options specification format
my @non_context_options = (
- 'build-only',
'dependency-tree',
'dependency-tree-fullpath',
'help|h',
- 'install-only',
'list-build',
'metadata-only',
- 'no-build',
- 'no-install',
'no-metadata',
- 'no-tests',
'print-modules',
'query=s',
'rc-file=s',
@@ -440,11 +447,9 @@ sub _supportedOptions
'set-module-option-value=s',
'show-info',
'show-options-specifiers',
- 'src-only|s',
'start-program|run=s{,}',
'stop-after|to=s',
'stop-before|until=s',
- 'uninstall',
'version|v',
);
@@ -453,7 +458,6 @@ sub _supportedOptions
'colorful-output|color!',
'ignore-modules|!=s{,}',
'niceness|nice:10',
- 'no-src|S',
'pretend|dry-run|p',
'refresh-build|r',
);
@@ -468,7 +472,7 @@ sub _supportedOptions
);
# For now, place the options we specified above
- my @options = (@non_context_options, @context_options_with_extra_specifier, @options_converted_to_canonical);
+ my @options = (@non_context_options, @phase_changing_options, @context_options_with_extra_specifier, @options_converted_to_canonical);
# Remove stuff like ! and =s from list above;
my @optNames = map { m/([a-zA-Z-]+)/; $1 } @options;
diff --git a/modules/ksb/Module.pm b/modules/ksb/Module.pm
index 28232d42..b428336d 100644
--- a/modules/ksb/Module.pm
+++ b/modules/ksb/Module.pm
@@ -79,7 +79,7 @@ sub new
croak_internal ("Invalid context $ctx");
}
- # Clone the passed-in phases so we can be different.
+ # Clone the passed-in phases so we can be different. They may be modified later in setOption.
my $phases = dclone($ctx->phases()) if $ctx;
my %newOptions = (
@@ -870,6 +870,52 @@ sub setOption
delete $options{'filter-out-phases'};
}
+ # Phases changes handling
+ #
+ # The context phases were handled by cmdline. The module-sets will eventually be expanded to modules. For module, we will handle its phases.
+ if (exists $options{"no-src"}) {
+ $self->phases()->filterOutPhase("update");
+ delete $options{"no-src"};
+ }
+ if (exists $options{"no-install"}) {
+ $self->phases()->filterOutPhase("install");
+ delete $options{"no-install"};
+ }
+ if (exists $options{"no-tests"}) {
+ $self->phases()->filterOutPhase("test"); # May not work properly yet.
+ delete $options{"no-tests"};
+ }
+ if (exists $options{"no-build"}) {
+ $self->phases()->filterOutPhase("build");
+ delete $options{"no-build"};
+ }
+ if (exists $options{"uninstall"}) {
+ # Not useful yet. Currently only may be useful to disable uninstallation when uninstalling with cmdline ("uninstall" run_mode)
+ if ($self->phases()->has("uninstall")) {
+ $self->phases->phases("uninstall");
+ } else {
+ $self->phases()->clear();
+ }
+ delete $options{"uninstall"};
+ }
+ if (exists $options{"build-only"}) {
+ if ($self->phases()->has("build")) {
+ $self->phases->phases("build");
+ } else {
+ $self->phases()->clear();
+ }
+ delete $options{"build-only"};
+ }
+ if (exists $options{"install-only"}) {
+ # Not useful yet, because install is invoked by run_mode or in the end of building function. See a todo with text "Likewise this should be a phase to run."
+ if ($self->phases()->has("install")) {
+ $self->phases->phases("install");
+ } else {
+ $self->phases()->clear();
+ }
+ delete $options{"install-only"};
+ }
+
$self->SUPER::setOption(%options);
}
More information about the kde-doc-english
mailing list