aboutsummaryrefslogtreecommitdiff
path: root/.github/workflows/gen_bindings.yml
blob: 11d908c40ee6f7407a2158fd96c5b9e3f72da5b5 (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
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
name: Bindings

on: [push, pull_request]

jobs:
  test-windows:
    runs-on: windows-latest
    steps:
      - uses: actions/checkout@main
      - name: test_win
        run: |
          cd tests
          test_win.cmd
        shell: cmd

  test-mac:
    runs-on: macos-latest
    steps:
      - uses: actions/checkout@main
      - uses: seanmiddleditch/gha-setup-ninja@master
      - name: test_macos
        run: |
          cd tests
          ./test_macos.sh

  test-linux:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@main
      - uses: seanmiddleditch/gha-setup-ninja@master
      - name: prepare
        run: |
          sudo apt-get update
          sudo apt-get install libgl1-mesa-dev libegl1-mesa-dev mesa-common-dev xorg-dev libasound-dev
      - name: test_linux
        run: |
          cd tests
          ./test_linux.sh

  gen-bindings:
    needs: [ test-windows, test-mac, test-linux ]
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@main
      - uses: actions/checkout@main
        with:
          repository: floooh/sokol-zig
          path: bindgen/sokol-zig
      - uses: actions/checkout@main
        with:
          repository: floooh/sokol-nim
          path: bindgen/sokol-nim
      - uses: actions/checkout@main
        with:
          repository: floooh/sokol-odin
          path: bindgen/sokol-odin
      - uses: actions/checkout@main
        with:
          repository: floooh/sokol-rust
          path: bindgen/sokol-rust
      - uses: actions/checkout@main
        with:
          repository: kassane/sokol-d
          path: bindgen/sokol-d
      - uses: actions/checkout@main
        with:
          repository: colinbellino/sokol-jai
          path: bindgen/sokol-jai
      - name: generate
        run: |
          cd bindgen
          python3 gen_all.py
      - name: upload-zig-artifact
        uses: actions/upload-artifact@main
        with:
          name: ignore-me-zig
          retention-days: 1
          path: bindgen/sokol-zig/src/sokol
      - name: upload-nim-artifact
        uses: actions/upload-artifact@main
        with:
          name: ignore-me-nim
          retention-days: 1
          path: bindgen/sokol-nim/src/sokol
      - name: upload-odin-artifact
        uses: actions/upload-artifact@main
        with:
          name: ignore-me-odin
          retention-days: 1
          path: |
            bindgen/sokol-odin/sokol
            bindgen/sokol-odin/c
      - name: upload-rust-artifact
        uses: actions/upload-artifact@main
        with:
          name: ignore-me-rust
          retention-days: 1
          path: bindgen/sokol-rust/src
      - name: upload-d-artifact
        uses: actions/upload-artifact@main
        with:
          name: ignore-me-d
          retention-days: 1
          path: bindgen/sokol-d/src/sokol
      - name: upload-jai-artifact
        uses: actions/upload-artifact@main
        with:
          name: ignore-me-jai
          retention-days: 1
          path: bindgen/sokol-jai/sokol

  test-zig:
    needs: gen-bindings
    strategy:
      matrix:
        os: [ubuntu-latest, macos-latest, windows-latest]
    runs-on: ${{matrix.os}}
    steps:
      - uses: actions/checkout@main
        with:
          repository: floooh/sokol-zig
      - uses: goto-bus-stop/setup-zig@default
      - uses: actions/download-artifact@main
        with:
          name: ignore-me-zig
          path: src/sokol
      - name: prepare
        if: runner.os == 'Linux'
        run: |
            sudo apt-get update
            sudo apt-get install libgl1-mesa-dev libegl1-mesa-dev mesa-common-dev xorg-dev libasound-dev
      - name: build
        run: zig build

  test-nim:
    needs: gen-bindings
    strategy:
      fail-fast: false
      matrix:
        # os: [ubuntu-latest, macos-latest, windows-latest]
        os: [ubuntu-latest, macos-latest]
    runs-on: ${{matrix.os}}
    steps:
      - if: runner.os == 'Linux'
        name: prepare
        run: |
            sudo apt-get update
            sudo apt-get install libglu1-mesa-dev mesa-common-dev xorg-dev libasound-dev
      - uses: actions/checkout@main
        with:
          repository: floooh/sokol-nim
      - uses: actions/download-artifact@main
        with:
          name: ignore-me-nim
          path: src/sokol
      - uses: jiro4989/setup-nim-action@v2
        with:
         nim-version: '2.0.x'
         repo-token: ${{ secrets.GITHUB_TOKEN }}
      - name: build
        run: |
          nimble install -Y
          nimble build_all

  test-odin:
    needs: gen-bindings
    strategy:
      fail-fast: false
      matrix:
        os: [ubuntu-latest, macos-latest, windows-latest]
    runs-on: ${{matrix.os}}
    steps:
      - uses: actions/checkout@main
        with:
          repository: floooh/sokol-odin
      - uses: actions/download-artifact@main
        with:
          name: ignore-me-odin
      # NOTE: see https://github.com/floooh/sokol-odin/blob/main/.github/workflows/main.yml
      - uses: ilammy/msvc-dev-cmd@v1
      - if: runner.os == 'Linux'
        name: prepare-linux
        run: |
          sudo apt-get update
          sudo apt-get install libglu1-mesa-dev mesa-common-dev xorg-dev libasound-dev
          wget https://apt.llvm.org/llvm.sh
          chmod +x llvm.sh
          echo "/usr/lib/llvm-17/bin" >> $GITHUB_PATH
          curl -L https://github.com/odin-lang/Odin/releases/download/dev-2024-04/odin-ubuntu-amd64-dev-2024-04.zip --output odin.zip
          unzip odin.zip
          unzip dist.zip
          rm -r ./dist/examples
          mv ./dist/* ./
          chmod a+x ./odin
          cd sokol
          chmod a+x ./build_clibs_linux.sh
          ./build_clibs_linux.sh
          cd ..
      - if: runner.os == 'macOS'
        name: prepare-macos
        run: |
          brew install llvm@17
          curl -L https://github.com/odin-lang/Odin/releases/download/dev-2024-04/odin-macos-amd64-dev-2024-04.zip --output odin.zip
          unzip odin.zip
          unzip dist.zip
          rm -r ./dist/examples
          mv ./dist/* ./
          chmod a+x ./odin
          cd sokol
          chmod a+x ./build_clibs_macos.sh
          ./build_clibs_macos.sh
          cd ..
      - if: runner.os == 'Windows'
        name: prepare-windows
        shell: cmd
        run: |
          curl -L https://github.com/odin-lang/Odin/releases/download/dev-2024-04/odin-windows-amd64-dev-2024-04.zip --output odin.zip
          unzip odin.zip
          cd sokol
          build_clibs_windows.cmd
          cd ..
      - name: build
        run: |
          ./odin build examples/clear -debug
          ./odin build examples/triangle -debug
          ./odin build examples/quad -debug
          ./odin build examples/bufferoffsets -debug
          ./odin build examples/cube -debug
          ./odin build examples/noninterleaved -debug
          ./odin build examples/texcube -debug
          ./odin build examples/shapes -debug
          ./odin build examples/offscreen -debug
          ./odin build examples/instancing -debug
          ./odin build examples/mrt -debug
          ./odin build examples/blend -debug
          ./odin build examples/debugtext -debug
          ./odin build examples/debugtext-print -debug
          ./odin build examples/debugtext-userfont -debug
          ./odin build examples/saudio -debug
          ./odin build examples/sgl -debug
          ./odin build examples/sgl-points -debug
          ./odin build examples/sgl-context -debug

  test-rust:
    needs: gen-bindings
    env:
      CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse
    strategy:
      fail-fast: false
      matrix:
        # os: [ubuntu-latest, macos-latest, windows-latest]
        os: [ubuntu-latest, windows-latest]
    runs-on: ${{matrix.os}}
    steps:
      - uses: actions/checkout@main
        with:
          repository: floooh/sokol-rust
      - uses: actions/download-artifact@main
        with:
          name: ignore-me-rust
          path: src
      - uses: dtolnay/rust-toolchain@master
        with:
          toolchain: stable
      - name: prepare-linux
        if: runner.os == 'Linux'
        run: |
            sudo apt-get update
            sudo apt-get install libglu1-mesa-dev mesa-common-dev xorg-dev libasound-dev
      - name: build
        run: |
            cargo --version
            cargo build --examples --verbose

  test-d:
    needs: gen-bindings
    strategy:
      matrix:
        os: [ubuntu-latest, macos-latest, windows-latest]
    runs-on: ${{matrix.os}}
    steps:
      - uses: actions/checkout@main
        with:
          repository: kassane/sokol-d
      - uses: goto-bus-stop/setup-zig@default
      - uses: dlang-community/setup-dlang@v1
        with:
          compiler: ldc-master
      - uses: actions/download-artifact@main
        with:
          name: ignore-me-d
          path: src/sokol
      - name: prepare
        if: runner.os == 'Linux'
        run: |
            sudo apt-get update
            sudo apt-get install libgl1-mesa-dev libegl1-mesa-dev mesa-common-dev xorg-dev libasound-dev
      - name: build
        run: zig build --summary all
  test-jai:
    needs: gen-bindings
    strategy:
      matrix:
        os: [ubuntu-latest, macos-latest, windows-latest]
    runs-on: ${{matrix.os}}
    steps:
      - uses: actions/checkout@main
        with:
          repository: colinbellino/sokol-jai
      - uses: actions/download-artifact@v4
        with:
          name: ignore-me-jai
          path: sokol
      - name: prepare
        if: runner.os == 'Linux'
        run: |
            sudo apt-get update
            sudo apt-get install libgl1-mesa-dev libegl1-mesa-dev mesa-common-dev xorg-dev libasound-dev
      - name: build
        run: echo "run jai here"

  # only deploy the bindings for commits on the main branch
  deploy-zig:
    needs: test-zig
    if: github.ref == 'refs/heads/master'
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          repository: floooh/sokol-zig
          ssh-key: ${{ secrets.GHACTIONS_ZIG_PUSH }}
      - uses: actions/download-artifact@v4
        with:
          name: ignore-me-zig
          path: src/sokol
      - name: "commit and push"
        run: |
          git config user.email "none"
          git config user.name "GH Action"
          git add -A
          git diff-index --quiet HEAD || git commit -m "updated (https://github.com/floooh/sokol/commit/${{ github.sha }})"
          git push

  deploy-nim:
    needs: test-nim
    if: github.ref == 'refs/heads/master'
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          repository: floooh/sokol-nim
          ssh-key: ${{ secrets.GHACTIONS_NIM_PUSH }}
      - uses: actions/download-artifact@v4
        with:
          name: ignore-me-nim
          path: src/sokol
      - name: "commit and push"
        run: |
          git config user.email "none"
          git config user.name "GH Action"
          git add -A
          git diff-index --quiet HEAD || git commit -m "updated (https://github.com/floooh/sokol/commit/${{ github.sha }})"
          git push

  deploy-odin:
    needs: test-odin
    if: github.ref == 'refs/heads/master'
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          repository: floooh/sokol-odin
          ssh-key: ${{ secrets.GHACTIONS_ODIN_PUSH }}
      - uses: actions/download-artifact@v4
        with:
          name: ignore-me-odin
      - name: "commit and push"
        run: |
          git config user.email "none"
          git config user.name "GH Action"
          git add -A
          git diff-index --quiet HEAD || git commit -m "updated (https://github.com/floooh/sokol/commit/${{ github.sha }})"
          git push

  deploy-rust:
    needs: test-rust
    env:
      CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse
    if: github.ref == 'refs/heads/master'
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          repository: floooh/sokol-rust
          ssh-key: ${{ secrets.GHACTIONS_RUST_PUSH }}
      - uses: actions/download-artifact@v4
        with:
          name: ignore-me-rust
          path: src
      - uses: dtolnay/rust-toolchain@master
        with:
          toolchain: stable
      - name: "cargo fmt"
        run: cargo fmt
      - name: "commit and push"
        run: |
          git config user.email "none"
          git config user.name "GH Action"
          git status -vv
          git add -A
          git diff-index --quiet HEAD || git commit -m "updated (https://github.com/floooh/sokol/commit/${{ github.sha }})"
          git push

  deploy-d:
    needs: test-d
    if: github.ref == 'refs/heads/master'
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          repository: kassane/sokol-d
          ssh-key: ${{ secrets.GHACTIONS_D_PUSH }}
      - uses: actions/download-artifact@v4
        with:
          name: ignore-me-d
          path: src/sokol
      - name: "commit and push"
        run: |
          git config user.email "none"
          git config user.name "GH Action"
          git add -A
          git diff-index --quiet HEAD || git commit -m "updated (https://github.com/floooh/sokol/commit/${{ github.sha }})"
          git push

  deploy-jai:
    needs: test-jai
    if: github.ref == 'refs/heads/master'
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          repository: colinbellino/sokol-jai
          ssh-key: ${{ secrets.GHACTIONS_JAI_PUSH }}
      - uses: actions/download-artifact@v4
        with:
          name: ignore-me-jai
          path: sokol
      - name: "commit and push"
        run: |
          git config user.email "none"
          git config user.name "GH Action"
          git add -A
          git diff-index --quiet HEAD || git commit -m "updated (https://github.com/floooh/sokol/commit/${{ github.sha }})"
          git push