From 7531bba2131a849de78f30af90ea3e6f229d5ad6 Mon Sep 17 00:00:00 2001 From: kaidegit <2857693944@qq.com> Date: Mon, 17 Feb 2025 19:20:56 +0800 Subject: [PATCH 01/18] ci: add cmake&ninja to speed up github action build --- .github/workflows/bsp_buildings.yml | 30 +++++++++++++- tools/ci/bsp_buildings.py | 61 ++++++++++++++++++++++++++++- 2 files changed, 89 insertions(+), 2 deletions(-) diff --git a/.github/workflows/bsp_buildings.yml b/.github/workflows/bsp_buildings.yml index 7726bbebca9..a255f56bdae 100644 --- a/.github/workflows/bsp_buildings.yml +++ b/.github/workflows/bsp_buildings.yml @@ -39,18 +39,22 @@ jobs: legs: - RTT_BSP: "RT-Thread Online Packages (STM32F407 RT-Spark)" RTT_TOOL_CHAIN: "sourcery-arm" + RTT_BUILD_TOOL: "scons" SUB_RTT_BSP: - "stm32/stm32f407-rt-spark" - RTT_BSP: "RTduino/Arduino Libraries (STM32F412 Nucleo)" RTT_TOOL_CHAIN: "sourcery-arm" + RTT_BUILD_TOOL: "scons" SUB_RTT_BSP: - "stm32/stm32f412-st-nucleo" - RTT_BSP: "RTduino/Arduino Libraries (Raspberry Pico)" RTT_TOOL_CHAIN: "sourcery-arm" + RTT_BUILD_TOOL: "scons" SUB_RTT_BSP: - "raspberry-pico" - RTT_BSP: "others_at32_hc32_ht32" RTT_TOOL_CHAIN: "sourcery-arm" + RTT_BUILD_TOOL: "scons" SUB_RTT_BSP: - "qemu-vexpress-a9" - "airm2m/air32f103" @@ -109,8 +113,9 @@ jobs: - "hc32l136" - "yichip/yc3121-pos" - "fm33lc026" - - RTT_BSP: "stm32l4_f0_f1" + - RTT_BSP: "stm32l4_f0_f1(cmake)" RTT_TOOL_CHAIN: "sourcery-arm" + RTT_BUILD_TOOL: "cmake" SUB_RTT_BSP: - "stm32/stm32l4r5-st-nucleo" - "stm32/stm32l4r9-st-eval" @@ -148,6 +153,7 @@ jobs: - "stm32/stm32f107-uc-eval" - RTT_BSP: "stm32_f2_f4" RTT_TOOL_CHAIN: "sourcery-arm" + RTT_BUILD_TOOL: "scons" SUB_RTT_BSP: - "stm32/stm32f207-st-nucleo" - "stm32/stm32f302-st-nucleo" @@ -175,6 +181,7 @@ jobs: - "stm32/stm32f469-st-disco" - RTT_BSP: "stm32_f7_g0_h7_mp15_u5_h5_wb5" RTT_TOOL_CHAIN: "sourcery-arm" + RTT_BUILD_TOOL: "scons" SUB_RTT_BSP: - "stm32/stm32f746-st-disco" - "stm32/stm32f746-st-nucleo" @@ -208,6 +215,7 @@ jobs: - "stm32/stm32wb55-st-nucleo" - RTT_BSP: "nxp_renesas" RTT_TOOL_CHAIN: "sourcery-arm" + RTT_BUILD_TOOL: "scons" SUB_RTT_BSP: - "nxp/lpc/lpc55sxx/lpc55s69_nxp_evk" - "nxp/lpc/lpc55sxx/lpc55s28_nxp_evk" @@ -252,6 +260,7 @@ jobs: - "xplorer4330/M4" - RTT_BSP: "nuvoton" RTT_TOOL_CHAIN: "sourcery-arm" + RTT_BUILD_TOOL: "scons" SUB_RTT_BSP: - "nuvoton/numaker-pfm-m487" - "nuvoton/numaker-hmi-ma35d1" @@ -267,6 +276,7 @@ jobs: - "nuvoton/numaker-m2354" - RTT_BSP: "gd32_n32_apm32" RTT_TOOL_CHAIN: "sourcery-arm" + RTT_BUILD_TOOL: "scons" SUB_RTT_BSP: - "gd32/arm/gd32103c-eval" - "gd32/arm/gd32105c-eval" @@ -310,6 +320,7 @@ jobs: - "apm32/apm32s103vb-miniboard" - RTT_BSP: "Infineon_TI_microchip" RTT_TOOL_CHAIN: "sourcery-arm" + RTT_BUILD_TOOL: "scons" SUB_RTT_BSP: - "Infineon/psoc6-cy8ckit-062S2-43012" - "Infineon/psoc6-cy8ckit-062-BLE" @@ -337,12 +348,14 @@ jobs: - "maxim/max32660-evsys" - RTT_BSP: "mips" RTT_TOOL_CHAIN: "sourcery-mips" + RTT_BUILD_TOOL: "scons" SUB_RTT_BSP: - "loongson/ls1bdev" - "loongson/ls2kdev" - "loongson/ls1cdev" - RTT_BSP: "aarch64" RTT_TOOL_CHAIN: "sourcery-aarch64" + RTT_BUILD_TOOL: "scons" SUB_RTT_BSP: - "qemu-virt64-aarch64" - "raspberry-pi/raspi3-64" @@ -351,17 +364,20 @@ jobs: - "phytium/aarch64" - RTT_BSP: "riscv-none" RTT_TOOL_CHAIN: "sourcery-riscv-none-embed" + RTT_BUILD_TOOL: "scons" SUB_RTT_BSP: - "k210" - "wch/risc-v/ch32v307v-r1" - RTT_BSP: "riscv64-unknown" RTT_TOOL_CHAIN: "sourcery-riscv64-unknown-elf" + RTT_BUILD_TOOL: "scons" SUB_RTT_BSP: - "bluetrum/ab32vg1-ab-prougen" - "bouffalo_lab/bl60x" - "bouffalo_lab/bl70x" - RTT_BSP: "hpmicro" RTT_TOOL_CHAIN: "RISC-V-GCC-RV32" + RTT_BUILD_TOOL: "scons" SUB_RTT_BSP: - "hpmicro/hpm6750evkmini" - "hpmicro/hpm6750evk" @@ -374,22 +390,27 @@ jobs: - "hpmicro/hpm6e00evk" - RTT_BSP: "llvm-arm" RTT_TOOL_CHAIN: "llvm-arm" + RTT_BUILD_TOOL: "scons" SUB_RTT_BSP: - "stm32/stm32l475-atk-pandora" - RTT_BSP: "simulator" RTT_TOOL_CHAIN: "gcc" + RTT_BUILD_TOOL: "scons" SUB_RTT_BSP: - "simulator" - RTT_BSP: "ESP32C3" RTT_TOOL_CHAIN: "sourcery-riscv32-esp32" + RTT_BUILD_TOOL: "scons" SUB_RTT_BSP: - "ESP32_C3" - RTT_BSP: "i386-unknown" RTT_TOOL_CHAIN: "sourcery-i386-unknown-elf" + RTT_BUILD_TOOL: "scons" SUB_RTT_BSP: - "x86" - RTT_BSP: "nordic(yml)" RTT_TOOL_CHAIN: "sourcery-arm" + RTT_BUILD_TOOL: "scons" SUB_RTT_BSP: - "nrf5x/nrf51822" - "nrf5x/nrf52832" @@ -414,6 +435,12 @@ jobs: echo "RTT_ROOT=${{ github.workspace }}" >> $GITHUB_ENV echo "RTT_CC=gcc" >> $GITHUB_ENV echo "export PATH=~/.env/tools/scripts:$PATH" > ~/.env/env.sh + + - name: Install Cmake & Ninja + uses: lukka/get-cmake@latest + with: + cmakeVersion: latestrc + ninjaVersion: latest - name: Install Arm ToolChains if: ${{ matrix.legs.RTT_TOOL_CHAIN == 'sourcery-arm' && success() }} @@ -505,6 +532,7 @@ jobs: env: RTT_BSP: ${{ matrix.legs.RTT_BSP }} RTT_TOOL_CHAIN: ${{ matrix.legs.RTT_TOOL_CHAIN }} + RTT_BUILD_TOOL: ${{ matrix.legs.RTT_BUILD_TOOL }} SRTT_BSP: ${{ join(matrix.legs.SUB_RTT_BSP, ',') }} run: | source ~/.env/env.sh diff --git a/tools/ci/bsp_buildings.py b/tools/ci/bsp_buildings.py index f170dbe8fad..23b9fb8de8d 100644 --- a/tools/ci/bsp_buildings.py +++ b/tools/ci/bsp_buildings.py @@ -81,6 +81,58 @@ def build_bsp(bsp, scons_args=''): return success +def build_bsp_cmake(bsp, scons_args=''): + """ + build bsp using cmake generater. + + cd {rtt_root} + scons -C bsp/{bsp} --pyconfig-silent > /dev/null + + cd {rtt_root}/bsp/{bsp} + pkgs --update > /dev/null + pkgs --list + + scons --target=cmake + mkdir build + cd build + cmake .. -G Ninja + ninja -j{nproc} + + cd .. + rm -rf build + rm -rf packages + + """ + if scons_args != '': + print("this project would be built regularly because `scons_args` is not empty") + return build_bsp(bsp, scons_args) + success = True + os.chdir(rtt_root) + if os.path.exists(f"{rtt_root}/bsp/{bsp}/Kconfig"): + os.chdir(rtt_root) + run_cmd(f'scons -C bsp/{bsp} --pyconfig-silent', output_info=False) + + os.chdir(f'{rtt_root}/bsp/{bsp}') + run_cmd('pkgs --update', output_info=False) + run_cmd('pkgs --list') + + nproc = multiprocessing.cpu_count() + + run_cmd('scons --target=cmake') + os.mkdir(f'{rtt_root}/bsp/{bsp}/cmake-build') + os.chdir(f'{rtt_root}/bsp/{bsp}/cmake-build') + run_cmd('cmake .. -G Ninja') + _, res = run_cmd(f'ninja -j{nproc}') + + if res != 0: + success = False + + build_dir = os.path.join(rtt_root, 'bsp', bsp, 'cmake-build') + shutil.rmtree(build_dir, ignore_errors=True) + pkg_dir = os.path.join(rtt_root, 'bsp', bsp, 'packages') + shutil.rmtree(pkg_dir, ignore_errors=True) + + return success def append_file(source_file, destination_file): """ @@ -166,11 +218,18 @@ def build_bsp_attachconfig(bsp, attach_file): rtt_root = os.getcwd() srtt_bsp = os.getenv('SRTT_BSP').split(',') + build_tool = os.getenv('RTT_BUILD_TOOL') for bsp in srtt_bsp: count += 1 print(f"::group::Compiling BSP: =={count}=== {bsp} ====") - res = build_bsp(bsp) + res = False + if build_tool == 'scons': + res = build_bsp(bsp) + elif build_tool =='cmake': + res = build_bsp_cmake(bsp) + else: + print(f"::error::build tool {build_tool} is not supported") if not res: print(f"::error::build {bsp} failed") add_summary(f"- ❌ build {bsp} failed.") From 8ad81ec28a6b2408e46bece8efde00cde798f920 Mon Sep 17 00:00:00 2001 From: kaidegit <2857693944@qq.com> Date: Mon, 17 Feb 2025 20:40:48 +0800 Subject: [PATCH 02/18] test path? --- .github/workflows/bsp_buildings.yml | 10 +++++++++- tools/ci/bsp_buildings.py | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/.github/workflows/bsp_buildings.yml b/.github/workflows/bsp_buildings.yml index a255f56bdae..a5998fe2fbe 100644 --- a/.github/workflows/bsp_buildings.yml +++ b/.github/workflows/bsp_buildings.yml @@ -439,9 +439,17 @@ jobs: - name: Install Cmake & Ninja uses: lukka/get-cmake@latest with: - cmakeVersion: latestrc + cmakeVersion: latest ninjaVersion: latest + - name: test cmake + shell: bash + run: | + which cmake + cmake --version + which ninja + ninja --version + - name: Install Arm ToolChains if: ${{ matrix.legs.RTT_TOOL_CHAIN == 'sourcery-arm' && success() }} shell: bash diff --git a/tools/ci/bsp_buildings.py b/tools/ci/bsp_buildings.py index 23b9fb8de8d..e3576f547f7 100644 --- a/tools/ci/bsp_buildings.py +++ b/tools/ci/bsp_buildings.py @@ -21,7 +21,7 @@ def run_cmd(cmd, output_info=True): res = 0 if output_info: - res = os.system(cmd + " > output.txt 2>&1") + res = os.system('/bin/bash -c' + cmd + " > output.txt 2>&1") else: res = os.system(cmd + " > /dev/null 2>output.txt") From 49bbddea43106c825853ea1a5a4286dec6fd40b7 Mon Sep 17 00:00:00 2001 From: kaidegit <2857693944@qq.com> Date: Mon, 17 Feb 2025 20:54:19 +0800 Subject: [PATCH 03/18] fix cmd --- tools/ci/bsp_buildings.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/ci/bsp_buildings.py b/tools/ci/bsp_buildings.py index e3576f547f7..64d395f3bef 100644 --- a/tools/ci/bsp_buildings.py +++ b/tools/ci/bsp_buildings.py @@ -21,7 +21,7 @@ def run_cmd(cmd, output_info=True): res = 0 if output_info: - res = os.system('/bin/bash -c' + cmd + " > output.txt 2>&1") + res = os.system('/bin/bash -c' + '"' + cmd + " > output.txt 2>&1" + '"') else: res = os.system(cmd + " > /dev/null 2>output.txt") From d2de1ad66e27e3f393bd5b79b55f8a1dd30e88ad Mon Sep 17 00:00:00 2001 From: kaidegit <2857693944@qq.com> Date: Mon, 17 Feb 2025 21:14:58 +0800 Subject: [PATCH 04/18] =?UTF-8?q?=E5=8F=A6=E8=B5=B7shell=E5=AF=BC=E8=87=B4?= =?UTF-8?q?=E4=B8=A2=E7=8E=AF=E5=A2=83=EF=BC=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/bsp_buildings.yml | 9 --------- tools/ci/bsp_buildings.py | 2 +- 2 files changed, 1 insertion(+), 10 deletions(-) diff --git a/.github/workflows/bsp_buildings.yml b/.github/workflows/bsp_buildings.yml index a5998fe2fbe..0f7dca60ea0 100644 --- a/.github/workflows/bsp_buildings.yml +++ b/.github/workflows/bsp_buildings.yml @@ -442,14 +442,6 @@ jobs: cmakeVersion: latest ninjaVersion: latest - - name: test cmake - shell: bash - run: | - which cmake - cmake --version - which ninja - ninja --version - - name: Install Arm ToolChains if: ${{ matrix.legs.RTT_TOOL_CHAIN == 'sourcery-arm' && success() }} shell: bash @@ -536,7 +528,6 @@ jobs: - name: Bsp Scons Compile if: ${{ success() }} - shell: bash env: RTT_BSP: ${{ matrix.legs.RTT_BSP }} RTT_TOOL_CHAIN: ${{ matrix.legs.RTT_TOOL_CHAIN }} diff --git a/tools/ci/bsp_buildings.py b/tools/ci/bsp_buildings.py index 64d395f3bef..23b9fb8de8d 100644 --- a/tools/ci/bsp_buildings.py +++ b/tools/ci/bsp_buildings.py @@ -21,7 +21,7 @@ def run_cmd(cmd, output_info=True): res = 0 if output_info: - res = os.system('/bin/bash -c' + '"' + cmd + " > output.txt 2>&1" + '"') + res = os.system(cmd + " > output.txt 2>&1") else: res = os.system(cmd + " > /dev/null 2>output.txt") From 7c10207a3102240743f095ca283e7524fec72d28 Mon Sep 17 00:00:00 2001 From: kaidegit <2857693944@qq.com> Date: Mon, 17 Feb 2025 21:21:34 +0800 Subject: [PATCH 05/18] ci --- .github/workflows/bsp_buildings.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/bsp_buildings.yml b/.github/workflows/bsp_buildings.yml index 0f7dca60ea0..0c895c1a031 100644 --- a/.github/workflows/bsp_buildings.yml +++ b/.github/workflows/bsp_buildings.yml @@ -425,7 +425,6 @@ jobs: python-version: 3.8 - name: Install Tools - shell: bash run: | wget https://raw.githubusercontent.com/RT-Thread/env/master/install_ubuntu.sh chmod 777 install_ubuntu.sh @@ -444,7 +443,6 @@ jobs: - name: Install Arm ToolChains if: ${{ matrix.legs.RTT_TOOL_CHAIN == 'sourcery-arm' && 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 @@ -534,6 +532,10 @@ jobs: RTT_BUILD_TOOL: ${{ matrix.legs.RTT_BUILD_TOOL }} SRTT_BSP: ${{ join(matrix.legs.SUB_RTT_BSP, ',') }} run: | + which cmake + cmake --version + which ninja + ninja --version source ~/.env/env.sh python tools/ci/bsp_buildings.py From 848331c1e747e65f5d91f99c37e460a31d83a65f Mon Sep 17 00:00:00 2001 From: kaidegit <2857693944@qq.com> Date: Mon, 17 Feb 2025 21:39:44 +0800 Subject: [PATCH 06/18] ci --- .github/workflows/bsp_buildings.yml | 1 + tools/ci/bsp_buildings.py | 2 ++ 2 files changed, 3 insertions(+) diff --git a/.github/workflows/bsp_buildings.yml b/.github/workflows/bsp_buildings.yml index 0c895c1a031..d821edba83e 100644 --- a/.github/workflows/bsp_buildings.yml +++ b/.github/workflows/bsp_buildings.yml @@ -534,6 +534,7 @@ jobs: run: | which cmake cmake --version + cmake --help which ninja ninja --version source ~/.env/env.sh diff --git a/tools/ci/bsp_buildings.py b/tools/ci/bsp_buildings.py index 23b9fb8de8d..53e110f17ed 100644 --- a/tools/ci/bsp_buildings.py +++ b/tools/ci/bsp_buildings.py @@ -126,6 +126,8 @@ def build_bsp_cmake(bsp, scons_args=''): if res != 0: success = False + + os.chdir(f'{rtt_root}/bsp/{bsp}') build_dir = os.path.join(rtt_root, 'bsp', bsp, 'cmake-build') shutil.rmtree(build_dir, ignore_errors=True) From 330a350edefa353f22e5f42938e76fd9510ae40f Mon Sep 17 00:00:00 2001 From: kaidegit <2857693944@qq.com> Date: Mon, 17 Feb 2025 22:10:41 +0800 Subject: [PATCH 07/18] test the version inside --- .github/workflows/bsp_buildings.yml | 2 +- tools/ci/bsp_buildings.py | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/.github/workflows/bsp_buildings.yml b/.github/workflows/bsp_buildings.yml index d821edba83e..ef9673116a8 100644 --- a/.github/workflows/bsp_buildings.yml +++ b/.github/workflows/bsp_buildings.yml @@ -525,7 +525,7 @@ jobs: echo "RTT_EXEC_PATH=/opt/i386-unknown-elf_for_x86_64-pc-linux-gnu/bin" >> $GITHUB_ENV - name: Bsp Scons Compile - if: ${{ success() }} + if: ${{ success() && matrix.legs.RTT_BSP == 'stm32l4_f0_f1(cmake)' }} env: RTT_BSP: ${{ matrix.legs.RTT_BSP }} RTT_TOOL_CHAIN: ${{ matrix.legs.RTT_TOOL_CHAIN }} diff --git a/tools/ci/bsp_buildings.py b/tools/ci/bsp_buildings.py index 53e110f17ed..412432d46f7 100644 --- a/tools/ci/bsp_buildings.py +++ b/tools/ci/bsp_buildings.py @@ -2,6 +2,7 @@ import shutil import re import multiprocessing +import subprocess import yaml def add_summary(text): @@ -221,6 +222,16 @@ def build_bsp_attachconfig(bsp, attach_file): rtt_root = os.getcwd() srtt_bsp = os.getenv('SRTT_BSP').split(',') build_tool = os.getenv('RTT_BUILD_TOOL') + + os.system("which cmake") + os.system("cmake --version") + os.system("cmake --help") + os.system("which ninja") + os.system("ninja --version") + + subprocess.run(['cmake', '--version']) + subprocess.run(['cmake', '--help']) + subprocess.run(['ninja', '--version']) for bsp in srtt_bsp: count += 1 From 4a23d32660f9fbf8b0ec72004aa8464fc9444d3d Mon Sep 17 00:00:00 2001 From: kaidegit <2857693944@qq.com> Date: Mon, 17 Feb 2025 22:17:19 +0800 Subject: [PATCH 08/18] try apt --- .github/workflows/bsp_buildings.yml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/bsp_buildings.yml b/.github/workflows/bsp_buildings.yml index ef9673116a8..4643e1d9430 100644 --- a/.github/workflows/bsp_buildings.yml +++ b/.github/workflows/bsp_buildings.yml @@ -434,12 +434,13 @@ jobs: echo "RTT_ROOT=${{ github.workspace }}" >> $GITHUB_ENV echo "RTT_CC=gcc" >> $GITHUB_ENV echo "export PATH=~/.env/tools/scripts:$PATH" > ~/.env/env.sh + sudo apt install cmake ninja-build - - name: Install Cmake & Ninja - uses: lukka/get-cmake@latest - with: - cmakeVersion: latest - ninjaVersion: latest + # - name: Install Cmake & Ninja + # uses: lukka/get-cmake@latest + # with: + # cmakeVersion: latest + # ninjaVersion: latest - name: Install Arm ToolChains if: ${{ matrix.legs.RTT_TOOL_CHAIN == 'sourcery-arm' && success() }} From 31541ae26d41447c52aa6eb0354d3b747a461c62 Mon Sep 17 00:00:00 2001 From: kaidegit <2857693944@qq.com> Date: Mon, 17 Feb 2025 22:46:15 +0800 Subject: [PATCH 09/18] =?UTF-8?q?scons=20=E4=B8=A5=E6=A0=BC=E6=A8=A1?= =?UTF-8?q?=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tools/ci/bsp_buildings.py | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/tools/ci/bsp_buildings.py b/tools/ci/bsp_buildings.py index 412432d46f7..3eac2063348 100644 --- a/tools/ci/bsp_buildings.py +++ b/tools/ci/bsp_buildings.py @@ -104,7 +104,11 @@ def build_bsp_cmake(bsp, scons_args=''): rm -rf packages """ - if scons_args != '': + ext_flags = '' + if scons_args == "--strict": + print("scons using strict mode, build it with `-Werror` flag") + ext_flags += '-DCMAKE_COMPILE_WARNING_AS_ERROR' + elif scons_args != '': print("this project would be built regularly because `scons_args` is not empty") return build_bsp(bsp, scons_args) success = True @@ -122,7 +126,7 @@ def build_bsp_cmake(bsp, scons_args=''): run_cmd('scons --target=cmake') os.mkdir(f'{rtt_root}/bsp/{bsp}/cmake-build') os.chdir(f'{rtt_root}/bsp/{bsp}/cmake-build') - run_cmd('cmake .. -G Ninja') + run_cmd(f'cmake {ext_flags} .. -G Ninja') _, res = run_cmd(f'ninja -j{nproc}') if res != 0: @@ -222,16 +226,6 @@ def build_bsp_attachconfig(bsp, attach_file): rtt_root = os.getcwd() srtt_bsp = os.getenv('SRTT_BSP').split(',') build_tool = os.getenv('RTT_BUILD_TOOL') - - os.system("which cmake") - os.system("cmake --version") - os.system("cmake --help") - os.system("which ninja") - os.system("ninja --version") - - subprocess.run(['cmake', '--version']) - subprocess.run(['cmake', '--help']) - subprocess.run(['ninja', '--version']) for bsp in srtt_bsp: count += 1 From 41b0744bd6fb84c71cfc6a08bae447414979bdaa Mon Sep 17 00:00:00 2001 From: kaidegit <2857693944@qq.com> Date: Mon, 17 Feb 2025 22:55:15 +0800 Subject: [PATCH 10/18] ci --- .github/workflows/bsp_buildings.yml | 11 ----------- tools/ci/bsp_buildings.py | 17 ++++++++++------- 2 files changed, 10 insertions(+), 18 deletions(-) diff --git a/.github/workflows/bsp_buildings.yml b/.github/workflows/bsp_buildings.yml index 4643e1d9430..2b6bde9aaa4 100644 --- a/.github/workflows/bsp_buildings.yml +++ b/.github/workflows/bsp_buildings.yml @@ -435,12 +435,6 @@ jobs: echo "RTT_CC=gcc" >> $GITHUB_ENV echo "export PATH=~/.env/tools/scripts:$PATH" > ~/.env/env.sh sudo apt install cmake ninja-build - - # - name: Install Cmake & Ninja - # uses: lukka/get-cmake@latest - # with: - # cmakeVersion: latest - # ninjaVersion: latest - name: Install Arm ToolChains if: ${{ matrix.legs.RTT_TOOL_CHAIN == 'sourcery-arm' && success() }} @@ -533,11 +527,6 @@ jobs: RTT_BUILD_TOOL: ${{ matrix.legs.RTT_BUILD_TOOL }} SRTT_BSP: ${{ join(matrix.legs.SUB_RTT_BSP, ',') }} run: | - which cmake - cmake --version - cmake --help - which ninja - ninja --version source ~/.env/env.sh python tools/ci/bsp_buildings.py diff --git a/tools/ci/bsp_buildings.py b/tools/ci/bsp_buildings.py index 3eac2063348..44a39eb3ead 100644 --- a/tools/ci/bsp_buildings.py +++ b/tools/ci/bsp_buildings.py @@ -38,6 +38,15 @@ def run_cmd(cmd, output_info=True): def build_bsp(bsp, scons_args=''): + if build_tool == 'scons': + return build_bsp_scons(bsp) + elif build_tool =='cmake': + return build_bsp_cmake(bsp) + else: + print(f"::error::build tool {build_tool} is not supported") + return False + +def build_bsp_scons(bsp, scons_args=''): """ build bsp. @@ -230,13 +239,7 @@ def build_bsp_attachconfig(bsp, attach_file): for bsp in srtt_bsp: count += 1 print(f"::group::Compiling BSP: =={count}=== {bsp} ====") - res = False - if build_tool == 'scons': - res = build_bsp(bsp) - elif build_tool =='cmake': - res = build_bsp_cmake(bsp) - else: - print(f"::error::build tool {build_tool} is not supported") + res = build_bsp(bsp) if not res: print(f"::error::build {bsp} failed") add_summary(f"- ❌ build {bsp} failed.") From 10e7cc1c89d40ebb2a46d68bbb29bcc77ccd25ee Mon Sep 17 00:00:00 2001 From: kaidegit <2857693944@qq.com> Date: Mon, 17 Feb 2025 23:04:27 +0800 Subject: [PATCH 11/18] fix --- tools/ci/bsp_buildings.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/ci/bsp_buildings.py b/tools/ci/bsp_buildings.py index 44a39eb3ead..16bf2bb0f33 100644 --- a/tools/ci/bsp_buildings.py +++ b/tools/ci/bsp_buildings.py @@ -119,7 +119,7 @@ def build_bsp_cmake(bsp, scons_args=''): ext_flags += '-DCMAKE_COMPILE_WARNING_AS_ERROR' elif scons_args != '': print("this project would be built regularly because `scons_args` is not empty") - return build_bsp(bsp, scons_args) + return build_bsp_scons(bsp, scons_args) success = True os.chdir(rtt_root) if os.path.exists(f"{rtt_root}/bsp/{bsp}/Kconfig"): From 9b6e7ad179dce3dcd2fa95693578d20f3d37d624 Mon Sep 17 00:00:00 2001 From: kaidegit <2857693944@qq.com> Date: Mon, 17 Feb 2025 23:20:29 +0800 Subject: [PATCH 12/18] fix --- tools/ci/bsp_buildings.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tools/ci/bsp_buildings.py b/tools/ci/bsp_buildings.py index 16bf2bb0f33..842ab439cb4 100644 --- a/tools/ci/bsp_buildings.py +++ b/tools/ci/bsp_buildings.py @@ -37,11 +37,13 @@ def run_cmd(cmd, output_info=True): return output_str_list, res -def build_bsp(bsp, scons_args=''): +def build_bsp(bsp, scons_args='', build_tool=None): + if build_tool is None: + build_tool = os.getenv('RTT_BUILD_TOOL') if build_tool == 'scons': - return build_bsp_scons(bsp) + return build_bsp_scons(bsp, scons_args) elif build_tool =='cmake': - return build_bsp_cmake(bsp) + return build_bsp_cmake(bsp, scons_args) else: print(f"::error::build tool {build_tool} is not supported") return False @@ -234,7 +236,6 @@ def build_bsp_attachconfig(bsp, attach_file): rtt_root = os.getcwd() srtt_bsp = os.getenv('SRTT_BSP').split(',') - build_tool = os.getenv('RTT_BUILD_TOOL') for bsp in srtt_bsp: count += 1 From 54b12808be33c8e45df697f79afffca3f53a3b59 Mon Sep 17 00:00:00 2001 From: kaidegit <2857693944@qq.com> Date: Mon, 17 Feb 2025 23:30:27 +0800 Subject: [PATCH 13/18] fix --- tools/ci/bsp_buildings.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/ci/bsp_buildings.py b/tools/ci/bsp_buildings.py index 842ab439cb4..4484b3f97b2 100644 --- a/tools/ci/bsp_buildings.py +++ b/tools/ci/bsp_buildings.py @@ -118,7 +118,7 @@ def build_bsp_cmake(bsp, scons_args=''): ext_flags = '' if scons_args == "--strict": print("scons using strict mode, build it with `-Werror` flag") - ext_flags += '-DCMAKE_COMPILE_WARNING_AS_ERROR' + ext_flags += '-DCMAKE_COMPILE_WARNING_AS_ERROR=1' elif scons_args != '': print("this project would be built regularly because `scons_args` is not empty") return build_bsp_scons(bsp, scons_args) From 1747fe32716e1b95806ebe0dbf4b91fe5cfae661 Mon Sep 17 00:00:00 2001 From: Kai <60053077+kaidegit@users.noreply.github.com> Date: Tue, 18 Feb 2025 12:43:49 +0800 Subject: [PATCH 14/18] esp32c3 cmake --- .github/workflows/bsp_buildings.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/bsp_buildings.yml b/.github/workflows/bsp_buildings.yml index 2b6bde9aaa4..57bf75823cd 100644 --- a/.github/workflows/bsp_buildings.yml +++ b/.github/workflows/bsp_buildings.yml @@ -398,9 +398,9 @@ jobs: RTT_BUILD_TOOL: "scons" SUB_RTT_BSP: - "simulator" - - RTT_BSP: "ESP32C3" + - RTT_BSP: "ESP32C3(cmake)" RTT_TOOL_CHAIN: "sourcery-riscv32-esp32" - RTT_BUILD_TOOL: "scons" + RTT_BUILD_TOOL: "cmake" SUB_RTT_BSP: - "ESP32_C3" - RTT_BSP: "i386-unknown" @@ -520,7 +520,7 @@ jobs: echo "RTT_EXEC_PATH=/opt/i386-unknown-elf_for_x86_64-pc-linux-gnu/bin" >> $GITHUB_ENV - name: Bsp Scons Compile - if: ${{ success() && matrix.legs.RTT_BSP == 'stm32l4_f0_f1(cmake)' }} + if: ${{ success() && matrix.legs.RTT_BUILD_TOOL == 'cmake' }} env: RTT_BSP: ${{ matrix.legs.RTT_BSP }} RTT_TOOL_CHAIN: ${{ matrix.legs.RTT_TOOL_CHAIN }} From 727842f1f4c789e85fcdf82d73553d31e660ab8f Mon Sep 17 00:00:00 2001 From: kaidegit <2857693944@qq.com> Date: Thu, 20 Feb 2025 22:21:36 +0800 Subject: [PATCH 15/18] check args --- tools/ci/bsp_buildings.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/ci/bsp_buildings.py b/tools/ci/bsp_buildings.py index 4484b3f97b2..868edc22c1b 100644 --- a/tools/ci/bsp_buildings.py +++ b/tools/ci/bsp_buildings.py @@ -116,11 +116,12 @@ def build_bsp_cmake(bsp, scons_args=''): """ ext_flags = '' + scons_arg = scons_arg.strip() if scons_args == "--strict": print("scons using strict mode, build it with `-Werror` flag") ext_flags += '-DCMAKE_COMPILE_WARNING_AS_ERROR=1' elif scons_args != '': - print("this project would be built regularly because `scons_args` is not empty") + print(f"this project would be built regularly because `scons_args` is `{scons_args}`") return build_bsp_scons(bsp, scons_args) success = True os.chdir(rtt_root) From 7bf657ee8732925fe8a84adafc7cf8545b9dcfd0 Mon Sep 17 00:00:00 2001 From: kaidegit <2857693944@qq.com> Date: Thu, 20 Feb 2025 22:26:04 +0800 Subject: [PATCH 16/18] typo --- tools/ci/bsp_buildings.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/ci/bsp_buildings.py b/tools/ci/bsp_buildings.py index 868edc22c1b..e1add903c38 100644 --- a/tools/ci/bsp_buildings.py +++ b/tools/ci/bsp_buildings.py @@ -116,7 +116,7 @@ def build_bsp_cmake(bsp, scons_args=''): """ ext_flags = '' - scons_arg = scons_arg.strip() + scons_args = scons_args.strip() if scons_args == "--strict": print("scons using strict mode, build it with `-Werror` flag") ext_flags += '-DCMAKE_COMPILE_WARNING_AS_ERROR=1' From 66a88ea15bf6562bd92b2ef42ac1c0c95e1cb2c4 Mon Sep 17 00:00:00 2001 From: kaidegit <2857693944@qq.com> Date: Sat, 22 Feb 2025 10:52:44 +0800 Subject: [PATCH 17/18] fix cmake generator collect flags --- tools/cmake.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/tools/cmake.py b/tools/cmake.py index fb894d1ed34..bb3c5fee4b3 100644 --- a/tools/cmake.py +++ b/tools/cmake.py @@ -46,9 +46,17 @@ def GenerateCFiles(env, project, project_name): OBJCOPY = tool_path_conv["CMAKE_OBJCOPY"]["path"] FROMELF = tool_path_conv["CMAKE_FROMELF"]["path"] - CFLAGS = rtconfig.CFLAGS.replace('\\', "/").replace('\"', "\\\"") + CFLAGS = rtconfig.CFLAGS + for group in project: + if 'CFLAGS' in group.keys(): + CFLAGS += ' ' + group['CFLAGS'] + CFLAGS = CFLAGS.replace('\\', "/").replace('\"', "\\\"") if 'CXXFLAGS' in dir(rtconfig): - CXXFLAGS = rtconfig.CXXFLAGS.replace('\\', "/").replace('\"', "\\\"") + CXXFLAGS = rtconfig.CXXFLAGS + for group in project: + if 'CXXFLAGS' in group.keys(): + CXXFLAGS +='' + group['CXXFLAGS'] + CXXFLAGS = CXXFLAGS.replace('\\', "/").replace('\"', "\\\"") else: CXXFLAGS = CFLAGS AFLAGS = rtconfig.AFLAGS.replace('\\', "/").replace('\"', "\\\"") From 972b47ae28c51c2db0c598e9c361aa85998115c0 Mon Sep 17 00:00:00 2001 From: kaidegit <2857693944@qq.com> Date: Sat, 22 Feb 2025 11:25:46 +0800 Subject: [PATCH 18/18] use flags in env --- tools/cmake.py | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/tools/cmake.py b/tools/cmake.py index bb3c5fee4b3..ee97cd42e9b 100644 --- a/tools/cmake.py +++ b/tools/cmake.py @@ -45,21 +45,13 @@ def GenerateCFiles(env, project, project_name): OBJDUMP = tool_path_conv["CMAKE_OBJDUMP"]["path"] OBJCOPY = tool_path_conv["CMAKE_OBJCOPY"]["path"] FROMELF = tool_path_conv["CMAKE_FROMELF"]["path"] - - CFLAGS = rtconfig.CFLAGS - for group in project: - if 'CFLAGS' in group.keys(): - CFLAGS += ' ' + group['CFLAGS'] - CFLAGS = CFLAGS.replace('\\', "/").replace('\"', "\\\"") + + CFLAGS = env['CFLAGS'].replace('\\', "/").replace('\"', "\\\"") if 'CXXFLAGS' in dir(rtconfig): - CXXFLAGS = rtconfig.CXXFLAGS - for group in project: - if 'CXXFLAGS' in group.keys(): - CXXFLAGS +='' + group['CXXFLAGS'] - CXXFLAGS = CXXFLAGS.replace('\\', "/").replace('\"', "\\\"") + CXXFLAGS = env['CXXFLAGS'].replace('\\', "/").replace('\"', "\\\"") else: CXXFLAGS = CFLAGS - AFLAGS = rtconfig.AFLAGS.replace('\\', "/").replace('\"', "\\\"") + AFLAGS = env['ASFLAGS'].replace('\\', "/").replace('\"', "\\\"") LFLAGS = env['LINKFLAGS'].replace('\\', "/").replace('\"', "\\\"") POST_ACTION = rtconfig.POST_ACTION