[sdk/kdesrc-build] /: Add --dependency-tree-fullpath option
Andrew Shark
null at kde.org
Thu Dec 28 09:46:46 GMT 2023
Git commit 42483187d75c2787f6c627d6ed1f84e0529a9b6f by Andrew Shark.
Committed on 28/12/2023 at 10:43.
Pushed by ashark into branch 'master'.
Add --dependency-tree-fullpath option
This option will do similar thing as --dependency-tree, but will print the full path on the line of each tree entry.
This may be convenient when you want to grep something from the printed tree, but want to still be able to see the paths.
M +1 -0 completions/zsh/_kdesrc-build
M +11 -0 doc/index.docbook
M +37 -2 modules/ksb/Application.pm
M +1 -0 modules/ksb/Cmdline.pm
https://invent.kde.org/sdk/kdesrc-build/-/commit/42483187d75c2787f6c627d6ed1f84e0529a9b6f
diff --git a/completions/zsh/_kdesrc-build b/completions/zsh/_kdesrc-build
index ca79d62e..e8ad66ea 100644
--- a/completions/zsh/_kdesrc-build
+++ b/completions/zsh/_kdesrc-build
@@ -14,6 +14,7 @@ _arguments \
'(--pretend -p)'{--pretend,-p}"[Don't actually take major actions, instead describe what would be done]" \
'--list-build[List what modules would be built in the order in which they would be built]' \
'--dependency-tree[Print out dependency information on the modules that would be built, using a `tree` format]' \
+ '--dependency-tree-fullpath[Print out dependency information on the modules that would be built, using a `fullpath` format]' \
'(--src-only --no-src)'{--src-only,--no-src}'[Only perform/Skip update source code]' \
'--refresh-build[Start the build from scratch]' \
'--rc-file=[Read configuration from filename instead of default]:::_files' \
diff --git a/doc/index.docbook b/doc/index.docbook
index 6a4a383d..058937d4 100644
--- a/doc/index.docbook
+++ b/doc/index.docbook
@@ -3795,6 +3795,17 @@ If this file doesn't exist, <filename>~/.config/kdesrc-buildrc</filename>
</listitem>
</varlistentry>
+<varlistentry id="cmdline-dependency-tree-fullpath">
+<term><parameter>--dependency-tree-fullpath</parameter></term>
+<listitem>
+<para>
+ Prints out dependency information on the modules that would be built using a tree
+ format (recursive). In fullpath format. Note: the generated
+ output may become quite large for applications with many dependencies.
+</para>
+</listitem>
+</varlistentry>
+
<varlistentry id="cmdline-run">
<term><parameter>--run</parameter></term>
<listitem><para>
diff --git a/modules/ksb/Application.pm b/modules/ksb/Application.pm
index 75c7da81..fa6cdaf1 100644
--- a/modules/ksb/Application.pm
+++ b/modules/ksb/Application.pm
@@ -185,6 +185,33 @@ sub _yieldModuleDependencyTreeEntry
$context->{report}($connector . $currentItem . ' ' . $statusInfo);
}
+sub _yieldModuleDependencyTreeEntry_FullPath
+{
+ my ($nodeInfo, $module, $context) = @_;
+
+ my $depth = $nodeInfo->{depth};
+ my $currentItem = $nodeInfo->{currentItem};
+
+ my $connectorStack = $context->{stack};
+
+ my $prefix = pop(@$connectorStack);
+
+ while($context->{depth} > $depth) {
+ $prefix = pop(@$connectorStack);
+ --($context->{depth});
+ }
+
+ push(@$connectorStack, $prefix);
+
+ my $connector;
+
+ $connector = $prefix;
+ push(@$connectorStack, $prefix . $currentItem . "/");
+
+ $context->{depth} = $depth + 1;
+ $context->{report}($connector . $currentItem);
+}
+
# Generates the build context and module list based on the command line options
# and module selectors provided, resolves dependencies on those modules if needed,
# filters out ignored or skipped modules, and sets up the module factory.
@@ -364,7 +391,7 @@ EOF
croak_runtime("Failed to resolve dependency graph");
}
- if (exists $cmdlineGlobalOptions->{'dependency-tree'}) {
+ if (exists $cmdlineGlobalOptions->{'dependency-tree'} || exists $cmdlineGlobalOptions->{'dependency-tree-fullpath'}) {
my $depTreeCtx = {
stack => [''],
depth => 0,
@@ -372,9 +399,17 @@ EOF
print(@_, "\n");
}
};
+
+ my $callback;
+ if (exists $cmdlineGlobalOptions->{'dependency-tree'}) {
+ $callback = \&_yieldModuleDependencyTreeEntry;
+ } else {
+ $callback = \&_yieldModuleDependencyTreeEntry_FullPath;
+ }
+
ksb::DependencyResolver::walkModuleDependencyTrees(
$moduleGraph->{graph},
- \&_yieldModuleDependencyTreeEntry,
+ $callback,
$depTreeCtx,
@modules
);
diff --git a/modules/ksb/Cmdline.pm b/modules/ksb/Cmdline.pm
index 2a8bc44c..fff3ecda 100644
--- a/modules/ksb/Cmdline.pm
+++ b/modules/ksb/Cmdline.pm
@@ -441,6 +441,7 @@ sub _supportedOptions
'colorful-output|color!',
'debug',
'dependency-tree',
+ 'dependency-tree-fullpath',
'help|h',
'ignore-modules|!=s{,}',
'd', # --include-dependencies, which is already pulled in via ksb::BuildContext::defaultGlobalFlags
More information about the kde-doc-english
mailing list