ADVRHumanoids / forest

Minimal python-based clone & build tool with dependencies
MIT License
6 stars 0 forks source link

Conditional cmake args #8

Open alaurenzi opened 3 years ago

alaurenzi commented 3 years ago

Latest devel now supports (maybe) conditional cmake args.

The first draft is very simple. Given a recipe such as

clone:
  type: git
  server: github.com
  repository: advrhumanoids/xbot2_examples.git
  tag: fi_gripper_btns

build:
  type: cmake
  args_if:  # <- note this
    xeno: -DXBOT2_ENABLE_XENO=ON

depends:
  - xbot2
  - cartesian_interface

The cmake arg -DXBOT2_ENABLE_XENO=ON is added if calling forest as follows: forest xbot2_examples -m xeno. More than one "mode" can be specified at command line.

@MarcoRuzzon what do you think? Can we test it on your use case scenario? Can you think of a better / more flexible way to do this?

alaurenzi commented 3 years ago

Evaluated conditions (New in d7a2eee807d0e9ff01f93c7a766b7c6c39433b21 !) For more complex use cases, the user might need to set different flags depending on more complex conditions. The first attempt at addressing this is the following:

build:
  args_if:
    "<python_statement_returning_bool>": -DMY_FLAG=VALUE
    "ubuntu_release == 18.04": -DMY_FLAG=VALUE  # example

The python statement can include any python's builtins (e.g., the == in the example), plus a list of supported attributes that we, as developers, enable my appropriate modification of the forest.common.eval_handler.Locals class. Right now, we only have ubuntu_release, but I'd expect to include at least

alaurenzi commented 3 years ago

The user needs to know which local attributes are supported. Output after 0db7577adaed611150972a709ff4b4a5bb9a2f60

arturo@arturo-iit-desktop ~ $ forest --list-eval-locals 
name                 type
----                 ----
ubuntu_release       float
shell                function(cmd:str) -> str
env                  function(key:str) -> str