Skip to content

Clean way to import a west.yml's west commands but no submodule #903

@johnhatten2

Description

@johnhatten2

Context

I have a zephyr module containing drivers and unit tests. This module is normally used by some main application, but here, I need a pipeline (native_sim) to run my unit tests. The only thing west needs to import is Zephyr, along with its west commands. I don't want any of Zephyr's own submodules.

Documentation and experimentation reveals that a module's commands define in its west.yml MUST be imported via the import: key in the parent project's west.yml

Describe the bug

The bug is not being able to import a submodule west commands, while NOT importing the submodule's own submodules, in a clean way.

I found 2 workarounds and 2 fix proposals.

Workaround 1

This is what I'm currently using. We trick west by passing a non-existent projet in the name-allowlist.
Note : The string passed here could be literally anything, so writing "None" looks clean but it feels hacky.

projects:
  - name: zephyr
    revision: master
    import:
      name-allowlist:
        - None # Hack

Workaround 2

We could simply block all project manually, but this isn't clean either

projects:
  - name: zephyr
    revision: master
    import:
      name-blocklist:
        - acpica
        - babblesim
        - and
        - everything
        - else

Fix 1

I propose we allow name-allowlist to accept an empty list. Looks like the cleanest and most straightforward solution to me

projects:
  - name: zephyr
    revision: master
    import:
      name-allowlist: []

Fix 2

Maybe we should manage command import separately from project imports, or add a new import flag. There are a couple ways of doing this, I'll let you guys take care of that, but here's an example

projects:
  - name: zephyr
    revision: master
    import-commands: true # Could also be an allowlist

Repro steps

  • Clone Zephyr's example application
    git clone https://github.com/zephyrproject-rtos/example-application.git && cd example-application
  • Remove the project imports in west.yml (cmsis, hal_nordic, hal_stm32)
  • Init the workspace
    west init --local --mf west.yml && west update (should pull only Zephyr)
  • Modify the example application to make it compatible with native_sim (a simple hello_world should do it)
  • Upon issue resolution, we should be able to run :
    west build -p -b native_sim app -t run

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions