diff --git a/scripts/xtensa-build-zephyr.py b/scripts/xtensa-build-zephyr.py index 531cb58655a0..51bcba219a3d 100755 --- a/scripts/xtensa-build-zephyr.py +++ b/scripts/xtensa-build-zephyr.py @@ -25,6 +25,7 @@ import argparse import shlex +import shutil import subprocess import pathlib import errno @@ -1169,6 +1170,32 @@ def reproducible_checksum(platform, ri_file): chk256 = sof_ri_info.EraseVariables(ri_file, parsed_ri, west_top / repro_output) print('sha256sum {0}\n{1} {0}'.format(repro_output, chk256)) +def create_firmware_bundle(): + if shutil.which('tar') is None: + print("tar tool not found, not creating firmware tarball") + return + + # vendor directories (typically under /lib/firmware) to include + # in the tarball + vendor_dirs = [ 'intel'] + + build_top = pathlib.Path(west_top, 'build-sof-staging', 'sof') + # special case when build script is called for a single + # target only + if len(args.platforms) == 1: + tarball_name = f'sof-%s.tar.gz' % args.platforms[0] + else: + tarball_name = 'sof.tar.gz' + + if args.pristine: + tarball = build_top / tarball_name + tarball.unlink(missing_ok = True) + + for vendor_dir in vendor_dirs: + vendor_dir_path = build_top / vendor_dir + if not vendor_dir_path.exists(): + continue + execute_command(['tar', 'zc', '--exclude=sof.tar.gz', '-f', tarball_name, vendor_dir], cwd=build_top, sof_log_env=True) def main(): parse_args() @@ -1190,7 +1217,9 @@ def main(): build_rimage() build_platforms() + create_firmware_bundle() show_installed_files() + if __name__ == "__main__": main()