Skip to content

Commit 8aa6d38

Browse files
committed
lmdk: deployment script for exported headers
To create zip headers pack we must run: python scripts/lmdk/headers_pack.py This way all headers declared in headers_manifest.json will be packed into zip file. Signed-off-by: Dobrowolski, PawelX <pawelx.dobrowolski@intel.com>
1 parent 236d46c commit 8aa6d38

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed

scripts/lmdk/header_pack.py

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#!/usr/bin/env python3
2+
# SPDX-License-Identifier: BSD-3-Clause
3+
4+
5+
import json
6+
import pathlib
7+
import shutil
8+
9+
10+
"""Headers for needs of lmdk are defined in
11+
lmdk/include/headers_list.json"""
12+
13+
14+
_SOF_TOP = pathlib.Path(__file__).parents[2].resolve()
15+
LMDK_HEADERS = _SOF_TOP / "lmdk" / "include" / "headers_manifest.json"
16+
17+
18+
def str_path_from_json(record):
19+
"""parsing json record to string"""
20+
src = ''
21+
for i in record:
22+
src += i
23+
src += "/"
24+
return src[:-1]
25+
26+
27+
def create_separate_headers():
28+
f = open(LMDK_HEADERS)
29+
data = json.load(f)
30+
31+
for i in data:
32+
src = str_path_from_json(i)
33+
p = pathlib.Path(_SOF_TOP, "lmdk", "include", "sof", src)
34+
p.parent.mkdir(parents=True, exist_ok=True)
35+
shutil.copyfile(_SOF_TOP / src, _SOF_TOP / "lmdk" /"include" / "sof" / src)
36+
f.close()
37+
38+
""" -> to do
39+
def validate_separate_headers():
40+
return 0"""
41+
42+
43+
def create_headers_pack():
44+
"""Creates pack of lmdk headers"""
45+
create_separate_headers()
46+
shutil.make_archive(_SOF_TOP / "lmdk" /"include" / "header_pack", "zip", _SOF_TOP / "lmdk" /"include" / "sof")
47+
shutil.rmtree(_SOF_TOP / "lmdk" /"include" / "sof", ignore_errors=True)
48+
return 0
49+
50+
51+
def main():
52+
create_headers_pack()
53+
54+
55+
if __name__ == "__main__":
56+
main()

0 commit comments

Comments
 (0)