Skip to content

Commit 5409a28

Browse files
committed
Use gbindgen to generate a C header
Signed-off-by: Marc-André Lureau <[email protected]>
1 parent 6ddc943 commit 5409a28

13 files changed

+18
-235
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ Ex-0.1.typelib
66
Ex-0.1.vapi
77
test-c
88
test-vala
9+
/include/

.gitmodules

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[submodule "cbindgen"]
2+
path = cbindgen
3+
url = https://github.com/elmarco/cbindgen.git
4+
branch = gbindgen

Makefile

+12-13
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,4 @@
1-
HEADERS = \
2-
include/ex/ex.h \
3-
include/ex/error.h \
4-
include/ex/flags.h \
5-
include/ex/color.h \
6-
include/ex/foo.h \
7-
include/ex/bar.h \
8-
include/ex/nameable.h \
9-
include/ex/rstring.h \
10-
include/ex/shared-rstring.h \
1+
HEADER = include/ex/ex.h
112

123
RUST_SOURCES = \
134
src/lib.rs \
@@ -45,14 +36,22 @@ export LD_LIBRARY_PATH=$(PWD)/target/debug
4536
target/debug/libgobject_example.so: $(RUST_SOURCES)
4637
cargo build
4738

48-
Ex-0.1.gir: target/debug/libgobject_example.so $(HEADERS)
39+
GBINDGEN = cbindgen/target/debug/gbindgen
40+
41+
$(GBINDGEN):
42+
cargo build --all-features --manifest-path=cbindgen/Cargo.toml
43+
44+
$(HEADER): $(GBINDGEN) $(RUST_SOURCES)
45+
$(GBINDGEN) -o $(HEADER)
46+
47+
Ex-0.1.gir: target/debug/libgobject_example.so $(HEADER)
4948
g-ir-scanner -v --warn-all \
5049
--namespace Ex --nsversion=0.1 \
5150
-Iinclude --c-include "ex/ex.h" \
5251
--library=gobject_example --library-path=target/debug \
5352
--include=GObject-2.0 -pkg gobject-2.0 \
5453
--output $@ \
55-
$(HEADERS)
54+
$(HEADER)
5655

5756
Ex-0.1.typelib: Ex-0.1.gir
5857
g-ir-compiler \
@@ -86,7 +85,7 @@ test-vala: test.vala Ex-0.1.vapi
8685
run-vala: test-vala
8786
./test-vala
8887

89-
test-c: test.c target/debug/libgobject_example.so Ex-0.1.pc $(HEADERS)
88+
test-c: test.c target/debug/libgobject_example.so Ex-0.1.pc $(HEADER)
9089
$(CC) -Wall $< `pkg-config --cflags --libs Ex-0.1` -o $@
9190

9291
run-c: test-c

cbindgen

Submodule cbindgen added at 5443bec

include/ex/bar.h

-37
This file was deleted.

include/ex/color.h

-21
This file was deleted.

include/ex/error.h

-20
This file was deleted.

include/ex/ex.h

-13
This file was deleted.

include/ex/flags.h

-21
This file was deleted.

include/ex/foo.h

-39
This file was deleted.

include/ex/nameable.h

-28
This file was deleted.

include/ex/rstring.h

-22
This file was deleted.

include/ex/shared-rstring.h

-21
This file was deleted.

0 commit comments

Comments
 (0)