Dive into features for specialized use cases
As Eta evolves and your packages make use of newer features, you will the need to start worrying about backwards compatibility for your package.
Or maybe you just want to provide different flavors of your package that is built against different dependencies according to certain conditions.
To handle these and other user cases, Etlas provides conditional configuration which allows you to configure options when certain conditions hold.
The following built-in predicates, or conditions, are available:
Predicate | Argument Type | Description (Returns true if...) |
os | os | Current operating system matches the argument |
arch | arch | Current architecture matches the argument |
impl | prog-constraint | Program constraint in the argument holds with the build configuration |
flag | flag | Flag has been assigned via CLI or cabal.project configuration |
Each of the argument types is explained in detail below.
The operating system can be specified by the following values:
Example
if os(freebsd)
cpp-options: -DPLATFORM_FREEBSD
The architecture can be specified by the following values:
Example
if arch(x86_64)
cpp-options: -DENABLE_64BIT_OPTIMIZATIONS
A program constraint takes the form [compiler-name] [version-range] where [compiler-name] can be the name of the compiler you want to check against and [version-range] has been specified in the previous section. Note that [version-range] is optional and if not present, just checks whether [compiler-name] is configured for the build.
Example 1
if impl(eta > 0.7.2.1)
java-sources: java/eta-0.7.3/Utils.java
else
java-sources: java/eta-0.7.2/Utils.java
Example 2
if impl(eta)
cpp-options: -DCOMPILING_ETA
This predicate is used to check whether a package flag has been evaluated to true or not.
Example
if flag(developer)
cpp-options: -DDEVELOPMENT