saker.build Documentation TaskDoc JavaDoc

var()

The var() task can be used to access a variable with the specified name in the enclosing build target scope. This task works the same way as accessing a variable via the dereferencing operator. However it cannot be used to access expression specific local variables (e.g. foreach loop variables). In any other cases, it works the same way as dereferencing an expression.

The result of the var() task can be used on the left hand side of an assignment expression.

Parameters

The following parameters are used by the task:

ParameterDescription
unnamedRequired name of the variable that is being accessed.

Task result

The reference to the variable.

Example

# the following is the same
$num = 3
var(num) = 3

foreach $item in [1, 2] {
	# accesses the item variable, not the loop variable
	var(item)
	# accesses the loop variable
	$item
}

build(in Input) {
	# accesses the Input parameter
	var(Input)
}