From 9be64e86e202f66d07dd4c00b14a76279c8a1196 Mon Sep 17 00:00:00 2001 From: Raphael Kubo da Costa Date: Mon, 12 Dec 2011 21:07:18 -0200 Subject: [PATCH] Teach the 'prefix' option to understand ${MODULE}/$MODULE. This commit should make the 'prefix' option expand this variable to the module's name, so one can easily install each module into a different directory. Reviewed-by: mpyne --- doc/index.docbook | 6 ++++-- kdesrc-build | 30 +++++++++++++++++++++++------- 2 files changed, 27 insertions(+), 9 deletions(-) diff --git a/doc/index.docbook b/doc/index.docbook index 94a5ae6..e1966c9 100644 --- a/doc/index.docbook +++ b/doc/index.docbook @@ -1904,11 +1904,13 @@ cannot figure out what you mean using branch. prefix Module setting overrides global -This option controls where to install the module (normally the +This option controls where to install the module (normally the setting is used). Using this option allows you to install a module to a different directory than where the KDE Platform libraries are installed, such as if you were using -&kdesrc-build; only to build applications. +&kdesrc-build; only to build applications. +You can use ${MODULE} or $MODULE +in the path to have them expanded to the module's name. diff --git a/kdesrc-build b/kdesrc-build index c1e0c50..087d4cc 100755 --- a/kdesrc-build +++ b/kdesrc-build @@ -2999,6 +2999,27 @@ EOF return $destDir; } + # Subroutine to return the installation path of a given module (the value + # that is passed to the CMAKE_INSTALL_PREFIX CMake option). + # It is based on the "prefix" and, if it is not set, the "kdedir" option. + # The user may use '$MODULE' or '${MODULE}' in the "prefix" option to have + # them replaced by the name of the module in question. + sub installationPath + { + my $self = assert_isa(shift, 'Module'); + my $path = $self->getOption('prefix'); + + if (!$path) + { + return $self->getOption('kdedir'); + } + + my $moduleName = $self->name(); + $path =~ s/(\${MODULE})|(\$MODULE\b)/$moduleName/g; + + return $path; + } + 1; } @@ -6276,10 +6297,7 @@ sub safe_run_cmake push @commands, "-DCMAKE_CXX_FLAGS:STRING=$cxxflags"; } - my $prefix = $module->getOption('prefix'); - - # If still no prefix, use KDEDIR - $prefix = $module->getOption('kdedir') unless $prefix; + my $prefix = $module->installationPath(); push @commands, "-DCMAKE_INSTALL_PREFIX=$prefix"; @@ -6565,9 +6583,7 @@ sub update_module_environment my $module = assert_isa(shift, 'Module'); my $kdedir = $module->getOption('kdedir'); my $qtdir = $module->getOption('qtdir'); - my $prefix = $module->getOption('prefix'); - - $prefix = $kdedir unless $prefix; + my $prefix = $module->installationPath(); # Add global set-envs setup_module_environment ($module->buildContext());