Skip to content

Commit

Permalink
building modules: using python scripts
Browse files Browse the repository at this point in the history
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.pem> -l smart_amp_test

We can build more then one module just by adding more module names.

Signed-off-by: Dobrowolski, PawelX <[email protected]>
  • Loading branch information
pjdobrowolski committed Feb 7, 2024
1 parent e04289d commit 685edbd
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions scripts/xtensa-build-zephyr.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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}")
Expand Down Expand Up @@ -1084,6 +1119,9 @@ def main():
build_rimage()
build_platforms()
show_installed_files()
if args.libraries:
build_libraries()


if __name__ == "__main__":
main()

0 comments on commit 685edbd

Please sign in to comment.