update circle ci to build make (#2769)

* update build.py script to work with circleci
* build make with circle ci
* build vm for esp only
* nrf imxrt with large resource
* nrf imxrt with large resource
* remove 2 of nrf boards
This commit is contained in:
Ha Thach 2024-08-21 19:09:37 +07:00 committed by GitHub
parent 5f519819ba
commit 6118700828
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
14 changed files with 292 additions and 368 deletions

View File

@ -18,16 +18,52 @@ jobs:
MATRIX_JSON=$(python .github/workflows/ci_set_matrix.py)
echo "MATRIX_JSON=$MATRIX_JSON"
TOOLCHAIN_LIST=("arm-clang" "arm-gcc")
for toolchain in "${TOOLCHAIN_LIST[@]}"; do
BUILDSYSTEM_TOOLCHAIN=(
"cmake arm-clang"
"make aarch64-gcc"
"make arm-gcc"
"make msp430-gcc"
"make riscv-gcc"
# "make rx-gcc" llvm-gcc-renesas.com seems to be down
"cmake esp-idf"
)
RESOURCE_LARGE='["nrf", "imxrt"]'
for e in "${BUILDSYSTEM_TOOLCHAIN[@]}"; do
e_arr=($e)
build_system="${e_arr[0]}"
toolchain="${e_arr[1]}"
FAMILY=$(echo $MATRIX_JSON | jq -r ".\"$toolchain\".family")
echo "${toolchain}_FAMILY=$FAMILY"
echo " - build:" >> .circleci/config2.yml
echo "FAMILY_${toolchain}=$FAMILY"
# FAMILY_LARGE = FAMILY - RESOURCE_LARGE
# Separate large from medium+ resources
FAMILY_LARGE=$(jq -n --argjson family "$FAMILY" --argjson resource "$RESOURCE_LARGE" '$family | map(select(IN($resource[])))')
FAMILY=$(jq -n --argjson family "$FAMILY" --argjson resource "$RESOURCE_LARGE" '$family | map(select(IN($resource[]) | not))')
if [[ $toolchain == esp-idf ]]; then
echo " - build-vm:" >> .circleci/config2.yml
else
echo " - build:" >> .circleci/config2.yml
fi
echo " matrix:" >> .circleci/config2.yml
echo " parameters:" >> .circleci/config2.yml
echo " build-system: ['$build_system']" >> .circleci/config2.yml
echo " toolchain: ['$toolchain']" >> .circleci/config2.yml
echo " build-system: ['cmake']" >> .circleci/config2.yml
echo " family: $FAMILY" >> .circleci/config2.yml
#echo " resource_class: ['medium+']" >> .circleci/config2.yml
# add large resources
if [ "$(echo $FAMILY_LARGE | jq 'length')" -gt 0 ]; then
echo " - build:" >> .circleci/config2.yml
echo " matrix:" >> .circleci/config2.yml
echo " parameters:" >> .circleci/config2.yml
echo " build-system: ['$build_system']" >> .circleci/config2.yml
echo " toolchain: ['$toolchain']" >> .circleci/config2.yml
echo " family: $FAMILY_LARGE" >> .circleci/config2.yml
echo " resource_class: ['large']" >> .circleci/config2.yml
fi
done
- continuation/continue:

View File

@ -5,42 +5,58 @@ commands:
parameters:
toolchain:
type: string
steps:
- run:
name: Set toolchain url and key
command: |
TOOLCHAIN_JSON='{
"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-gcc": "https://github.com/xpack-dev-tools/arm-none-eabi-gcc-xpack/releases/download/v12.3.1-1.1/xpack-arm-none-eabi-gcc-12.3.1-1.1-linux-x64.tar.gz",
"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-elf-gcc-xpack/releases/download/v13.2.0-2/xpack-riscv-none-elf-gcc-13.2.0-2-linux-x64.tar.gz",
"rx-gcc": "https://llvm-gcc-renesas.com/downloads/get.php?f=rx/8.3.0.202004-gnurx/gcc-8.3.0.202004-GNURX-ELF.run"
}'
toolchain_url=$(echo $TOOLCHAIN_JSON | jq -r '.["<< parameters.toolchain >>"]')
# only cache if not a github link
if [[ $toolchain_url != "https://github.com"* ]]; then
echo "<< parameters.toolchain >>-$toolchain_url" > toolchain_key
fi
echo "export toolchain_url=$toolchain_url" >> $BASH_ENV
- restore_cache:
name: Restore Toolchain Cache
key: deps-{{ checksum "toolchain_key" }}
paths:
- ~/cache/<< parameters.toolchain >>
- run:
name: Install Toolchain
command: |
TOOLCHAIN_JSON='{
"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-gcc": "https://github.com/xpack-dev-tools/arm-none-eabi-gcc-xpack/releases/download/v12.3.1-1.1/xpack-arm-none-eabi-gcc-12.3.1-1.1-linux-x64.tar.gz"
}'
toolchain_url=$(echo $TOOLCHAIN_JSON | jq -r '.["<< parameters.toolchain >>"]')
echo "toolchain_url=$toolchain_url"
# download and extract toolchain
mkdir -p ~/cache/<< parameters.toolchain >>
wget $toolchain_url -O toolchain.tar.gz
tar -C ~/cache/<< parameters.toolchain >> -xaf toolchain.tar.gz
# download if folder does not exist (not cached)
if [ ! -d ~/cache/<< parameters.toolchain >> ]; then
mkdir -p ~/cache/<< parameters.toolchain >>
wget --progress=dot:giga $toolchain_url -O toolchain.tar.gz
if [[ << parameters.toolchain >> == rx-gcc ]]; then
mv toolchain.tar.gz toolchain.run
chmod +x toolchain.run
./toolchain.run -p ~/cache/<< parameters.toolchain >>/gnurx -y
else
tar -C ~/cache/<< parameters.toolchain >> -xaf toolchain.tar.gz
fi
fi
# Add toolchain to PATH
echo "export PATH=$PATH:`echo ~/cache/<< parameters.toolchain >>/*/bin`" >> $BASH_ENV
get-deps:
parameters:
family:
type: string
steps:
- run:
name: Get Dependencies
command: |
python tools/get_deps.py << parameters.family >>
- save_cache:
name: Save Toolchain Cache
key: deps-{{ checksum "toolchain_key" }}
paths:
- ~/cache/<< parameters.toolchain >>
# Install Pico SDK
if [ << parameters.family >> == "rp2040" ]; then
git clone --depth 1 https://github.com/raspberrypi/pico-sdk.git ~/pico-sdk
echo "export PICO_SDK_PATH=~/pico-sdk" >> $BASH_ENV
fi
jobs:
build:
parameters:
build-system:
@ -50,42 +66,102 @@ jobs:
family:
type: string
docker:
- image: cimg/base:current
resource_class: medium+
steps:
- checkout
- when:
condition: << parameters.build-system >> == 'cmake'
condition:
not:
equal: [esp-idf, << parameters.toolchain >>]
steps:
- run:
name: Install Ninja
command: |
# Install Ninja
NINJA_URL=https://github.com/ninja-build/ninja/releases/download/v1.12.1/ninja-linux.zip
wget $NINJA_URL -O ninja-linux.zip
unzip ninja-linux.zip -d ~/bin
- setup-toolchain:
toolchain: << parameters.toolchain >>
- get-deps:
family: << parameters.family >>
- setup-toolchain:
toolchain: << parameters.toolchain >>
- run:
name: Get Dependencies
command: |
python tools/get_deps.py << parameters.family >>
# Install ninja if cmake build system
if [ << parameters.build-system >> == "cmake" ]; then
NINJA_URL=https://github.com/ninja-build/ninja/releases/download/v1.12.1/ninja-linux.zip
wget $NINJA_URL -O ninja-linux.zip
unzip ninja-linux.zip -d ~/bin
fi
# Install Pico SDK
if [ << parameters.family >> == "rp2040" ]; then
git clone --depth 1 https://github.com/raspberrypi/pico-sdk.git ~/pico-sdk
echo "export PICO_SDK_PATH=~/pico-sdk" >> $BASH_ENV
fi
- run:
name: Build
command: |
# Only build one board per family for non PRs i.e commit to master
ONE_PER_FAMILY=""
if [ -z "$CIRCLE_PULL_REQUEST" ]; then
ONE_PER_FAMILY="--one-per-family"
if [ << parameters.toolchain >> == esp-idf ]; then
docker run --rm -v $PWD:/project -w /project espressif/idf:v5.1.1 python tools/build.py << parameters.family >>
else
# Only build one board per family for non PRs i.e commit to master
ONE_PER_FAMILY=""
if [ -z "$CIRCLE_PULL_REQUEST" ]; then
ONE_PER_FAMILY="--one-per-family"
fi
# Toolchain option default is gcc
if [ << parameters.toolchain >> == arm-clang ]; then
TOOLCHAIN_OPTION="--toolchain clang"
elif [ << parameters.toolchain >> == arm-gcc ]; then
TOOLCHAIN_OPTION="--toolchain gcc"
fi
python tools/build.py $ONE_PER_FAMILY -s << parameters.build-system >> $TOOLCHAIN_OPTION << parameters.family >>
fi
# Toolchain option default is gcc
if [ "<< parameters.toolchain >>" == "arm-clang" ]; then
TOOLCHAIN_OPTION="--toolchain clang"
elif [ "<< parameters.toolchain >>" == "arm-gcc" ]; then
TOOLCHAIN_OPTION="--toolchain gcc"
fi
jobs:
# Build using docker
build:
parameters:
resource_class:
type: string
default: medium+
build-system:
type: string
toolchain:
type: string
family:
type: string
python tools/build.py $ONE_PER_FAMILY -s << parameters.build-system >> $TOOLCHAIN_OPTION << parameters.family >>
docker:
- image: cimg/base:current
resource_class: << parameters.resource_class >>
steps:
- build:
build-system: << parameters.build-system >>
toolchain: << parameters.toolchain >>
family: << parameters.family >>
# Build using VM
build-vm:
parameters:
resource_class:
type: string
default: large
build-system:
type: string
toolchain:
type: string
family:
type: string
machine:
image: ubuntu-2404:current
resource_class: << parameters.resource_class >>
steps:
- build:
build-system: << parameters.build-system >>
toolchain: << parameters.toolchain >>
family: << parameters.family >>
workflows:
build:
@ -93,6 +169,14 @@ workflows:
# - build:
# matrix:
# parameters:
# toolchain: ['arm-clang']
# toolchain: [ 'arm-gcc' ]
# build-system: [ 'cmake' ]
# family: [ 'nrf' ]
# resource_class: ['large']
# - build-vm:
# matrix:
# parameters:
# toolchain: ['esp-idf']
# build-system: ['cmake']
# family: ['imxrt']
# family: ['-bespressif_kaluga_1']
# resource_class: ['large']

View File

@ -51,7 +51,6 @@ jobs:
# Build CMake
# ---------------------------------------
cmake:
# if: false
needs: set-matrix
uses: ./.github/workflows/build_util.yml
strategy:
@ -60,6 +59,7 @@ jobs:
toolchain:
# - 'arm-clang' is built by circle-ci in PR
- 'aarch64-gcc'
- 'arm-gcc'
- 'msp430-gcc'
- 'riscv-gcc'
with:
@ -69,41 +69,28 @@ jobs:
one-per-family: ${{ github.event_name == 'push' }}
# ---------------------------------------
# Build CMake arm-gcc
# only build with push, for PR: all board is built by circle-ci
# ---------------------------------------
cmake-arm-gcc:
if: github.event_name == 'push'
needs: set-matrix
uses: ./.github/workflows/build_util.yml
with:
build-system: 'cmake'
toolchain: 'arm-gcc'
build-args: ${{ toJSON(fromJSON(needs.set-matrix.outputs.json)['arm-gcc'].family) }}
one-per-family: true
# ---------------------------------------
# Build Make
# Build Make (built by circle-ci in PR, only build on push here)
# ---------------------------------------
make:
# if: false
if: github.event_name == 'push'
needs: set-matrix
uses: ./.github/workflows/build_util.yml
strategy:
fail-fast: false
matrix:
toolchain:
# 'arm-clang' would be built by circle-ci
- 'aarch64-gcc'
# 'arm-clang'
- 'arm-gcc'
- 'aarch64-gcc'
- 'msp430-gcc'
- 'riscv-gcc'
- 'rx-gcc'
- 'esp-idf' # buid-system is ignored
with:
build-system: 'make'
toolchain: ${{ matrix.toolchain }}
build-args: ${{ toJSON(fromJSON(needs.set-matrix.outputs.json)[matrix.toolchain].family) }}
one-per-family: ${{ github.event_name == 'push' }}
one-per-family: true
# ---------------------------------------
# Build Make on Windows/MacOS
@ -122,29 +109,10 @@ jobs:
build-args: '["stm32h7"]'
one-per-family: true
# ---------------------------------------
# Build Espressif
# ---------------------------------------
espressif:
# if: false
uses: ./.github/workflows/build_util.yml
strategy:
fail-fast: false
matrix:
board:
- 'espressif_kaluga_1'
- 'espressif_s3_devkitm'
with:
build-system: 'cmake'
toolchain: 'esp-idf'
toolchain_version: 'v5.1.1'
build-args: '["-b${{ matrix.board }}"]'
# ---------------------------------------
# Build IAR on HFP self-hosted
# ---------------------------------------
arm-iar:
# if: false
if: github.repository_owner == 'hathach'
needs: set-matrix
runs-on: [self-hosted, Linux, X64, hifiphile]

View File

@ -9,9 +9,6 @@ on:
toolchain:
required: true
type: string
toolchain_version:
required: false
type: string
build-args:
required: true
type: string
@ -40,7 +37,7 @@ jobs:
uses: ./.github/actions/setup_toolchain
with:
toolchain: ${{ inputs.toolchain }}
toolchain_version: ${{ inputs.toolchain_version }}
toolchain_version: 'v5.1.1'
- name: Get Dependencies
uses: ./.github/actions/get_deps
@ -60,7 +57,7 @@ jobs:
- name: Build
run: |
if [ "${{ inputs.toolchain }}" == "esp-idf" ]; then
docker run --rm -v $PWD:/project -w /project espressif/idf:${{ inputs.toolchain_version }} python3 tools/build.py ${{ matrix.arg }}
docker run --rm -v $PWD:/project -w /project espressif/idf:v5.1.1 python tools/build.py ${{ matrix.arg }}
else
python tools/build.py -s ${{ inputs.build-system }} ${{ steps.setup-toolchain.outputs.build_option }} ${{ steps.set-one-per-family.outputs.build_option }} ${{ matrix.arg }}
fi

View File

@ -6,6 +6,7 @@ toolchain_list = [
"arm-clang",
"arm-iar",
"arm-gcc",
"esp-idf",
"msp430-gcc",
"riscv-gcc",
"rx-gcc"
@ -31,15 +32,19 @@ family_list = {
"ra": ["arm-gcc"],
"rp2040": ["arm-gcc"],
"rx": ["rx-gcc"],
"samd11 samd21 saml2x": ["arm-gcc", "arm-clang"],
"samd11 saml2x": ["arm-gcc", "arm-clang"],
"samd21": ["arm-gcc", "arm-clang"],
"samd5x_e5x samg": ["arm-gcc", "arm-clang"],
"stm32f0 stm32f1 stm32f2 stm32f3": ["arm-gcc", "arm-clang", "arm-iar"],
"stm32f4": ["arm-gcc", "arm-clang", "arm-iar"],
"stm32f7": ["arm-gcc", "arm-clang", "arm-iar"],
"stm32g0 stm32g4 stm32h5": ["arm-gcc", "arm-clang", "arm-iar"],
"stm32h7": ["arm-gcc", "arm-clang", "arm-iar"],
"stm32l0 stm32l4 stm32u5 stm32wb": ["arm-gcc", "arm-clang", "arm-iar"],
"stm32l0 stm32l4": ["arm-gcc", "arm-clang", "arm-iar"],
"stm32u5 stm32wb": ["arm-gcc", "arm-clang", "arm-iar"],
"xmc4000": ["arm-gcc"],
"-bespressif_kaluga_1": ["esp-idf"],
"-bespressif_s3_devkitm": ["esp-idf"],
}

View File

@ -1,5 +0,0 @@
set(MCU_VARIANT nrf52840)
set(LD_FILE_GNU ${CMAKE_CURRENT_LIST_DIR}/nrf52840_mdk_dongle.ld)
function(update_board TARGET)
endfunction()

View File

@ -1,52 +0,0 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2020, Ha Thach (tinyusb.org)
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* This file is part of the TinyUSB stack.
*/
#ifndef BOARD_H_
#define BOARD_H_
#ifdef __cplusplus
extern "C" {
#endif
#define _PINNUM(port, pin) ((port)*32 + (pin))
// LED
#define LED_PIN _PINNUM(0, 23)
#define LED_STATE_ON 0
// Button
#define BUTTON_PIN _PINNUM(0, 18)
#define BUTTON_STATE_ACTIVE 0
// UART
#define UART_RX_PIN 2
#define UART_TX_PIN 3
#ifdef __cplusplus
}
#endif
#endif /* BOARD_H_ */

View File

@ -1,15 +0,0 @@
MCU_VARIANT = nrf52840
CFLAGS += -DNRF52840_XXAA
LD_FILE = $(BOARD_PATH)/$(BOARD).ld
# flash using Nordic nrfutil (pip3 install nrfutil)
# make BOARD=nrf52840_mdk_dongle SERIAL=/dev/ttyACM0 all flash
NRFUTIL = nrfutil
$(BUILD)/$(PROJECT).zip: $(BUILD)/$(PROJECT).hex
$(NRFUTIL) pkg generate --hw-version 52 --sd-req 0x0000 --debug-mode --application $^ $@
flash: $(BUILD)/$(PROJECT).zip
@:$(call check_defined, SERIAL, example: SERIAL=/dev/ttyACM0)
$(NRFUTIL) dfu usb-serial --package $^ -p $(SERIAL) -b 115200

View File

@ -1,13 +0,0 @@
/* Linker script to configure memory regions. */
SEARCH_DIR(.)
/*GROUP(-lgcc -lc -lnosys) not compatible with clang*/
MEMORY
{
FLASH (rx) : ORIGIN = 0x1000, LENGTH = 0xE0000-0x1000
RAM (rwx) : ORIGIN = 0x20000008, LENGTH = 0x3fff8
}
INCLUDE "nrf_common.ld"

View File

@ -1,4 +0,0 @@
set(MCU_VARIANT nrf52840)
function(update_board TARGET)
endfunction()

View File

@ -1,52 +0,0 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2020, Ha Thach (tinyusb.org)
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* This file is part of the TinyUSB stack.
*/
#ifndef BOARD_H_
#define BOARD_H_
#ifdef __cplusplus
extern "C" {
#endif
#define _PINNUM(port, pin) ((port)*32 + (pin))
// LED
#define LED_PIN _PINNUM(1, 13)
#define LED_STATE_ON 0
// Button
#define BUTTON_PIN _PINNUM(0, 15)
#define BUTTON_STATE_ACTIVE 0
// UART
#define UART_RX_PIN 25
#define UART_TX_PIN 24
#ifdef __cplusplus
}
#endif
#endif /* BOARD_H_ */

View File

@ -1,7 +0,0 @@
MCU_VARIANT = nrf52840
CFLAGS += -DNRF52840_XXAA
LD_FILE = hw/mcu/nordic/nrfx/mdk/nrf52840_xxaa.ld
# flash using jlink
flash: flash-jlink

View File

@ -9,19 +9,29 @@ from multiprocessing import Pool
import build_utils
SUCCEEDED = "\033[32msucceeded\033[0m"
FAILED = "\033[31mfailed\033[0m"
STATUS_OK = "\033[32mOK\033[0m"
STATUS_FAILED = "\033[31mFailed\033[0m"
STATUS_SKIPPED = "\033[33mSkipped\033[0m"
build_separator = '-' * 106
RET_OK = 0
RET_FAILED = 1
RET_SKIPPED = 2
build_format = '| {:30} | {:40} | {:16} | {:5} |'
build_separator = '-' * 95
build_status = [STATUS_OK, STATUS_FAILED, STATUS_SKIPPED]
# -----------------------------
# Helper
# -----------------------------
def run_cmd(cmd):
#print(cmd)
r = subprocess.run(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
title = 'command error'
title = f'Command Error: {cmd}'
if r.returncode != 0:
# print build output if failed
if os.getenv('CI'):
if os.getenv('GITHUB_ACTIONS'):
print(f"::group::{title}")
print(r.stdout.decode("utf-8"))
print(f"::endgroup::")
@ -30,6 +40,7 @@ def run_cmd(cmd):
print(r.stdout.decode("utf-8"))
return r
def find_family(board):
bsp_dir = Path("hw/bsp")
for family_dir in bsp_dir.iterdir():
@ -56,70 +67,91 @@ def get_examples(family):
return all_examples
def build_board_cmake(board, toolchain):
start_time = time.monotonic()
ret = [0, 0, 0]
def print_build_result(board, example, status, duration):
if isinstance(duration, (int, float)):
duration = "{:.2f}s".format(duration)
print(build_format.format(board, example, build_status[status], duration))
# -----------------------------
# CMake
# -----------------------------
def cmake_board(board, toolchain):
ret = [0, 0, 0]
start_time = time.monotonic()
build_dir = f"cmake-build/cmake-build-{board}"
family = find_family(board)
if family == 'espressif':
# for espressif, we have to build example individually
all_examples = get_examples(family)
for example in all_examples:
r = run_cmd(f'cmake examples/{example} -B {build_dir}/{example} -G "Ninja" -DBOARD={board} -DMAX3421_HOST=1')
if r.returncode == 0:
r = run_cmd(f'cmake --build {build_dir}/{example}')
if r.returncode == 0:
ret[0] += 1
else:
ret[1] += 1
rcmd = run_cmd(f'cmake examples/{example} -B {build_dir}/{example} -G "Ninja" -DBOARD={board} -DMAX3421_HOST=1')
if rcmd.returncode == 0:
rcmd = run_cmd(f'cmake --build {build_dir}/{example}')
ret[0 if rcmd.returncode == 0 else 1] += 1
else:
r = run_cmd(f'cmake examples -B {build_dir} -G "Ninja" -DBOARD={board} -DCMAKE_BUILD_TYPE=MinSizeRel -DTOOLCHAIN={toolchain}')
if r.returncode == 0:
r = run_cmd(f"cmake --build {build_dir}")
if r.returncode == 0:
ret[0] += 1
else:
ret[1] += 1
rcmd = run_cmd(f'cmake examples -B {build_dir} -G "Ninja" -DBOARD={board} -DCMAKE_BUILD_TYPE=MinSizeRel -DTOOLCHAIN={toolchain}')
if rcmd.returncode == 0:
rcmd = run_cmd(f"cmake --build {build_dir}")
ret[0 if rcmd.returncode == 0 else 1] += 1
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)
print_build_result(board, example, 0 if ret[1] == 0 else 1, time.monotonic() - start_time)
return ret
def build_board_make_all_examples(board, toolchain, all_examples):
# -----------------------------
# Make
# -----------------------------
def make_one_example(example, board, make_option):
# Check if board is skipped
if build_utils.skip_example(example, board):
print_build_result(board, example, 2, '-')
r = 2
else:
start_time = time.monotonic()
# skip -j for circleci
if not os.getenv('CIRCLECI'):
make_option += ' -j'
make_cmd = f"make -C examples/{example} BOARD={board} {make_option}"
# run_cmd(f"{make_cmd} clean")
build_result = run_cmd(f"{make_cmd} all")
r = 0 if build_result.returncode == 0 else 1
print_build_result(board, example, r, time.monotonic() - start_time)
ret = [0, 0, 0]
ret[r] = 1
return ret
def make_board(board, toolchain):
print(build_separator)
all_examples = get_examples(find_family(board))
start_time = time.monotonic()
ret = [0, 0, 0]
with Pool(processes=os.cpu_count()) as pool:
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(make_one_example, pool_args)
# sum all element of same index (column sum)
rsum = list(map(sum, list(zip(*r))))
ret[0] += rsum[0]
ret[1] += rsum[1]
ret[2] += rsum[2]
duration = time.monotonic() - start_time
if ret[1] == 0:
status = SUCCEEDED
else:
status = FAILED
flash_size = "-"
sram_size = "-"
ret = list(map(sum, list(zip(*r))))
example = 'all'
title = build_utils.build_format.format(example, board, status, "{:.2f}s".format(duration), flash_size, sram_size)
print(title)
print_build_result(board, example, 0 if ret[1] == 0 else 1, time.monotonic() - start_time)
return ret
# -----------------------------
# Build Family
# -----------------------------
def build_boards_list(boards, toolchain, build_system):
ret = [0, 0, 0]
for b in boards:
r = [0, 0, 0]
if build_system == 'cmake':
r = cmake_board(b, toolchain)
elif build_system == 'make':
r = make_board(b, toolchain)
ret[0] += r[0]
ret[1] += r[1]
ret[2] += r[2]
return ret
@ -131,7 +163,6 @@ def build_family(family, toolchain, build_system, one_per_family, boards):
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:
@ -140,21 +171,13 @@ def build_family(family, toolchain, build_system, one_per_family, boards):
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]
ret = build_boards_list(all_boards, toolchain, build_system)
return ret
# -----------------------------
# Main
# -----------------------------
def main():
parser = argparse.ArgumentParser()
parser.add_argument('families', nargs='*', default=[], help='Families to build')
@ -175,7 +198,7 @@ def main():
return 1
print(build_separator)
print(build_utils.build_format.format('Example', 'Board', '\033[39mResult\033[0m', 'Time', 'Flash', 'SRAM'))
print(build_format.format('Board', 'Example', '\033[39mResult\033[0m', 'Time'))
total_time = time.monotonic()
result = [0, 0, 0]
@ -189,28 +212,22 @@ def main():
all_families = list(families)
all_families.sort()
# succeeded, failed
# succeeded, failed, skipped
for f in all_families:
fret = build_family(f, toolchain, build_system, one_per_family, boards)
result[0] += fret[0]
result[1] += fret[1]
result[2] += fret[2]
# build boards
for b in boards:
r = [0, 0, 0]
if build_system == 'cmake':
r = build_board_cmake(b, toolchain)
elif build_system == 'make':
all_examples = get_examples(find_family(b))
r = build_board_make_all_examples(b, toolchain, all_examples)
r = build_family(f, toolchain, build_system, one_per_family, boards)
result[0] += r[0]
result[1] += r[1]
result[2] += r[2]
# build boards
r = build_boards_list(boards, toolchain, build_system)
result[0] += r[0]
result[1] += r[1]
result[2] += r[2]
total_time = time.monotonic() - total_time
print(build_separator)
print(f"Build Summary: {result[0]} {SUCCEEDED}, {result[1]} {FAILED} and took {total_time:.2f}s")
print(f"Build Summary: {result[0]} {STATUS_OK}, {result[1]} {STATUS_FAILED} and took {total_time:.2f}s")
print(build_separator)
return result[1]

View File

@ -92,38 +92,3 @@ def build_size(make_cmd):
return (flash_size, sram_size)
return (0, 0)
def build_example(example, board, make_option):
start_time = time.monotonic()
flash_size = "-"
sram_size = "-"
# succeeded, failed, skipped
ret = [0, 0, 0]
make_cmd = f"make -j -C examples/{example} BOARD={board} {make_option}"
# Check if board is skipped
if skip_example(example, board):
status = SKIPPED
ret[2] = 1
print(build_format.format(example, board, status, '-', flash_size, sram_size))
else:
build_result = subprocess.run(f"{make_cmd} all", shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
if build_result.returncode == 0:
status = SUCCEEDED
ret[0] = 1
(flash_size, sram_size) = build_size(make_cmd)
else:
status = FAILED
ret[1] = 1
build_duration = time.monotonic() - start_time
print(build_format.format(example, board, status, "{:.2f}s".format(build_duration), flash_size, sram_size))
if build_result.returncode != 0:
print(build_result.stdout.decode("utf-8"))
return ret