|
| 1 | +class GnomeOnlineAccounts < Formula |
| 2 | + desc "Single sign-on framework for GNOME" |
| 3 | + homepage "https://gitlab.gnome.org/GNOME/gnome-online-accounts" |
| 4 | + url "https://download.gnome.org/sources/gnome-online-accounts/3.52/gnome-online-accounts-3.52.3.1.tar.xz" |
| 5 | + sha256 "49ed727d6fc49474996fa7edf0919b21e4fc856ea37e6e30f17b50b103af9701" |
| 6 | + license "LGPL-2.0-or-later" |
| 7 | + head "https://gitlab.gnome.org/GNOME/gnome-online-accounts.git", branch: "master" |
| 8 | + |
| 9 | + depends_on "dbus" => :build |
| 10 | + depends_on "docbook-xsl" => :build |
| 11 | + depends_on "gobject-introspection" => :build |
| 12 | + depends_on "meson" => :build |
| 13 | + depends_on "ninja" => :build |
| 14 | + depends_on "pkgconf" => [:build, :test] |
| 15 | + depends_on "vala" => :build |
| 16 | + |
| 17 | + depends_on "glib" |
| 18 | + depends_on "gtk4" |
| 19 | + depends_on "json-glib" |
| 20 | + depends_on "libadwaita" |
| 21 | + depends_on "libgoa" |
| 22 | + depends_on "librest" |
| 23 | + depends_on "libsecret" |
| 24 | + depends_on "libsoup" |
| 25 | + |
| 26 | + uses_from_macos "libxslt" => :build # for xsltproc |
| 27 | + uses_from_macos "libxml2" |
| 28 | + |
| 29 | + on_macos do |
| 30 | + depends_on "gettext" |
| 31 | + end |
| 32 | + |
| 33 | + on_linux do |
| 34 | + depends_on "gcr" |
| 35 | + depends_on "keyutils" |
| 36 | + depends_on "krb5" |
| 37 | + end |
| 38 | + |
| 39 | + def install |
| 40 | + # NOTE: `libgoa` is split out to provide a lightweight formula with minimal dependencies |
| 41 | + inreplace "src/meson.build", /^subdir\('goa'\)$/, "libgoa_dep = dependency(goa_api_name)" |
| 42 | + rm_r("src/goa") |
| 43 | + |
| 44 | + ENV["DESTDIR"] = "/" |
| 45 | + ENV["XML_CATALOG_FILES"] = etc/"xml/catalog" |
| 46 | + |
| 47 | + args = ["-Ddocumentation=false"] |
| 48 | + args << "-Dkerberos=false" if OS.mac? |
| 49 | + |
| 50 | + system "meson", "setup", "build", *args, *std_meson_args |
| 51 | + system "meson", "compile", "-C", "build", "--verbose" |
| 52 | + system "meson", "install", "-C", "build" |
| 53 | + end |
| 54 | + |
| 55 | + def post_install |
| 56 | + system Formula["glib"].opt_bin/"glib-compile-schemas", HOMEBREW_PREFIX/"share/glib-2.0/schemas" |
| 57 | + system Formula["gtk4"].opt_bin/"gtk4-update-icon-cache", "-f", "-t", HOMEBREW_PREFIX/"share/icons/hicolor" |
| 58 | + end |
| 59 | + |
| 60 | + test do |
| 61 | + # https://gitlab.gnome.org/GNOME/gnome-online-accounts/-/blob/master/src/examples/list-providers.c |
| 62 | + (testpath/"test.c").write <<~'C' |
| 63 | + #define GOA_API_IS_SUBJECT_TO_CHANGE |
| 64 | + #define GOA_BACKEND_API_IS_SUBJECT_TO_CHANGE |
| 65 | + #include <goabackend/goabackend.h> |
| 66 | +
|
| 67 | + typedef struct { |
| 68 | + GMainLoop *loop; |
| 69 | + GList *providers; |
| 70 | + GError *error; |
| 71 | + } GetAllData; |
| 72 | +
|
| 73 | + static void get_all_cb (GObject *source, GAsyncResult *res, gpointer user_data) { |
| 74 | + GetAllData *data = user_data; |
| 75 | + goa_provider_get_all_finish (&data->providers, res, &data->error); |
| 76 | + g_main_loop_quit (data->loop); |
| 77 | + } |
| 78 | +
|
| 79 | + int main (int argc, char **argv) { |
| 80 | + GetAllData data = {0,}; |
| 81 | + GoaProvider *provider; |
| 82 | + GList *l; |
| 83 | +
|
| 84 | + data.loop = g_main_loop_new (NULL, FALSE); |
| 85 | + goa_provider_get_all (get_all_cb, &data); |
| 86 | + g_main_loop_run (data.loop); |
| 87 | +
|
| 88 | + if (data.error != NULL) { |
| 89 | + g_printerr ("Failed to list providers: %s (%s, %d)\n", |
| 90 | + data.error->message, |
| 91 | + g_quark_to_string (data.error->domain), |
| 92 | + data.error->code); |
| 93 | + g_error_free (data.error); |
| 94 | + goto out; |
| 95 | + } |
| 96 | +
|
| 97 | + for (l = data.providers; l != NULL; l = l->next) { |
| 98 | + char *provider_name; |
| 99 | +
|
| 100 | + provider = GOA_PROVIDER (l->data); |
| 101 | + provider_name = goa_provider_get_provider_name (provider, NULL); |
| 102 | + g_print ("%s\n", provider_name); |
| 103 | + g_free (provider_name); |
| 104 | + provider = NULL; |
| 105 | + } |
| 106 | +
|
| 107 | + out: |
| 108 | + g_main_loop_unref (data.loop); |
| 109 | + g_list_free_full (data.providers, g_object_unref); |
| 110 | +
|
| 111 | + return 0; |
| 112 | + } |
| 113 | + C |
| 114 | + |
| 115 | + providers = ["Google", "WebDAV", "Nextcloud", "Microsoft", "Microsoft Exchange", "IMAP and SMTP"] |
| 116 | + providers << "Kerberos" unless OS.mac? |
| 117 | + providers << "Microsoft 365" |
| 118 | + |
| 119 | + system ENV.cc, "test.c", "-o", "test", *shell_output("pkgconf --cflags --libs goa-backend-1.0").chomp.split |
| 120 | + assert_equal providers, shell_output("./test").lines(chomp: true) |
| 121 | + end |
| 122 | +end |
0 commit comments