-
Notifications
You must be signed in to change notification settings - Fork 321
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
lmdk: deployment script for exported headers
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]>
- Loading branch information
1 parent
8123ab9
commit d37bae0
Showing
1 changed file
with
56 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#!/usr/bin/env python3 | ||
# SPDX-License-Identifier: BSD-3-Clause | ||
|
||
|
||
import json | ||
import pathlib | ||
import shutil | ||
|
||
|
||
"""Headers for needs of lmdk are defined in | ||
lmdk/include/headers_list.json""" | ||
|
||
|
||
_SOF_TOP = pathlib.Path(__file__).parents[2].resolve() | ||
LMDK_HEADERS = _SOF_TOP / "lmdk" / "include" / "headers_manifest.json" | ||
|
||
|
||
def str_path_from_json(record): | ||
"""parsing json record to string""" | ||
src = '' | ||
for i in record: | ||
src += i | ||
src += "/" | ||
return src[:-1] | ||
|
||
|
||
def create_separate_headers(): | ||
f = open(LMDK_HEADERS) | ||
data = json.load(f) | ||
|
||
for i in data: | ||
src = str_path_from_json(i) | ||
p = pathlib.Path(_SOF_TOP, "lmdk", "include", "sof", src) | ||
p.parent.mkdir(parents=True, exist_ok=True) | ||
shutil.copyfile(_SOF_TOP / src, _SOF_TOP / "lmdk" /"include" / "sof" / src) | ||
f.close() | ||
|
||
""" -> to do | ||
def validate_separate_headers(): | ||
return 0""" | ||
|
||
|
||
def create_headers_pack(): | ||
"""Creates pack of lmdk headers""" | ||
create_separate_headers() | ||
shutil.make_archive(_SOF_TOP / "lmdk" /"include" / "header_pack", "zip", _SOF_TOP / "lmdk" /"include" / "sof") | ||
shutil.rmtree(_SOF_TOP / "lmdk" /"include" / "sof", ignore_errors=True) | ||
return 0 | ||
|
||
|
||
def main(): | ||
create_headers_pack() | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |