|
| 1 | +name: Build Toolchains |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_call: |
| 5 | + inputs: |
| 6 | + targets: |
| 7 | + description: Stringified JSON target list |
| 8 | + required: false |
| 9 | + default: >- |
| 10 | + ["arc32", "arc64"] |
| 11 | + type: string |
| 12 | + |
| 13 | + gcc_branch: |
| 14 | + description: GCC branch name |
| 15 | + required: false |
| 16 | + default: arc64 |
| 17 | + type: string |
| 18 | + |
| 19 | + binutils_branch: |
| 20 | + description: Binutils branch name |
| 21 | + required: false |
| 22 | + default: arc64 |
| 23 | + type: string |
| 24 | + |
| 25 | + newlib_branch: |
| 26 | + description: Newlib branch name |
| 27 | + required: false |
| 28 | + default: arc64 |
| 29 | + type: string |
| 30 | + |
| 31 | + glibc_branch: |
| 32 | + description: glibc branch name |
| 33 | + required: false |
| 34 | + default: arc64 |
| 35 | + type: string |
| 36 | + |
| 37 | + release_tag: |
| 38 | + description: release tag |
| 39 | + required: false |
| 40 | + default: "" |
| 41 | + type: string |
| 42 | + |
| 43 | +env: |
| 44 | + build_dir: ${{ github.workspace }}/output |
| 45 | + |
| 46 | +jobs: |
| 47 | + build: |
| 48 | + runs-on: ubuntu-18.04 |
| 49 | + |
| 50 | + strategy: |
| 51 | + fail-fast: false |
| 52 | + matrix: |
| 53 | + mode: [newlib, linux] |
| 54 | + target: ${{ fromJSON(inputs.targets) }} |
| 55 | + |
| 56 | + # exclude arc32 bare-metal toolchain because it is built by arc64 multilib toolchain |
| 57 | + exclude: |
| 58 | + - { mode: newlib, target: arc32 } |
| 59 | + |
| 60 | + steps: |
| 61 | + - uses: actions/checkout@v2 |
| 62 | + - name: Install apt dependencies |
| 63 | + run: | |
| 64 | + sudo apt-get -y update |
| 65 | + sudo apt-get install -y --no-install-recommends \ |
| 66 | + autoconf \ |
| 67 | + automake \ |
| 68 | + autotools-dev \ |
| 69 | + bc \ |
| 70 | + bison \ |
| 71 | + build-essential \ |
| 72 | + curl \ |
| 73 | + flex \ |
| 74 | + gawk \ |
| 75 | + gperf \ |
| 76 | + libgmp-dev \ |
| 77 | + libmpc-dev \ |
| 78 | + libmpfr-dev \ |
| 79 | + libtool \ |
| 80 | + patchutils \ |
| 81 | + texinfo |
| 82 | +
|
| 83 | + - name: Build ${{ matrix.target }}-${{ matrix.mode }} toolchain |
| 84 | + id: build_toolchain |
| 85 | + |
| 86 | + run: | |
| 87 | + if [ "${{ matrix.mode }}" == "linux" ]; then |
| 88 | + BUILD_FLAGS="--enable-linux" |
| 89 | + MODE="glibc"; |
| 90 | + else |
| 91 | + BUILD_FLAGS="--enable-multilib" |
| 92 | + MODE="elf"; |
| 93 | + fi |
| 94 | +
|
| 95 | + if [ -n ${{ inputs.release_tag }} ]; then |
| 96 | + RELEASE_TAG="${{ inputs.release_tag }}" |
| 97 | + else |
| 98 | + RELEASE_TAG="$(date --utc '+%Y.%m.%d')" |
| 99 | + fi |
| 100 | +
|
| 101 | + echo ::set-output name=toolchain_name::${{ matrix.target }}-${MODE}-${RELEASE_TAG} |
| 102 | +
|
| 103 | + ${{ github.workspace }}/configure \ |
| 104 | + ${BUILD_FLAGS} \ |
| 105 | + --target=${{ matrix.target }} \ |
| 106 | + --prefix=${{ env.build_dir }} \ |
| 107 | + --disable-qemu \ |
| 108 | + --disable-werror |
| 109 | +
|
| 110 | + cat > build.config <<EOF |
| 111 | + GCC_BRANCH=${{ inputs.gcc_branch }} |
| 112 | + BINUTILS_BRANCH=${{ inputs.binutils_branch }} |
| 113 | + NEWLIB_BRANCH=${{ inputs.newlib_branch }} |
| 114 | + GLIBC_BRANCH=${{ inputs.glibc_branch }} |
| 115 | + EOF |
| 116 | +
|
| 117 | + make ${{ matrix.mode }} -j$(nproc) |
| 118 | + shell: bash |
| 119 | + |
| 120 | + - name: Create toolchain tarball |
| 121 | + run: | |
| 122 | + tar -czvf ${{ steps.build_toolchain.outputs.toolchain_name }}.tar.gz --owner=0 --group=0 -C ${{ env.build_dir }} . |
| 123 | +
|
| 124 | + - name: Upload toolchain tarball |
| 125 | + uses: actions/upload-artifact@v3 |
| 126 | + with: |
| 127 | + name: ${{ steps.build_toolchain.outputs.toolchain_name }}.tar.gz |
| 128 | + path: ${{ steps.build_toolchain.outputs.toolchain_name }}.tar.gz |
| 129 | + retention-days: 7 |
0 commit comments