Skip to content

Commit 4ece1c2

Browse files
committed
building modules: using python scripts
Added function for CMake to build modules using python scripts Now using -l switch triggers CMakeLists for module passed after switch. f.e. xtensa-build-zephyr.py -u mtl -k ../keys/mtl_private_key.pem -l smart_amp_test We can build more then one module just by adding more module names. Signed-off-by: Dobrowolski, PawelX <pawelx.dobrowolski@intel.com>
1 parent 8cad5be commit 4ece1c2

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

scripts/xtensa-build-zephyr.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,13 @@ def __call__(self, parser, namespace, values, option_string=None):
162162
raise argparse.ArgumentError(self, f"Unsupported platform: {value}")
163163
setattr(namespace, "platforms", values)
164164

165+
166+
class stores_libraries_arguments(argparse.Action):
167+
"""Stores libraries arguments whether provided module name is supported."""
168+
def __call__(self, parser, namespace, values, option_string=None):
169+
setattr(namespace, "libraries", values)
170+
171+
165172
args = None
166173
def parse_args():
167174
global args
@@ -298,6 +305,10 @@ def parse_args():
298305
parser.add_argument("--version", required=False, action="store_true",
299306
help="Prints version of this script.")
300307

308+
parser.add_argument("-l", "--libraries", nargs="*", action=stores_libraries_arguments, default=[],
309+
help=""" Function for CMake building modules.
310+
We can build more then one module just by adding more module names.""")
311+
301312
args = parser.parse_args()
302313

303314
if args.all:
@@ -689,7 +700,31 @@ def rimage_options(platform_dict):
689700
return opts
690701

691702

703+
LMDK_BUILD_DIR = west_top / "sof" / "lmdk"
704+
705+
706+
def build_libraries():
707+
708+
library_dir = LMDK_BUILD_DIR / "libraries"
709+
# CMake build rimage module
710+
for lib in args.libraries:
711+
library_cmake = library_dir / lib / "CMakeLists.txt"
712+
if (library_cmake).is_file():
713+
print(f"\nBuilding loadable module: " + lib)
714+
lib_path = pathlib.Path(library_dir, lib, "build")
715+
rmtree_if_exists(lib_path)
716+
lib_path.mkdir(parents=True, exist_ok=True)
717+
rimage_bin = RIMAGE_BUILD_DIR / "rimage.exe"
718+
if not (rimage_bin).is_file():
719+
rimage_bin = RIMAGE_BUILD_DIR / "rimage"
720+
execute_command(["cmake", "-B", "build", "-G", "Ninja",
721+
"-DRIMAGE_COMMAND="+str(rimage_bin), "-DSIGNING_KEY="+str(PlatformConfig.RIMAGE_KEY)],
722+
cwd=library_dir/lib)
723+
execute_command(["cmake", "--build", "build", "-v"], cwd=library_dir/lib)
724+
692725
STAGING_DIR = None
726+
727+
693728
def build_platforms():
694729
global west_top, SOF_TOP
695730
print(f"SOF_TOP={SOF_TOP}")
@@ -1084,6 +1119,9 @@ def main():
10841119
build_rimage()
10851120
build_platforms()
10861121
show_installed_files()
1122+
if args.libraries:
1123+
build_libraries()
1124+
10871125

10881126
if __name__ == "__main__":
10891127
main()

0 commit comments

Comments
 (0)