Move set-env handling to Module.

wilder
Michael Pyne 13 years ago
parent 8421e995c3
commit f6b40110c1
  1. 21
      kdesrc-build
  2. 2
      kdesrc-build-test.pl
  3. 39
      modules/ksb/Module.pm

@ -716,7 +716,7 @@ sub parse_moduleset
}
}
elsif ($option eq 'set-env') {
handle_set_env(\%optionSet, $option, $value);
Module::processSetEnvOption(\%optionSet, $option, $value);
}
else {
$optionSet{$option} = $value;
@ -1238,25 +1238,6 @@ sub extract_option_value_required($\@)
return $returnValue;
}
# Utility subroutine to handle setting the environment variable type of value.
# Returns true (non-zero) if this subroutine handled everything, 0 otherwise.
# The first parameter should by the reference to the hash with the 'set-env'
# hash ref, second parameter is the exact option to check, and the third
# option is the value to set that option to.
sub handle_set_env
{
my ($href, $option, $value) = @_;
return 0 if $option !~ /^#?set-env$/;
my ($var, @values) = split(' ', $value);
${$href}{$option} //= { };
${$href}{$option}->{$var} = join(' ', @values);
return 1;
}
# Function: process_arguments
#
# Processes the command line arguments, which are used to modify the given

@ -95,7 +95,7 @@ eval {
ksb::Util->import();
# If using set-env, it is handled by the handle_set_env routine, so the
# If using set-env, it is handled by the Module::processSetEnvOption, so the
# value should be the space separated VAR and VALUE.
$ctx->setOption('set-env', 'TESTY_MCTEST yes');
$ctx->setOption('cxxflags', '-g -O0');

@ -821,6 +821,39 @@ sub hasOption
return exists $self->{options}{$key};
}
# Function: processSetEnvOption
#
# Handles setting set-env options in a format appropriate for a Module option
# hash (a reference to which should be given as the first argument).
#
# Though part of the Module package, this is a simple sub, not a "method", so
# call with Module::processSetEnvOption, not ->.
#
# Parameters:
#
# optionHash - hashref to the option hash where the set-env option(s) will be
# stored. The environment variable settings will be stored under the 'set-env'
# key, which will hold a hashref to the variables/values.
# variable - Name of the environment variable to later set.
# value - Value to give to the environment (can be empty).
#
# Returns:
#
# Boolean true if variable was processed, false otherwise.
sub processSetEnvOption
{
my ($href, $variable, $value) = @_;
return if $variable !~ /^#?set-env$/;
my ($var, @values) = split(' ', $value);
${$href}{$variable} //= { };
${$href}{$variable}->{$var} = join(' ', @values);
return 1;
}
# Sets the option refered to by the first parameter (a string) to the
# scalar (e.g. references are OK too) value given as the second paramter.
sub setOption
@ -828,9 +861,9 @@ sub setOption
my ($self, %options) = @_;
while (my ($key, $value) = each %options) {
# ref($value) checks if value is already a reference (i.e. a hashref)
# which means we should just copy it over, as all handle_set_env does
# is convert the string to the right hashref.
if (!ref($value) && main::handle_set_env($self->{options}, $key, $value))
# which means we should just copy it over, as all processSetEnvOption
# does is convert the string to the right hashref.
if (!ref($value) && processSetEnvOption($self->{options}, $key, $value))
{
return
}

Loading…
Cancel
Save