Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for expressions in syscfg values #470

Draft
wants to merge 13 commits into
base: master
Choose a base branch
from

Commits on Mar 23, 2022

  1. Add support for expressions in syscfg values

    This adds support for evaluating syscfg values as expressions. To make
    it compatible with existing code, syscfg value is only evaluated as
    expression if its type is explicitly set to "expr", i.e.:
    
    syscfg.defs:
      FOO:
        description: ...
        type: expr
        value: 1 + 2 + 3
    
    Following tokens are allowed in expressions:
    - literals (integers and strings)
    - identifiers (references to other syscfg values)
    - parentheses
    - binary operators (arthmetic, relational and boolean)
    - unary operator (boolean negation)
    - built-in function calls
    
    Most of operators support only integer values. Strings are supported by
    "==" and "!=" only.
    
    Available built-in functions are:
    - min(a,b) - returns lesser of "a" and "b"
    - max(a,b) - returns greater of "a" and "b"
    - in_range(v,a,b) - returns if "v" is inside [a,b] range
    - clamp(v,a,b) - clamps "v" to be inside [a,b] range
    - ite(v,a,b) - if-then-else, returns "a" if "v", otherwise returns "b"
    - in_set(v,...) - returns if "v" is one of remaining arguments
    
    Note: all arguments to built-in functions shall be integer only, except
    for "a" and "b" in ite() and all arguments in in_set().
    andrzej-kaczmarek committed Mar 23, 2022
    Configuration menu
    Copy the full SHA
    19adfe6 View commit details
    Browse the repository at this point in the history

Commits on Mar 24, 2022

  1. Configuration menu
    Copy the full SHA
    181abdb View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    8d08985 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    e553f16 View commit details
    Browse the repository at this point in the history
  4. [expr] Evaluate all syscfg as expressions

    Except for defunc settings since those are not used anyway.
    andrzej-kaczmarek committed Mar 24, 2022
    Configuration menu
    Copy the full SHA
    d5ae4e7 View commit details
    Browse the repository at this point in the history
  5. [expr] Add fallback for MYNEWT_VAL_ prefix identifiers

    Some settings may reference values with MYNEWT_VAL_ prefix - this was
    done to actually evaluate them as expression in preprocessor.
    We can fix those and emit warning instead of failing.
    andrzej-kaczmarek committed Mar 24, 2022
    Configuration menu
    Copy the full SHA
    3205dd2 View commit details
    Browse the repository at this point in the history
  6. [expr] Add support for choices values

    If syscfg value is a choice, it's evaluated as an identifier so we need
    to add special handling in such case - if identifier is evaluated
    directly "from" entry, we should first check if value is a valid choice.
    andrzej-kaczmarek committed Mar 24, 2022
    Configuration menu
    Copy the full SHA
    02174f0 View commit details
    Browse the repository at this point in the history
  7. [expr] Add support for raw syscfg values

    This adds function "raw" that expects a single string argument and will
    return that argument contents as raw value, i.e. syscfg value will be
    exactly that string without quotes.
    andrzej-kaczmarek committed Mar 24, 2022
    Configuration menu
    Copy the full SHA
    b1367b6 View commit details
    Browse the repository at this point in the history
  8. Configuration menu
    Copy the full SHA
    2e457b9 View commit details
    Browse the repository at this point in the history
  9. [expr] Add support for empty string values

    This allows to differentiate empty strings (i.e. #define XXX "") and
    empty values (i.e. #undef XXX).
    andrzej-kaczmarek committed Mar 24, 2022
    Configuration menu
    Copy the full SHA
    9f920db View commit details
    Browse the repository at this point in the history
  10. Configuration menu
    Copy the full SHA
    a473a1a View commit details
    Browse the repository at this point in the history
  11. Configuration menu
    Copy the full SHA
    369dea1 View commit details
    Browse the repository at this point in the history

Commits on Mar 25, 2022

  1. [expr] rewrite evaluator to separate package

    this moves evaluator to separate package which interfaces with syscfg
    via interface. this removes direct dependency on syscfg package.
    andrzej-kaczmarek committed Mar 25, 2022
    Configuration menu
    Copy the full SHA
    7f1a65d View commit details
    Browse the repository at this point in the history