1
1
mirror of https://github.com/tweag/nickel.git synced 2024-10-07 00:30:47 +03:00
nickel/examples/config-gcc
2021-07-05 17:27:54 +02:00
..
config-gcc.ncl unkown -> unknown 2021-07-05 17:27:54 +02:00
README.md Put each example in its own directory with a README 2021-04-28 18:37:11 +02:00

GCC Configuration

This is an example of writing contracts and generating a configuration for an invocation of the gcc compiler.

Run

$ nickel -f config-gcc.ncl export

Contracts

This example defines a couple contracts:

  • GccFlag: define valid flags that can be passed to gcc. It demonstrates a use-case where data can be specified in different format: here, a flag is either a simple string like "-Wextra" or a structured value {flag = "W", arg = "extra"}. The contract normalizes the value to a string, so that it appears as such in the output. This contract is illustrative and by no mean exhaustive.
  • Path: define a valid /-separated path as a string. In particular, the // sequence is forbidden.
  • SharedObjectFile: define a file whose extension is .so.
  • OptLevel: optimization level, either 0, 1 or 2.
  • Contract: the schema of the end configuration.

Playground

You can try to break any of the previous contracts to see what happens: provide a non supported flag, a pathLibC that doesn't end in ".so", and so on.