From d37bae0a0735582f3a2d7f7a2ca17ede5c7a79f8 Mon Sep 17 00:00:00 2001 From: "Dobrowolski, PawelX" Date: Thu, 14 Mar 2024 11:38:49 +0100 Subject: [PATCH] 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 --- lmdk/scripts/header_pack.py | 56 +++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 lmdk/scripts/header_pack.py diff --git a/lmdk/scripts/header_pack.py b/lmdk/scripts/header_pack.py new file mode 100644 index 000000000000..7c2a3b1bab8d --- /dev/null +++ b/lmdk/scripts/header_pack.py @@ -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() \ No newline at end of file