OSDN Git Service

8848a8e14c9f8f88b00a32af823b936eae204f6f
[hengbandforosx/hengbandosx.git] / .github / workflows / build-with-autotools.yml
1 name: Build with Autotools
2
3 on:
4   workflow_call:
5     inputs:
6       cxx:
7         type: string
8         required: true
9       cxx-flags:
10         type: string
11         required: true
12       configure-opts:
13         type: string
14         required: false
15       distcheck:
16         type: boolean
17         required: false
18       use-ccache:
19         type: boolean
20         required: false
21
22 jobs:
23   build:
24     runs-on: ubuntu-22.04
25     steps:
26       - uses: actions/checkout@v3
27         with:
28           submodules: true
29
30       - id: calculate-cache-key
31         name: Calculate cache key for ccache
32         run: |
33           key=$(echo "${{ inputs.cxx }} ${{ inputs.cxx-flags }} ${{ inputs.configure-opts }}" | sha256sum | cut -d' ' -f1)
34           echo "key=$key" >> $GITHUB_OUTPUT
35
36       - if: ${{ inputs.use-ccache }}
37         uses: hendrikmuhs/ccache-action@v1.2
38         with:
39           key: ${{ steps.calculate-cache-key.outputs.key }}
40
41       - name: Configuring ccache to use precompiled headers
42         if: ${{ inputs.use-ccache }}
43         run: |
44           ln -s /usr/bin/ccache /usr/local/bin/${{ inputs.cxx }}
45           /usr/bin/ccache --set-config=sloppiness=pch_defines,time_macros,include_file_mtime,include_file_ctime
46           /usr/bin/ccache --set-config=pch_external_checksum=true
47           /usr/bin/ccache -p
48
49       - name: Install required packages
50         run: |
51           sudo apt-get update
52           sudo apt-get install \
53             libncursesw5-dev \
54             libcurl4-openssl-dev \
55             nkf \
56
57       - name: Generate configure
58         run: ./bootstrap
59
60       - name: Configure
61         run: ./configure ${{ inputs.configure-opts }}
62         env:
63           CXX: ${{ inputs.cxx }}
64           CXXFLAGS: ${{ inputs.cxx-flags }}
65
66       - name: Build with distcheck
67         if: ${{ inputs.distcheck }}
68         run: make DISTCHECK_CONFIGURE_FLAGS="CXX=\"${{ inputs.cxx }}\" CXXFLAGS=\"${{ inputs.cxx-flags }}\" ${{ inputs.configure-opts }}" -j$(nproc) distcheck >/dev/null
69
70       - name: Build
71         if: ${{ !inputs.distcheck }}
72         run: make -j$(nproc) >/dev/null