Skip to content

Commit

Permalink
build arm-clang on circleci with pull request (#2644)
Browse files Browse the repository at this point in the history
* Build arm-clang using circle ci (only on PR): cache most of mandatory deps, clang toolchain
* update get_deps.py to include CMSIS_5 with --print + no arguments, prevent duplicated deps
  • Loading branch information
hathach authored May 14, 2024
1 parent ae01de2 commit 3c24ba3
Show file tree
Hide file tree
Showing 4 changed files with 102 additions and 29 deletions.
117 changes: 95 additions & 22 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,33 +1,106 @@
# Use the latest 2.1 version of CircleCI pipeline process engine.
# See: https://circleci.com/docs/configuration-reference
version: 2.1

# Define a job to be invoked later in a workflow.
# See: https://circleci.com/docs/jobs-steps/#jobs-overview & https://circleci.com/docs/configuration-reference/#jobs
commands:
setup-toolchain:
parameters:
toolchain:
type: string
toolchain_url:
type: string
steps:
- run:
name: Make toolchain cache key
command: echo "<< parameters.toolchain >>-<< parameters.toolchain_url>>" > toolchain_key
- restore_cache:
name: Restore Toolchain Cache
key: deps-{{ checksum "toolchain_key" }}
paths:
- ~/cache/<< parameters.toolchain >>
- run:
name: Install Toolchain
command: |
# Only download if folder does not exist (not cached)
if [ ! -d ~/cache/<< parameters.toolchain >> ]; then
mkdir -p ~/cache/<< parameters.toolchain >>
wget << parameters.toolchain_url>> -O toolchain.tar.gz
tar -C ~/cache/<< parameters.toolchain >> -xaf toolchain.tar.gz
fi
- save_cache:
name: Save Toolchain Cache
key: deps-{{ checksum "toolchain_key" }}
paths:
- ~/cache/<< parameters.toolchain >>
- run:
name: Setup build environment
command: |
echo "export PATH=$PATH:`echo ~/cache/<< parameters.toolchain >>/*/bin`" >> $BASH_ENV
# 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
get-deps:
parameters:
family:
type: string
steps:
- run:
name: Make deps cache key
command: |
python tools/get_deps.py --print > deps_key
- restore_cache:
name: Restore Dependencies Cache
key: deps-{{ checksum "deps_key" }}
paths:
- lib/CMSIS_5
- lib/FreeRTOS-Kernel
- lib/lwip
- tools/uf2
- run:
name: Get Dependencies
command: |
python tools/get_deps.py << parameters.family >>
- save_cache:
name: Save Dependencies Cache
key: deps-{{ checksum "deps_key" }}
paths:
- lib/CMSIS_5
- lib/FreeRTOS-Kernel
- lib/lwip
- tools/uf2

jobs:
say-hello:
# Specify the execution environment. You can specify an image from Docker Hub or use one of our convenience images from CircleCI's Developer Hub.
# See: https://circleci.com/docs/executor-intro/ & https://circleci.com/docs/configuration-reference/#executor-job
arm-clang:
parameters:
family:
type: string
build-system:
type: string

docker:
# Specify the version you desire here
# See: https://circleci.com/developer/images/image/cimg/base
- image: cimg/base:current

resource_class: small

# Add steps to the job
# See: https://circleci.com/docs/jobs-steps/#steps-overview & https://circleci.com/docs/configuration-reference/#steps
resource_class: medium
environment:
TOOLCHAIN_URL: 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
steps:
# Checkout the code as the first step.
- checkout
- setup-toolchain:
toolchain: clang
toolchain_url: $TOOLCHAIN_URL
- get-deps:
family: << parameters.family >>
- run:
name: "Say hello"
command: "echo Hello, World!"
name: Build
command: python tools/build.py -s << parameters.build-system >> --toolchain clang << parameters.family >>

# Orchestrate jobs using workflows
# See: https://circleci.com/docs/workflows/ & https://circleci.com/docs/configuration-reference/#workflows
workflows:
say-hello-workflow: # This is the name of the workflow, feel free to change it to better match your workflow.
# Inside the workflow, you define the jobs you want to run.
build:
jobs:
- say-hello
- arm-clang:
matrix:
parameters:
build-system:
- cmake
#family: ['stm32f1']
#family: ['stm32f1', 'stm32f2']
family: ['imxrt', 'kinetis_k kinetis_kl kinetis_k32l2', 'lpc11 lpc13 lpc15', 'lpc17 lpc18 lpc40 lpc43', 'lpc51 lpc54 lpc55', 'nrf', 'samd11 samd21 saml2x', 'samd5x_e5x samg', 'stm32f0 stm32f1 stm32f2 stm32f3', 'stm32f4', 'stm32f7', 'stm32g0 stm32g4 stm32h5', 'stm32h7', 'stm32l4 stm32u5 stm32wb']
2 changes: 1 addition & 1 deletion .github/actions/get_deps/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ name: Get dependencies

inputs:
arg:
description: 'Arguments to get_deps.py'
required: true
type: string

runs:
using: "composite"
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ jobs:
matrix:
toolchain:
- 'aarch64-gcc'
# - 'arm-clang'
# - 'arm-clang' # clang is built by circle-ci
- 'arm-gcc'
- 'msp430-gcc'
- 'riscv-gcc'
Expand All @@ -81,7 +81,7 @@ jobs:
matrix:
toolchain:
- 'aarch64-gcc'
#- 'arm-clang'
# - 'arm-clang' # clang is built by circle-ci
- 'arm-gcc'
- 'msp430-gcc'
- 'riscv-gcc'
Expand Down
8 changes: 4 additions & 4 deletions tools/get_deps.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,9 +249,6 @@ def main():
boards = args.board
print_only = args.print

if len(families) == 0 and len(boards) == 0:
print("Warning: family and board are not specified, only fetching mandatory dependencies.")

status = 0
deps = list(deps_mandatory.keys())

Expand All @@ -267,11 +264,14 @@ def main():

for f in families:
for d in deps_optional:
if f in deps_optional[d][2]:
if d not in deps and f in deps_optional[d][2]:
deps.append(d)

if print_only:
pvalue = {}
# print only without arguments, always add CMSIS_5
if len(families) == 0 and len(boards) == 0:
deps.append('lib/CMSIS_5')
for d in deps:
commit = deps_all[d][1]
pvalue[d] = commit
Expand Down

0 comments on commit 3c24ba3

Please sign in to comment.