From c2dd6369f82c5fab530ae3c5cfc6c420554c6a0b Mon Sep 17 00:00:00 2001 From: Michael Pyne Date: Sun, 25 Nov 2012 00:58:57 -0500 Subject: [PATCH] modularize: Move QMake build system to separate file. --- kdesrc-build | 84 ++++++-------------------------- kdesrc-build-test.pl | 9 +++- modules/ksb/BuildSystem/QMake.pm | 63 ++++++++++++++++++++++++ 3 files changed, 84 insertions(+), 72 deletions(-) create mode 100644 modules/ksb/BuildSystem/QMake.pm diff --git a/kdesrc-build b/kdesrc-build index 0618d24..d381db0 100755 --- a/kdesrc-build +++ b/kdesrc-build @@ -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) { diff --git a/kdesrc-build-test.pl b/kdesrc-build-test.pl index 4293b22..bd60d54 100755 --- a/kdesrc-build-test.pl +++ b/kdesrc-build-test.pl @@ -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.'); } diff --git a/modules/ksb/BuildSystem/QMake.pm b/modules/ksb/BuildSystem/QMake.pm new file mode 100644 index 0000000..f0c1ebf --- /dev/null +++ b/modules/ksb/BuildSystem/QMake.pm @@ -0,0 +1,63 @@ +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;