From dc56a543f3d0e122e183878e364462bbc95a1bb5 Mon Sep 17 00:00:00 2001 From: Erwan Gouriou Date: Thu, 18 Jan 2024 10:35:56 +0100 Subject: [PATCH] scripts: board_v1_to_v2: Add License + copyright When creating file Kconfig., get the copyright from old Kconfig.board file and use it in the new file. Add the License as well. Signed-off-by: Erwan Gouriou --- scripts/utils/board_v1_to_v2.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/scripts/utils/board_v1_to_v2.py b/scripts/utils/board_v1_to_v2.py index 23ce2ab5f1a..dc721e7dd07 100644 --- a/scripts/utils/board_v1_to_v2.py +++ b/scripts/utils/board_v1_to_v2.py @@ -156,19 +156,27 @@ def board_v1_to_v2(board_root, board, new_board, group, vendor, soc, variants): board_kconfig_defconfig_file.unlink() print(f"Creating or updating Kconfig.{new_board}...") + board_kconfig_file = new_board_path / "Kconfig.board" + with open(board_kconfig_file) as f: + for line in f.readlines(): + if "Copyright" in line: + copyright = line new_board_kconfig_file = new_board_path / f"Kconfig.{new_board}" - selects = "\n\t" + "\n\t".join(["select " + setting for setting in board_soc_settings]) + header = "# SPDX-License-Identifier: Apache-2.0\n" + if copyright is not None: + header = copyright + header + selects = "\n\t" + "\n\t".join(["select " + setting for setting in board_soc_settings]) + "\n" if not new_board_kconfig_file.exists(): with open(new_board_kconfig_file, "w") as f: f.write( - f"config BOARD_{new_board.upper()}{selects}" + header + + f"\nconfig BOARD_{new_board.upper()}{selects}" ) else: with open(new_board_kconfig_file, "a") as f: f.write(selects) print("Removing old Kconfig.board...") - board_kconfig_file = new_board_path / "Kconfig.board" board_kconfig_file.unlink() print("Conversion done!")