From 98fc3cf2108790200aa12635bc46e3cb3cb0139a Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Fri, 21 Mar 2025 10:40:00 +0100 Subject: all: move generated modules into gi:: namespace Signed-off-by: Drew DeVault --- Makefile | 43 +++++++++++++++++++++++++++++++++---------- bindings/gi/glib/types.ha | 10 ++++++++++ bindings/gi/gobject/types.ha | 13 +++++++++++++ bindings/glib/types.ha | 10 ---------- bindings/gobject/types.ha | 13 ------------- cmd/demo/main.ha | 8 ++++---- cmd/demo4/main.ha | 8 ++++---- generate | 29 +++++++++++++++-------------- generate4 | 37 +++++++++++++++++++------------------ 9 files changed, 98 insertions(+), 73 deletions(-) create mode 100644 bindings/gi/glib/types.ha create mode 100644 bindings/gi/gobject/types.ha delete mode 100644 bindings/glib/types.ha delete mode 100644 bindings/gobject/types.ha diff --git a/Makefile b/Makefile index 9b658bb..84d83cc 100644 --- a/Makefile +++ b/Makefile @@ -1,10 +1,7 @@ .POSIX: .SUFFIXES: -BINDINGS_DIR = bindings -CORE_MODULES = glib gobject gio gmodule atk gdkpixbuf freetype harfbuzz cairo pango xlib types/libc -MODULES3 = $(CORE_MODULES) gdk gtk -MODULES4 = $(CORE_MODULES) gdk4 gtk4 pangocairo graphene gsk +all: hare-gi DESTDIR = PREFIX = /usr/local @@ -12,31 +9,57 @@ SRCDIR = $(PREFIX)/src HARESRCDIR = $(SRCDIR)/hare THIRDPARTYDIR = $(HARESRCDIR)/third-party -all: - @true +BINDINGS_DIR = bindings +MODULES_CORE = \ + types/libc \ + gi/glib \ + gi/gobject \ + gi/gio \ + gi/gmodule +MODULES_GTK_SHARED = \ + gi/atk \ + gi/gdkpixbuf \ + gi/freetype \ + gi/harfbuzz \ + gi/cairo \ + gi/pango \ + gi/xlib +MODULES_GTK3 = $(MODULES_CORE) $(MODULES_GTK_SHARED) \ + gi/gdk \ + gi/gtk +MODULES_GTK4 = $(MODULES_CORE) $(MODULES_GTK_SHARED) \ + gi/gdk4 \ + gi/gtk4 \ + gi/pangocairo \ + gi/graphene \ + gi/gsk + +hare-gi: + hare build -o $@ cmd/hare-gi/ +.PHONY: hare-gi install: - @for mod in $(MODULES3); do \ + @for mod in $(MODULES_GTK3); do \ printf "installing %s\n" "$$mod"; \ mkdir -p "$(DESTDIR)$(THIRDPARTYDIR)/$$mod"; \ install -m644 "$(BINDINGS_DIR)/$$mod"/* "$(DESTDIR)$(THIRDPARTYDIR)/$$mod"; \ done install4: - @for mod in $(MODULES4); do \ + @for mod in $(MODULES_GTK4); do \ printf "installing %s\n" "$$mod"; \ mkdir -p "$(DESTDIR)$(THIRDPARTYDIR)/$$mod"; \ install -m644 "$(BINDINGS_DIR)/$$mod"/* "$(DESTDIR)$(THIRDPARTYDIR)/$$mod"; \ done uninstall: - @for mod in $(MODULES3); do \ + @for mod in $(MODULES_GTK3); do \ printf "uninstalling %s\n" "$$mod"; \ rm -r "$(DESTDIR)$(THIRDPARTYDIR)/$$mod"; \ done uninstall4: - @for mod in $(MODULES4); do \ + @for mod in $(MODULES_GTK4); do \ printf "uninstalling %s\n" "$$mod"; \ rm -r "$(DESTDIR)$(THIRDPARTYDIR)/$$mod"; \ done diff --git a/bindings/gi/glib/types.ha b/bindings/gi/glib/types.ha new file mode 100644 index 0000000..2492c4e --- /dev/null +++ b/bindings/gi/glib/types.ha @@ -0,0 +1,10 @@ +export type Type = size; + +// Boolean type used by GLib and related libraries, equivalent to gboolean in C. +export type boolean = uint; + +// True value of [[boolean]]. +export def TRUE: boolean = 1; + +// False value of [[boolean]]. +export def FALSE: boolean = 0; diff --git a/bindings/gi/gobject/types.ha b/bindings/gi/gobject/types.ha new file mode 100644 index 0000000..570fe30 --- /dev/null +++ b/bindings/gi/gobject/types.ha @@ -0,0 +1,13 @@ +use types::c; + +export type ValueUnion = union { + v_int: int, + v_uint: uint, + v_long: c::long, + v_ulong: c::ulong, + v_int64: i64, + v_uint64: u64, + v_float: f32, + v_double: f64, + v_pointer: *opaque, +}; diff --git a/bindings/glib/types.ha b/bindings/glib/types.ha deleted file mode 100644 index 2492c4e..0000000 --- a/bindings/glib/types.ha +++ /dev/null @@ -1,10 +0,0 @@ -export type Type = size; - -// Boolean type used by GLib and related libraries, equivalent to gboolean in C. -export type boolean = uint; - -// True value of [[boolean]]. -export def TRUE: boolean = 1; - -// False value of [[boolean]]. -export def FALSE: boolean = 0; diff --git a/bindings/gobject/types.ha b/bindings/gobject/types.ha deleted file mode 100644 index 570fe30..0000000 --- a/bindings/gobject/types.ha +++ /dev/null @@ -1,13 +0,0 @@ -use types::c; - -export type ValueUnion = union { - v_int: int, - v_uint: uint, - v_long: c::long, - v_ulong: c::ulong, - v_int64: i64, - v_uint64: u64, - v_float: f32, - v_double: f64, - v_pointer: *opaque, -}; diff --git a/cmd/demo/main.ha b/cmd/demo/main.ha index 8f9151b..a106b5c 100644 --- a/cmd/demo/main.ha +++ b/cmd/demo/main.ha @@ -1,7 +1,7 @@ -use gio; -use glib; -use gobject; -use gtk; +use gi::gio; +use gi::glib; +use gi::gobject; +use gi::gtk; use os; use rt; use types::c; diff --git a/cmd/demo4/main.ha b/cmd/demo4/main.ha index 97693eb..39ca4ca 100644 --- a/cmd/demo4/main.ha +++ b/cmd/demo4/main.ha @@ -1,7 +1,7 @@ -use gio; -use glib; -use gobject; -use gtk4; +use gi::gio; +use gi::glib; +use gi::gobject; +use gi::gtk4; use os; use rt; use types::c; diff --git a/generate b/generate index 0e7911b..3b17734 100755 --- a/generate +++ b/generate @@ -1,25 +1,26 @@ #!/bin/sh -BIND=./bindings +BIND=./bindings/gi +NS=gi:: mkdir -p "$BIND"/glib "$BIND"/gobject "$BIND"/gio "$BIND"/gmodule "$BIND"/atk \ "$BIND"/gdkpixbuf "$BIND"/freetype "$BIND"/harfbuzz "$BIND"/cairo \ "$BIND"/pango "$BIND"/gdk "$BIND"/xlib "$BIND"/gtk hare build cmd/hare-gi && exec ./hare-gi -B \ - -m GLib,glib,"$BIND"/glib/_generated.ha \ - -m GObject,gobject,"$BIND"/gobject/_generated.ha \ - -m Gio,gio,"$BIND"/gio/_generated.ha \ - -m GModule,gmodule,"$BIND"/gmodule/_generated.ha \ - -m Atk,atk,"$BIND"/atk/_generated.ha \ - -m GdkPixbuf,gdkpixbuf,"$BIND"/gdkpixbuf/_generated.ha \ - -m freetype2,freetype,"$BIND"/freetype/_generated.ha \ - -m HarfBuzz,harfbuzz,"$BIND"/harfbuzz/_generated.ha \ - -m cairo,cairo,"$BIND"/cairo/_generated.ha \ - -m Pango,pango,"$BIND"/pango/_generated.ha \ - -m Gdk,gdk,"$BIND"/gdk/_generated.ha \ - -m xlib,xlib,"$BIND"/xlib/_generated.ha \ - -m Gtk,gtk,"$BIND"/gtk/_generated.ha \ + -m GLib,${NS}glib,"$BIND"/glib/_generated.ha \ + -m GObject,${NS}gobject,"$BIND"/gobject/_generated.ha \ + -m Gio,${NS}gio,"$BIND"/gio/_generated.ha \ + -m GModule,${NS}gmodule,"$BIND"/gmodule/_generated.ha \ + -m Atk,${NS}atk,"$BIND"/atk/_generated.ha \ + -m GdkPixbuf,${NS}gdkpixbuf,"$BIND"/gdkpixbuf/_generated.ha \ + -m freetype2,${NS}freetype,"$BIND"/freetype/_generated.ha \ + -m HarfBuzz,${NS}harfbuzz,"$BIND"/harfbuzz/_generated.ha \ + -m cairo,${NS}cairo,"$BIND"/cairo/_generated.ha \ + -m Pango,${NS}pango,"$BIND"/pango/_generated.ha \ + -m Gdk,${NS}gdk,"$BIND"/gdk/_generated.ha \ + -m xlib,${NS}xlib,"$BIND"/xlib/_generated.ha \ + -m Gtk,${NS}gtk,"$BIND"/gtk/_generated.ha \ /usr/share/gir-1.0/GLib-2.0.gir \ /usr/share/gir-1.0/GObject-2.0.gir \ /usr/share/gir-1.0/Gio-2.0.gir \ diff --git a/generate4 b/generate4 index de2eb6f..26a15d4 100755 --- a/generate4 +++ b/generate4 @@ -1,29 +1,30 @@ #!/bin/sh -BIND=./bindings +BIND=./bindings/gi +NS=gi:: mkdir -p "$BIND"/glib "$BIND"/gobject "$BIND"/gio "$BIND"/gmodule "$BIND"/atk \ "$BIND"/gdkpixbuf "$BIND"/freetype "$BIND"/harfbuzz "$BIND"/cairo \ "$BIND"/pango "$BIND"/pangocairo "$BIND"/gdk4 "$BIND"/xlib "$BIND"/graphene \ "$BIND"/gsk "$BIND"/gtk4 -hare build cmd/hare-gi && exec ./hare-gi -B \ - -m GLib,glib,"$BIND"/glib/_generated.ha \ - -m GObject,gobject,"$BIND"/gobject/_generated.ha \ - -m Gio,gio,"$BIND"/gio/_generated.ha \ - -m GModule,gmodule,"$BIND"/gmodule/_generated.ha \ - -m Atk,atk,"$BIND"/atk/_generated.ha \ - -m GdkPixbuf,gdkpixbuf,"$BIND"/gdkpixbuf/_generated.ha \ - -m freetype2,freetype,"$BIND"/freetype/_generated.ha \ - -m HarfBuzz,harfbuzz,"$BIND"/harfbuzz/_generated.ha \ - -m cairo,cairo,"$BIND"/cairo/_generated.ha \ - -m Pango,pango,"$BIND"/pango/_generated.ha \ - -m PangoCairo,pangocairo,"$BIND"/pangocairo/_generated.ha \ - -m Gdk,gdk4,"$BIND"/gdk4/_generated.ha \ - -m xlib,xlib,"$BIND"/xlib/_generated.ha \ - -m Graphene,graphene,"$BIND"/graphene/_generated.ha \ - -m Gsk,gsk,"$BIND"/gsk/_generated.ha \ - -m Gtk,gtk4,"$BIND"/gtk4/_generated.ha \ +hare build cmd/hare-gi && exec ./hare-gi \ + -m GLib,${NS}glib,"$BIND"/glib/_generated.ha \ + -m GObject,${NS}gobject,"$BIND"/gobject/_generated.ha \ + -m Gio,${NS}gio,"$BIND"/gio/_generated.ha \ + -m GModule,${NS}gmodule,"$BIND"/gmodule/_generated.ha \ + -m Atk,${NS}atk,"$BIND"/atk/_generated.ha \ + -m GdkPixbuf,${NS}gdkpixbuf,"$BIND"/gdkpixbuf/_generated.ha \ + -m freetype2,${NS}freetype,"$BIND"/freetype/_generated.ha \ + -m HarfBuzz,${NS}harfbuzz,"$BIND"/harfbuzz/_generated.ha \ + -m cairo,${NS}cairo,"$BIND"/cairo/_generated.ha \ + -m Pango,${NS}pango,"$BIND"/pango/_generated.ha \ + -m PangoCairo,${NS}pangocairo,"$BIND"/pangocairo/_generated.ha \ + -m Gdk,${NS}gdk4,"$BIND"/gdk4/_generated.ha \ + -m xlib,${NS}xlib,"$BIND"/xlib/_generated.ha \ + -m Graphene,${NS}graphene,"$BIND"/graphene/_generated.ha \ + -m Gsk,${NS}gsk,"$BIND"/gsk/_generated.ha \ + -m Gtk,${NS}gtk4,"$BIND"/gtk4/_generated.ha \ /usr/share/gir-1.0/GLib-2.0.gir \ /usr/share/gir-1.0/GObject-2.0.gir \ /usr/share/gir-1.0/Gio-2.0.gir \ -- cgit 1.3.0-6-gf8a5