-
Notifications
You must be signed in to change notification settings - Fork 1
Configuration Options
Autoproj supports adding user decision in the installation process of a software system. They can be used to local customization of the installation on a users PC. For example they can be used to let the user decide whether he requires a certain feature or not, or which particular implementation of a selection of possible choices for a technology he wants to use.
During the processing of aup
or autoproj update
, the user will be prompted to select a value for Configuration Options, for which no choice has been made so far.
To change assignments of Configuration Options, run the following command autoproj reconfigure
.
The user promt will look like shown on this screenshot:
The place for defining Configuration Options are the init.rb
or .autobuild
files of a Package Set. Here's an example.
Definition of a Configuration Option
The following snipped defines a string
Configuration Option with a set of allowed values:
# In file libs.autobuild of a package set
# An example using an String option
Autoproj.configuration_option('MY_USER_OPTION', 'string',
:default => 'first_option',
:possible_values => ['first_option', 'another_option', 'third_option'],
:doc => [
"Choose your option wisely ?",
"Above text is the question which will be asked to t user during configuring your installation.", "Explain more elaborately what this option means", "you can split your text in multiple lines", "by splitting the text into separate strings per line."])
The following snipped defines a boolean
Configuration Option:
# In file libs.autobuild of a package set
# An example using a bool option
Autoproj.configuration_option "ENABLE_FEATURE_A", "boolean",
:doc => ["Enable feature A ?",
"Feature is very good. It's the best feature!",
"You should really consider enabling it."],
:default => 'yes'
Evaluating the selection
In this example the user choice of a Configuration Option is evaluated to customize the compilation of a software package.
# In file libs.autobuild of a package set
cmake_package 'some_package' do |pkg|
if Autoproj.config.get("ENABLE_FEATURE_A")
pkg.define("SOME_COMPILER_OPTION", "On")
pkg.depends_on('some_additional_package')
Autoproj.info "Building 'some_package' with FEATURE_A!"
else
Autoproj.info "Building 'some_package' without FEATURE_A!"
end
end
This example defines a package only if a special feature is enabled:
if Autoproj.config.get("ENABLE_FEATURE_A")
cmake_package 'some_package'
end