[kde-doc-english] [kdesrc-build] /: Add --stop-{before, after} command line options.

Michael Pyne mpyne at kde.org
Wed Feb 20 04:28:34 UTC 2013


Git commit f3d30fb5a056f297181aa63d66af5f92f45b2635 by Michael Pyne.
Committed on 20/02/2013 at 05:23.
Pushed by mpyne into branch 'master'.

Add --stop-{before,after} command line options.

Should hopefully be pretty much what it says on the tin. Stop either
right before or right after the given module. (GUI flag since this
involves documentation changes to the Handbook and man page).

BUG:315251
FIXED-IN:1.16
GUI:

M  +34   -3    doc/index.docbook
M  +42   -3    doc/man-kdesrc-build.1.docbook
M  +93   -27   kdesrc-build

http://commits.kde.org/kdesrc-build/f3d30fb5a056f297181aa63d66af5f92f45b2635

diff --git a/doc/index.docbook b/doc/index.docbook
index e84a488..94f3218 100644
--- a/doc/index.docbook
+++ b/doc/index.docbook
@@ -2,7 +2,7 @@
 <!DOCTYPE book PUBLIC "-//KDE//DTD DocBook XML V4.2-Based Variant V1.1//EN" "dtd/kdex.dtd" [
   <!--
     Documentation for kdesrc-build.
-    Copyright (c) 2005-2008, 2010-2012 Michael Pyne <mpyne at kde.org>
+    Copyright (c) 2005-2008, 2010-2013 Michael Pyne <mpyne at kde.org>
 
     Copyright (c) 2005 Carlos Leonhard Woelz <carloswoelz at imap-mail.com>
     Copyright (c) 2009 Burkhard Lück <lueck at hube-lueck.de>
@@ -97,6 +97,7 @@
 <year>2010</year>
 <year>2011</year>
 <year>2012</year>
+<year>2013</year>
 <holder>Michael Pyne</holder>
 </copyright>
 
@@ -107,8 +108,8 @@
 
 <legalnotice>&FDLNotice;</legalnotice>
 
-<date>2012-05-05</date>
-<releaseinfo>1.15</releaseinfo>
+<date>2013-02-19</date>
+<releaseinfo>1.16</releaseinfo>
 
 <abstract>
 <para>&kdesrc-build; is a script which builds and installs &kde; software
@@ -2780,6 +2781,36 @@ yourself, and want &kdesrc-build; to start again with the next
 module.</para></listitem>
 </varlistentry>
 
+<varlistentry id="cmdline-stop-before">
+<term><parameter>--stop-before</parameter></term>
+<listitem><para>
+This command line option is used to stop the normal build process just
+<emphasis>before</emphasis> a module would ordinarily be built.
+</para><para>
+For example, if the normal build list was <simplelist type='inline'>
+<member>moduleA</member><member>moduleB</member><member>moduleC</member></simplelist>,
+then <option>--stop-before=<replaceable>moduleB</replaceable></option> would cause
+&kdesrc-build; to only build <literal>moduleA</literal>.
+</para><para>
+This command line option was added with &kdesrc-build; 1.16.
+</para></listitem>
+</varlistentry>
+
+<varlistentry id="cmdline-stop-after">
+<term><parameter>--stop-after</parameter></term>
+<listitem><para>
+This command line option is used to stop the normal build process just
+<emphasis>after</emphasis> a module would ordinarily be built.
+</para><para>
+For example, if the normal build list was <simplelist type='inline'>
+<member>moduleA</member><member>moduleB</member><member>moduleC</member></simplelist>,
+then <option>--stop-after=<replaceable>moduleB</replaceable></option> would cause
+&kdesrc-build; to build <literal>moduleA</literal> and <literal>moduleB</literal>.
+</para><para>
+This command line option was added with &kdesrc-build; 1.16.
+</para></listitem>
+</varlistentry>
+
 <varlistentry id="cmdline-rc-file">
 <term><parameter>--rc-file</parameter></term>
 <listitem><para>
diff --git a/doc/man-kdesrc-build.1.docbook b/doc/man-kdesrc-build.1.docbook
index 9bd2a4c..100215e 100644
--- a/doc/man-kdesrc-build.1.docbook
+++ b/doc/man-kdesrc-build.1.docbook
@@ -22,13 +22,13 @@
     <email>mpyne at kde.org</email>
     <personblurb><para>Authored man page</para></personblurb>
 </author>
-<date>2012-05-05</date>
+<date>2013-02-19</date>
 </refentryinfo>
 
 <refmeta>
 <refentrytitle><command>kdesrc-build</command></refentrytitle>
 <manvolnum>1</manvolnum>
-<refmiscinfo class="version">1.15</refmiscinfo>
+<refmiscinfo class="version">1.16</refmiscinfo>
 </refmeta>
 
 <refnamediv>
@@ -319,6 +319,45 @@ combining short options into one at this point. (E.g. running
 
 <varlistentry>
 <term>
+<option>--stop-before=<replaceable>foo</replaceable></option>
+</term>
+
+<listitem>
+<para>
+    This is similar to the <option>--resume-from</option> flag. This option
+    causes the module list for the given build to be truncated just
+    <emphasis>before</emphasis> <replaceable>foo</replaceable> would normally
+    have been built. <replaceable>foo</replaceable> is <emphasis>not</emphasis>
+    built (but see <option>--stop-after</option>).
+</para>
+
+<para>
+    This flag may be used with <option>--resume-from</option> or
+    <option>--resume-after</option>.
+</para>
+</listitem>
+</varlistentry>
+
+<varlistentry>
+<term>
+<option>--stop-after=<replaceable>foo</replaceable></option>
+</term>
+
+<listitem>
+<para>
+    This is just like <option>--stop-before</option>, except that the given module
+    <emphasis>is</emphasis> included in the build.
+</para>
+
+<para>
+    This flag may be used with <option>--resume-from</option> or
+    <option>--resume-after</option>.
+</para>
+</listitem>
+</varlistentry>
+
+<varlistentry>
+<term>
 <option>--ignore-modules</option>
 </term>
 
@@ -942,7 +981,7 @@ url="http://kdesrc-build.kde.org/documentation/">http://kdesrc-build.kde.org/doc
 <refsect1>
 <title>COPYING</title>
 
-<para>Copyright (C) 2003-2011 Michael Pyne.</para>
+<para>Copyright (C) 2003-2013 Michael Pyne.</para>
 
 <para>This program is free software; you can redistribute it and/or modify it
 under the terms of the GNU General Public License as published by the Free
diff --git a/kdesrc-build b/kdesrc-build
index 5e7e3f0..41052b5 100755
--- a/kdesrc-build
+++ b/kdesrc-build
@@ -1351,6 +1351,9 @@ Options:
     --resume-after=<pkg> Skips modules up to and including the given package,
                          then operates as normal.
 
+    --stop-before=<pkg>  Skips the given package and all later packages.
+    --stop-after=<pkg>   Skips all packages after the given package.
+
     --reconfigure        Run CMake/configure again, but don't clean the build
                          directory.
     --build-system-only  Create the build infrastructure, but don't actually
@@ -1597,6 +1600,20 @@ DONE
                 last SWITCH;
             };
 
+            /^--stop-after=?/ && do {
+                $_ = extract_option_value_required($_, @options);
+                $ctx->setOption('#stop-after', $_);
+
+                last SWITCH;
+            };
+
+            /^--stop-before=?/ && do {
+                $_ = extract_option_value_required($_, @options);
+                $ctx->setOption('#stop-before', $_);
+
+                last SWITCH;
+            };
+
             /^--/ && do {
                 # First let's see if they're trying to override a global option.
                 my ($option) = /^--([-\w\d\/]+)/;
@@ -2462,8 +2479,9 @@ sub handle_uninstall
 # each module as-is but change the phases they operate as part of, this
 # function could remove a module entirely from the build).
 #
-# Used for --resume-from and --resume-after, but more could be added in theory.
-# This subroutine supports --resume-* for both modules and module-sets.
+# Used for --resume-{from,after} and --stop-{before,after}, but more could be
+# added in theory.
+# This subroutine supports --{resume,stop}-* for both modules and module-sets.
 #
 # Parameters:
 #  ctx - <BuildContext> in use.
@@ -2478,9 +2496,10 @@ sub applyModuleFilters
     my $ctx = assert_isa(shift, 'ksb::BuildContext');
     my @moduleList = @_;
 
-    if (!$ctx->getOption('resume-from') && !$ctx->getOption('resume-after'))
+    if (!$ctx->getOption('resume-from') && !$ctx->getOption('resume-after') &&
+        !$ctx->getOption('stop-before') && !$ctx->getOption('stop-after'))
     {
-        debug ("No --resume-from or --resume-after seems present.");
+        debug ("No command-line filter seems to be present.");
         return @moduleList;
     }
 
@@ -2495,38 +2514,85 @@ EOF
         croak_runtime("Both --resume-after and --resume-from specified.");
     }
 
+    if ($ctx->getOption('stop-before') && $ctx->getOption('stop-after'))
+    {
+        # This one's an error.
+        error (<<EOF);
+You specified both r[b[--stop-before] and r[b[--stop-after] but you can only
+use one.
+EOF
+
+        croak_runtime("Both --stop-before and --stop-from specified.");
+    }
+
     my $resumePoint = $ctx->getOption('resume-from') ||
                       $ctx->getOption('resume-after');
 
-    debug ("Looking for $resumePoint for --resume-* option");
-
-    # || 0 is a hack to force Boolean context.
-    my $filterInclusive = $ctx->getOption('resume-from') || 0;
-    my $found = 0;
-
-    # If we already found our resume point, include this module. If this module
-    # *is* the resume point, include it if filterInclusive is true, otherwise
-    # just flag it. Module sets complicate the logic a bit, but it's basically
-    # just harder in the --resume-after case where we have to leave that module
-    # set before we can allow modules through the filter.
-    my $filterTest = sub {
-        return 1 if $_->scmType() eq 'metadata'; # Don't filter this one!
-        my $moduleSet = $_->moduleSet() // '';
-        if ($found) {
-            return $filterInclusive || $moduleSet ne $resumePoint;
-        }
-        $found = $_->{'name'} eq $resumePoint || $moduleSet eq $resumePoint;
-        return $found && $filterInclusive;
-    };
+    my $startIndex = scalar @moduleList;
+
+    if ($resumePoint) {
+        debug ("Looking for $resumePoint for --resume-* option");
 
-    my @resultList = grep { &$filterTest } (@moduleList);
+        # || 0 is a hack to force Boolean context.
+        my $filterInclusive = $ctx->getOption('resume-from') || 0;
+        my $found = 0;
+
+        for (my $i = 0; $i < scalar @moduleList; $i++) {
+            my $module = $moduleList[$i];
+            my $moduleSet = $module->moduleSet() // '';
+
+            # If a match was found we can only still be here if looking at
+            # --resume-after. If we matched on module set name then eliminate
+            # all of the module set before stopping.
+            if ($found && ($moduleSet ne $resumePoint)) {
+                $startIndex = $i;
+                last;
+            }
+
+            $found = $module->{'name'} eq $resumePoint || $moduleSet eq $resumePoint;
+            if ($found && $filterInclusive) {
+                $startIndex = $i;
+                last;
+            }
+        }
+    }
+    else {
+        $startIndex = 0;
+    }
+
+    my $stopPoint = $ctx->getOption('stop-before') ||
+                    $ctx->getOption('stop-after');
+
+    my $stopIndex = 0;
+
+    if ($stopPoint) {
+        debug ("Looking for $stopPoint for --stop-* option");
+
+        # || 0 is a hack to force Boolean context.
+        my $filterInclusive = $ctx->getOption('stop-before') || 0;
+        my $found = 0;
+
+        for (my $i = $startIndex; $i < scalar @moduleList; $i++) {
+            my $module = $moduleList[$i];
+            my $moduleSet = $module->moduleSet() // '';
+
+            $found = $module->{'name'} eq $stopPoint || $moduleSet eq $stopPoint;
+            if ($found) {
+                $stopIndex = $i - ($filterInclusive ? 1 : 0);
+                last;
+            }
+        }
+    }
+    else {
+        $stopIndex = scalar @moduleList - 1;
+    }
 
-    if (!@resultList && @moduleList) {
+    if ($startIndex > $stopIndex || scalar @moduleList == 0) {
         # Lost all modules somehow.
-        croak_runtime("Unknown resume point $resumePoint.");
+        croak_runtime("Unknown resume -> stop point $resumePoint -> $stopPoint.");
     }
 
-    return @resultList;
+    return @moduleList[$startIndex .. $stopIndex];
 }
 
 # Function: spliceOptionModules


More information about the kde-doc-english mailing list