summaryrefslogtreecommitdiffstats
path: root/.github/workflows/build_cmake.yml
blob: 4ad755f3a8c0571c8ca3e05bd2e350dd92a46da8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
name: CMake Build for Doxygen

on: [push, pull_request]

jobs:
  build:
    name: ${{ matrix.config.name }}
    runs-on: ${{ matrix.config.os }}
    strategy:
      fail-fast: false
      matrix:
        config:
        - {
            name: "Ubuntu Latest GCC Release",
            os: ubuntu-18.04,
            build_type: "Release", cc: "gcc", cxx: "g++",
            build_gen: "Unix Makefiles",
            cmake_extra_opts: "-Dbuild_search=YES -Dbuild_app=YES -Dbuild_parse=YES -Dbuild_xmlparser=YES"
          }
        - {
            name: "Ubuntu Latest GCC Debug",
            os: ubuntu-18.04,
            build_type: "Debug", cc: "gcc", cxx: "g++",
            build_gen: "Unix Makefiles",
            cmake_extra_opts: "-Dbuild_search=YES -Dbuild_app=YES -Dbuild_parse=YES -Dbuild_xmlparser=YES"
          }
        - {
            name: "Ubuntu Latest Clang Release",
            os: ubuntu-20.04,
            build_type: "Release", cc: "clang", cxx: "clang++",
            build_gen: "Unix Makefiles",
            cmake_extra_opts: "-Duse_libclang=YES -Dstatic_libclang=YES -Duse_libc++=NO"
          }
        - {
            name: "Ubuntu Latest Clang Debug",
            os: ubuntu-20.04,
            build_type: "Debug", cc: "clang", cxx: "clang++",
            build_gen: "Unix Makefiles",
            cmake_extra_opts: "-Duse_libclang=YES -Dstatic_libclang=YES -Duse_libc++=NO"
          }
        - {
            name: "macOS Latest Release",
            os: macos-latest,
            build_type: "Release", cc: "clang", cxx: "clang++",
            build_gen: "Unix Makefiles"
          }
        - {
            name: "macOS Latest Debug",
            os: macos-latest,
            build_type: "Debug", cc: "clang", cxx: "clang++",
            build_gen: "Unix Makefiles"
          }
        - {
            name: "Windows Latest MSVC Debug", 
            os: windows-latest,
            build_type: "Debug", cc: "cl", cxx: "cl",
            build_gen: "NMake Makefiles"
          }
        - {
            name: "Windows Latest MSVC Release", 
            os: windows-latest,
            build_type: "Release", cc: "cl", cxx: "cl",
            build_gen: "NMake Makefiles"
          }
    steps:
    - uses: actions/checkout@v1
      
    - name: Download MikTex (Windows)
      run: |
        $wc = New-Object System.Net.WebClient;
        $maxAttempts=5;
        $attemptCount=0;
        Do {
          $attemptCount++;
          Try {
            $wc.DownloadFile("https://ctan.math.illinois.edu/systems/win32/miktex/setup/windows-x64/miktexsetup-4.1-x64.zip","miktexsetup-4.1-x64.zip")
          } Catch [Exception] {
            Write-Host $_.Exception | format-list -force
          }
        } while (((Test-Path "miktexsetup-x64.zip") -eq $false) -and ($attemptCount -le $maxAttempts))  
      shell: pwsh
      if: matrix.config.os == 'windows-latest'
      
    - uses: suisei-cn/actions-download-file@v1
      with: 
        url: "https://github.com/pffang/libiconv-for-Windows/releases/download/v1.16/libiconv-for-Windows_1.16.7z"
        target: .  
      if: matrix.config.os == 'windows-latest'

    - name: Install LaTeX (Linux)
      run: sudo apt-get install texlive texlive-latex-recommended texlive-extra-utils texlive-latex-extra texlive-font-utils
      if: startsWith(matrix.config.os,'ubuntu-')

    - name: Install LaTeX (MacOS)
      run: |
        brew install --cask mactex;
        echo "/Library/TeX/texbin/" >> $GITHUB_PATH
      if: matrix.config.os == 'macos-latest'
    
    - name: Install libclang (Ubuntu 20.04)
      run: |
        sudo apt remove llvm-8 clang-8 libclang-common-8-dev clang-format-8 libllvm8
        sudo apt remove llvm-9 llvm-9-dev llvm-9-tools llvm-9-runtime clang-9 libclang-common-9-dev clang-format-9 libllvm9
        #sudo apt remove llvm-10 llvm-10-dev llvm-10-tools llvm-10-runtime clang-10 clang-format-10 libclang-common-10-dev libclang-cpp10 libclang1-10 libllvm10  
        sudo apt-get autoremove
        sudo apt-get clean
        #sudo apt install libclang-9-dev libclang-common-9-dev
        sudo apt install libclang-10-dev libclang-common-10-dev
        apt list --installed | egrep '(clang|llvm)'
        ls -d /usr/lib/llvm-*/include/
        clang++ -v
      if: matrix.config.os == 'ubuntu-20.04'
    
    - name: Install libxapian (Ubuntu 18.04)
      run: |
        sudo apt install libxapian-dev
      if: matrix.config.os == 'ubuntu-18.04'
          
    - name: Extract MikTex zip (Windows)
      shell: bash
      run: |
        unzip miktexsetup-4.1-x64.zip
      if: matrix.config.os == 'windows-latest'

    - name: Download MikTex packages (Windows)
      shell: bash
      run: |
        ./miktexsetup --verbose \
                      --local-package-repository=C:/miktex-repository \
                      --remote-package-repository="https://ctan.math.illinois.edu/systems/win32/miktex/tm/packages/" \
                      --package-set=essential \
                      download
      if: matrix.config.os == 'windows-latest'

    - name: Install MikTex packages (Windows)
      shell: bash
      run: |
        ./miktexsetup --local-package-repository=C:/miktex-repository \
                      --package-set=essential \
                      --shared \
                      install
      if: matrix.config.os == 'windows-latest'

    - name: Setting MikTex paths (Windows)
      shell: bash
      run: |
        echo "C:/Program Files/MiKTeX/miktex/bin/x64/" >> $GITHUB_PATH
        export PATH="/c/Program Files/MiKTeX/miktex/bin/x64/:$PATH"
        
        echo "Configuring MiKTeX to install missing packages on the fly"
        initexmf --admin --verbose --set-config-value='[MPM]AutoInstall=1'
      if: matrix.config.os == 'windows-latest'

    - name: Install Ghostscript (Linux)
      run: sudo apt-get install ghostscript
      if: startsWith(matrix.config.os,'ubuntu-')
    
    - name: Install Ghostscript (Windows)
      run:
        choco install ghostscript
      if: matrix.config.os == 'windows-latest'

    - name: Setting Ghostscript paths (Windows)
      shell: bash
      run: |
        echo "C:/Program Files (x86)/gs/gs9.53.3/bin/" >> $GITHUB_PATH
        echo "C:/Program Files/gs/gs9.53.3/bin/" >> $GITHUB_PATH
        export PATH="/c/Program Files (x86)/gs/gs9.53.3/bin/:$PATH"
        export PATH="/c/Program Files/gs/gs9.53.3/bin/:$PATH"
      if: matrix.config.os == 'windows-latest'
      
    - name: Install xmllint (Linux)
      run: sudo apt-get install libxml2-utils
      if: startsWith(matrix.config.os,'ubuntu-')

    - name: Install xmllint (MacOS)
      run: brew install libxml2
      if: matrix.config.os == 'macos-latest'

    - name: Install bison (MacOS)
      run: |
        brew install bison;
        echo "/usr/local/opt/bison/bin" >> $GITHUB_PATH
      if: matrix.config.os == 'macos-latest'
    
    - name: Install bison/flex (Windows)
      run:
        choco install winflexbison
      if: matrix.config.os == 'windows-latest'

    - name: Install Graphviz (Linux)
      run: sudo apt-get install graphviz
      if: startsWith(matrix.config.os,'ubuntu-')

    - name: Install Graphviz (MacOS)
      run: brew install graphviz
      if: matrix.config.os == 'macos-latest'

    - name: Install Graphviz (Windows)
      run:
        choco install graphviz.portable
      if: matrix.config.os == 'windows-latest'

#    - name: Install Perl (Windows)
#      run:
#        choco install activeperl
#      if: matrix.config.os == 'windows-latest'

    - name: Setup VS Environment (Windows)
      uses: seanmiddleditch/gha-setup-vsdevenv@master
      if: matrix.config.os == 'windows-latest'

    - name: Refresh Env (Windows)
      run:
        refreshenv
      if: matrix.config.os == 'windows-latest'
    
    - name: Install Qt
      uses: jurplel/install-qt-action@v2
    
    - name: Check tool versions (Linux / MacOS)
      shell: bash
      run: |
        echo "=== perl ===";
        perl --version;
        echo "=== python ===";
        python --version;
        echo "=== cmake ===";
        cmake --version;
        echo "=== latex ===";
        latex --version;
        echo "=== bibtex ===";
        bibtex --version
        echo "=== dvips ===";
        dvips --version
        echo "=== bison ===";
        bison --version;
        echo "=== flex ===";
        flex --version;
        echo "=== dot ===";
        dot -V;
        echo "=== ghostscript ===";
        gs --version;
      if: matrix.config.os != 'windows-latest'

    - name: Check tool versions (Windows)
      shell: bash
      run: |
        echo "=== perl ===";
        perl --version;
        echo "=== python ===";
        python --version;
        echo "=== cmake ===";
        cmake --version;
        echo "=== latex ===";
        latex --version;
        echo "=== bibtex ===";
        bibtex --version
        echo "=== dvips ===";
        dvips --version
        echo "=== bison ===";
        win_bison --version;
        echo "=== flex ===";
        win_flex --version;
        echo "=== dot ===";
        dot -V;
        echo "=== ghostscript ===";
        gswin64c --version;
      if: matrix.config.os == 'windows-latest'

    - name: Configure
      shell: cmake -P {0}
      run: |
        set(ENV{CC} ${{ matrix.config.cc }})
        set(ENV{CXX} ${{ matrix.config.cxx }})

        execute_process(
          COMMAND cmake
            -S .
            -B build
            -D CMAKE_BUILD_TYPE=${{ matrix.config.build_type }}
            -G "${{ matrix.config.build_gen }}"
            -Dbuild_doc=YES
            -Dbuild_wizard=YES
            ${{ matrix.config.cmake_extra_opts }}            
          RESULT_VARIABLE result
        )
        if (NOT result EQUAL 0)
          message(FATAL_ERROR "Bad exit status")
        endif()

    - name: Build
      shell: cmake -P {0}
      run: |
        include(ProcessorCount)
        ProcessorCount(N)
        execute_process(
          COMMAND cmake --build build --parallel ${N} 
          RESULT_VARIABLE result
          OUTPUT_VARIABLE output
          ERROR_VARIABLE output
          ECHO_OUTPUT_VARIABLE ECHO_ERROR_VARIABLE
        )
        if (NOT result EQUAL 0)
          string(REGEX MATCH "FAILED:.*$" error_message "${output}")
          string(REPLACE "\n" "%0A" error_message "${error_message}")
          message("::error::${error_message}")
          message(FATAL_ERROR "Build failed")
        endif()

    - name: Archive build artifacts
      uses: actions/upload-artifact@v2
      with:
        name: "${{ matrix.config.name }} build artifacts"
        path: build/bin/

    - name: Run tests (Linux / MacOS)
      shell: cmake -P {0}
      run: |
        include(ProcessorCount)
        ProcessorCount(N)

        set(ENV{CTEST_OUTPUT_ON_FAILURE} "ON")

        execute_process(
          COMMAND cmake --build build --target tests TEST_FLAGS="--xml --xmlxsd --xhtml --docbook --rtf"
          RESULT_VARIABLE result
        )
        if (NOT result EQUAL 0)
          message(FATAL_ERROR "Running tests failed!")
        endif()
      if: matrix.config.os != 'windows-latest'

    - name: Run tests (Windows)
      shell: cmake -P {0}
      run: |
        include(ProcessorCount)
        ProcessorCount(N)

        set(ENV{CTEST_OUTPUT_ON_FAILURE} "ON")

        execute_process(
          COMMAND cmake --build build --target tests TEST_FLAGS="--xml --xmlxsd"
          RESULT_VARIABLE result
        )
        if (NOT result EQUAL 0)
          message(FATAL_ERROR "Running tests failed!")
        endif()
      if: matrix.config.os == 'windows-latest'

    - name: Generate documentation
      shell: cmake -P {0}
      run: |
        execute_process(
          COMMAND cmake --build build --target docs
          RESULT_VARIABLE result
        )
        if (NOT result EQUAL 0)
          message(FATAL_ERROR "Building documentation failed")
        endif()
      if: matrix.config.os != 'windows-latest'