From daa00fcf033ee5aa7d01c951fd8ae27c064698ea Mon Sep 17 00:00:00 2001 From: Luca Barbato Date: Tue, 3 Sep 2024 11:30:08 +0200 Subject: [PATCH] Add cargo-c metadata (#170) --- c-api/Cargo.toml | 7 +++++++ c-api/README.md | 19 +++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/c-api/Cargo.toml b/c-api/Cargo.toml index ea38baf2..a386995e 100644 --- a/c-api/Cargo.toml +++ b/c-api/Cargo.toml @@ -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" }] diff --git a/c-api/README.md b/c-api/README.md index 95b68183..1d40a875 100644 --- a/c-api/README.md +++ b/c-api/README.md @@ -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= +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).