diff --git a/scripts/xtensa-build-zephyr.py b/scripts/xtensa-build-zephyr.py index 66e5d80d780f..11b87b9c28d8 100755 --- a/scripts/xtensa-build-zephyr.py +++ b/scripts/xtensa-build-zephyr.py @@ -162,6 +162,13 @@ def __call__(self, parser, namespace, values, option_string=None): raise argparse.ArgumentError(self, f"Unsupported platform: {value}") setattr(namespace, "platforms", values) + +class stores_libraries_arguments(argparse.Action): + """Stores libraries arguments whether provided module name is supported.""" + def __call__(self, parser, namespace, values, option_string=None): + setattr(namespace, "libraries", values) + + args = None def parse_args(): global args @@ -298,6 +305,10 @@ def parse_args(): parser.add_argument("--version", required=False, action="store_true", help="Prints version of this script.") + parser.add_argument("-l", "--libraries", nargs="*", action=stores_libraries_arguments, default=[], + help=""" Function for CMake building modules. + We can build more then one module just by adding more module names.""") + args = parser.parse_args() if args.all: @@ -689,7 +700,31 @@ def rimage_options(platform_dict): return opts +LMDK_BUILD_DIR = west_top / "sof" / "lmdk" + + +def build_libraries(): + + library_dir = LMDK_BUILD_DIR / "libraries" + # CMake build rimage module + for lib in args.libraries: + library_cmake = library_dir / lib / "CMakeLists.txt" + if (library_cmake).is_file(): + print(f"\nBuilding loadable module: " + lib) + lib_path = pathlib.Path(library_dir, lib, "build") + rmtree_if_exists(lib_path) + lib_path.mkdir(parents=True, exist_ok=True) + rimage_bin = RIMAGE_BUILD_DIR / "rimage.exe" + if not (rimage_bin).is_file(): + rimage_bin = RIMAGE_BUILD_DIR / "rimage" + execute_command(["cmake", "-B", "build", "-G", "Ninja", + "-DRIMAGE_COMMAND="+str(rimage_bin), "-DSIGNING_KEY="+str(PlatformConfig.RIMAGE_KEY)], + cwd=library_dir/lib) + execute_command(["cmake", "--build", "build", "-v"], cwd=library_dir/lib) + STAGING_DIR = None + + def build_platforms(): global west_top, SOF_TOP print(f"SOF_TOP={SOF_TOP}") @@ -1084,6 +1119,9 @@ def main(): build_rimage() build_platforms() show_installed_files() + if args.libraries: + build_libraries() + if __name__ == "__main__": main()