refactor: Move cmake logic to KDE4 build system.

wilder
Michael Pyne 13 years ago
parent 83e358d366
commit 4211e1d44e
  1. 92
      kdesrc-build
  2. 9
      modules/ksb/Application.pm
  3. 1
      modules/ksb/BuildContext.pm
  4. 80
      modules/ksb/BuildSystem/KDE4.pm
  5. 2
      modules/ksb/BuildSystem/Qt4.pm
  6. 3
      modules/ksb/ModuleSet.pm
  7. 2
      modules/ksb/Updater/Git.pm
  8. 19
      modules/ksb/Util.pm

@ -196,98 +196,6 @@ sub get_module_path_dir
return %result;
}
# Returns a hash digest of the given options in the list. The return value is
# base64-encoded at this time.
#
# Note: Don't be dumb and pass data that depends on execution state as the
# returned hash is almost certainly not useful for whatever you're doing with
# it. (i.e. passing a reference to a list is not helpful, pass the list itself)
#
# Parameters: List of scalar values to hash.
# Return value: base64-encoded hash value.
sub get_list_digest
{
use Digest::MD5 "md5_base64"; # Included standard with Perl 5.8
return md5_base64(@_);
}
# Subroutine to run CMake to create the build directory for a module.
# CMake is not actually run if pretend mode is enabled.
#
# First parameter is the module to run cmake on.
# Return value is the shell return value as returned by log_command(). i.e.
# 0 for success, non-zero for failure.
sub safe_run_cmake
{
my $module = assert_isa(shift, 'ksb::Module');
my $srcdir = $module->fullpath('source');
my @commands = split_quoted_on_whitespace ($module->getOption('cmake-options'));
# grep out empty fields
@commands = grep {!/^\s*$/} @commands;
# Add -DBUILD_foo=OFF options for the directories in do-not-compile.
# This will only work if the CMakeLists.txt file uses macro_optional_add_subdirectory()
my @masked_directories = split(' ', $module->getOption('do-not-compile'));
push @commands, "-DBUILD_$_=OFF" foreach @masked_directories;
# Get the user's CXXFLAGS, use them if specified and not already given
# on the command line.
my $cxxflags = $module->getOption('cxxflags');
if ($cxxflags and not grep { /^-DCMAKE_CXX_FLAGS(:\w+)?=/ } @commands)
{
push @commands, "-DCMAKE_CXX_FLAGS:STRING=$cxxflags";
}
my $prefix = $module->installationPath();
push @commands, "-DCMAKE_INSTALL_PREFIX=$prefix";
if ($module->getOption('run-tests') &&
!grep { /^\s*-DKDE4_BUILD_TESTS(:BOOL)?=(ON|TRUE|1)\s*$/ } (@commands)
)
{
whisper ("Enabling tests");
push @commands, "-DKDE4_BUILD_TESTS:BOOL=ON";
# Also enable phonon tests.
if ($module =~ /^phonon$/) {
push @commands, "-DPHONON_BUILD_TESTS:BOOL=ON";
}
}
if ($module->getOption('run-tests') eq 'upload')
{
whisper ("Enabling upload of test results");
push @commands, "-DBUILD_experimental:BOOL=ON";
}
unshift @commands, 'cmake', $srcdir; # Add to beginning of list.
my $old_options =
$module->getPersistentOption('last-cmake-options') || '';
my $builddir = $module->fullpath('build');
if (($old_options ne get_list_digest(@commands)) ||
$module->getOption('reconfigure') ||
! -e "$builddir/CMakeCache.txt" # File should exist only on successful cmake run
)
{
info ("\tRunning g[cmake]...");
# Remove any stray CMakeCache.txt
safe_unlink ("$srcdir/CMakeCache.txt") if -e "$srcdir/CMakeCache.txt";
safe_unlink ("$builddir/CMakeCache.txt") if -e "$builddir/CMakeCache.txt";
$module->setPersistentOption('last-cmake-options', get_list_digest(@commands));
return log_command($module, "cmake", \@commands);
}
# Skip cmake run
return 0;
}
# Subroutine to recursively symlink a directory into another location, in a
# similar fashion to how the XFree/X.org lndir() program does it. This is
# reimplemented here since some systems lndir doesn't seem to work right.

@ -17,6 +17,8 @@ use ksb::Util;
use ksb::BuildContext;
use ksb::BuildSystem::QMake;
use ksb::Module;
use ksb::ModuleSet;
use ksb::ModuleSet::KDEProjects;
use ksb::RecursiveFH;
use ksb::DependencyResolver 0.20;
use ksb::IPC::Pipe 0.20;
@ -800,13 +802,10 @@ sub _readConfigurationOptions
}
else {
# Overwrite options set for existing modules.
if (my @modules = grep { $_->name() eq $modulename } @module_list) {
if (my @modules = grep { $_->isa('ksb::Module') && ($_->name() eq $modulename) } @module_list) {
# We check for definedness as a module-set can exist but be
# unnamed.
if ($modules[0]->moduleSet()->isa('ksb::ModuleSet::Null')) {
warning ("Multiple module declarations for $modules[0]");
}
warning ("Multiple module declarations for $modules[0]");
_parseModuleOptions($ctx, $fileReader, $modules[0]); # Don't re-add
}
else {

@ -26,6 +26,7 @@ use ksb::Module::BranchGroupResolver;
use ksb::Updater::KDEProjectMetadata;
use ksb::Version qw(scriptVersion);
use File::Temp qw(tempfile);
use File::Spec; # rel2abs
# We derive from ksb::Module so that BuildContext acts like the 'global'
# ksb::Module, with some extra functionality.

@ -104,7 +104,7 @@ sub configureInternal
# Use cmake to create the build directory (sh script return value
# semantics).
if (main::safe_run_cmake ($module))
if (_safe_run_cmake ($module))
{
error ("\tUnable to configure r[$module] with CMake!");
return 0;
@ -113,4 +113,82 @@ sub configureInternal
return 1;
}
### Internal package functions.
# Subroutine to run CMake to create the build directory for a module.
# CMake is not actually run if pretend mode is enabled.
#
# First parameter is the module to run cmake on.
# Return value is the shell return value as returned by log_command(). i.e.
# 0 for success, non-zero for failure.
sub _safe_run_cmake
{
my $module = assert_isa(shift, 'ksb::Module');
my $srcdir = $module->fullpath('source');
my @commands = split_quoted_on_whitespace ($module->getOption('cmake-options'));
# grep out empty fields
@commands = grep {!/^\s*$/} @commands;
# Add -DBUILD_foo=OFF options for the directories in do-not-compile.
# This will only work if the CMakeLists.txt file uses macro_optional_add_subdirectory()
my @masked_directories = split(' ', $module->getOption('do-not-compile'));
push @commands, "-DBUILD_$_=OFF" foreach @masked_directories;
# Get the user's CXXFLAGS, use them if specified and not already given
# on the command line.
my $cxxflags = $module->getOption('cxxflags');
if ($cxxflags and not grep { /^-DCMAKE_CXX_FLAGS(:\w+)?=/ } @commands)
{
push @commands, "-DCMAKE_CXX_FLAGS:STRING=$cxxflags";
}
my $prefix = $module->installationPath();
push @commands, "-DCMAKE_INSTALL_PREFIX=$prefix";
if ($module->getOption('run-tests') &&
!grep { /^\s*-DKDE4_BUILD_TESTS(:BOOL)?=(ON|TRUE|1)\s*$/ } (@commands)
)
{
whisper ("Enabling tests");
push @commands, "-DKDE4_BUILD_TESTS:BOOL=ON";
# Also enable phonon tests.
if ($module =~ /^phonon$/) {
push @commands, "-DPHONON_BUILD_TESTS:BOOL=ON";
}
}
if ($module->getOption('run-tests') eq 'upload')
{
whisper ("Enabling upload of test results");
push @commands, "-DBUILD_experimental:BOOL=ON";
}
unshift @commands, 'cmake', $srcdir; # Add to beginning of list.
my $old_options =
$module->getPersistentOption('last-cmake-options') || '';
my $builddir = $module->fullpath('build');
if (($old_options ne get_list_digest(@commands)) ||
$module->getOption('reconfigure') ||
! -e "$builddir/CMakeCache.txt" # File should exist only on successful cmake run
)
{
info ("\tRunning g[cmake]...");
# Remove any stray CMakeCache.txt
safe_unlink ("$srcdir/CMakeCache.txt") if -e "$srcdir/CMakeCache.txt";
safe_unlink ("$builddir/CMakeCache.txt") if -e "$builddir/CMakeCache.txt";
$module->setPersistentOption('last-cmake-options', get_list_digest(@commands));
return log_command($module, "cmake", \@commands);
}
# Skip cmake run
return 0;
}
1;

@ -78,7 +78,7 @@ EOF
my $builddir = $module->fullpath('build');
my $old_flags = $module->getPersistentOption('last-configure-flags') || '';
my $cur_flags = main::get_list_digest(@commands);
my $cur_flags = get_list_digest(@commands);
if(($cur_flags ne $old_flags) ||
($module->getOption('reconfigure')) ||

@ -39,7 +39,8 @@ our $VERSION = '0.10';
use ksb::Debug;
use ksb::Util;
use ksb::PhaseList;
use ksb::BuildContext;
use ksb::Module;
use Storable qw(dclone);
sub new

@ -16,6 +16,8 @@ use File::Basename; # basename
use File::Spec; # tmpdir
use POSIX qw(strftime);
use List::Util qw(first);
use URI;
use ksb::IPC::Null;
use constant {

@ -15,6 +15,7 @@ use File::Find;
use Cwd qw(getcwd);
use Errno qw(:POSIX);
use Digest::MD5;
use LWP::UserAgent;
use ksb::Debug;
use ksb::Version qw(scriptVersion);
@ -25,7 +26,7 @@ our @EXPORT = qw(list_has make_exception assert_isa assert_in any
croak_runtime croak_internal download_file absPathToExecutable
fileDigestMD5 log_command disable_locale_message_translation
split_quoted_on_whitespace safe_unlink safe_system p_chdir
pretend_open safe_rmtree
pretend_open safe_rmtree get_list_digest
super_mkdir filter_program_output prettify_seconds);
# Function to work around a Perl language limitation.
@ -674,5 +675,21 @@ sub safe_rmtree
return 1;
}
# Returns a hash digest of the given options in the list. The return value is
# base64-encoded at this time.
#
# Note: Don't be dumb and pass data that depends on execution state as the
# returned hash is almost certainly not useful for whatever you're doing with
# it. (i.e. passing a reference to a list is not helpful, pass the list itself)
#
# Parameters: List of scalar values to hash.
# Return value: base64-encoded hash value.
sub get_list_digest
{
use Digest::MD5 "md5_base64"; # Included standard with Perl 5.8
return md5_base64(@_);
}
1;

Loading…
Cancel
Save