diff --git a/cbindgen/.signature b/cbindgen/.signature index 584a63353..9014e7e70 100644 --- a/cbindgen/.signature +++ b/cbindgen/.signature @@ -1,5 +1,6 @@ untrusted comment: verify with /etc/ports/contrib.pub -RWSagIOpLGJF3wf7xjlon4vGEZMelA+XgeMzjRovvUvEbwkPdNPFsnzmhc5gBF4EsVioGyOYvYm0Ac/NUd/JIJ85NkcrWdd2XwU= -SHA256 (Pkgfile) = 46e235f1f717d14bc087e24952b0ad03b035eac217d29dced9be1ef15a802a2a +RWSagIOpLGJF31KiF7uEkehoyT1DVyiSyrHLhO/HYCohGSDNq+goWiEYetJwTV16P/ndRqrrtQj6Q8pYxStwFsCYzNIq0NoiSwk= +SHA256 (Pkgfile) = 190b594d6fcf4d6569f79cc59cc3cc143fe7301b886e8009da38230360f3ecbb SHA256 (.footprint) = fd60992957bd0010460d49684c69464200651af797acdb98547f4847fc9f3f3c SHA256 (cbindgen-v0.14.0.tar.gz) = d3d077de08f09386d3a4db6cc9e79cf0e819c01712eb2476c786c119dab0108c +SHA256 (firefox.patch) = d260660e51a751c9dd6a3bc721c31898f01fe6a373963d37e272f35ffc34b6e8 diff --git a/cbindgen/Pkgfile b/cbindgen/Pkgfile index c00510555..347b7b23d 100644 --- a/cbindgen/Pkgfile +++ b/cbindgen/Pkgfile @@ -6,12 +6,16 @@ name=cbindgen version=0.14.0 -release=1 -source=(https://github.com/eqrion/cbindgen/archive/v$version/$name-v$version.tar.gz) +release=2 +source=(https://github.com/eqrion/cbindgen/archive/v$version/$name-v$version.tar.gz + firefox.patch) build() { cd $name-$version + # https://github.com/eqrion/cbindgen/issues/500 + patch -p1 -R -i $SRC/firefox.patch + prt-get isinst sccache && export RUSTC_WRAPPER=/usr/bin/sccache mkdir "$PKGMK_SOURCE_DIR/rust" || true export CARGO_HOME="$PKGMK_SOURCE_DIR/rust" diff --git a/cbindgen/firefox.patch b/cbindgen/firefox.patch new file mode 100644 index 000000000..ffb06cc76 --- /dev/null +++ b/cbindgen/firefox.patch @@ -0,0 +1,255 @@ +From ec1631f3e47686e6e0c1b7641bb08b0e39c59250 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= +Date: Tue, 31 Mar 2020 17:41:48 +0200 +Subject: [PATCH] Allow excluding monomorph structs in C mode. + +Fixes #500. +--- + src/bindgen/library.rs | 4 +++- + .../both/exclude_generic_monomorph.c | 15 ++++++++++++ + .../both/exclude_generic_monomorph.compat.c | 23 +++++++++++++++++++ + .../expectations/exclude_generic_monomorph.c | 15 ++++++++++++ + .../exclude_generic_monomorph.compat.c | 23 +++++++++++++++++++ + .../exclude_generic_monomorph.cpp | 15 ++++++++++++ + .../tag/exclude_generic_monomorph.c | 15 ++++++++++++ + .../tag/exclude_generic_monomorph.compat.c | 23 +++++++++++++++++++ + tests/rust/exclude_generic_monomorph.rs | 10 ++++++++ + tests/rust/exclude_generic_monomorph.toml | 11 +++++++++ + 10 files changed, 153 insertions(+), 1 deletion(-) + create mode 100644 tests/expectations/both/exclude_generic_monomorph.c + create mode 100644 tests/expectations/both/exclude_generic_monomorph.compat.c + create mode 100644 tests/expectations/exclude_generic_monomorph.c + create mode 100644 tests/expectations/exclude_generic_monomorph.compat.c + create mode 100644 tests/expectations/exclude_generic_monomorph.cpp + create mode 100644 tests/expectations/tag/exclude_generic_monomorph.c + create mode 100644 tests/expectations/tag/exclude_generic_monomorph.compat.c + create mode 100644 tests/rust/exclude_generic_monomorph.rs + create mode 100644 tests/rust/exclude_generic_monomorph.toml + +diff --git a/src/bindgen/library.rs b/src/bindgen/library.rs +index 0cdd07ea..4cb0b8b8 100644 +--- a/src/bindgen/library.rs ++++ b/src/bindgen/library.rs +@@ -54,7 +54,6 @@ impl Library { + } + + pub fn generate(mut self) -> Result { +- self.remove_excluded(); + self.transfer_annotations(); + self.simplify_standard_types(); + +@@ -67,7 +66,10 @@ impl Library { + + if self.config.language == Language::C { + self.instantiate_monomorphs(); ++ self.remove_excluded(); + self.resolve_declaration_types(); ++ } else { ++ self.remove_excluded(); + } + + self.rename_items(); +diff --git a/tests/expectations/both/exclude_generic_monomorph.c b/tests/expectations/both/exclude_generic_monomorph.c +new file mode 100644 +index 00000000..2d43ce15 +--- /dev/null ++++ b/tests/expectations/both/exclude_generic_monomorph.c +@@ -0,0 +1,15 @@ ++#include ++ ++typedef uint64_t Option_Foo; ++ ++ ++#include ++#include ++#include ++#include ++ ++typedef struct Bar { ++ Option_Foo foo; ++} Bar; ++ ++void root(Bar f); +diff --git a/tests/expectations/both/exclude_generic_monomorph.compat.c b/tests/expectations/both/exclude_generic_monomorph.compat.c +new file mode 100644 +index 00000000..76a0a3bb +--- /dev/null ++++ b/tests/expectations/both/exclude_generic_monomorph.compat.c +@@ -0,0 +1,23 @@ ++#include ++ ++typedef uint64_t Option_Foo; ++ ++ ++#include ++#include ++#include ++#include ++ ++typedef struct Bar { ++ Option_Foo foo; ++} Bar; ++ ++#ifdef __cplusplus ++extern "C" { ++#endif // __cplusplus ++ ++void root(Bar f); ++ ++#ifdef __cplusplus ++} // extern "C" ++#endif // __cplusplus +diff --git a/tests/expectations/exclude_generic_monomorph.c b/tests/expectations/exclude_generic_monomorph.c +new file mode 100644 +index 00000000..e7178367 +--- /dev/null ++++ b/tests/expectations/exclude_generic_monomorph.c +@@ -0,0 +1,15 @@ ++#include ++ ++typedef uint64_t Option_Foo; ++ ++ ++#include ++#include ++#include ++#include ++ ++typedef struct { ++ Option_Foo foo; ++} Bar; ++ ++void root(Bar f); +diff --git a/tests/expectations/exclude_generic_monomorph.compat.c b/tests/expectations/exclude_generic_monomorph.compat.c +new file mode 100644 +index 00000000..062e71ca +--- /dev/null ++++ b/tests/expectations/exclude_generic_monomorph.compat.c +@@ -0,0 +1,23 @@ ++#include ++ ++typedef uint64_t Option_Foo; ++ ++ ++#include ++#include ++#include ++#include ++ ++typedef struct { ++ Option_Foo foo; ++} Bar; ++ ++#ifdef __cplusplus ++extern "C" { ++#endif // __cplusplus ++ ++void root(Bar f); ++ ++#ifdef __cplusplus ++} // extern "C" ++#endif // __cplusplus +diff --git a/tests/expectations/exclude_generic_monomorph.cpp b/tests/expectations/exclude_generic_monomorph.cpp +new file mode 100644 +index 00000000..e7178367 +--- /dev/null ++++ b/tests/expectations/exclude_generic_monomorph.cpp +@@ -0,0 +1,15 @@ ++#include ++ ++typedef uint64_t Option_Foo; ++ ++ ++#include ++#include ++#include ++#include ++ ++typedef struct { ++ Option_Foo foo; ++} Bar; ++ ++void root(Bar f); +diff --git a/tests/expectations/tag/exclude_generic_monomorph.c b/tests/expectations/tag/exclude_generic_monomorph.c +new file mode 100644 +index 00000000..32686ad9 +--- /dev/null ++++ b/tests/expectations/tag/exclude_generic_monomorph.c +@@ -0,0 +1,15 @@ ++#include ++ ++typedef uint64_t Option_Foo; ++ ++ ++#include ++#include ++#include ++#include ++ ++struct Bar { ++ Option_Foo foo; ++}; ++ ++void root(struct Bar f); +diff --git a/tests/expectations/tag/exclude_generic_monomorph.compat.c b/tests/expectations/tag/exclude_generic_monomorph.compat.c +new file mode 100644 +index 00000000..27408515 +--- /dev/null ++++ b/tests/expectations/tag/exclude_generic_monomorph.compat.c +@@ -0,0 +1,23 @@ ++#include ++ ++typedef uint64_t Option_Foo; ++ ++ ++#include ++#include ++#include ++#include ++ ++struct Bar { ++ Option_Foo foo; ++}; ++ ++#ifdef __cplusplus ++extern "C" { ++#endif // __cplusplus ++ ++void root(struct Bar f); ++ ++#ifdef __cplusplus ++} // extern "C" ++#endif // __cplusplus +diff --git a/tests/rust/exclude_generic_monomorph.rs b/tests/rust/exclude_generic_monomorph.rs +new file mode 100644 +index 00000000..78fd1973 +--- /dev/null ++++ b/tests/rust/exclude_generic_monomorph.rs +@@ -0,0 +1,10 @@ ++#[repr(transparent)] ++pub struct Foo(NonZeroU64); ++ ++#[repr(C)] ++pub struct Bar { ++ foo: Option, ++} ++ ++#[no_mangle] ++pub extern "C" fn root(f: Bar) {} +diff --git a/tests/rust/exclude_generic_monomorph.toml b/tests/rust/exclude_generic_monomorph.toml +new file mode 100644 +index 00000000..82d33617 +--- /dev/null ++++ b/tests/rust/exclude_generic_monomorph.toml +@@ -0,0 +1,11 @@ ++language = "C" ++header = """ ++#include ++ ++typedef uint64_t Option_Foo; ++""" ++ ++[export] ++exclude = [ ++ "Option_Foo", ++]