xtensa-build-zephyr.py: add flexibility to generate `tools/` only

Installing most of the tools/ directory does not technically require
building any platform, so add that possibility.

This is useful because the Jenkins-based CI builds the (userspace) tools
separately. So far it has been picking hardcoded source paths but of
course the HWMv2 transition just broke that:
https://github.com/thesofproject/sof/pull/8913

While it's too late this time (we want to keep CI able to test stable
branches for some time), this commit prepares a future where all CIs can
stop hardcoding Zephyr source paths and pick the output of the
xtensa-build-zephyr.py installer and indirection layer instead.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
This commit is contained in:
Marc Herbert 2024-03-07 05:25:52 +00:00 committed by Kai Vehmanen
parent 06869cb20d
commit 665817fe84
1 changed files with 15 additions and 13 deletions

View File

@ -203,7 +203,7 @@ Supported platforms: {list(platform_configs)}"""
parser.add_argument("-a", "--all", required=False, action="store_true",
help="Build all currently supported platforms")
parser.add_argument("platforms", nargs="*", action=validate_platforms_arguments,
help="List of platforms to build")
help="List of platforms to build. Zero platform + any flag (-p) still creates 'tools/'")
parser.add_argument("-d", "--debug", required=False, action="store_true",
help="Shortcut for: -o sof/app/debug_overlay.conf")
# NO SOF release will ever user the option --fw-naming.
@ -727,6 +727,8 @@ def build_platforms():
# smex does not use 'install -D'
sof_output_dir = pathlib.Path(STAGING_DIR, "sof")
sof_output_dir.mkdir(parents=True, exist_ok=True)
platform_build_dir_name = None
for platform in args.platforms:
platf_build_environ = os.environ.copy()
@ -870,19 +872,20 @@ def build_platforms():
install_platform(platform, sof_platform_output_dir, platf_build_environ)
src_dest_list = []
# Install sof-logger
sof_logger_dir = pathlib.Path(west_top, platform_build_dir_name, "zephyr",
"sof-logger_ep", "build", "logger")
sof_logger_executable_to_copy = pathlib.Path(shutil.which("sof-logger", path=sof_logger_dir))
tools_output_dir = pathlib.Path(STAGING_DIR, "tools")
sof_logger_installed_file = pathlib.Path(tools_output_dir, sof_logger_executable_to_copy.name).resolve()
src_dest_list += [(sof_logger_executable_to_copy, sof_logger_installed_file)]
# Install sof-logger from the last platform built (requires building at least one platform).
if platform_build_dir_name:
sof_logger_dir = pathlib.Path(west_top, platform_build_dir_name, "zephyr",
"sof-logger_ep", "build", "logger")
sof_logger_executable_to_copy = pathlib.Path(shutil.which("sof-logger", path=sof_logger_dir))
sof_logger_installed_file = pathlib.Path(tools_output_dir, sof_logger_executable_to_copy.name).resolve()
src_dest_list += [(sof_logger_executable_to_copy, sof_logger_installed_file)]
src_dest_list += [(pathlib.Path(SOF_TOP) /
"tools" / "mtrace"/ "mtrace-reader.py",
tools_output_dir)]
tools_output_dir / "mtrace-reader.py")]
# Append future files to `src_dest_list` here (but prefer
# copying entire directories; more flexible)
@ -1109,10 +1112,9 @@ def main():
west_update()
create_zephyr_sof_symlink()
if args.platforms:
build_rimage()
build_platforms()
show_installed_files()
build_rimage()
build_platforms()
show_installed_files()
if __name__ == "__main__":
main()