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

Conditional cmake args #8

Open
alaurenzi opened this issue Jul 16, 2021 · 2 comments
Open

Conditional cmake args #8

alaurenzi opened this issue Jul 16, 2021 · 2 comments
Assignees
Labels
enhancement New feature or request [zube]: Backlog

Comments

@alaurenzi
Copy link
Contributor

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
Copy link
Contributor Author

Evaluated conditions (New in d7a2eee !)
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

  • env() -> method to retrieve environment variables
  • shell() -> method to invoke the shell
  • others.. @MarcoRuzzon ?

@alaurenzi
Copy link
Contributor Author

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

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request [zube]: Backlog
Projects
None yet
Development

No branches or pull requests

3 participants