Skip to content

Commit 0eeb758

Browse files
committed
gir: Add GObject Introspection generation
1 parent 2f1a0cb commit 0eeb758

File tree

4 files changed

+60
-4
lines changed

4 files changed

+60
-4
lines changed

demo/main.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ int main(int argc, char **argv)
6060
app = gtk_application_new("com.mattjakeman.LibWebGTK", G_APPLICATION_DEFAULT_FLAGS);
6161

6262
gtk_init();
63-
webembed_init();
63+
web_embed_init();
6464

6565
g_signal_connect(app, "activate", G_CALLBACK (on_activate), NULL);
6666

src/CMakeLists.txt

+57-1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ set(SOURCES
2121
Embed/webembed.cpp
2222
)
2323

24+
set(EMBED
25+
"Embed/webcontentview.h"
26+
"Embed/webembed.h"
27+
)
28+
2429
add_library(webembed ${SOURCES})
2530

2631
set(DEPS ${GTK4_LIBRARIES} LibCore LibFileSystem LibGfx LibGUI LibIPC LibJS LibMain LibWeb LibWebView LibSQL LibWebSocket LibCrypto LibGemini LibHTTP LibTLS LibDiff)
@@ -42,4 +47,55 @@ add_subdirectory(SQLServer)
4247
add_subdirectory(WebContent)
4348
add_subdirectory(WebDriver)
4449

45-
add_dependencies(webembed SQLServer WebContent WebDriver)
50+
add_dependencies(webembed SQLServer WebContent WebDriver)
51+
52+
# Loosely inspired by HarfBuzz's Build System
53+
# Licensed under the "Old" MIT License
54+
set(INTROSPECTION ON)
55+
if (INTROSPECTION)
56+
find_package(PkgConfig)
57+
pkg_check_modules(GOBJECT_INTROSPECTION QUIET gobject-introspection-1.0)
58+
59+
find_program(G_IR_SCANNER g-ir-scanner
60+
HINTS ${PC_g_ir_scanner}
61+
)
62+
63+
find_program(G_IR_COMPILER g-ir-compiler
64+
HINTS ${PC_g_ir_compiler}
65+
)
66+
67+
set(G_IR_SCANNER_CMD "${G_IR_SCANNER}")
68+
set(web_libpath "$<TARGET_FILE_DIR:webembed>")
69+
70+
add_custom_command (
71+
TARGET webembed
72+
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
73+
POST_BUILD
74+
COMMAND ${G_IR_SCANNER_CMD}
75+
--warn-all --no-libtool --verbose
76+
--namespace=Web
77+
--nsversion=0.0
78+
--identifier-prefix=Web
79+
--symbol-prefix=web_
80+
--include GObject-2.0
81+
--include Gtk-4.0
82+
--pkg-export=webembed
83+
--library=webembed
84+
-L${web_libpath}
85+
${GTK4_CFLAGS}
86+
${EMBED}
87+
-o ${web_libpath}/Web-0.0.gir
88+
DEPENDS webembed
89+
)
90+
91+
add_custom_command (
92+
TARGET webembed
93+
POST_BUILD
94+
COMMAND "${G_IR_COMPILER}"
95+
--verbose --debug
96+
--includedir ${CMAKE_CURRENT_BINARY_DIR}
97+
${web_libpath}/Web-0.0.gir
98+
-o ${web_libpath}/Web-0.0.typelib
99+
DEPENDS ${web_libpath}/Web-0.0.gir webembed
100+
)
101+
endif ()

src/Embed/webembed.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ static ErrorOr<void> handle_attached_debugger()
4646

4747
std::unique_ptr<Core::EventLoop> event_loop_ptr;
4848

49-
void webembed_init()
49+
void web_embed_init()
5050
{
5151
gtk_init();
5252
Gtk::init_gtkmm_internals();

src/Embed/webembed.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
extern "C" {
1111
#endif
1212

13-
void webembed_init();
13+
void web_embed_init();
1414

1515
#ifdef __cplusplus
1616
}

0 commit comments

Comments
 (0)