Prechádzať zdrojové kódy

[action] add the yml file support

Supper Thomas 9 mesiacov pred
rodič
commit
96165a5e99

+ 1 - 1
.github/workflows/bsp_buildings.yml

@@ -390,7 +390,7 @@ jobs:
     steps:
       - uses: actions/checkout@v4
       - name: Set up Python
-        uses: actions/setup-python@v3
+        uses: actions/setup-python@main
         with:
           python-version: 3.8
 

+ 36 - 0
bsp/nrf5x/nrf52840/.ci/attachconfig/ci.attachconfig.yml

@@ -0,0 +1,36 @@
+devices.gpio:
+    kconfig:
+      - CONFIG_BSP_USING_GPIO=y
+    scons_arg:
+      - '--strict'
+devices.adc:
+    kconfig:
+      - CONFIG_BSP_USING_SAADC=y
+devices.flash:
+    kconfig:
+      - CONFIG_BSP_USING_ON_CHIP_FLASH=y
+devices.i2c:
+    kconfig:
+      - CONFIG_BSP_USING_I2C=y
+devices.spi:    
+    kconfig:
+      - CONFIG_BSP_USING_SPI=y  
+devices.uart:   
+    kconfig:
+      - CONFIG_BSP_USING_UART=y
+devices.watchdog: 
+    kconfig:
+      - CONFIG_BSP_USING_WDT=y
+devices.qspi_flash:
+    kconfig:
+      - CONFIG_BSP_USING_QSPI_FLASH=y
+devices.pwm:
+    kconfig:
+      - CONFIG_BSP_USING_PWM=y
+devices.rtc:
+    kconfig:
+      - CONFIG_BSP_USING_ONCHIP_RTC=y
+devices.hwtimer:
+    kconfig:
+      - CONFIG_BSP_USING_TIM=y
+      - CONFIG_BSP_USING_TIM0=y

+ 0 - 1
bsp/nrf5x/nrf52840/.ci/attachconfig/devices/adc.attach

@@ -1 +0,0 @@
-CONFIG_BSP_USING_SAADC=y

+ 0 - 1
bsp/nrf5x/nrf52840/.ci/attachconfig/devices/flash.attach

@@ -1 +0,0 @@
-CONFIG_BSP_USING_ON_CHIP_FLASH=y

+ 0 - 1
bsp/nrf5x/nrf52840/.ci/attachconfig/devices/gpio.attach

@@ -1 +0,0 @@
-CONFIG_BSP_USING_GPIO=y

+ 0 - 2
bsp/nrf5x/nrf52840/.ci/attachconfig/devices/hwtimer.attach

@@ -1,2 +0,0 @@
-CONFIG_BSP_USING_TIM=y
-CONFIG_BSP_USING_TIM0=y

+ 0 - 1
bsp/nrf5x/nrf52840/.ci/attachconfig/devices/i2c.attach

@@ -1 +0,0 @@
-CONFIG_BSP_USING_I2C=y

+ 0 - 1
bsp/nrf5x/nrf52840/.ci/attachconfig/devices/pwm.attach

@@ -1 +0,0 @@
-CONFIG_BSP_USING_PWM=y

+ 0 - 1
bsp/nrf5x/nrf52840/.ci/attachconfig/devices/qspi_flash.attach

@@ -1 +0,0 @@
-CONFIG_BSP_USING_QSPI_FLASH=y

+ 0 - 1
bsp/nrf5x/nrf52840/.ci/attachconfig/devices/rtc.attach

@@ -1 +0,0 @@
-CONFIG_BSP_USING_ONCHIP_RTC=y

+ 0 - 1
bsp/nrf5x/nrf52840/.ci/attachconfig/devices/spi.attach

@@ -1 +0,0 @@
-CONFIG_BSP_USING_SPI=y

+ 0 - 1
bsp/nrf5x/nrf52840/.ci/attachconfig/devices/uart.attach

@@ -1 +0,0 @@
-CONFIG_BSP_USING_UART=y

+ 0 - 1
bsp/nrf5x/nrf52840/.ci/attachconfig/devices/wdt.attach

@@ -1 +0,0 @@
-CONFIG_BSP_USING_WDT=y

+ 41 - 4
tools/ci/bsp_buildings.py

@@ -2,7 +2,7 @@ import os
 import shutil
 import re
 import multiprocessing
-
+import yaml
 
 def add_summary(text):
     """
@@ -159,13 +159,50 @@ if __name__ == "__main__":
             add_summary(f'- ✅ build {bsp} success.')
         print("::endgroup::")
 
+        yml_files_content = []
+        directory = os.path.join(rtt_root, 'bsp', bsp, '.ci/attachconfig')
+        if os.path.exists(directory):
+            for filename in os.listdir(directory):
+                if filename.endswith('attachconfig.yml'):
+                    file_path = os.path.join(directory, filename)
+                    if os.path.exists(file_path):
+                        with open(file_path, 'r') as file:
+                            content = yaml.safe_load(file)
+                            yml_files_content.append(content)
+
+        config_file = os.path.join(rtt_root, 'bsp', bsp, '.config')
+
+        for projects in yml_files_content:
+            for name, details in projects.items():
+                count += 1
+                config_bacakup = config_file+'.origin'
+                shutil.copyfile(config_file, config_bacakup)
+                with open(config_file, 'a') as destination:
+                    for line in details.get('kconfig'):
+                        destination.write(line + '\n')
+                scons_arg = details.get('scons_arg')
+                scons_arg_str = scons_arg[0] if scons_arg else ' '
+                print(f"::group::\tCompiling yml project: =={count}==={name}=scons_arg={scons_arg_str}==")
+                res = build_bsp(bsp, scons_arg_str)
+                if not res:
+                    print(f"::error::build {bsp} {name} failed.")
+                    add_summary(f'\t- ❌ build {bsp} {name} failed.')
+                    failed += 1
+                else:
+                    add_summary(f'\t- ✅ build {bsp} {name} success.')
+                print("::endgroup::")
+
+                shutil.copyfile(config_bacakup, config_file)
+                os.remove(config_bacakup)
+
         attach_dir = os.path.join(rtt_root, 'bsp', bsp, '.ci/attachconfig')
         attach_list = []
         for root, dirs, files in os.walk(attach_dir):
             for file in files:
-                file_path = os.path.join(root, file)
-                relative_path = os.path.relpath(file_path, attach_dir)
-                attach_list.append(relative_path)
+                if file.endswith('attach'):
+                    file_path = os.path.join(root, file)
+                    relative_path = os.path.relpath(file_path, attach_dir)
+                    attach_list.append(relative_path)
 
         for attach_file in attach_list:
             count += 1

+ 2 - 0
tools/ci/requirements.txt

@@ -0,0 +1,2 @@
+pyyaml
+pandas