|
| 1 | +name: Build and run tests (Linux) |
| 2 | + |
| 3 | +on: [push, pull_request] |
| 4 | + |
| 5 | +jobs: |
| 6 | + test-linux: |
| 7 | + runs-on: ${{ matrix.os.id }} |
| 8 | + strategy: |
| 9 | + matrix: |
| 10 | + os: |
| 11 | + - { id: ubuntu-20.04, name: focal } |
| 12 | + compiler: |
| 13 | + - 'clang-12' |
| 14 | + - 'gcc-11' |
| 15 | + cpp_std: |
| 16 | + - 'c++11' |
| 17 | + - 'c++14' |
| 18 | + - 'c++17' |
| 19 | + - 'c++20' |
| 20 | + include: |
| 21 | + # Limit the older compilers to C++11 mode |
| 22 | + - os: { id: ubuntu-20.04, name: focal } |
| 23 | + compiler: 'clang-11' |
| 24 | + cpp_std: 'c++11' |
| 25 | + - os: { id: ubuntu-20.04, name: focal } |
| 26 | + compiler: 'gcc-10' |
| 27 | + cpp_std: 'c++11' |
| 28 | + fail-fast: false |
| 29 | + steps: |
| 30 | + - name: Install Dependencies |
| 31 | + shell: bash |
| 32 | + run: | |
| 33 | + sudo apt-get update |
| 34 | + sudo apt-get install gperf build-essential bison flex libreadline-dev gawk tcl-dev libffi-dev git graphviz xdot pkg-config python python3 libboost-system-dev libboost-python-dev libboost-filesystem-dev zlib1g-dev |
| 35 | +
|
| 36 | + - name: Setup GCC |
| 37 | + if: startsWith(matrix.compiler, 'gcc') |
| 38 | + shell: bash |
| 39 | + run: | |
| 40 | + CXX=${CC/#gcc/g++} |
| 41 | + sudo apt-add-repository ppa:ubuntu-toolchain-r/test |
| 42 | + sudo apt-get update |
| 43 | + sudo apt-get install $CC $CXX |
| 44 | + echo "CC=$CC" >> $GITHUB_ENV |
| 45 | + echo "CXX=$CXX" >> $GITHUB_ENV |
| 46 | + env: |
| 47 | + CC: ${{ matrix.compiler }} |
| 48 | + |
| 49 | + - name: Setup Clang |
| 50 | + if: startsWith(matrix.compiler, 'clang') |
| 51 | + shell: bash |
| 52 | + run: | |
| 53 | + wget https://apt.llvm.org/llvm-snapshot.gpg.key |
| 54 | + sudo apt-key add llvm-snapshot.gpg.key |
| 55 | + rm llvm-snapshot.gpg.key |
| 56 | + sudo apt-add-repository "deb https://apt.llvm.org/${{ matrix.os.name }}/ llvm-toolchain-${{ matrix.os.name }} main" |
| 57 | + sudo apt-get update |
| 58 | + CXX=${CC/#clang/clang++} |
| 59 | + sudo apt-get install $CC $CXX |
| 60 | + echo "CC=$CC" >> $GITHUB_ENV |
| 61 | + echo "CXX=$CXX" >> $GITHUB_ENV |
| 62 | + env: |
| 63 | + CC: ${{ matrix.compiler }} |
| 64 | + |
| 65 | + - name: Runtime environment |
| 66 | + shell: bash |
| 67 | + env: |
| 68 | + WORKSPACE: ${{ github.workspace }} |
| 69 | + run: | |
| 70 | + echo "GITHUB_WORKSPACE=`pwd`" >> $GITHUB_ENV |
| 71 | + echo "$GITHUB_WORKSPACE/.local/bin" >> $GITHUB_PATH |
| 72 | + echo "procs=$(nproc)" >> $GITHUB_ENV |
| 73 | +
|
| 74 | + - name: Tool versions |
| 75 | + shell: bash |
| 76 | + run: | |
| 77 | + $CC --version |
| 78 | + $CXX --version |
| 79 | +
|
| 80 | + - name: Checkout Yosys |
| 81 | + uses: actions/checkout@v3 |
| 82 | + |
| 83 | + - name: Get iverilog |
| 84 | + shell: bash |
| 85 | + run: | |
| 86 | + git clone https://github.com/steveicarus/iverilog.git |
| 87 | +
|
| 88 | + - name: Cache iverilog |
| 89 | + id: cache-iverilog |
| 90 | + uses: actions/cache@v3 |
| 91 | + with: |
| 92 | + path: .local/ |
| 93 | + key: ${{ matrix.os.id }}-${{ hashFiles('iverilog/.git/refs/heads/master') }} |
| 94 | + |
| 95 | + - name: Build iverilog |
| 96 | + if: steps.cache-iverilog.outputs.cache-hit != 'true' |
| 97 | + shell: bash |
| 98 | + run: | |
| 99 | + mkdir -p $GITHUB_WORKSPACE/.local/ |
| 100 | + cd iverilog |
| 101 | + autoconf |
| 102 | + CC=gcc CXX=g++ ./configure --prefix=$GITHUB_WORKSPACE/.local |
| 103 | + make -j${{ env.procs }} |
| 104 | + make install |
| 105 | +
|
| 106 | + - name: Build yosys |
| 107 | + shell: bash |
| 108 | + run: | |
| 109 | + make config-${CC%%-*} |
| 110 | + make -j${{ env.procs }} CCXXSTD=${{ matrix.cpp_std }} CC=$CC CXX=$CC LD=$CC |
| 111 | +
|
| 112 | + - name: Run tests |
| 113 | + if: (matrix.cpp_std == 'c++11') && (matrix.compiler == 'gcc-11') |
| 114 | + shell: bash |
| 115 | + run: | |
| 116 | + make -j${{ env.procs }} test CXXSTD=${{ matrix.cpp_std }} CC=$CC CXX=$CC LD=$CC |
0 commit comments