From 3c24ba3ff2eb5fdb4e214f668a25ed2038a847ad Mon Sep 17 00:00:00 2001 From: Ha Thach Date: Tue, 14 May 2024 12:44:36 +0700 Subject: [PATCH] build arm-clang on circleci with pull request (#2644) * 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 --- .circleci/config.yml | 125 ++++++++++++++++++++++------ .github/actions/get_deps/action.yml | 2 +- .github/workflows/build.yml | 4 +- tools/get_deps.py | 8 +- 4 files changed, 106 insertions(+), 33 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index d91de8419..77ab30f00 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -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 -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 - 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 +commands: + setup-toolchain: + parameters: + toolchain: + type: string + toolchain_url: + type: string steps: - # Checkout the code as the first step. - - checkout - run: - name: "Say hello" - command: "echo Hello, World!" + 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: + arm-clang: + parameters: + family: + type: string + build-system: + type: string + + docker: + - image: cimg/base:current + 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 + - setup-toolchain: + toolchain: clang + toolchain_url: $TOOLCHAIN_URL + - get-deps: + family: << parameters.family >> + - run: + 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'] diff --git a/.github/actions/get_deps/action.yml b/.github/actions/get_deps/action.yml index 38b44a70e..eea241c6c 100644 --- a/.github/actions/get_deps/action.yml +++ b/.github/actions/get_deps/action.yml @@ -2,8 +2,8 @@ name: Get dependencies inputs: arg: + description: 'Arguments to get_deps.py' required: true - type: string runs: using: "composite" diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2cd348847..78d95fbbc 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -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' @@ -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' diff --git a/tools/get_deps.py b/tools/get_deps.py index 2c2f97b4b..87c1c5ccd 100644 --- a/tools/get_deps.py +++ b/tools/get_deps.py @@ -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()) @@ -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