Skip to content

Commit

Permalink
stop using JLL-packaged introspection data
Browse files Browse the repository at this point in the history
  • Loading branch information
jwahlstrand committed Nov 9, 2024
1 parent c2e1262 commit 03c55fc
Show file tree
Hide file tree
Showing 19 changed files with 738 additions and 600 deletions.
4 changes: 2 additions & 2 deletions GI/src/giexport.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
function _enums_and_flags(es, skiplist, incl_typeinit, const_mod, const_exports, loaded)
for e in es
name = Symbol(get_name(e))
typeinit = in(name, skiplist) ? false : incl_typeinit
push!(const_mod.args, unblock(decl(e,typeinit)))
in(name, skiplist) && continue
push!(const_mod.args, unblock(decl(e,incl_typeinit)))
push!(const_exports.args, name)
push!(loaded,name)
end
Expand Down
2 changes: 0 additions & 2 deletions gen/Project.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
[deps]
EzXML = "8f5d6c58-4d21-5cfd-889c-e3ad7ee6a615"
GI = "1830b3f8-56ad-42bc-ae49-7513e085da97"
gdk_pixbuf_jll = "da03df04-f53b-5353-a52f-6a8b0620ced0"
gobject_introspection_jll = "6306888c-5478-5f78-9aeb-34cb5688c579"
8 changes: 3 additions & 5 deletions gen/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# Generation scripts for constants, structs, and `G_` modules

The scripts in this directory are used to generate code using GObject introspection.
Introspection data for GLib (which includes GObject and Gio namespaces) and Cairo is packaged in `gobject_introspection_jll` for the x86_64-linux-gnu platform. The same is true for GdkPixbuf, which is packaged in `gdk_pixbuf_jll`. The script `gen_all.jl` uses JLL packaged data to generate code. The autogenerated code is created in `src/gen`. This should work for anyone on x86_64-linux-gnu.

The long term plan is to do the same for the rest of the namespaces. So far this has proven to be a challenge. Currently, code for the other libraries (Graphene, Pango, and Gtk4) is generated using platform-installed libraries (outside JLL's) using the script `gen_rest.jl`. This has only been done so far on Fedora.

For the platform-installed libraries, the version of the libraries used to generate code should ideally be the same as in the JLL's.
The autogenerated code is created in `src/gen`.
Currently, code is generated using platform-installed libraries (outside JLL's) using the script `gen_all.jl`. This has only been done so far on Fedora.
The version of the platform-installed libraries used to generate code should ideally be the same as in the JLL's.
19 changes: 12 additions & 7 deletions gen/gen_all.jl
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
using gobject_introspection_jll, gdk_pixbuf_jll
using GI
using GI, EzXML

# Generates code for libraries where introspection data is present in JLL's
# This should work on any Linux machine
# Generates code for libraries where we use introspection data outside JLL's
# This code is typically run on a recent version of Fedora where the library
# version is the same or close to what's present in Yggdrasil.

GI.prepend_search_path(gobject_introspection_jll)
GI.prepend_search_path(gdk_pixbuf_jll)
GI.prepend_search_path("/usr/lib64/girepository-1.0")
include("gen_glib.jl")
include("gen_gobject.jl")
include("gen_gio.jl")
include("gen_cairo.jl")
include("gen_gdkpixbuf.jl")

include("gen_pango.jl")
include("gen_pangocairo.jl")
include("gen_graphene.jl")
include("gen_gsk.jl")
include("gen_gdk4.jl")
include("gen_gtk4.jl")
include("gen_adwaita.jl")
4 changes: 2 additions & 2 deletions gen/gen_gdkpixbuf.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ using GI
printstyled("Generating code for GdkPixbuf\n";bold=true)

ns = GINamespace(:GdkPixbuf,"2.0")
d = GI.read_gir(gdk_pixbuf_jll, ns)
d = readxml("/usr/share/gir-1.0/$(GI.ns_id(ns)).gir")
path="../src/gen"

GI.export_consts!(ns, path, "gdkpixbuf", [:PixbufFormatFlags]; doc_prefix = "gdk-pixbuf", doc_xml = d, export_constants = false)
GI.export_consts!(ns, path, "gdkpixbuf", []; doc_prefix = "gdk-pixbuf", doc_xml = d, export_constants = false)

## structs

Expand Down
4 changes: 2 additions & 2 deletions gen/gen_gio.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ toplevel, exprs, exports = GI.output_exprs()
path="../src/gen"

ns = GINamespace(:Gio,"2.0")
d = GI.read_gir(gobject_introspection_jll, ns)
d = readxml("/usr/share/gir-1.0/$(GI.ns_id(ns)).gir")

## structs

Expand All @@ -19,7 +19,7 @@ struct_skiplist=vcat(disguised, [:ActionEntry,:DBusAnnotationInfo,:DBusArgInfo,:
:XdpDocumentsSkeletonClass,:XdpOpenURIProxy,:XdpOpenURIProxyClass,:XdpOpenURISkeletonClass,
:XdpProxyResolverProxy,:XdpProxyResolverProxyClass,:XdpProxyResolverSkeleton,:XdpProxyResolverSkeletonClass,:XdpTrashProxy,:XdpTrashProxyClass,:XdpTrashSkeleton,:XdpTrashSkeletonClass,:_FreedesktopDBusProxyClass,:_FreedesktopDBusSkeletonClass])

obj_skiplist=[:UnixMountMonitor,:UnixOutputStream,:UnixInputStream,:UnixFDList,:UnixFDMessage,:UnixSocketAddress,:DebugControllerDBus]
obj_skiplist=[:UnixMountMonitor,:UnixOutputStream,:UnixInputStream,:UnixFDList,:UnixFDMessage,:UnixSocketAddress,:DebugControllerDBus,:DBusInterfaceSkeleton,:DBusObjectSkeleton,:DBusObjectManagerServer]

obj_constructor_skiplist = [:new_for_bus_sync,:new_sync,:new_with_fd_list,:new_for_address_finish,:new_for_bus_finish,:new_for_bus_finish,:new_from_filename,:new_loopback,:new_section,:new_with_default_fallbacks,:new_from_file_with_password]

Expand Down
30 changes: 22 additions & 8 deletions gen/gen_glib.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using gobject_introspection_jll
ENV["GI_TYPELIB_PATH"]=gobject_introspection_jll.find_artifact_dir()*"/lib/girepository-1.0"
using GI, EzXML

printstyled("Generating constants for GLib, GObject, and Gio\n";bold=true)
Expand Down Expand Up @@ -27,13 +25,13 @@ const_exports = Expr(:export)
const_skip = [:E,:LN2,:LN10,:LOG_2_BASE_10,:PI,:PI_2,:PI_4,:SQRT2]

c = GI.all_const_exprs!(const_mod, const_exports, ns, skiplist=const_skip; incl_typeinit=false)
dglib = GI.read_gir(gobject_introspection_jll, ns)
dglib = readxml("/usr/share/gir-1.0/$(GI.ns_id(ns)).gir")
GI.append_const_docs!(const_mod.args, "glib", dglib, c)
c = GI.all_const_exprs!(const_mod, const_exports, ns2, skiplist=[:ConnectFlags,:ParamFlags,:SignalFlags,:SignalMatchType,:TypeFlags,:TypeFundamentalFlags])
d = GI.read_gir(gobject_introspection_jll, ns2)
c = GI.all_const_exprs!(const_mod, const_exports, ns2, skiplist=[:IOCondition])
d = readxml("/usr/share/gir-1.0/$(GI.ns_id(ns2)).gir")
GI.append_const_docs!(const_mod.args, "gobject", d, c)
c = GI.all_const_exprs!(const_mod, const_exports, ns3, skiplist=[:TlsProtocolVersion])
d = GI.read_gir(gobject_introspection_jll, ns3)
d = readxml("/usr/share/gir-1.0/$(GI.ns_id(ns3)).gir")
GI.append_const_docs!(const_mod.args, "gio", d, c)
push!(const_mod.args,const_exports)

Expand Down Expand Up @@ -63,7 +61,7 @@ struct_skiplist=vcat(disguised, special, [:Cond,:HashTableIter,:Hook,
:TestLogBuffer,:TestLogMsg,:Thread,:ThreadPool,:Tree,:UriParamsIter])

callback_skiplist=[:LogWriterFunc]
constructor_skiplist=[:new,:new_take,:new_from_unix_utc,:new_now_utc,:new_utc,:new_maybe]
constructor_skiplist=[:new,:new_take,:new_from_unix_utc,:new_now_utc,:new_utc,:new_maybe,:new_from_unix_local_usec,:new_from_unix_utc_usec]

GI.export_struct_exprs!(ns,path, "glib", struct_skiplist, import_as_opaque; doc_xml = dglib, constructor_skiplist = constructor_skiplist, output_object_cache_init = false, output_object_cache_define = false, output_boxed_types_def = false, callback_skiplist)

Expand Down Expand Up @@ -94,7 +92,23 @@ GI.write_to_file(path,"glib_methods",toplevel)
toplevel, exprs, exports = GI.output_exprs()

# many of these are skipped because they involve callbacks
skiplist=[:convert,:atomic_rc_box_release_full,:child_watch_add,:datalist_foreach,:dataset_foreach,:io_add_watch,:io_create_watch,:log_set_handler,:log_set_writer_func,:rc_box_release_full,:spawn_async,:spawn_async_with_fds,:spawn_async_with_pipes,:spawn_async_with_pipes_and_fds,:spawn_sync,:test_add_data_func,:test_add_data_func_full,:test_add_func,:test_queue_destroy,:thread_self, :unix_fd_add_full,:unix_signal_add, :datalist_get_data, :datalist_get_flags, :datalist_id_get_data, :datalist_set_flags, :datalist_unset_flags,:hook_destroy,:hook_destroy_link,:hook_free,:hook_insert_before, :hook_prepend,:hook_unref,:poll, :sequence_get,:sequence_move,:sequence_move_range,:sequence_remove,:sequence_remove_range,:sequence_set,:sequence_swap,:shell_parse_argv,:source_remove_by_funcs_user_data,:test_run_suite, :assertion_message_error,:uri_parse_params, :pattern_match,:pattern_match_string,:log_structured_array,:log_writer_default,:log_writer_format_fields,:log_writer_journald,:log_writer_standard_streams,:parse_debug_string,:child_watch_source_new,:date_strftime,:idle_source_new,:main_current_source,:timeout_source_new,:timeout_source_new_seconds,:unix_fd_source_new,:unix_signal_source_new,:datalist_id_remove_multiple,:base64_encode_close,:base64_encode_step,:sequence_insert_before,:sequence_range_get_midpoint]
skiplist=[:convert,:atomic_rc_box_release_full,:child_watch_add,:datalist_foreach,:dataset_foreach,
:io_add_watch,:io_create_watch,:log_set_handler,:log_set_writer_func,:rc_box_release_full,
:spawn_async,:spawn_async_with_fds,:spawn_async_with_pipes,:spawn_async_with_pipes_and_fds,
:spawn_sync,:test_add_data_func,:test_add_data_func_full,:test_add_func,:test_queue_destroy,
:thread_self, :unix_fd_add_full,:unix_signal_add, :datalist_get_data, :datalist_get_flags,
:datalist_id_get_data, :datalist_set_flags, :datalist_unset_flags,:hook_destroy,
:hook_destroy_link,:hook_free,:hook_insert_before, :hook_prepend,:hook_unref,:poll,
:sequence_get,:sequence_move,:sequence_move_range,:sequence_remove,:sequence_remove_range,
:sequence_set,:sequence_swap,:shell_parse_argv,:source_remove_by_funcs_user_data,
:test_run_suite,:assertion_message_error,:uri_parse_params, :pattern_match,
:pattern_match_string,:log_structured_array,:log_writer_default,:log_writer_format_fields,
:log_writer_journald,:log_writer_standard_streams,:parse_debug_string,:lstat,:stat,
:child_watch_source_new,:date_strftime,:idle_source_new,:main_current_source,
:timeout_source_new,:timeout_source_new_seconds,:unix_fd_source_new,
:unix_signal_source_new,:datalist_id_remove_multiple,:base64_encode_close,
:base64_encode_step,:sequence_insert_before,:sequence_range_get_midpoint,
:list_push_allocator,:node_push_allocator,:slist_push_allocator,:sequence_foreach_range,:sequence_sort_changed,:sequence_sort_changed_iter]

GI.all_functions!(exprs,ns,skiplist=skiplist,symbol_skiplist=symbols_handled, liboverride=:libglib)

Expand Down
4 changes: 2 additions & 2 deletions gen/gen_gobject.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ printstyled("Generating code for GObject\n";bold=true)
path="../src/gen"

ns = GINamespace(:GObject,"2.0")
d = GI.read_gir(gobject_introspection_jll, ns)
d = readxml("/usr/share/gir-1.0/$(GI.ns_id(ns)).gir")

## structs

Expand Down Expand Up @@ -60,7 +60,7 @@ skiplist=vcat(handled_list,[:enum_complete_type_info,:enum_register_static,:flag
:source_set_closure,:source_set_dummy_callback,
:type_check_instance,:type_check_instance_is_a,:type_check_instance_is_fundamentally_a,
:type_default_interface_unref,:type_free_instance,
:type_name_from_instance,:type_register_fundamental,
:type_name_from_instance,:type_register_fundamental,:variant_get_gtype,
:signal_set_va_marshaller,:signal_emitv,:param_value_convert,:param_value_defaults,:param_value_set_default,:param_value_validate,:param_values_cmp])

GI.all_functions!(exprs,ns,skiplist=skiplist,symbol_skiplist=symbols_handled)
Expand Down
2 changes: 1 addition & 1 deletion gen/gen_gtk4.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ path="../src/gen"
ns = GINamespace(:Gtk,"4.0")
d = readxml("/usr/share/gir-1.0/$(GI.ns_id(ns)).gir")

GI.export_consts!(ns, path, "gtk4", [:CssParserError,:CssParserWarning]; doc_xml = d)
GI.export_consts!(ns, path, "gtk4", []; doc_xml = d)

disguised = Symbol[]
struct_skiplist=vcat(disguised, [:PageRange,:TreeRowReference])
Expand Down
14 changes: 0 additions & 14 deletions gen/gen_rest.jl

This file was deleted.

4 changes: 0 additions & 4 deletions src/gen/gio_functions
Original file line number Diff line number Diff line change
Expand Up @@ -666,10 +666,6 @@ $(Expr(:toplevel, quote
ret = ccall(("g_resolver_error_quark", libgio), UInt32, ())
ret
end
function resolver_record_type_to_rrtype(_type)
ret = ccall(("g_resolver_record_type_to_rrtype", libgio), Int32, (UInt32,), _type)
ret
end
function resource_error_quark()
ret = ccall(("g_resource_error_quark", libgio), UInt32, ())
ret
Expand Down
Loading

0 comments on commit 03c55fc

Please sign in to comment.