Skip to content

Commit

Permalink
Add cargo-c metadata (#170)
Browse files Browse the repository at this point in the history
  • Loading branch information
lu-zero authored Sep 3, 2024
1 parent 8450cc8 commit daa00fc
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
7 changes: 7 additions & 0 deletions c-api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@ variable-fonts = ["ttf-parser/variable-fonts"]
gvar-alloc = ["ttf-parser/gvar-alloc"]
# opentype-layout is not supported.
# apple-layout is not supported.
capi = []

[profile.release]
lto = true

[package.metadata.capi.header]
generation = false

[package.metadata.capi.install.include]
asset = [{ from="ttfparser.h" }]
19 changes: 19 additions & 0 deletions c-api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,25 @@ gcc test.c -g -o test -L./target/debug/ -lttfparser
env LD_LIBRARY_PATH=./target/debug/ ./test
```

## Using cargo-c
This crate can be built and installed using [cargo-c](https://crates.io/crates/cargo-c).

### Build and test
To build and used it uninstalled
```sh
cargo cbuild -v --library-type staticlib
export PKG_CONFIG_PATH=<the path cbuild shows at the end>
gcc test.c -g -o test `pkg-config --libs --cflags tffparser`
./test
```

### Install
To install it system-wide
```sh
cargo cinstall --destdir /tmp/ttf-parser
sudo cp -a /tmp/ttf-parser/* /
```

## Safety

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

0 comments on commit daa00fc

Please sign in to comment.