Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New package cbindgen #11880

Merged
merged 1 commit into from
Jan 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions cbindgen.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package:
name: cbindgen
version: 0.26.0
epoch: 0
description: Tool to generate C bindings from Rust code
copyright:
- license: MPL-2.0

environment:
contents:
packages:
- build-base
- busybox
- rust

pipeline:
- uses: git-checkout
with:
repository: https://github.com/mozilla/cbindgen
tag: v${{package.version}}
expected-commit: 703b53c06f9fe2dbc0193d67626558cfa84a0f62

- runs: |
cargo build --release
mkdir -p ${{targets.destdir}}/usr/bin
cp target/release/cbindgen ${{targets.destdir}}/usr/bin/

test:
environment:
contents:
packages:
- wolfi-base
- rustup
pipeline:
- runs: |
# We need to install nightly rust because cbindgen uses a nightly
# feature (-Zunpretty=expanded).
rustup install nightly
ARCH=$(uname -m)
export PATH="$HOME/.rustup/toolchains/nightly-${ARCH}-unknown-linux-gnu/bin:$PATH"
cbindgen --version
cbindgen --help
cbindgen --config cbindgen.toml --crate bitfield --output my_header.h --lang c
cat my_header.h

update:
enabled: true
github:
identifier: mozilla/cbindgen
strip-prefix: v
5 changes: 5 additions & 0 deletions cbindgen/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions cbindgen/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[package]
name = "bitfield"
version = "0.1.0"
authors = ["cbindgen"]

[features]
cbindgen = []
3 changes: 3 additions & 0 deletions cbindgen/cbindgen.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[parse.expand]
crates = ["bitfield"]
features = ["cbindgen"]
15 changes: 15 additions & 0 deletions cbindgen/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#[repr(C)]
pub struct HasBitfields {
#[cfg(not(feature = "cbindgen"))]
foo_and_bar: u64,

#[cfg(feature = "cbindgen")]
/// cbindgen:bitfield=8
foo: u64,
#[cfg(feature = "cbindgen")]
/// cbindgen:bitfield=56
bar: u64,
}

#[no_mangle]
pub extern "C" fn root(_: &HasBitfields) {}
Loading