Skip to content

Commit daa00fc

Browse files
authored
Add cargo-c metadata (#170)
1 parent 8450cc8 commit daa00fc

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

c-api/Cargo.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,13 @@ variable-fonts = ["ttf-parser/variable-fonts"]
2626
gvar-alloc = ["ttf-parser/gvar-alloc"]
2727
# opentype-layout is not supported.
2828
# apple-layout is not supported.
29+
capi = []
2930

3031
[profile.release]
3132
lto = true
33+
34+
[package.metadata.capi.header]
35+
generation = false
36+
37+
[package.metadata.capi.install.include]
38+
asset = [{ from="ttfparser.h" }]

c-api/README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,25 @@ gcc test.c -g -o test -L./target/debug/ -lttfparser
1919
env LD_LIBRARY_PATH=./target/debug/ ./test
2020
```
2121

22+
## Using cargo-c
23+
This crate can be built and installed using [cargo-c](https://crates.io/crates/cargo-c).
24+
25+
### Build and test
26+
To build and used it uninstalled
27+
```sh
28+
cargo cbuild -v --library-type staticlib
29+
export PKG_CONFIG_PATH=<the path cbuild shows at the end>
30+
gcc test.c -g -o test `pkg-config --libs --cflags tffparser`
31+
./test
32+
```
33+
34+
### Install
35+
To install it system-wide
36+
```sh
37+
cargo cinstall --destdir /tmp/ttf-parser
38+
sudo cp -a /tmp/ttf-parser/* /
39+
```
40+
2241
## Safety
2342

2443
- The library doesn't use `unsafe` (except the bindings itself).

0 commit comments

Comments
 (0)