Skip to content

Commit

Permalink
update circle ci to build make (#2769)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
hathach authored Aug 21, 2024
1 parent 5f51981 commit 6118700
Show file tree
Hide file tree
Showing 14 changed files with 274 additions and 350 deletions.
46 changes: 41 additions & 5 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
162 changes: 123 additions & 39 deletions .circleci/config2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,44 +5,124 @@ commands:
parameters:
toolchain:
type: string

steps:
- run:
name: Install Toolchain
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"
"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 >>"]')
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
# 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: |
# 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:
- save_cache:
name: Save Toolchain Cache
key: deps-{{ checksum "toolchain_key" }}
paths:
- ~/cache/<< parameters.toolchain >>

build:
parameters:
build-system:
type: string
toolchain:
type: string
family:
type: string

steps:
- checkout
- when:
condition:
not:
equal: [esp-idf, << parameters.toolchain >>]
steps:
- 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: |
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
jobs:
# Build using docker
build:
parameters:
resource_class:
type: string
default: medium+
build-system:
type: string
toolchain:
Expand All @@ -52,47 +132,51 @@ jobs:

docker:
- image: cimg/base:current
resource_class: medium+
resource_class: << parameters.resource_class >>

steps:
- checkout
- when:
condition: << parameters.build-system >> == 'cmake'
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:
- build:
build-system: << parameters.build-system >>
toolchain: << parameters.toolchain >>
- get-deps:
family: << parameters.family >>
- 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"
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
# Build using VM
build-vm:
parameters:
resource_class:
type: string
default: large
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 >>
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:
jobs:
# - 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']
46 changes: 7 additions & 39 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ jobs:
# Build CMake
# ---------------------------------------
cmake:
# if: false
needs: set-matrix
uses: ./.github/workflows/build_util.yml
strategy:
Expand All @@ -60,6 +59,7 @@ jobs:
toolchain:
# - 'arm-clang' is built by circle-ci in PR
- 'aarch64-gcc'
- 'arm-gcc'
- 'msp430-gcc'
- 'riscv-gcc'
with:
Expand All @@ -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
Expand All @@ -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]
Expand Down
7 changes: 2 additions & 5 deletions .github/workflows/build_util.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ on:
toolchain:
required: true
type: string
toolchain_version:
required: false
type: string
build-args:
required: true
type: string
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
Loading

0 comments on commit 6118700

Please sign in to comment.