-
-
Notifications
You must be signed in to change notification settings - Fork 62
173 lines (139 loc) · 5.39 KB
/
example-project.yml
File metadata and controls
173 lines (139 loc) · 5.39 KB
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
name: Build example project
on: [push, pull_request]
env:
CARGO_TERM_COLOR: always
jobs:
example-project:
strategy:
matrix:
include:
- os: ubuntu-latest
- os: macos-latest
- os: windows-latest
toolchain-suffix: -gnu
- os: windows-latest
toolchain-suffix: -msvc
runs-on: ${{ matrix.os }}
steps:
- name: Clone Git repository
uses: actions/checkout@v6
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable${{ matrix.toolchain-suffix }}
- name: Install pkgconf
if: runner.os == 'Windows'
uses: msys2/setup-msys2@v2
id: msys2
with:
msystem: ucrt64
install: mingw-w64-ucrt-x86_64-pkgconf
- name: Put pkgconf on PATH
if: runner.os == 'Windows'
run: Add-Content $env:GITHUB_PATH "${{ steps.msys2.outputs.msys2-location }}\ucrt64\bin"
- name: Install cargo-c applet
run: cargo install --path .
- name: Test example project
working-directory: example-project
run: cargo test --verbose
- name: Build C API for example project
working-directory: example-project
run: cargo cbuild --verbose --release
- name: Run C API tests for example project
working-directory: example-project
run: cargo ctest --verbose --release
- name: Install into /usr/local
if: runner.os != 'Windows'
working-directory: example-project
run: sudo -E env PATH=$PATH cargo cinstall --verbose --release --prefix=/usr/local
- name: Install into MSYS2 root
if: runner.os == 'Windows'
working-directory: example-project
run: cargo cinstall --verbose --release --prefix="${{ steps.msys2.outputs.msys2-location }}\ucrt64"
- name: Test pkgconf
if: runner.os == 'macOS'
run: |
set -x
pkgconf --version
test "$(pkgconf --cflags example_project)" = "-I/usr/local/include/example-project-0.1"
test "$(pkgconf --libs example_project)" = "-L/usr/local/lib -lexample-project"
- name: Test pkgconf
if: runner.os == 'Linux'
run: |
set -x
pkgconf --version
ARCHDIR=`dpkg-architecture -qDEB_HOST_MULTIARCH`
# ubuntu seems to add trailing spaces for no specific reasons.
CFLAGS=$(pkgconf --cflags example_project)
LIBS=$(pkgconf --libs example_project)
test "${CFLAGS%% }" = "-I/usr/local/include/example-project-0.1"
test "${LIBS%% }" = "-L/usr/local/lib/${ARCHDIR} -lexample-project"
- name: Test pkgconf
if: runner.os == 'Windows'
shell: bash
run: |
set -x
pkgconf --version
# use --define-variable=prefix=C:/foo to test relative libdir/includedir generation
# https://github.com/lu-zero/cargo-c/commit/76a66cd72eb4271501557eebea7060821e63b702
test "$(pkgconf --define-variable=prefix=C:/foo --cflags example_project)" = "-IC:/foo/include/example-project-0.1"
test "$(pkgconf --define-variable=prefix=C:/foo --libs example_project)" = "-LC:/foo/lib -lexample-project"
- name: Update dynamic linker cache
if: runner.os == 'Linux'
run: sudo ldconfig
- name: Test usage from C (using Makefile)
if: runner.os != 'Windows'
working-directory: example-project/usage-from-c
run: make
- name: Setup Meson + Ninja
if: runner.os == 'Windows' && matrix.toolchain-suffix == '-msvc'
run: |
python3 -m pip install --upgrade pip setuptools wheel
python3 -m pip install meson ninja
- name: Setup MSVC for test
if: runner.os == 'Windows' && matrix.toolchain-suffix == '-msvc'
uses: ilammy/msvc-dev-cmd@v1
with:
arch: x86_64
- name: Test usage from C (Meson)
if: runner.os == 'Windows' && matrix.toolchain-suffix == '-msvc'
working-directory: example-project/usage-from-c
env:
PKG_CONFIG: pkgconf
run: |
meson setup build
meson compile -C build
meson test -C build
example-project-cygwin:
runs-on: windows-latest
defaults:
run:
shell: msys2 {0}
steps:
- name: Clone Git repository
uses: actions/checkout@v6
- name: Install rust
uses: msys2/setup-msys2@v2
with:
update: true
msystem: MSYS
install: rust pkgconf gcc openssl-devel libopenssl make
- name: Install cargo-c applet
run: cargo install --path .
- name: Build C API for example project
working-directory: example-project
run: cargo cbuild --verbose --release
- name: Install into /usr/local
working-directory: example-project
run: cargo cinstall --verbose --release --prefix=/usr/local
- name: Test pkgconf
run: |
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
pkgconf --version
test "$(pkgconf --cflags example_project)" = "-I/usr/local/include/example-project-0.1"
test "$(pkgconf --libs example_project)" = "-L/usr/local/lib -lexample-project"
- name: Test usage from C (using Makefile)
working-directory: example-project/usage-from-c
run: |
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
make