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

manifest: Do not allow projects inside the west directory #754

Merged
merged 3 commits into from
Oct 21, 2024

Conversation

pdgendt
Copy link
Collaborator

@pdgendt pdgendt commented Oct 14, 2024

It's not allowed to have projects inside the .west directory, add a check when parsing the manifest.

Fixes #102

@pdgendt pdgendt added this to the v1.3.0 milestone Oct 14, 2024
@pdgendt pdgendt force-pushed the west-projects-check branch from b87f24c to 714dfad Compare October 14, 2024 12:00
Copy link
Collaborator

@marc-hb marc-hb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small change requested, everything else looks great! Thanks for the cleanup.

src/west/manifest.py Outdated Show resolved Hide resolved
@pdgendt pdgendt force-pushed the west-projects-check branch from 714dfad to 59665f3 Compare October 15, 2024 06:35
Copy link
Collaborator

@tejlmand tejlmand left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for fixing.

Changes looks good, but I wonder if we should unify to use west_dir() instead of west_dir() in some places and topdir / WEST_DIR concatenation at other places.

Thoughts ?

@@ -43,7 +43,7 @@
from typing import Any, Dict, Iterable, List, Optional, Tuple, TYPE_CHECKING
import warnings

from west.util import west_dir, WestNotFound, PathType
from west.util import WEST_DIR, west_dir, WestNotFound, PathType
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not wrong, but looks a bit strange to import both WEST_DIR and west_dir.
Same name, just different casing.

Easy to confuse readers.

Why not just use west_dir(), when we anyway import it, instead of doing path concatenation.
(see other comment).

@@ -616,7 +616,7 @@ def _location(cfg: ConfigFile, topdir: Optional[PathType] = None,
return env['WEST_CONFIG_LOCAL']

if topdir:
return os.fspath(Path(topdir) / '.west' / 'config')
return os.fspath(Path(topdir) / WEST_DIR / 'config')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

west_dir() supports a dir argument, and if that dir is having the .west then the logic returns immediately.

This means we can have a uniform way to always fetch west_dir() and thus keep the knowledge of how .west is placed under topdir at a single location (west.util).

Doing so will also remove the need of import WEST_DIR.

Suggested change
return os.fspath(Path(topdir) / WEST_DIR / 'config')
return os.fspath(Path(west_dir(topdir)) / 'config')

Ref:

west/src/west/util.py

Lines 71 to 73 in c3aadf5

while True:
if (cur_dir / '.west').is_dir():
return os.fspath(cur_dir)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, applied your suggestion here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had to revert here, it's possible that the path does not exist yet. So it would require more changes.

I'll create a follow-up PR for v1.4 or v2.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had to revert here, it's possible that the path does not exist yet. So it would require more changes.

As usual, initialization/"bootstrapping" is at the top of complex situations. Always underestimated :-)

@pdgendt pdgendt force-pushed the west-projects-check branch from 59665f3 to 7c040cb Compare October 21, 2024 11:24
Use the literal constant WEST_DIR instead of using the same string
value scattered around the project.

Signed-off-by: Pieter De Gendt <[email protected]>
It's not allowed to have projects inside the .west directory,
add a check when parsing the manifest.

Signed-off-by: Pieter De Gendt <[email protected]>
Add tests for cases where projects are inside the .west directory.

Signed-off-by: Pieter De Gendt <[email protected]>
@pdgendt pdgendt force-pushed the west-projects-check branch from 7c040cb to d57283e Compare October 21, 2024 11:31
@pdgendt pdgendt merged commit d36e887 into zephyrproject-rtos:main Oct 21, 2024
16 checks passed
@pdgendt pdgendt deleted the west-projects-check branch October 21, 2024 11:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Projects in the west directory are not forbidden
3 participants