forked from RT-Thread/rt-thread
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added CI to compile more drivers for the changed BSP
- Loading branch information
Showing
3 changed files
with
175 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,64 @@ | ||
name: BSP compilation with more drivers | ||
|
||
# Controls when the action will run. Triggers the workflow on push or pull request | ||
# events but only for the master branch | ||
on: | ||
# Runs at 16:00 UTC (BeiJing 00:00) on the 1st of every month | ||
schedule: | ||
- cron: '0 16 1 * *' | ||
push: | ||
branches: | ||
- master | ||
paths-ignore: | ||
- documentation/** | ||
- '**/README.md' | ||
- '**/README_zh.md' | ||
pull_request: | ||
branches: | ||
- master | ||
paths-ignore: | ||
- documentation/** | ||
- '**/README.md' | ||
- '**/README_zh.md' | ||
|
||
permissions: | ||
contents: read # to fetch code (actions/checkout) | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
name: BSP Compilation with More Drivers | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up Python | ||
uses: actions/setup-python@v3 | ||
with: | ||
python-version: 3.8 | ||
|
||
- name: Install Tools | ||
shell: bash | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get -qq install gcc-multilib libncurses5 libncurses5-dev libncursesw5-dev scons | ||
sudo python -m pip install --upgrade pip -qq | ||
git config --global http.postBuffer 524288000 | ||
git remote -v | ||
git fetch origin | ||
python -c "import tools.menuconfig; tools.menuconfig.touch_env()" | ||
- name: Install Arm ToolChains | ||
if: ${{ success() }} | ||
shell: bash | ||
run: | | ||
wget -q https://github.com/RT-Thread/toolchains-ci/releases/download/v1.3/gcc-arm-none-eabi-10-2020-q4-major-x86_64-linux.tar.bz2 | ||
sudo tar xjf gcc-arm-none-eabi-10-2020-q4-major-x86_64-linux.tar.bz2 -C /opt | ||
/opt/gcc-arm-none-eabi-10-2020-q4-major/bin/arm-none-eabi-gcc --version | ||
echo "RTT_EXEC_PATH=/opt/gcc-arm-none-eabi-10-2020-q4-major/bin" >> $GITHUB_ENV | ||
- name: Bsp Scons Compile | ||
if: ${{ success() }} | ||
shell: bash | ||
run: | | ||
source ~/.env/env.sh | ||
python tools/ci/compile_bsp_with_drivers.py |
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 |
---|---|---|
|
@@ -78,3 +78,8 @@ void SystemClock_Config(void) | |
HAL_RCCEx_EnableMSIPLLMode(); | ||
} | ||
|
||
|
||
|
||
|
||
|
||
|
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,106 @@ | ||
import subprocess | ||
import logging | ||
import os | ||
|
||
CONFIG_BSP_USING_X = ["CONFIG_BSP_USING_UART", "CONFIG_BSP_USING_I2C", "CONFIG_BSP_USING_SPI", "CONFIG_BSP_USING_PWM"] | ||
|
||
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 = [] | ||
for file in file_list: | ||
if "bsp/" in file: | ||
logging.info("Modifed file: {}".format(file)) | ||
bsp_paths.append(file) | ||
|
||
dirs = [] | ||
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.append(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, 'a') as file: | ||
for item in configs: | ||
file.write(item + "=y" '\n') | ||
|
||
def recompile_bsp(recompile_bsp_dirs): | ||
# dirs = [] | ||
# for dir in recompile_bsp_dirs: | ||
# 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.append(dir) | ||
# break | ||
# new_dir = os.path.dirname(dir) | ||
# dir = new_dir | ||
|
||
for dir in recompile_bsp_dirs: | ||
logging.info("recomplie bsp: {}".format(dir)) | ||
# result = subprocess.run(['scons', '-C', dir + "\\"], stdout = subprocess.PIPE) | ||
# rtt_root = os.environ["RTT_ROOT"] | ||
# os.system("pwd") | ||
# os.system("ls") | ||
# os.system("cd bsp") | ||
os.system("scons --useconfig=USECONFIG") | ||
os.system("scons -C " + dir) | ||
# logging.info(result.stdout.decode()) | ||
|
||
if __name__ == '__main__': | ||
init_logger() | ||
recompile_bsp_dirs = diff() | ||
# recompile_bsp_dirs = ["D:/Workspace/OpenSource/rt-thread/bsp/stm32/stm32l496-st-nucleo/rt-config.h"] | ||
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(dot_config_path, configs) | ||
recompile_bsp(recompile_bsp_dirs) |