-
Notifications
You must be signed in to change notification settings - Fork 321
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
building modules: using python scripts #8828
base: main
Are you sure you want to change the base?
building modules: using python scripts #8828
Conversation
ce03b31
to
34442a5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand how this can be useful but please don't embed this new, unrelated loop inside xtensa-build-zephyr.py
. Isn't a separate build one of the most important LMDK design choices?
Also, CMake's GLOB is generally not recommended but this case looks like a good exception and a reason to implement this with a top-level CMake instead of Python. Multiple ExternalProject_Add() will build all libraries in parallel: much faster.
You are right. I wasn't sure what community would be say about that. How about deployment - release build? It is being prepared by python I presume. Modules binaries and exported headers should be gathered in the same place as sof binary. Can it be integrated inside python scripts? |
Separate helper script is fine, I assume we may need to share logic from the baseFW script ? if so how ? |
From my perspective python script for building base_fw needs refactor. It is too long and it has to many functions so it might be a good excuse for clean up, add extra functions etc. |
34442a5
to
685edbd
Compare
Yes,
I won't name anyone but I even know people who refuse to use it (and then wonder why their firmware is sligthly different from everyone else's... I digress) However, all these ugly jobs have one very important thing in common: it's the list of everything that is required to build the "base firmware" - and it's very convenient to have all these in a single place. So there is a tiny bit of beautiful consistency! So let's draw a line and let's not overload that boat with things required by a new, separate and totally different and independent build. Divide and conquer - one ugly build at a time! https://mesonbuild.com/Design-rationale.html
Immediately contradicting myself a little bit: if there are some specific bits of Or maybe not because “a little copying is better than a little dependency” (Go proverb) |
I agree. There are a lot of useful things. I suggest to separate building rimage, deployment to new files, document what are they doing and import them to main script. It would take some time but it be easier to understand and use in future. |
685edbd
to
a97b580
Compare
a0cef35
to
a581aa5
Compare
scripts/lmdk/tools/cmake_build.py
Outdated
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" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.exe?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So let's draw a line and let's not overload that boat with things required by a new, separate and totally different and independent build.
a581aa5
to
a98ae2e
Compare
scripts/lmdk/tools/cmake_build.py
Outdated
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" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@softwarecki if .exe is not available use binary version.
@marc-hb I removed building from main script. |
ac9911c
to
56d59d7
Compare
82c2b61
to
b6da2cf
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pjdobrowolski what the plan to integrate lmdk builds into top level src/audio
for module that support lmdk ? Having this a separate stand alone directory is a bit confusing.
scripts/lmdk/tools/utils.py
Outdated
if env_change and run_kwargs.get('sof_log_env'): | ||
output += "\n... with extra/modified environment:\n" | ||
for k_v in env_change: | ||
output += f"{k_v[0]}={k_v[1]}\n" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ping. This serves a purpose where you copied it from but here the env_change
thing does nothing, doesn't it?
bbf1bf1
to
3e5ace5
Compare
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" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think that it works for programs out of PATH.
print(shutil.which("C:\\Users\\paweldox\\zephyrproject\\build-rimage\\rimage"))
None
Right, so using the path
argument works:
print(shutil.which("rimage", path="C:/Users/paweldox/zephyrproject/build-rimage/"))
=> 'C:/Users/paweldox/zephyrproject/build-rimage/rimage.EXE'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I've checked it on linux and windows to be sure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you missed my point. I tested the path
argument on Windows. You don't need is_file()
.
|
||
def execute_command(*run_args, **run_kwargs): | ||
"""[summary] Provides wrapper for subprocess.run that prints | ||
command executed when 'more verbose' verbosity level is set.""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You stripped down this function to the point where... it does not print the command executed, which was its entire purpose!?
But there are some bits left that don't do anything...
I don't know why you started by blindly copying huge parts of xtensa-build-zephyr.py instead of just the bits you need one by one. After way too many force-pushes there's extremely little code copied from xtensa-build-zephyr.py now. This has been been really difficult to make sense of and time consuming to review.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Look at comment to PR. I've started that script as a part of xtensa-build-zephyr.py . After your's suggestions I've separated parts I needed to external pythons scripts without changes from original spaghetti code.
It all started as simple function in xtensa-build-zephyr.py. I just followed suggestions from you and it looks as it looks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Process digressions aside: what does this execute_command()
function do now? It does not do what what the obsolete pydoc says it does. If it does nothing any more, why is it kept?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems almost ready to go, can you @pjdobrowolski check the last few comments in libraries_build.py script
3e5ace5
to
d00ff6e
Compare
@kv2019i it would be nice, because I would move to loadable up_down_mixer. |
@pjdobrowolski Can you check the CI fails? There seems to be a lot of failures, e.g. https://github.com/thesofproject/sof/actions/runs/8780400627/job/24090240938?pr=8828 |
7b206f9
to
fc8ccdf
Compare
Not all headers and functions are used in loadable modules that is why we need for smaller header packs reduce it to what is truly need. Signed-off-by: Dobrowolski, PawelX <[email protected]>
For independent libraries building was created manifest describing required headers. Signed-off-by: Dobrowolski, PawelX <[email protected]>
Libraries are build now: python lmdk/scripts/libraries_build.py -l <modules_names> we can build multiple modules by adding them one after another. Signed-off-by: Dobrowolski, PawelX <[email protected]>
To create zip headers pack we must run: python lmdk/scripts/headers_pack.py This way all headers declared in headers_manifest.json will be packed into zip file. Signed-off-by: Dobrowolski, PawelX <[email protected]>
As an example there is a need to show how to include headers Signed-off-by: Dobrowolski, PawelX <[email protected]>
To not stage header_pack.zip added new rule Signed-off-by: Dobrowolski, PawelX <[email protected]>
fc8ccdf
to
c2fcacb
Compare
Cleaned up. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR LGTM, but my big sticking point before v2.10 is to get the lmdk directory merged into existing modules, scripts, include directories so we are not duplicating and/or causing confusion. We are probably at the stage today where this is easy enough todo.
Ready to be merged once require CI is ok. @pjdobrowolski can you check the issue with quickbuild? |
Hang on, @pjdobrowolski and I have an update thats pending some internal discussion. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some weird things still present in the Python code.
|
||
def execute_command(*run_args, **run_kwargs): | ||
"""[summary] Provides wrapper for subprocess.run that prints | ||
command executed when 'more verbose' verbosity level is set.""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Process digressions aside: what does this execute_command()
function do now? It does not do what what the obsolete pydoc says it does. If it does nothing any more, why is it kept?
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" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you missed my point. I tested the path
argument on Windows. You don't need is_file()
.
/* | ||
* Definition used to extend structure definitions to include fields for exclusive use by SOF. | ||
* This is a temporary solution used until work on separating a common interface for loadable | ||
* modules is completed. | ||
*/ | ||
#define SOF_MODULE_API_PRIVATE | ||
#define SOF_MONOLITHIC_BUILD |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need to put this under #ifndef SOF_MONOLITHIC_BUILD
and it makes little sense that way - if it isn't defined, then we define it... From this commit I don't see any other places where this can be defined, so this doesn't seem to protect against redefinition.
Added function for CMake to build modules using python scriptsNow 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.
---------------------> update 08.02.2024 <--------------------------
I've separate building script from xtensa, I also create utils for generic functions used in that spaghetti script. More to come in next commits.
---------------------> update 14.02.2024 <--------------------------
To build modules using pythons were created several tools making
building easier.
For future deployment there is a tool extracting headers descibed in
manifest and creating zip file from them.
modules are build now:
python scripts/lmdk/libraries_build.py -l <modules_names> -k <key_directory>python lmdk/scripts/libraries_build.py -l <modules_names> -k <key_directory>
To create deployment pack of headers use
python scripts/lmdk/header_pack.pypython lmdk/scripts/header_pack.py
we can build multiple modules by adding them one after another.
---------------------> update 19.04.2024 <--------------------------
Scripts updated with removed env copy part from extensa building python scripts.
Scripts moved to lmdk directory to not create multiple locations for the same application.