diff options
author | Yuval Peress <peress@chromium.org> | 2021-02-05 13:22:12 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-02-05 22:59:02 +0000 |
commit | 689ff97247ec53f907fe72d6308baa909cdf0b18 (patch) | |
tree | b93b3653382940a169a252b0deb181464201f88e | |
parent | 8ee143bbaedceb238fd32870870d017d52a2576d (diff) | |
download | chrome-ec-689ff97247ec53f907fe72d6308baa909cdf0b18.tar.gz |
zephyr: zmake: Fix zmake default build directory resolution
The previous changes to the zmake build system made the
incorrect assumption that the build directory exists already
as such, running `zmake configure -B $build_dir` with a new
non-initialized director would fail since the
resolve_build_dir function would fail to recognize it as a
valid build directory.
The new logic also allows for passing directories which do
not yet exist.
BRANCH=none
BUG=none
TEST=pytest zephyr/zmake/tests/test_util.py
TEST=zmake configure -B /tmp/z/pos \
zephyr/projects/posix-ec/ \
&& zmake -l DEBUG build /tmp/z/pos
Signed-off-by: Yuval Peress <peress@chromium.org>
Change-Id: I754d4545f8d98cc65270b8d50f327cbb04ce3c87
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2678927
Tested-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
-rw-r--r-- | zephyr/zmake/tests/test_util.py | 13 | ||||
-rw-r--r-- | zephyr/zmake/zmake/util.py | 4 |
2 files changed, 2 insertions, 15 deletions
diff --git a/zephyr/zmake/tests/test_util.py b/zephyr/zmake/tests/test_util.py index 41197ce72a..4d6c64f1e5 100644 --- a/zephyr/zmake/tests/test_util.py +++ b/zephyr/zmake/tests/test_util.py @@ -19,8 +19,6 @@ relative_path = st.from_regex(regex=r"\A\w+[\w/]*\Z") def test_resolve_build_dir_with_build_dir(platform_ec_subdir, project_subdir, build_subdir): with tempfile.TemporaryDirectory() as temp_dir_name: platform_ec_dir = pathlib.Path(temp_dir_name) / platform_ec_subdir - (platform_ec_dir / build_subdir / 'project').mkdir(parents=True) - (platform_ec_dir / build_subdir / 'project' / 'zmake.yaml').touch() build_dir = util.resolve_build_dir( platform_ec_dir=platform_ec_dir, project_dir=platform_ec_dir / project_subdir, @@ -45,22 +43,11 @@ def test_resolve_build_dir_invalid_project(platform_ec_subdir, project_subdir): @hypothesis.given(relative_path, relative_path) def test_resolve_build_dir_from_project(platform_ec_subdir, project_subdir): - """Since the build dir is not a configured build directory but instead a - project directory, it should be ignored. - """ with tempfile.TemporaryDirectory() as temp_dir_name: platform_ec_dir = pathlib.Path(temp_dir_name) / platform_ec_subdir project_dir = platform_ec_dir / project_subdir project_dir.mkdir(parents=True) (project_dir / 'zmake.yaml').touch() - # Test when project_dir == build_dir. - build_dir = util.resolve_build_dir( - platform_ec_dir=platform_ec_dir, - project_dir=project_dir, - build_dir=project_dir) - assert build_dir == platform_ec_dir / 'build' / project_subdir - - # Test when build_dir is None (it should be ignored). build_dir = util.resolve_build_dir( platform_ec_dir=platform_ec_dir, project_dir=project_dir, diff --git a/zephyr/zmake/zmake/util.py b/zephyr/zmake/zmake/util.py index 50e42d655a..03bf580617 100644 --- a/zephyr/zmake/zmake/util.py +++ b/zephyr/zmake/zmake/util.py @@ -158,8 +158,8 @@ def resolve_build_dir(platform_ec_dir, project_dir, build_dir): Returns: The resolved build directory (using build_dir if not None). """ - if build_dir and pathlib.Path.exists( - build_dir / 'project' / 'zmake.yaml'): + if build_dir and (not pathlib.Path.exists(build_dir) or pathlib.Path.exists( + build_dir / 'project' / 'zmake.yaml')): return build_dir if not pathlib.Path.exists(project_dir / 'zmake.yaml'): |