Add check for "essential" programs before building.

If you (for whatever reason) don't have things like cmake installed before
trying to run a full build you'll just spend a lot of time to eventually figure
out that kdesrc-build wasn't able to build anything.

Now we can (optionally!) skip the build process entirely if "essential"
programs do not seem to be available before running the build. Each build
system type is able to determine which programs are considered essential.

Note that if 'qmake' is the only holdup then we don't complain if we seem to be
building Qt or if we're in pretend mode (since it's certainly possible to fool
build system detection when in pretend mode). If qmake is really missing the
user /should/ just find out when they run without --pretend (since then Qt
should show up amongst the build-modules' build systems).

BUG:263936
FIXED-IN:1.15
wilder
Michael Pyne 14 years ago
parent 616744a176
commit 67ad3fa3da
  1. 99
      kdesrc-build

@ -2713,6 +2713,14 @@ HOME
return 1;
}
# This should return a list of executable names that must be present to
# even bother attempting to use this build system. An empty list should be
# returned if there's no required programs.
sub requiredPrograms
{
return;
}
sub name
{
return 'generic';
@ -2877,6 +2885,11 @@ HOME
return 'qmake';
}
sub requiredPrograms
{
return qw{qmake};
}
# Return value style: boolean
sub configureInternal
{
@ -3153,6 +3166,11 @@ HOME
return 'CMAKE_PREFIX_PATH';
}
sub requiredPrograms
{
return qw{cmake qmake};
}
sub runTestsuite
{
my $self = assert_isa(shift, 'KDEBuildSystem');
@ -7650,6 +7668,75 @@ sub expandl10nModules
return @modules;
}
# This subroutine checks for programs which are absolutely essential to the
# *build* process and returns false if they are not all present. Right now this
# just means qmake and cmake (although this depends on what modules are
# actually present in the build context).
#
# Pass the build context as the only parameter.
sub checkForEssentialBuildPrograms
{
my $ctx = assert_isa(shift, 'ksb::BuildContext');
return 1 if pretending();
my @buildModules = $ctx->modulesInPhase('build');
my %requiredPrograms;
my %modulesRequiringProgram;
foreach my $module ($ctx->modulesInPhase('build')) {
my @progs = $module->buildSystem()->requiredPrograms();
# Deliberately used @, since requiredPrograms can return a list.
@requiredPrograms{@progs} = 1;
foreach my $prog (@progs) {
$modulesRequiringProgram{$prog} //= { };
$modulesRequiringProgram{$prog}->{$module->name()} = 1;
}
}
my $wasError = 0;
for my $prog (keys %requiredPrograms) {
my %requiredPackages = (
qmake => 'Qt',
cmake => 'CMake',
);
if (!absPathToExecutable($prog)) {
# Don't complain about Qt if we're building it...
if ($prog eq 'qmake' && (
grep { $_->buildSystemType() eq 'Qt' } (@buildModules)) ||
pretending()
)
{
next;
}
$wasError = 1;
my $reqPackage = $requiredPackages{$prog} || $prog;
my @modulesNeeding = keys %{$modulesRequiringProgram{$prog}};
local $, = ', '; # List separator in output
error (<<"EOF");
Unable to find r[b[$prog]. This program is absolutely essential for building
the modules: y[@modulesNeeding].
Please ensure the development packages for
$reqPackage are installed by using your distribution's package manager.
You can also see the
http://techbase.kde.org/Getting_Started/Build/Distributions page for
information specific to your distribution (although watch for outdated
information :( ).
EOF
}
}
return !$wasError;
}
# Subroutine to handle the build process.
# First parameter is a reference of a list containing the packages
# we are to build.
@ -7675,6 +7762,18 @@ sub handle_build
note ("<<< Build Process >>>");
# Check for absolutely essential programs now.
if (!checkForEssentialBuildPrograms($ctx) &&
!exists $ENV{KDESRC_BUILD_IGNORE_MISSING_PROGRAMS})
{
error (" r[b[*] Aborting now to save a lot of wasted time.");
error (" y[b[*] export KDESRC_BUILD_IGNORE_MISSING_PROGRAMS=1 and re-run (perhaps with --no-src)");
error (" r[b[*] to continue anyways. If this check was in error please report a bug against");
error (" y[b[*] kdesrc-build at https://bugs.kde.org/");
return 1;
}
# IPC queue should have a message saying whether or not to bother with the
# build.
$ipc->waitForStreamStart();

Loading…
Cancel
Save