-
-
Notifications
You must be signed in to change notification settings - Fork 57
153 lines (126 loc) · 4.58 KB
/
example-project.yml
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
name: Build example project
on: [push, pull_request]
env:
CARGO_TERM_COLOR: always
jobs:
example-project:
strategy:
matrix:
include:
- os: ubuntu-latest
# x86_64:
- os: macos-13
# arm64:
- 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@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable${{ matrix.toolchain-suffix }}
- 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 temporary location
working-directory: example-project
run: |
cargo cinstall --verbose --release --destdir=temp
- name: Copy installed files to /usr/local
if: startsWith(matrix.os, 'macos') || startsWith(matrix.os, 'ubuntu')
working-directory: example-project
run: |
sudo cp -r temp/usr/local/* /usr/local/
- name: Install into Cargo root
if: startsWith(matrix.os, 'windows')
shell: bash
working-directory: example-project
run: |
cargo cinstall --verbose --release --prefix=$CARGO_HOME
- name: Test pkg-config
if: startsWith(matrix.os, 'macos')
run: |
set -x
test "$(pkg-config --cflags example_project)" = "-I/usr/local/include/example-project-0.1"
test "$(pkg-config --libs example_project)" = "-L/usr/local/lib -lexample-project"
- name: Install pkgconf
if: startsWith(matrix.os, 'ubuntu')
uses: awalsh128/cache-apt-pkgs-action@latest
with:
packages: pkgconf
- name: Setup Meson + Ninja
if: startsWith(matrix.os, 'windows')
run: |
python3 -m pip install --upgrade pip setuptools wheel
python3 -m pip install meson ninja
- name: Setup MSVC for test
if: startsWith(matrix.os, 'windows')
uses: ilammy/msvc-dev-cmd@v1
with:
arch: x86_64
# https://github.com/pkgconf/pkgconf/issues/364
- name: Install pkgconf
if: startsWith(matrix.os, 'windows')
run: |
git clone https://github.com/amyspark/pkgconf --branch msvc
cd pkgconf
meson setup build --prefix=$env:CARGO_HOME
meson compile -C build
meson install -C build
- name: Test pkgconf
if: startsWith(matrix.os, 'ubuntu')
run: |
set -x
pkgconf --version
pkg-config --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: startsWith(matrix.os, 'windows')
shell: bash
run: |
set -x
pkgconf --version
CFLAGS=$(pkgconf --cflags example_project)
LIBS=$(pkgconf --libs example_project)
test "${CFLAGS%% }" = "-I${CARGO_HOME//\\//}/bin/../include/example-project-0.1"
test "${LIBS%% }" = "-L${CARGO_HOME//\\//}/bin/../lib -lexample-project"
- name: Update dynamic linker cache
if: startsWith(matrix.os, 'ubuntu')
run: |
sudo ldconfig
- name: Test usage from C (using Makefile)
if: startsWith(matrix.os, 'macos') || startsWith(matrix.os, 'ubuntu')
working-directory: example-project/usage-from-c
run: |
make
- name: Test usage from C (Meson)
if: startsWith(matrix.os, 'windows') && matrix.toolchain-suffix == '-msvc'
working-directory: example-project/usage-from-c
shell: pwsh
run: |
$env:PKG_CONFIG="$env:CARGO_HOME/bin/pkgconf.exe"
meson setup build
meson compile -C build
meson test -C build