Ci tweak3 (#2643)
- enable --one-per-family to build 1 board per family, also skip family if board specified in -b also present - minimize ci run for push event - only build one board per family - skip hil test on both pi4 and hfp - full build will be runn for PR event - IAR always build 1 board per family regardless of event - update build.py to optimize make - remove all setup python since we don't really need it
This commit is contained in:
3
.github/actions/setup_toolchain/action.yml
vendored
3
.github/actions/setup_toolchain/action.yml
vendored
@@ -32,6 +32,7 @@ runs:
|
|||||||
- name: Download Toolchain
|
- name: Download Toolchain
|
||||||
if: >-
|
if: >-
|
||||||
inputs.toolchain != 'arm-gcc' &&
|
inputs.toolchain != 'arm-gcc' &&
|
||||||
|
inputs.toolchain != 'arm-iar' &&
|
||||||
inputs.toolchain != 'esp-idf'
|
inputs.toolchain != 'esp-idf'
|
||||||
uses: ./.github/actions/setup_toolchain/download
|
uses: ./.github/actions/setup_toolchain/download
|
||||||
with:
|
with:
|
||||||
@@ -44,6 +45,8 @@ runs:
|
|||||||
BUILD_OPTION=""
|
BUILD_OPTION=""
|
||||||
if [[ "${{ inputs.toolchain }}" == *"clang"* ]]; then
|
if [[ "${{ inputs.toolchain }}" == *"clang"* ]]; then
|
||||||
BUILD_OPTION="--toolchain clang"
|
BUILD_OPTION="--toolchain clang"
|
||||||
|
elif [[ "${{ inputs.toolchain }}" == "arm-iar" ]]; then
|
||||||
|
BUILD_OPTION="--toolchain iar"
|
||||||
fi
|
fi
|
||||||
echo "build_option=$BUILD_OPTION"
|
echo "build_option=$BUILD_OPTION"
|
||||||
echo "build_option=$BUILD_OPTION" >> $GITHUB_OUTPUT
|
echo "build_option=$BUILD_OPTION" >> $GITHUB_OUTPUT
|
||||||
|
50
.github/workflows/build.yml
vendored
50
.github/workflows/build.yml
vendored
@@ -37,11 +37,6 @@ jobs:
|
|||||||
outputs:
|
outputs:
|
||||||
json: ${{ steps.set-matrix-json.outputs.matrix }}
|
json: ${{ steps.set-matrix-json.outputs.matrix }}
|
||||||
steps:
|
steps:
|
||||||
- name: Setup Python
|
|
||||||
uses: actions/setup-python@v5
|
|
||||||
with:
|
|
||||||
python-version: '3.x'
|
|
||||||
|
|
||||||
- name: Checkout TinyUSB
|
- name: Checkout TinyUSB
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
@@ -63,27 +58,22 @@ jobs:
|
|||||||
matrix:
|
matrix:
|
||||||
toolchain:
|
toolchain:
|
||||||
- 'aarch64-gcc'
|
- 'aarch64-gcc'
|
||||||
- 'arm-clang'
|
# - 'arm-clang'
|
||||||
- 'arm-gcc'
|
- 'arm-gcc'
|
||||||
- 'msp430-gcc'
|
- 'msp430-gcc'
|
||||||
- 'riscv-gcc'
|
- 'riscv-gcc'
|
||||||
if: >-
|
|
||||||
matrix.toolchain != 'arm-clang' ||
|
|
||||||
github.event_name == 'pull_request' ||
|
|
||||||
(github.event_name == 'push' && github.ref == 'refs/heads/master')
|
|
||||||
with:
|
with:
|
||||||
build-system: 'cmake'
|
build-system: 'cmake'
|
||||||
toolchain: ${{ matrix.toolchain }}
|
toolchain: ${{ matrix.toolchain }}
|
||||||
toolchain_url: ${{ fromJSON(needs.set-matrix.outputs.json)[matrix.toolchain].toolchain_url }}
|
toolchain_url: ${{ fromJSON(needs.set-matrix.outputs.json)[matrix.toolchain].toolchain_url }}
|
||||||
build-args: ${{ toJSON(fromJSON(needs.set-matrix.outputs.json)[matrix.toolchain].family) }}
|
build-args: ${{ toJSON(fromJSON(needs.set-matrix.outputs.json)[matrix.toolchain].family) }}
|
||||||
|
one-per-family: ${{ github.event_name != 'pull_request' }}
|
||||||
|
|
||||||
# ---------------------------------------
|
# ---------------------------------------
|
||||||
# Build Make
|
# Build Make
|
||||||
# ---------------------------------------
|
# ---------------------------------------
|
||||||
make:
|
make:
|
||||||
if: >-
|
#if: github.event_name == 'pull_request'
|
||||||
github.event_name == 'pull_request' ||
|
|
||||||
(github.event_name == 'push' && github.ref == 'refs/heads/master')
|
|
||||||
needs: set-matrix
|
needs: set-matrix
|
||||||
uses: ./.github/workflows/build_util.yml
|
uses: ./.github/workflows/build_util.yml
|
||||||
strategy:
|
strategy:
|
||||||
@@ -100,6 +90,7 @@ jobs:
|
|||||||
toolchain: ${{ matrix.toolchain }}
|
toolchain: ${{ matrix.toolchain }}
|
||||||
toolchain_url: ${{ fromJSON(needs.set-matrix.outputs.json)[matrix.toolchain].toolchain_url }}
|
toolchain_url: ${{ fromJSON(needs.set-matrix.outputs.json)[matrix.toolchain].toolchain_url }}
|
||||||
build-args: ${{ toJSON(fromJSON(needs.set-matrix.outputs.json)[matrix.toolchain].family) }}
|
build-args: ${{ toJSON(fromJSON(needs.set-matrix.outputs.json)[matrix.toolchain].family) }}
|
||||||
|
one-per-family: ${{ github.event_name != 'pull_request' }}
|
||||||
|
|
||||||
# ---------------------------------------
|
# ---------------------------------------
|
||||||
# Build Make on Windows/MacOS
|
# Build Make on Windows/MacOS
|
||||||
@@ -114,7 +105,8 @@ jobs:
|
|||||||
os: ${{ matrix.os }}
|
os: ${{ matrix.os }}
|
||||||
build-system: 'make'
|
build-system: 'make'
|
||||||
toolchain: 'arm-gcc'
|
toolchain: 'arm-gcc'
|
||||||
build-args: '["-bstm32f411disco"]'
|
build-args: '["stm32h7"]'
|
||||||
|
one-per-family: true
|
||||||
|
|
||||||
# ---------------------------------------
|
# ---------------------------------------
|
||||||
# Build Espressif
|
# Build Espressif
|
||||||
@@ -134,3 +126,33 @@ jobs:
|
|||||||
toolchain: 'esp-idf'
|
toolchain: 'esp-idf'
|
||||||
toolchain_url: 'v5.1.1'
|
toolchain_url: 'v5.1.1'
|
||||||
build-args: '["-b${{ matrix.board }}"]'
|
build-args: '["-b${{ matrix.board }}"]'
|
||||||
|
|
||||||
|
# ---------------------------------------
|
||||||
|
# Build IAR on HFP self-hosted
|
||||||
|
# ---------------------------------------
|
||||||
|
arm-iar:
|
||||||
|
if: github.repository_owner == 'hathach'
|
||||||
|
needs: set-matrix
|
||||||
|
runs-on: [self-hosted, Linux, X64, hifiphile]
|
||||||
|
env:
|
||||||
|
BUILD_ARGS: ${{ join(fromJSON(needs.set-matrix.outputs.json)['arm-iar'].family, ' ') }}
|
||||||
|
steps:
|
||||||
|
- name: Clean workspace
|
||||||
|
run: |
|
||||||
|
echo "Cleaning up previous run"
|
||||||
|
rm -rf "${{ github.workspace }}"
|
||||||
|
mkdir -p "${{ github.workspace }}"
|
||||||
|
|
||||||
|
- name: Checkout TinyUSB
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Get Dependencies
|
||||||
|
run: python3 tools/get_deps.py $BUILD_ARGS
|
||||||
|
|
||||||
|
- name: Build
|
||||||
|
run: python3 tools/build.py --one-per-family --toolchain iar $BUILD_ARGS
|
||||||
|
|
||||||
|
- name: Test on actual hardware (hardware in the loop)
|
||||||
|
if: github.event_name == 'pull_request'
|
||||||
|
run: |
|
||||||
|
python3 test/hil/hil_test.py hfp.json
|
||||||
|
50
.github/workflows/build_iar.yml
vendored
50
.github/workflows/build_iar.yml
vendored
@@ -1,50 +0,0 @@
|
|||||||
name: Build IAR
|
|
||||||
|
|
||||||
on:
|
|
||||||
workflow_dispatch:
|
|
||||||
pull_request:
|
|
||||||
branches: [ master ]
|
|
||||||
paths:
|
|
||||||
- 'src/**'
|
|
||||||
- 'examples/**'
|
|
||||||
- 'lib/**'
|
|
||||||
- 'hw/**'
|
|
||||||
- 'tools/get_deps.py'
|
|
||||||
- 'test/hil/**'
|
|
||||||
- '.github/workflows/build_iar.yml'
|
|
||||||
|
|
||||||
concurrency:
|
|
||||||
group: ${{ github.workflow }}-${{ github.ref }}
|
|
||||||
cancel-in-progress: true
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
cmake:
|
|
||||||
if: github.repository_owner == 'hathach'
|
|
||||||
runs-on: [self-hosted, Linux, X64, hifiphile]
|
|
||||||
strategy:
|
|
||||||
fail-fast: false
|
|
||||||
matrix:
|
|
||||||
family:
|
|
||||||
# Alphabetical order
|
|
||||||
# Note: bundle multiple families into a matrix since there is only one self-hosted instance can
|
|
||||||
# run IAR build. Too many matrix can hurt due to setup/teardown overhead.
|
|
||||||
- 'lpc43 stm32f0 stm32f1 stm32f7 stm32g0 stm32g4 stm32l4'
|
|
||||||
steps:
|
|
||||||
- name: Clean workspace
|
|
||||||
run: |
|
|
||||||
echo "Cleaning up previous run"
|
|
||||||
rm -rf "${{ github.workspace }}"
|
|
||||||
mkdir -p "${{ github.workspace }}"
|
|
||||||
|
|
||||||
- name: Checkout TinyUSB
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: Get Dependencies
|
|
||||||
run: python3 tools/get_deps.py ${{ matrix.family }}
|
|
||||||
|
|
||||||
- name: Build
|
|
||||||
run: python3 tools/build.py --toolchain iar ${{ matrix.family }}
|
|
||||||
|
|
||||||
- name: Test on actual hardware (hardware in the loop)
|
|
||||||
run: |
|
|
||||||
python3 test/hil/hil_test.py hfp.json
|
|
5
.github/workflows/build_renesas.yml
vendored
5
.github/workflows/build_renesas.yml
vendored
@@ -34,11 +34,6 @@ jobs:
|
|||||||
# Alphabetical order
|
# Alphabetical order
|
||||||
- 'rx'
|
- 'rx'
|
||||||
steps:
|
steps:
|
||||||
- name: Setup Python
|
|
||||||
uses: actions/setup-python@v5
|
|
||||||
with:
|
|
||||||
python-version: '3.x'
|
|
||||||
|
|
||||||
- name: Checkout TinyUSB
|
- name: Checkout TinyUSB
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
21
.github/workflows/build_util.yml
vendored
21
.github/workflows/build_util.yml
vendored
@@ -15,6 +15,10 @@ on:
|
|||||||
build-args:
|
build-args:
|
||||||
required: true
|
required: true
|
||||||
type: string
|
type: string
|
||||||
|
one-per-family:
|
||||||
|
required: false
|
||||||
|
default: false
|
||||||
|
type: boolean
|
||||||
os:
|
os:
|
||||||
required: false
|
required: false
|
||||||
type: string
|
type: string
|
||||||
@@ -31,11 +35,6 @@ jobs:
|
|||||||
- name: Checkout TinyUSB
|
- name: Checkout TinyUSB
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Setup Python
|
|
||||||
uses: actions/setup-python@v5
|
|
||||||
with:
|
|
||||||
python-version: '3.x'
|
|
||||||
|
|
||||||
- name: Setup Toolchain
|
- name: Setup Toolchain
|
||||||
id: setup-toolchain
|
id: setup-toolchain
|
||||||
uses: ./.github/actions/setup_toolchain
|
uses: ./.github/actions/setup_toolchain
|
||||||
@@ -48,10 +47,20 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
arg: ${{ matrix.arg }}
|
arg: ${{ matrix.arg }}
|
||||||
|
|
||||||
|
- name: Set build one-per-family option
|
||||||
|
id: set-one-per-family
|
||||||
|
run: |
|
||||||
|
if [[ "${{ inputs.one-per-family }}" == "true" ]]; then
|
||||||
|
BUILD_OPTION="--one-per-family"
|
||||||
|
fi
|
||||||
|
echo "build_option=$BUILD_OPTION"
|
||||||
|
echo "build_option=$BUILD_OPTION" >> $GITHUB_OUTPUT
|
||||||
|
shell: bash
|
||||||
|
|
||||||
- name: Build
|
- name: Build
|
||||||
if: inputs.toolchain != 'esp-idf'
|
if: inputs.toolchain != 'esp-idf'
|
||||||
run: |
|
run: |
|
||||||
python tools/build.py -s ${{ inputs.build-system }} ${{ steps.setup-toolchain.outputs.build_option }} ${{ matrix.arg }}
|
python tools/build.py -s ${{ inputs.build-system }} ${{ steps.setup-toolchain.outputs.build_option }} ${{ steps.set-one-per-family.outputs.build_option }} ${{ matrix.arg }}
|
||||||
|
|
||||||
- name: Build using ESP-IDF docker
|
- name: Build using ESP-IDF docker
|
||||||
if: inputs.toolchain == 'esp-idf'
|
if: inputs.toolchain == 'esp-idf'
|
||||||
|
22
.github/workflows/ci_set_matrix.py
vendored
22
.github/workflows/ci_set_matrix.py
vendored
@@ -4,6 +4,7 @@ import json
|
|||||||
toolchain_list = {
|
toolchain_list = {
|
||||||
"aarch64-gcc": "https://developer.arm.com/-/media/Files/downloads/gnu-a/10.3-2021.07/binrel/gcc-arm-10.3-2021.07-x86_64-aarch64-none-elf.tar.xz",
|
"aarch64-gcc": "https://developer.arm.com/-/media/Files/downloads/gnu-a/10.3-2021.07/binrel/gcc-arm-10.3-2021.07-x86_64-aarch64-none-elf.tar.xz",
|
||||||
"arm-clang": "https://github.com/ARM-software/LLVM-embedded-toolchain-for-Arm/releases/download/release-17.0.1/LLVMEmbeddedToolchainForArm-17.0.1-Linux-x86_64.tar.xz",
|
"arm-clang": "https://github.com/ARM-software/LLVM-embedded-toolchain-for-Arm/releases/download/release-17.0.1/LLVMEmbeddedToolchainForArm-17.0.1-Linux-x86_64.tar.xz",
|
||||||
|
"arm-iar": "",
|
||||||
"arm-gcc": "",
|
"arm-gcc": "",
|
||||||
"msp430-gcc": "http://software-dl.ti.com/msp430/msp430_public_sw/mcu/msp430/MSPGCC/9_2_0_0/export/msp430-gcc-9.2.0.50_linux64.tar.bz2",
|
"msp430-gcc": "http://software-dl.ti.com/msp430/msp430_public_sw/mcu/msp430/MSPGCC/9_2_0_0/export/msp430-gcc-9.2.0.50_linux64.tar.bz2",
|
||||||
"riscv-gcc": "https://github.com/xpack-dev-tools/riscv-none-embed-gcc-xpack/releases/download/v10.1.0-1.1/xpack-riscv-none-embed-gcc-10.1.0-1.1-linux-x64.tar.gz",
|
"riscv-gcc": "https://github.com/xpack-dev-tools/riscv-none-embed-gcc-xpack/releases/download/v10.1.0-1.1/xpack-riscv-none-embed-gcc-10.1.0-1.1-linux-x64.tar.gz",
|
||||||
@@ -28,12 +29,12 @@ family_list = {
|
|||||||
"rp2040": ["arm-gcc"],
|
"rp2040": ["arm-gcc"],
|
||||||
"samd11 samd21 saml2x": ["arm-gcc", "arm-clang"],
|
"samd11 samd21 saml2x": ["arm-gcc", "arm-clang"],
|
||||||
"samd5x_e5x samg": ["arm-gcc", "arm-clang"],
|
"samd5x_e5x samg": ["arm-gcc", "arm-clang"],
|
||||||
"stm32f0 stm32f1 stm32f2 stm32f3": ["arm-gcc", "arm-clang"],
|
"stm32f0 stm32f1 stm32f2 stm32f3": ["arm-gcc", "arm-clang", "arm-iar"],
|
||||||
"stm32f4": ["arm-gcc", "arm-clang"],
|
"stm32f4": ["arm-gcc", "arm-clang", "arm-iar"],
|
||||||
"stm32f7": ["arm-gcc", "arm-clang"],
|
"stm32f7": ["arm-gcc", "arm-clang", "arm-iar"],
|
||||||
"stm32g0 stm32g4 stm32h5": ["arm-gcc", "arm-clang"],
|
"stm32g0 stm32g4 stm32h5": ["arm-gcc", "arm-clang", "arm-iar"],
|
||||||
"stm32h7": ["arm-gcc", "arm-clang"],
|
"stm32h7": ["arm-gcc", "arm-clang", "arm-iar"],
|
||||||
"stm32l4 stm32u5 stm32wb": ["arm-gcc", "arm-clang"],
|
"stm32l4 stm32u5 stm32wb": ["arm-gcc", "arm-clang", "arm-iar"],
|
||||||
"xmc4000": ["arm-gcc"],
|
"xmc4000": ["arm-gcc"],
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -43,7 +44,16 @@ def set_matrix_json():
|
|||||||
for toolchain in toolchain_list.keys():
|
for toolchain in toolchain_list.keys():
|
||||||
filtered_families = [family for family, supported_toolchain in family_list.items() if
|
filtered_families = [family for family, supported_toolchain in family_list.items() if
|
||||||
toolchain in supported_toolchain]
|
toolchain in supported_toolchain]
|
||||||
|
|
||||||
|
# always add board in hfp.json for arm-iar
|
||||||
|
if toolchain == 'arm-iar':
|
||||||
|
with open('test/hil/hfp.json') as f:
|
||||||
|
hfp_data = json.load(f)
|
||||||
|
hfp_boards = [f"-b{board['name']}" for board in hfp_data['boards']]
|
||||||
|
filtered_families = filtered_families + hfp_boards
|
||||||
|
|
||||||
matrix[toolchain] = {"family": filtered_families, "toolchain_url": toolchain_list[toolchain]}
|
matrix[toolchain] = {"family": filtered_families, "toolchain_url": toolchain_list[toolchain]}
|
||||||
|
|
||||||
print(json.dumps(matrix))
|
print(json.dumps(matrix))
|
||||||
|
|
||||||
|
|
||||||
|
10
.github/workflows/hil_test.yml
vendored
10
.github/workflows/hil_test.yml
vendored
@@ -30,11 +30,6 @@ jobs:
|
|||||||
- name: Checkout TinyUSB
|
- name: Checkout TinyUSB
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Setup Python
|
|
||||||
uses: actions/setup-python@v5
|
|
||||||
with:
|
|
||||||
python-version: '3.x'
|
|
||||||
|
|
||||||
- name: Parse HIL json
|
- name: Parse HIL json
|
||||||
id: parse_hil_json
|
id: parse_hil_json
|
||||||
run: |
|
run: |
|
||||||
@@ -78,11 +73,6 @@ jobs:
|
|||||||
- name: Checkout TinyUSB
|
- name: Checkout TinyUSB
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Setup Python
|
|
||||||
uses: actions/setup-python@v5
|
|
||||||
with:
|
|
||||||
python-version: '3.x'
|
|
||||||
|
|
||||||
- name: Parse HIL json
|
- name: Parse HIL json
|
||||||
id: parse_hil_json
|
id: parse_hil_json
|
||||||
run: |
|
run: |
|
||||||
|
5
.github/workflows/pre-commit.yml
vendored
5
.github/workflows/pre-commit.yml
vendored
@@ -14,11 +14,6 @@ jobs:
|
|||||||
pre-commit:
|
pre-commit:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Setup Python
|
|
||||||
uses: actions/setup-python@v5
|
|
||||||
with:
|
|
||||||
python-version: '3.x'
|
|
||||||
|
|
||||||
- name: Setup Ruby
|
- name: Setup Ruby
|
||||||
uses: ruby/setup-ruby@v1
|
uses: ruby/setup-ruby@v1
|
||||||
with:
|
with:
|
||||||
|
@@ -115,7 +115,7 @@ void board_init(void) {
|
|||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
|
|
||||||
void board_led_write(bool state) {
|
void board_led_write(bool state) {
|
||||||
GPIO_PinState pin_state = (GPIO_PinState)(state ? LED_STATE_ON : (1 - LED_STATE_ON));
|
GPIO_PinState pin_state = (GPIO_PinState) (state ? LED_STATE_ON : (1 - LED_STATE_ON));
|
||||||
HAL_GPIO_WritePin(LED_PORT, LED_PIN, pin_state);
|
HAL_GPIO_WritePin(LED_PORT, LED_PIN, pin_state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -124,7 +124,7 @@ void board_init(void) {
|
|||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
|
|
||||||
void board_led_write(bool state) {
|
void board_led_write(bool state) {
|
||||||
GPIO_PinState pin_state = (GPIO_PinState)(state ? LED_STATE_ON : (1 - LED_STATE_ON));
|
GPIO_PinState pin_state = (GPIO_PinState) (state ? LED_STATE_ON : (1 - LED_STATE_ON));
|
||||||
HAL_GPIO_WritePin(LED_PORT, LED_PIN, pin_state);
|
HAL_GPIO_WritePin(LED_PORT, LED_PIN, pin_state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -108,7 +108,8 @@ void board_init(void) {
|
|||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
|
|
||||||
void board_led_write(bool state) {
|
void board_led_write(bool state) {
|
||||||
HAL_GPIO_WritePin(LED_PORT, LED_PIN, state ? LED_STATE_ON : (1 - LED_STATE_ON));
|
GPIO_PinState pin_state = (GPIO_PinState) (state ? LED_STATE_ON : (1 - LED_STATE_ON));
|
||||||
|
HAL_GPIO_WritePin(LED_PORT, LED_PIN, pin_state);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t board_button_read(void) {
|
uint32_t board_button_read(void) {
|
||||||
|
@@ -108,7 +108,8 @@ void board_init(void) {
|
|||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
|
|
||||||
void board_led_write(bool state) {
|
void board_led_write(bool state) {
|
||||||
HAL_GPIO_WritePin(LED_PORT, LED_PIN, state ? LED_STATE_ON : (1 - LED_STATE_ON));
|
GPIO_PinState pin_state = (GPIO_PinState) (state ? LED_STATE_ON : (1 - LED_STATE_ON));
|
||||||
|
HAL_GPIO_WritePin(LED_PORT, LED_PIN, pin_state);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t board_button_read(void) {
|
uint32_t board_button_read(void) {
|
||||||
@@ -142,7 +143,7 @@ uint32_t board_millis(void) {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
void HardFault_Handler(void) {
|
void HardFault_Handler(void) {
|
||||||
asm("bkpt");
|
asm("bkpt 0");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Required by __libc_init_array in startup code if we are compiling using
|
// Required by __libc_init_array in startup code if we are compiling using
|
||||||
|
@@ -203,7 +203,8 @@ void board_init(void) {
|
|||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
|
|
||||||
void board_led_write(bool state) {
|
void board_led_write(bool state) {
|
||||||
HAL_GPIO_WritePin(LED_PORT, LED_PIN, state ? LED_STATE_ON : (1 - LED_STATE_ON));
|
GPIO_PinState pin_state = (GPIO_PinState) (state ? LED_STATE_ON : (1 - LED_STATE_ON));
|
||||||
|
HAL_GPIO_WritePin(LED_PORT, LED_PIN, pin_state);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t board_button_read(void) {
|
uint32_t board_button_read(void) {
|
||||||
|
@@ -136,7 +136,8 @@ void board_init(void) {
|
|||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
|
|
||||||
void board_led_write(bool state) {
|
void board_led_write(bool state) {
|
||||||
HAL_GPIO_WritePin(LED_PORT, LED_PIN, state ? LED_STATE_ON : (1 - LED_STATE_ON));
|
GPIO_PinState pin_state = (GPIO_PinState) (state ? LED_STATE_ON : (1 - LED_STATE_ON));
|
||||||
|
HAL_GPIO_WritePin(LED_PORT, LED_PIN, pin_state);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t board_button_read(void) {
|
uint32_t board_button_read(void) {
|
||||||
@@ -174,7 +175,7 @@ uint32_t board_millis(void) {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
void HardFault_Handler(void) {
|
void HardFault_Handler(void) {
|
||||||
asm("bkpt");
|
asm("bkpt 1");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Required by __libc_init_array in startup code if we are compiling using
|
// Required by __libc_init_array in startup code if we are compiling using
|
||||||
|
104
tools/build.py
104
tools/build.py
@@ -1,4 +1,5 @@
|
|||||||
import argparse
|
import argparse
|
||||||
|
import random
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
@@ -96,32 +97,61 @@ def build_board_cmake(board, toolchain):
|
|||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
|
||||||
def build_family(family, toolchain, build_system):
|
def build_board_make_all_examples(board, toolchain, all_examples):
|
||||||
all_boards = []
|
start_time = time.monotonic()
|
||||||
for entry in os.scandir(f"hw/bsp/{family}/boards"):
|
|
||||||
if entry.is_dir() and entry.name != 'pico_sdk':
|
|
||||||
all_boards.append(entry.name)
|
|
||||||
all_boards.sort()
|
|
||||||
|
|
||||||
# success, failed, skipped
|
|
||||||
ret = [0, 0, 0]
|
ret = [0, 0, 0]
|
||||||
if build_system == 'cmake':
|
|
||||||
for board in all_boards:
|
|
||||||
if build_board_cmake(board, toolchain):
|
|
||||||
ret[0] += 1
|
|
||||||
else:
|
|
||||||
ret[1] += 1
|
|
||||||
elif build_system == 'make':
|
|
||||||
all_examples = get_examples(family)
|
|
||||||
for example in all_examples:
|
|
||||||
with Pool(processes=os.cpu_count()) as pool:
|
with Pool(processes=os.cpu_count()) as pool:
|
||||||
pool_args = list((map(lambda b, e=example, o=f"TOOLCHAIN={toolchain}": [e, b, o], all_boards)))
|
pool_args = list((map(lambda e, b=board, o=f"TOOLCHAIN={toolchain}": [e, b, o], all_examples)))
|
||||||
r = pool.starmap(build_utils.build_example, pool_args)
|
r = pool.starmap(build_utils.build_example, pool_args)
|
||||||
# sum all element of same index (column sum)
|
# sum all element of same index (column sum)
|
||||||
rsum = list(map(sum, list(zip(*r))))
|
rsum = list(map(sum, list(zip(*r))))
|
||||||
ret[0] += rsum[0]
|
ret[0] += rsum[0]
|
||||||
ret[1] += rsum[1]
|
ret[1] += rsum[1]
|
||||||
ret[2] += rsum[2]
|
ret[2] += rsum[2]
|
||||||
|
duration = time.monotonic() - start_time
|
||||||
|
if ret[1] == 0:
|
||||||
|
status = SUCCEEDED
|
||||||
|
else:
|
||||||
|
status = FAILED
|
||||||
|
|
||||||
|
flash_size = "-"
|
||||||
|
sram_size = "-"
|
||||||
|
example = 'all'
|
||||||
|
title = build_utils.build_format.format(example, board, status, "{:.2f}s".format(duration), flash_size, sram_size)
|
||||||
|
print(title)
|
||||||
|
return ret
|
||||||
|
|
||||||
|
|
||||||
|
def build_family(family, toolchain, build_system, one_per_family, boards):
|
||||||
|
all_boards = []
|
||||||
|
for entry in os.scandir(f"hw/bsp/{family}/boards"):
|
||||||
|
if entry.is_dir() and entry.name != 'pico_sdk':
|
||||||
|
all_boards.append(entry.name)
|
||||||
|
all_boards.sort()
|
||||||
|
|
||||||
|
ret = [0, 0, 0]
|
||||||
|
|
||||||
|
# If only-one flag is set, select one random board
|
||||||
|
if one_per_family:
|
||||||
|
for b in boards:
|
||||||
|
# skip if -b already specify one in this family
|
||||||
|
if find_family(b) == family:
|
||||||
|
return ret
|
||||||
|
all_boards = [random.choice(all_boards)]
|
||||||
|
|
||||||
|
# success, failed, skipped
|
||||||
|
all_examples = get_examples(family)
|
||||||
|
for board in all_boards:
|
||||||
|
r = [0, 0, 0]
|
||||||
|
if build_system == 'cmake':
|
||||||
|
r = build_board_cmake(board, toolchain)
|
||||||
|
elif build_system == 'make':
|
||||||
|
r = build_board_make_all_examples(board, toolchain, all_examples)
|
||||||
|
ret[0] += r[0]
|
||||||
|
ret[1] += r[1]
|
||||||
|
ret[2] += r[2]
|
||||||
|
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
|
||||||
@@ -131,12 +161,14 @@ def main():
|
|||||||
parser.add_argument('-b', '--board', action='append', default=[], help='Boards to build')
|
parser.add_argument('-b', '--board', action='append', default=[], help='Boards to build')
|
||||||
parser.add_argument('-t', '--toolchain', default='gcc', help='Toolchain to use, default is gcc')
|
parser.add_argument('-t', '--toolchain', default='gcc', help='Toolchain to use, default is gcc')
|
||||||
parser.add_argument('-s', '--build-system', default='cmake', help='Build system to use, default is cmake')
|
parser.add_argument('-s', '--build-system', default='cmake', help='Build system to use, default is cmake')
|
||||||
|
parser.add_argument('-1', '--one-per-family', action='store_true', default=False, help='Build only one random board inside a family')
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
families = args.families
|
families = args.families
|
||||||
boards = args.board
|
boards = args.board
|
||||||
toolchain = args.toolchain
|
toolchain = args.toolchain
|
||||||
build_system = args.build_system
|
build_system = args.build_system
|
||||||
|
one_per_family = args.one_per_family
|
||||||
|
|
||||||
if len(families) == 0 and len(boards) == 0:
|
if len(families) == 0 and len(boards) == 0:
|
||||||
print("Please specify families or board to build")
|
print("Please specify families or board to build")
|
||||||
@@ -145,10 +177,9 @@ def main():
|
|||||||
print(build_separator)
|
print(build_separator)
|
||||||
print(build_utils.build_format.format('Example', 'Board', '\033[39mResult\033[0m', 'Time', 'Flash', 'SRAM'))
|
print(build_utils.build_format.format('Example', 'Board', '\033[39mResult\033[0m', 'Time', 'Flash', 'SRAM'))
|
||||||
total_time = time.monotonic()
|
total_time = time.monotonic()
|
||||||
total_result = [0, 0, 0]
|
result = [0, 0, 0]
|
||||||
|
|
||||||
# build families: cmake, make
|
# build families
|
||||||
if families is not None:
|
|
||||||
all_families = []
|
all_families = []
|
||||||
if 'all' in families:
|
if 'all' in families:
|
||||||
for entry in os.scandir("hw/bsp"):
|
for entry in os.scandir("hw/bsp"):
|
||||||
@@ -160,35 +191,28 @@ def main():
|
|||||||
|
|
||||||
# succeeded, failed
|
# succeeded, failed
|
||||||
for f in all_families:
|
for f in all_families:
|
||||||
fret = build_family(f, toolchain, build_system)
|
fret = build_family(f, toolchain, build_system, one_per_family, boards)
|
||||||
total_result[0] += fret[0]
|
result[0] += fret[0]
|
||||||
total_result[1] += fret[1]
|
result[1] += fret[1]
|
||||||
total_result[2] += fret[2]
|
result[2] += fret[2]
|
||||||
|
|
||||||
# build board (only cmake)
|
# build boards
|
||||||
if boards is not None:
|
|
||||||
for b in boards:
|
for b in boards:
|
||||||
|
r = [0, 0, 0]
|
||||||
if build_system == 'cmake':
|
if build_system == 'cmake':
|
||||||
r = build_board_cmake(b, toolchain)
|
r = build_board_cmake(b, toolchain)
|
||||||
total_result[0] += r[0]
|
|
||||||
total_result[1] += r[1]
|
|
||||||
total_result[2] += r[2]
|
|
||||||
elif build_system == 'make':
|
elif build_system == 'make':
|
||||||
all_examples = get_examples(find_family(b))
|
all_examples = get_examples(find_family(b))
|
||||||
with Pool(processes=os.cpu_count()) as pool:
|
r = build_board_make_all_examples(b, toolchain, all_examples)
|
||||||
pool_args = list((map(lambda e, bb=b, o=f"TOOLCHAIN={toolchain}": [e, bb, o], all_examples)))
|
result[0] += r[0]
|
||||||
r = pool.starmap(build_utils.build_example, pool_args)
|
result[1] += r[1]
|
||||||
# sum all element of same index (column sum)
|
result[2] += r[2]
|
||||||
rsum = list(map(sum, list(zip(*r))))
|
|
||||||
total_result[0] += rsum[0]
|
|
||||||
total_result[1] += rsum[1]
|
|
||||||
total_result[2] += rsum[2]
|
|
||||||
|
|
||||||
total_time = time.monotonic() - total_time
|
total_time = time.monotonic() - total_time
|
||||||
print(build_separator)
|
print(build_separator)
|
||||||
print(f"Build Summary: {total_result[0]} {SUCCEEDED}, {total_result[1]} {FAILED} and took {total_time:.2f}s")
|
print(f"Build Summary: {result[0]} {SUCCEEDED}, {result[1]} {FAILED} and took {total_time:.2f}s")
|
||||||
print(build_separator)
|
print(build_separator)
|
||||||
return total_result[1]
|
return result[1]
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
Reference in New Issue
Block a user