mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2026-08-23 02:08:48 +08:00
ToolsCI / Tools (push) Has been cancelled
RT-Thread BSP Static Build Check / 🔍 Summary of Git Diff Changes (push) Has been cancelled
pkgs_test / change (push) Has been cancelled
utest_auto_run / A9 :components/dfs.cfg (push) Has been cancelled
utest_auto_run / A9 :components/lwip.cfg (push) Has been cancelled
utest_auto_run / A9 :components/netdev.cfg (push) Has been cancelled
utest_auto_run / A9 :components/sal.cfg (push) Has been cancelled
utest_auto_run / A9 :cpp11/cpp11.cfg (push) Has been cancelled
utest_auto_run / AARCH64-rtsmart :default.cfg (push) Has been cancelled
utest_auto_run / A9-rtsmart :default.cfg (push) Has been cancelled
utest_auto_run / RISCV-rtsmart :default.cfg (push) Has been cancelled
utest_auto_run / XUANTIE-rtsmart :default.cfg (push) Has been cancelled
utest_auto_run / AARCH64 :default.cfg (push) Has been cancelled
utest_auto_run / AARCH64-smp :default.cfg (push) Has been cancelled
utest_auto_run / A9 :default.cfg (push) Has been cancelled
utest_auto_run / A9-smp :default.cfg (push) Has been cancelled
utest_auto_run / RISCV :default.cfg (push) Has been cancelled
utest_auto_run / RISCV-smp :default.cfg (push) Has been cancelled
utest_auto_run / A9 :kernel/atomic_c11.cfg (push) Has been cancelled
utest_auto_run / RISCV :kernel/atomic_c11.cfg (push) Has been cancelled
utest_auto_run / A9-rtsmart :kernel/ipc.cfg (push) Has been cancelled
utest_auto_run / RISCV-rtsmart :kernel/ipc.cfg (push) Has been cancelled
utest_auto_run / XUANTIE-rtsmart :kernel/ipc.cfg (push) Has been cancelled
utest_auto_run / A9 :kernel/ipc.cfg (push) Has been cancelled
utest_auto_run / A9-smp :kernel/ipc.cfg (push) Has been cancelled
utest_auto_run / RISCV :kernel/ipc.cfg (push) Has been cancelled
utest_auto_run / A9-rtsmart :kernel/kernel_basic.cfg (push) Has been cancelled
utest_auto_run / RISCV-rtsmart :kernel/kernel_basic.cfg (push) Has been cancelled
utest_auto_run / XUANTIE-rtsmart :kernel/kernel_basic.cfg (push) Has been cancelled
utest_auto_run / A9 :kernel/kernel_basic.cfg (push) Has been cancelled
utest_auto_run / A9-smp :kernel/kernel_basic.cfg (push) Has been cancelled
utest_auto_run / RISCV :kernel/kernel_basic.cfg (push) Has been cancelled
utest_auto_run / AARCH64-rtsmart :kernel/mem.cfg (push) Has been cancelled
utest_auto_run / A9-rtsmart :kernel/mem.cfg (push) Has been cancelled
utest_auto_run / RISCV-rtsmart :kernel/mem.cfg (push) Has been cancelled
utest_auto_run / XUANTIE-rtsmart :kernel/mem.cfg (push) Has been cancelled
utest_auto_run / AARCH64 :kernel/mem.cfg (push) Has been cancelled
utest_auto_run / AARCH64-smp :kernel/mem.cfg (push) Has been cancelled
utest_auto_run / A9 :kernel/mem.cfg (push) Has been cancelled
utest_auto_run / A9-smp :kernel/mem.cfg (push) Has been cancelled
utest_auto_run / RISCV :kernel/mem.cfg (push) Has been cancelled
utest_auto_run / RISCV-smp :kernel/mem.cfg (push) Has been cancelled
RT-Thread BSP Static Build Check / ${{ matrix.legs.RTT_BSP }} (push) Has been cancelled
RT-Thread BSP Static Build Check / collect-artifacts (push) Has been cancelled
122 lines
3.8 KiB
Python
122 lines
3.8 KiB
Python
#
|
|
# Copyright (c) 2006-2023, RT-Thread Development Team
|
|
#
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
#
|
|
# Change Logs:
|
|
# Date Author Notes
|
|
# 2023-06-27 dejavudwh the first version
|
|
#
|
|
|
|
import subprocess
|
|
import logging
|
|
import os
|
|
import sys
|
|
|
|
CONFIG_BSP_USING_X = ["CONFIG_BSP_USING_UART", "CONFIG_BSP_USING_I2C", "CONFIG_BSP_USING_SPI", "CONFIG_BSP_USING_ADC", "CONFIG_BSP_USING_DAC"]
|
|
|
|
def init_logger():
|
|
log_format = "[%(filename)s %(lineno)d %(levelname)s] %(message)s "
|
|
date_format = '%Y-%m-%d %H:%M:%S %a '
|
|
logging.basicConfig(level=logging.INFO,
|
|
format=log_format,
|
|
datefmt=date_format,
|
|
)
|
|
|
|
def diff():
|
|
result = subprocess.run(['git', 'diff', '--name-only', 'HEAD', 'origin/master', '--diff-filter=ACMR', '--no-renames', '--full-index'], stdout = subprocess.PIPE)
|
|
file_list = result.stdout.decode().strip().split('\n')
|
|
logging.info(file_list)
|
|
bsp_paths = set()
|
|
for file in file_list:
|
|
if "bsp/" in file:
|
|
logging.info("Modifed file: {}".format(file))
|
|
bsp_paths.add(file)
|
|
|
|
dirs = set()
|
|
for dir in bsp_paths:
|
|
dir = os.path.dirname(dir)
|
|
while "bsp/" in dir:
|
|
files = os.listdir(dir)
|
|
if ".config" in files and "rt-thread.elf" not in files and not dir.endswith("bsp"):
|
|
logging.info("Found bsp path: {}".format(dir))
|
|
dirs.add(dir)
|
|
break
|
|
new_dir = os.path.dirname(dir)
|
|
dir = new_dir
|
|
|
|
return dirs
|
|
|
|
def check_config_in_line(line):
|
|
for config in CONFIG_BSP_USING_X:
|
|
if config in line and '#' in line:
|
|
logging.info("Found in {}".format(line))
|
|
return config
|
|
|
|
return ""
|
|
|
|
def check_config_in_file(file_path):
|
|
configs = set()
|
|
found = False
|
|
try:
|
|
with open(file_path, 'r') as file:
|
|
for line in file:
|
|
line.strip()
|
|
if found:
|
|
res = check_config_in_line(line)
|
|
if res:
|
|
configs.add(res)
|
|
elif "On-chip Peripheral Drivers" in line:
|
|
logging.info("Found On-chip Peripheral Drivers")
|
|
found = True
|
|
except FileNotFoundError:
|
|
logging.error("The .config file does not exist for this BSP, please recheck the file directory!")
|
|
|
|
return configs
|
|
|
|
def modify_config(file_path, configs):
|
|
with open(file_path + "/rtconfig.h", 'a') as file:
|
|
for item in configs:
|
|
define1 = item.replace("CONFIG_BSP", "BSP")
|
|
define2 = item.replace("CONFIG_BSP", "RT")
|
|
file.write("#define " + define1 + "\n")
|
|
file.write("#define " + define2 + "\n")
|
|
|
|
def check_scons_build_files(dir):
|
|
missing = []
|
|
for filename in ["SConstruct", "SConscript"]:
|
|
if not os.path.isfile(os.path.join(dir, filename)):
|
|
missing.append(filename)
|
|
|
|
if missing:
|
|
logging.error("missing %s in %s", ", ".join(missing), dir)
|
|
return False
|
|
|
|
return True
|
|
|
|
def recompile_bsp(dir):
|
|
logging.info("recomplie bsp: {}".format(dir))
|
|
if not check_scons_build_files(dir):
|
|
return 1
|
|
|
|
result = subprocess.run(["scons", "-C", dir])
|
|
if result.returncode != 0:
|
|
logging.error("scons failed for %s", dir)
|
|
return result.returncode
|
|
|
|
if __name__ == '__main__':
|
|
init_logger()
|
|
recompile_bsp_dirs = diff()
|
|
failed = 0
|
|
for dir in recompile_bsp_dirs:
|
|
dot_config_path = dir + "/" + ".config"
|
|
configs = check_config_in_file(dot_config_path)
|
|
logging.info("add config:")
|
|
logging.info(configs)
|
|
logging.info("Add configurations and recompile!")
|
|
modify_config(dir, configs)
|
|
if recompile_bsp(dir) != 0:
|
|
failed += 1
|
|
|
|
sys.exit(failed)
|