From c24a4943350ce7848e48b6ee5085b861d6fbf110 Mon Sep 17 00:00:00 2001 From: viktorxda <35473052+viktorxda@users.noreply.github.com> Date: Fri, 26 May 2023 22:09:12 +0200 Subject: [PATCH] Workflow: create separate toolchain action --- .github/workflows/build.yml | 93 ++++----------------------- .github/workflows/cache.yml | 2 +- .github/workflows/toolchain.yml | 79 +++++++++++++++++++++++ Makefile | 7 +- general/external.mk | 1 - general/scripts/executing_commands.sh | 7 +- 6 files changed, 99 insertions(+), 90 deletions(-) create mode 100644 .github/workflows/toolchain.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 59d06675..14222016 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,5 +1,4 @@ name: build - on: pull_request: types: @@ -14,87 +13,21 @@ on: workflow_dispatch: env: + TAG_NAME: latest MAX_KERNEL_SIZE: 0x200000 MAX_ROOTFS_SIZE: 0x500000 MAX_KERNEL_SIZE_ULTIMATE: 0x300000 MAX_ROOTFS_SIZE_ULTIMATE: 0xA00000 MAX_KERNEL_SIZE_NAND: 0x0800000 MAX_ROOTFS_SIZE_NAND: 0x1000000 - TAG_NAME: latest + TG_TOKEN: ${{secrets.TELEGRAM_TOKEN_BOT_OPENIPC}} + TG_CHANNEL: ${{secrets.TELEGRAM_CHANNEL_OPENIPC_DEV}} + TG_OPTIONS: -s --connect-timeout 30 --retry 10 --http1.1 -o /dev/null -w %{http_code} jobs: - toolchain: - name: Toolchain - runs-on: ubuntu-latest - - strategy: - fail-fast: false - matrix: - platform: - - ak3918ev300 - - dm36x - - fh8852v100 - - fh8852v200 - - gk7102 - - gm8136 - - hi3516cv100 - - hi3516cv200 - - hi3516cv300 - - hi3516cv500 - - hi3516ev200 - - hi3519v101 - - hi3536cv100 - - msc313e - - msc316dc - - msc316dm - - nt98562 - - rv1126 - - s3l - - ssc335 - - ssc338q - - t31 - - t40 - - xm510 - - xm530 - - steps: - - name: Checkout source - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - - name: Determine toolchain - run: | - GCC=$(make BOARD=${{matrix.platform}}_lite toolname) - echo GCC=${GCC} >> ${GITHUB_ENV} - URL=https://github.com/${GITHUB_REPOSITORY}/releases/download/${TAG_NAME}/${GCC}.tgz - echo Check: ${URL} - if ! wget --spider ${URL} 2> /dev/null; then - echo BUILD=true >> ${GITHUB_ENV} - fi - - - name: Build toolchain - if: env.BUILD - run: | - make BOARD=${{matrix.platform}}_lite br-sdk - SDK=$(find output/images -name *_sdk-buildroot.tar.gz) - mv ${SDK} ${GCC}.tgz - - - name: Upload toolchain - if: env.BUILD && github.event_name != 'pull_request' - uses: softprops/action-gh-release@v1 - with: - tag_name: ${{env.TAG_NAME}} - files: ${{env.GCC}}.tgz - buildroot: name: Firmware - needs: toolchain runs-on: ubuntu-latest - env: - TG_TOKEN: ${{secrets.TELEGRAM_TOKEN_BOT_OPENIPC}} - TG_CHANNEL: ${{secrets.TELEGRAM_CHANNEL_OPENIPC_DEV}} - TG_OPTIONS: -s --connect-timeout 30 --retry 10 --http1.1 -o /dev/null -w %{http_code} strategy: fail-fast: false @@ -267,12 +200,6 @@ jobs: with: fetch-depth: 0 - - name: Restore download - uses: actions/cache/restore@v3 - with: - path: /tmp/download - key: buildroot-cache - - name: Determine toolchain run: | GCC=$(make BOARD=${{matrix.platform}}_lite toolname) @@ -295,6 +222,12 @@ jobs: path: /tmp/ccache key: ${{env.GCC}} + - name: Restore download + uses: actions/cache/restore@v3 + with: + path: /tmp/download + key: buildroot-cache + - name: Build firmware run: | FAMILY=${{matrix.platform}} @@ -337,9 +270,7 @@ jobs: echo BR2_CCACHE=y >> ${CONFIG} echo BR2_CCACHE_DIR=\"/tmp/ccache\" >> ${CONFIG} - export BR2_DL_DIR=/tmp/download - export BR2_EXTERNAL_LIBC=${LIBC} export GIT_HASH=$(git rev-parse --short ${GITHUB_SHA}) export GIT_BRANCH=${GITHUB_REF_NAME} @@ -347,12 +278,10 @@ jobs: echo GIT_BRANCH=${GIT_BRANCH} >> ${GITHUB_ENV} echo ------------------------------------------------------------ - echo ${CONFIG} + make info BOARD=${FAMILY}_${RELEASE} echo ------------------------------------------------------------ cat ${CONFIG} echo ------------------------------------------------------------ - make info BOARD=${FAMILY}_${RELEASE} - echo ------------------------------------------------------------ make all BOARD=${FAMILY}_${RELEASE} echo ------------------------------------------------------------ diff --git a/.github/workflows/cache.yml b/.github/workflows/cache.yml index 4184b6f8..be832e36 100644 --- a/.github/workflows/cache.yml +++ b/.github/workflows/cache.yml @@ -3,7 +3,7 @@ on: workflow_dispatch: env: - REMOVE: aws* linux* gcc majestic mini + REMOVE: linux* gcc glibc aws* majestic mini jobs: download: diff --git a/.github/workflows/toolchain.yml b/.github/workflows/toolchain.yml new file mode 100644 index 00000000..406fab65 --- /dev/null +++ b/.github/workflows/toolchain.yml @@ -0,0 +1,79 @@ +name: toolchain +on: + workflow_dispatch: + +env: + TAG_NAME: latest + +jobs: + toolchain: + name: Toolchain + runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: + platform: + - ak3918ev300 + - dm36x + - fh8852v100 + - fh8852v200 + - gk7102 + - gm8136 + - hi3516cv100 + - hi3516cv200 + - hi3516cv300 + - hi3516cv500 + - hi3516ev200 + - hi3519v101 + - hi3536cv100 + - msc313e + - msc316dc + - msc316dm + - nt98562 + - rv1126 + - s3l + - ssc335 + - ssc338q + - t31 + - t40 + - xm510 + - xm530 + + steps: + - name: Checkout source + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Determine toolchain + run: | + GCC=$(make BOARD=${{matrix.platform}}_lite toolname) + echo GCC=${GCC} >> ${GITHUB_ENV} + URL=https://github.com/${GITHUB_REPOSITORY}/releases/download/${TAG_NAME}/${GCC}.tgz + echo Check: ${URL} + if ! wget --spider ${URL} 2> /dev/null; then + echo BUILD=true >> ${GITHUB_ENV} + fi + + - name: Restore download + if: env.BUILD + uses: actions/cache/restore@v3 + with: + path: /tmp/download + key: buildroot-cache + + - name: Build toolchain + if: env.BUILD + run: | + export BR2_DL_DIR=/tmp/download + make BOARD=${{matrix.platform}}_lite br-sdk + SDK=$(find output/images -name *_sdk-buildroot.tar.gz) + mv ${SDK} ${GCC}.tgz + + - name: Upload toolchain + if: env.BUILD + uses: softprops/action-gh-release@v1 + with: + tag_name: ${{env.TAG_NAME}} + files: ${{env.GCC}}.tgz diff --git a/Makefile b/Makefile index c25119ca..e71cefbe 100644 --- a/Makefile +++ b/Makefile @@ -34,14 +34,14 @@ br-%: defconfig defconfig: prepare @$(BR_MAKE) BR2_DEFCONFIG=$(PWD)/$(CONFIG) defconfig -toolname: prepare - @general/scripts/show_toolchains.sh $(CONFIG) $(BR_VER) - prepare: @mkdir -p /tmp/download @test -e $(BR_FILE) || wget -c -q $(BR_LINK)/$(BR_VER).tar.gz -O $(BR_FILE) @test -e buildroot-$(BR_VER) || tar -xf $(BR_FILE) -C $(PWD) +toolname: + @general/scripts/show_toolchains.sh $(CONFIG) + buildroot-version: @echo $(BR_VER) @@ -52,6 +52,7 @@ distclean: @rm -rf output buildroot-$(BR_VER) $(BR_FILE) info: + @echo $(CONFIG): @cat $(CONFIG) | grep BR2_OPENIPC | tr -d '"' | sed "s|BR2_OPENIPC_||g" list: diff --git a/general/external.mk b/general/external.mk index 88bd77f6..1d185e97 100644 --- a/general/external.mk +++ b/general/external.mk @@ -3,7 +3,6 @@ export OPENIPC_MODEL = $(call qstrip,$(BR2_OPENIPC_MODEL)) export OPENIPC_FAMILY = $(call qstrip,$(BR2_OPENIPC_FAMILY)) export OPENIPC_RELEASE = $(call qstrip,$(BR2_OPENIPC_RELEASE)) -export BR2_EXTERNAL_LIBC ?= $(call qstrip,$(BR2_TOOLCHAIN_BUILDROOT_LIBC)) export BR2_EXTERNAL_SCRIPTS = $(BR2_EXTERNAL)/scripts export BR2_EXTERNAL_VENDOR = $(BR2_EXTERNAL)/../br-ext-chip-$(BR2_OPENIPC_VENDOR) diff --git a/general/scripts/executing_commands.sh b/general/scripts/executing_commands.sh index 1c4d722d..87476b86 100755 --- a/general/scripts/executing_commands.sh +++ b/general/scripts/executing_commands.sh @@ -8,15 +8,16 @@ date +GITHUB_VERSION="\"${GIT_BRANCH-local}+${GIT_HASH-build}, %Y-%m-%d"\" >> ${ echo BUILD_OPTION=${OPENIPC_RELEASE} >> ${FILE} date +TIME_STAMP=%s >> ${FILE} -echo --- BR2_TOOLCHAIN_BUILDROOT_LIBC: ${BR2_EXTERNAL_LIBC} +LIBC=$(grep -oP "TOOLCHAIN_USES.\K\w+" ${BR2_CONFIG} | awk '{print tolower($0)}') +echo --- BR2_TOOLCHAIN_BUILDROOT_LIBC: ${LIBC} rm -f ${TARGET_DIR}/usr/bin/gdbserver CONF="INGENIC_OSDRV_T30=y|LIBV4L=y|MAVLINK_ROUTER=y|WIFIBROADCAST=y" -if [ ${BR2_EXTERNAL_LIBC} != "glibc" ] && ! grep -qE ${CONF} ${BR2_CONFIG}; then +if [ ${LIBC} != "glibc" ] && ! grep -qP ${CONF} ${BR2_CONFIG}; then rm -f ${TARGET_DIR}/usr/lib/libstdc++* fi -if [ ${BR2_EXTERNAL_LIBC} = "musl" ]; then +if [ ${LIBC} = "musl" ]; then NAME=${OPENIPC_RELEASE/lte/fpv} LIST=${BR2_EXTERNAL_SCRIPTS}/excludes/${OPENIPC_MODEL}_${NAME}.list test -e ${LIST} && xargs -a ${LIST} -i rm -f ${TARGET_DIR}{}