From 3d9612f95c024db63050db502b43aea9d7c3cbe5 Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Tue, 29 May 2018 15:11:52 +0700 Subject: [PATCH] Add enabled_if to aliases/tests This field controls whether the alias/test will be run or not. Boolean expressions are defined using the Blang.t type. This type represents simple boolean expressions that become useful when we allow to interpolate variables into them. Signed-off-by: Rudi Grinberg --- doc/dune-files.rst | 34 ++++++++++++++++++++ src/blang.ml | 45 ++++++++++++++++++++++++++ src/blang.mli | 25 +++++++++++++++ src/gen_rules.ml | 1 + src/jbuild.ml | 73 ++++++++++++++++++++++++++++++++++--------- src/jbuild.mli | 10 +++--- src/simple_rules.ml | 69 +++++++++++++++++++++++----------------- src/stdune/bool.ml | 10 ++++++ src/stdune/bool.mli | 5 +++ src/stdune/sexp.ml | 1 - src/stdune/stdune.ml | 1 + src/super_context.mli | 8 +++++ src/value.ml | 23 +++++++++++++- src/value.mli | 12 +++++++ 14 files changed, 269 insertions(+), 48 deletions(-) create mode 100644 src/blang.ml create mode 100644 src/blang.mli create mode 100644 src/stdune/bool.ml create mode 100644 src/stdune/bool.mli diff --git a/doc/dune-files.rst b/doc/dune-files.rst index 5cdfe664..9ed1feb4 100644 --- a/doc/dune-files.rst +++ b/doc/dune-files.rst @@ -569,6 +569,10 @@ The syntax is as follows: - ``(locks ())`` specify that the action must be run while holding the following locks. See the `Locks`_ section for more details. +- ``(enabled_if )`` specifies the boolean condition that must + be true for the tests to run. The condition is specified using the blang_, and + the field allows for variables_ to appear in the expressions. + The typical use of the ``alias`` stanza is to define tests: .. code:: scheme @@ -824,6 +828,36 @@ doesn't start by `-`, you can simply quote it: ``("x" y z)``. Most fields using the ordered set language also support `Variables expansion`_. Variables are expanded after the set language is interpreted. +.. _blang: + +Boolean Language +---------------- + +The boolean language allows the user to define simple boolean expressions that +dune can evaluate. Here's a semi formal specification of the language: + +.. code:: + + op := '=' | '<' | '>' | '<>' | '>=' | '<=' + + expr := (and +) + | (or +) + | (