Commit c2dd6369 authored by Michael Pyne's avatar Michael Pyne
Browse files

modularize: Move QMake build system to separate file.

parent 6bcfdc23
......@@ -927,68 +927,6 @@ EOM
}
# }}}
# package QMakeBuildSystem {{{
{
package QMakeBuildSystem;
use List::Util qw(first);
use ksb::Debug;
use ksb::Util;
use ksb::BuildSystem;
our @ISA = ('ksb::BuildSystem');
sub name
{
return 'qmake';
}
sub requiredPrograms
{
return qw{qmake};
}
# Returns the absolute path to 'qmake'. Note the actual executable name may
# not necessarily be 'qmake' as some distributions rename it to allow for
# co-installability with Qt 3 (and 5...)
# If no suitable qmake can be found, undef is returned.
# This is a "static class method" i.e. use QMakeBuildSystem::absPathToQMake()
sub absPathToQMake
{
my @possibilities = qw/qmake qmake4 qmake-qt4 qmake-mac/;
return first { absPathToExecutable($_) } @possibilities;
}
# Return value style: boolean
sub configureInternal
{
my $self = assert_isa(shift, 'QMakeBuildSystem');
my $module = $self->module();
my $builddir = $module->fullpath('build');
my $sourcedir = $module->fullpath('source');
my @projectFiles = glob("$sourcedir/*.pro");
if (!@projectFiles || !$projectFiles[0]) {
croak_internal("No *.pro files could be found for $module");
}
if (@projectFiles > 1) {
error (" b[r[*] Too many possible *.pro files for $module");
return 0;
}
p_chdir($builddir);
my $qmake = absPathToQMake();
return 0 unless $qmake;
return log_command($module, 'qmake', [ $qmake, $projectFiles[0] ]) == 0;
}
1;
}
# }}}
# package AutotoolsBuildSystem {{{
{
package AutotoolsBuildSystem;
......@@ -1741,12 +1679,18 @@ EOF
my $buildSystem;
given(lc($name)) {
when('generic') { $buildSystem = ksb::BuildSystem -> new($self); }
when('qmake') { $buildSystem = QMakeBuildSystem -> new($self); }
when('cmake-bootstrap') { $buildSystem = CMakeBootstrapSystem -> new($self); }
when('kde') { $buildSystem = KDEBuildSystem -> new($self); }
when('qt') { $buildSystem = QtBuildSystem -> new($self); }
when('autotools') { $buildSystem = AutotoolsBuildSystem -> new($self); }
when('generic')
{ $buildSystem = ksb::BuildSystem -> new($self); }
when('qmake')
{ $buildSystem = ksb::BuildSystem::QMake->new($self); }
when('cmake-bootstrap')
{ $buildSystem = CMakeBootstrapSystem -> new($self); }
when('kde')
{ $buildSystem = KDEBuildSystem -> new($self); }
when('qt')
{ $buildSystem = QtBuildSystem -> new($self); }
when('autotools')
{ $buildSystem = AutotoolsBuildSystem -> new($self); }
default { croak_runtime("Invalid build system $name requested"); }
}
......@@ -1793,7 +1737,7 @@ EOF
}
if (!$buildType && (glob ("$sourceDir/*.pro"))) {
$buildType = QMakeBuildSystem->new($self);
$buildType = ksb::BuildSystem::QMake->new($self);
}
# 'configure' is a popular fall-back option even for other build
......@@ -4715,7 +4659,7 @@ sub checkForEssentialBuildPrograms
# qmake is not necessarily named 'qmake'
if (!$programPath && $prog eq 'qmake') {
$programPath = QMakeBuildSystem::absPathToQMake();
$programPath = ksb::BuildSystem::QMake::absPathToQMake();
}
if (!$programPath) {
......
......@@ -28,12 +28,17 @@ require 'kdesrc-build';
# kdesrc-build.
package main;
use FindBin qw($RealBin);
use lib "$RealBin/../share/apps/kdesrc-build/modules";
use lib "$RealBin/modules";
# Must come after require kdesrc-build. note will interfere with our debugging
# function, and we don't use it in the test harness anyways.
use Test::More import => ['!note'];
use File::Temp 'tempdir';
use Storable 'dclone';
use File::Copy;
use ksb::BuildSystem::QMake;
# From kdesrc-build
our %ENV_VARS;
......@@ -506,14 +511,14 @@ ok ($buildSystem->isSubdirBuildable(''), 'l10n-build isSubdirBuildable-other');
# Note to packagers: This assumes qmake or qmake-qt4 are already installed on
# the system.
my @qmakePossibilities = QMakeBuildSystem::absPathToQMake();
my @qmakePossibilities = ksb::BuildSystem::QMake::absPathToQMake();
SKIP: {
is (scalar @qmakePossibilities, 1, 'Ensure exactly one qmake is returned from possibilities.')
or skip "Need a qmake candidate for next test", 1; # Skip next tests if no qmake
like ($qmakePossibilities[0], qr/^qmake/, 'qmake candidate looks like a qmake executable.');
# Duplicate test in scalar context the whole time.
my $newQMakePossibility = QMakeBuildSystem::absPathToQMake();
my $newQMakePossibility = ksb::BuildSystem::QMake::absPathToQMake();
like ($newQMakePossibility, qr/^qmake/, 'qmake looks like an executable even in scalar context.');
}
......
package ksb::BuildSystem::QMake;
# A build system used to build modules that use qmake
use strict;
use warnings;
use v5.10;
use List::Util qw(first);
use ksb::Debug;
use ksb::Util;
use ksb::BuildSystem;
our @ISA = ('ksb::BuildSystem');
sub name
{
return 'qmake';
}
sub requiredPrograms
{
return qw{qmake};
}
# Returns the absolute path to 'qmake'. Note the actual executable name may
# not necessarily be 'qmake' as some distributions rename it to allow for
# co-installability with Qt 3 (and 5...)
# If no suitable qmake can be found, undef is returned.
# This is a "static class method" i.e. use ksb::BuildSystem::QMake::absPathToQMake()
sub absPathToQMake
{
my @possibilities = qw/qmake qmake4 qmake-qt4 qmake-mac/;
return first { absPathToExecutable($_) } @possibilities;
}
# Return value style: boolean
sub configureInternal
{
my $self = assert_isa(shift, 'ksb::BuildSystem::QMake');
my $module = $self->module();
my $builddir = $module->fullpath('build');
my $sourcedir = $module->fullpath('source');
my @projectFiles = glob("$sourcedir/*.pro");
if (!@projectFiles || !$projectFiles[0]) {
croak_internal("No *.pro files could be found for $module");
}
if (@projectFiles > 1) {
error (" b[r[*] Too many possible *.pro files for $module");
return 0;
}
p_chdir($builddir);
my $qmake = absPathToQMake();
return 0 unless $qmake;
return log_command($module, 'qmake', [ $qmake, $projectFiles[0] ]) == 0;
}
1;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment