bin_PROGRAMS += g-ir-compiler g-ir-generate
bin_SCRIPTS += g-ir-scanner g-ir-annotation-tool
+bin_PROGRAMS += g-ir-dep-tool
if BUILD_DOCTOOL
bin_SCRIPTS += g-ir-doc-tool
libgirepository-1.0.la \
$(GIREPO_LIBS)
+g_ir_dep_tool_SOURCES = tools/g-ir-dep-tool.c
+g_ir_dep_tool_CFLAGS = $(GIO_CFLAGS) -I$(top_srcdir)/girepository
+g_ir_dep_tool_LDADD = \
+ libgirepository-internals.la \
+ libgirepository-1.0.la \
+ $(GIREPO_LIBS)
+
GCOVSOURCES = \
$(g_ir_compiler_SOURCES) \
$(g_ir_generate_SOURCES)
-CLEANFILES += g-ir-scanner g-ir-annotation-tool g-ir-doc-tool
+CLEANFILES += g-ir-scanner g-ir-annotation-tool g-ir-doc-tool g-ir-dep-tool
--- /dev/null
+#!/bin/sh
+
+# Automatically find Provides and Requires for typelib() gobject-introspection bindings.
+# can be started with -R (Requires) and -P (Provides)
+
+# Copyright 2011 by Dominique Leuenberger, Amsterdam, Netherlands (dimstar [at] opensuse.org)
+# This file is released under the GPLv2 or later.
+
+function split_name_version {
+base=$1
+tsymbol=${base%-*}
+# Sometimes we get a Requires on Gdk.Settings.foo, bebause you can directly use imports.gi.Gdk.Settings.Foo in Javascript.
+# We know that the symbol in this case is call Gdk, so we cut everything after the . away.
+symbol=$(echo $tsymbol | awk -F. '{print $1}')
+version=${base#*-}
+# In case there is no '-' in the filename, then the split above 'fails' and version == symbol (thus: no version specified)
+if [ "$tsymbol" = "$version" ]; then
+ unset version
+fi
+}
+
+function print_req_prov {
+echo -n "typelib($symbol)"
+if [ ! -z "$version" ]; then
+ echo " = ${version}"
+else
+ echo ""
+fi
+}
+
+function find_provides {
+while read file; do
+ case $file in
+ *.typelib)
+ split_name_version $(basename $file | sed 's,.typelib$,,')
+ print_req_prov
+ ;;
+ esac
+done
+}
+
+function find_requires {
+# FIXME: There are multiple ways gi bindings can be imported. We only catch the 'basic' one
+# Currently, we detect:
+# - in python:
+# . from gi.repository import foo [Unversioned requirement of 'foo']
+# . from gi.repository import foo-1.0 [versioned requirement]
+# . And we do not stumble over:
+# from gi.repository import foo as _bar
+# from gi.repository import foo, bar
+# - in JS:
+# . imports.gi.foo; [unversioned requirement of 'foo']
+# . imports.gi.goo-1.0; [versioned requirement]
+# . The imports can be listed on one line, and we catch them.
+# Forms currently not detected:
+# - js: imports.gi.versions.Gtk = '3.0';
+# - py: gi.require_version('Gtk', '3.0')
+
+while read file; do
+ case $file in
+ *.js)
+ for module in $(grep -h -P -o "imports.gi.([^\s'\";]+)" $file | grep -v "imports.gi.version" | sed -r -e 's,\s+$,,g' -e 's,imports.gi.,,'); do
+ split_name_version $module
+ print_req_prov
+ done
+ for module in $(grep -h -P -o "imports.gi.versions.([^\s'\";]+)\s*=\s*['\"].+['\"]" $file | \
+ sed -e 's:imports.gi.versions.::' -e "s:['\"]::g" -e 's:=:-:' -e 's: ::g'); do
+ split_name_version $module
+ print_req_prov
+ done
+ ;;
+ *.py)
+ for module in $(grep -h -P "from gi.repository import (\w+)" $file | sed -e 's:#.*::' -e 's:raise ImportError.*::' | sed -e 's,from gi.repository import,,' -r -e 's:\s+$::g' -e 's:\s+as\s+\w+::g' -e 's:,: :g'); do
+ split_name_version $module
+ print_req_prov
+ done
+ ;;
+ *.typelib)
+ split_name_version $(basename $file | sed 's,.typelib$,,')
+ oldIFS=$IFS
+ IFS=$'\n'
+ for req in $(g-ir-dep-tool $symbol $version); do
+ case $req in
+ typelib:*)
+ module=${req#typelib: }
+ split_name_version $module
+ print_req_prov
+ ;;
+ shlib:*)
+ echo "${req#shlib: }${shlib_64}"
+ ;;
+ esac
+ done
+ IFS=$oldIFS
+ ;;
+ esac
+done
+}
+
+for path in \
+ $(for tlpath in \
+ $(find ${RPM_BUILD_ROOT}/usr/lib64 ${RPM_BUILD_ROOT}/usr/lib /usr/lib64 /usr/lib -name '*.typelib' 2>/dev/null); do
+ dirname $tlpath; done | uniq ); do
+ export GI_TYPELIB_PATH=$GI_TYPELIB_PATH:$path
+done
+
+if [ "${HOSTTYPE}" == "x86_64" -o "${HOSTTYPE}" == "ppc64" -o "${HOSTTYPE}" == "s390x" -o "${HOSTTYPE}" == "ia64" ]; then
+ shlib_64="()(64bit)"
+fi
+case $1 in
+ -P)
+ find_provides
+ ;;
+ -R)
+ find_requires
+ ;;
+esac
+
--- /dev/null
+addFilter(".*devel-file-in-non-devel-package.*/usr/share/gir-.*/*\.gir")
+addFilter(".*devel-file-in-non-devel-package.*/usr/share/gobject-introspection-.*/*\.[ch]")
--- /dev/null
+typelib(DBus) = 1.0
+typelib(DBusGLib) = 1.0
+typelib(GIRepository) = 2.0
+typelib(GL) = 1.0
+typelib(GLib) = 2.0
+typelib(GModule) = 2.0
+typelib(GObject) = 2.0
+typelib(Gio) = 2.0
+typelib(cairo) = 1.0
+typelib(fontconfig) = 2.0
+typelib(freetype2) = 2.0
+typelib(libxml2) = 2.0
+typelib(xfixes) = 4.0
+typelib(xft) = 2.0
+typelib(xlib) = 2.0
+typelib(xrandr) = 1.3
--- /dev/null
+Name: gobject-introspection
+Version: 1.34.0
+Release: 3.2
+Summary: GObject Introspection Tools
+License: LGPL-2.1+ and GPL-2.0+
+Group: Development/Libraries/GNOME
+Url: http://live.gnome.org/GObjectIntrospection
+Source0: http://download.gnome.org/sources/gobject-introspection/1.34/%{name}-%{version}.tar.xz
+Source1: gi-find-deps.sh
+Source2: gobjectintrospection.attr
+Source3: gobject-introspection-typelib.template
+Source99: %{name}-rpmlintrc
+BuildRequires: bison
+BuildRequires: fdupes
+BuildRequires: flex
+BuildRequires: libffi-devel
+BuildRequires: libtool
+BuildRequires: python-devel
+BuildRequires: python-xml
+BuildRequires: pkgconfig(cairo)
+BuildRequires: pkgconfig(cairo-gobject)
+BuildRequires: pkgconfig(gobject-2.0)
+Requires: libgirepository = %{version}
+Requires: python-xml
+BuildRoot: %{_tmppath}/%{name}-%{version}-build
+
+%description
+The goal of the project is to describe the APIs and collect them in
+a uniform, machine readable format.
+
+%package -n libgirepository
+Summary: GObject Introspection Library
+License: LGPL-2.1+
+Group: System/Libraries
+Requires: girepository >= %{version}
+
+%description -n libgirepository
+The goal of the project is to describe the APIs and collect them in
+a uniform, machine readable format.
+
+%package -n girepository
+Summary: Base GObject Introspection Bindings
+License: LGPL-2.1+
+Group: System/Libraries
+Requires: libgirepository >= %{version}
+%(cat %{S:3} | awk '{ print "Provides: " $0}')
+
+%description -n girepository
+The goal of the project is to describe the APIs and collect them in
+a uniform, machine readable format.
+
+%package devel
+Summary: GObject Introspection Development Files
+License: LGPL-2.1+
+Group: Development/Libraries/GNOME
+# Note: the devel package requires the binaries, not just the library
+Requires: %{name} = %{version}
+Requires: libffi-devel
+
+%description devel
+The goal of the project is to describe the APIs and collect them in
+a uniform, machine readable format.
+
+%prep
+%setup -q
+
+%if 0%{?BUILD_FROM_VCS}
+[ -x ./autogen.sh ] && NOCONFIGURE=1 ./autogen.sh
+%endif
+
+%build
+autoreconf -fi
+%configure \
+%if 0%{?BUILD_FROM_VCS}
+ --enable-gtk-doc \
+%endif
+ --disable-static
+%__make %{?_smp_mflags} V=1
+
+%install
+%make_install
+find %{buildroot} -type f -name "*.la" -delete -print
+install -D %{S:1} %{buildroot}%{_rpmconfigdir}/gi-find-deps.sh
+install -D %{S:2} -m 0644 %{buildroot}%{_rpmconfigdir}/fileattrs/gobjectintrospection.attr
+# comparing, if we provide all the symbols expected.
+ls %{buildroot}%{_libdir}/girepository-1.0/*.typelib | sh %{S:1} -P > gobject-introspection-typelib.installed
+diff -s %{S:3} gobject-introspection-typelib.installed
+%fdupes %{buildroot}
+
+
+%post -n libgirepository -p /sbin/ldconfig
+
+%postun -n libgirepository -p /sbin/ldconfig
+
+%docs_package
+
+%files
+%defattr(-,root,root)
+%doc COPYING COPYING.GPL
+%{_bindir}/g-ir-annotation-tool
+%{_bindir}/g-ir-compiler
+%{_bindir}/g-ir-dep-tool
+%{_bindir}/g-ir-generate
+%{_bindir}/g-ir-scanner
+%{_datadir}/aclocal/introspection.m4
+%{_datadir}/gir-1.0/*.gir
+%dir %{_libdir}/gobject-introspection
+%{_libdir}/gobject-introspection/giscanner/
+%dir %{_datadir}/gobject-introspection-1.0
+%{_datadir}/gobject-introspection-1.0/Makefile.introspection
+%{_datadir}/gobject-introspection-1.0/tests/
+%{_datadir}/gobject-introspection-1.0/gdump.c
+%{_rpmconfigdir}/gi-find-deps.sh
+%{_rpmconfigdir}/fileattrs/gobjectintrospection.attr
+
+%files -n libgirepository
+%defattr(-,root,root)
+%doc COPYING.LGPL
+%dir %{_datadir}/gir-1.0
+%{_libdir}/libgirepository-1.0.so.*
+%dir %{_libdir}/girepository-1.0
+
+%files -n girepository
+%defattr(-,root,root)
+%{_libdir}/girepository-1.0/*.typelib
+
+%files devel
+%defattr(-,root,root)
+%doc %{_datadir}/gtk-doc/html/gi/
+%{_includedir}/gobject-introspection-1.0/
+%{_libdir}/libgirepository-1.0.so
+%{_libdir}/pkgconfig/gobject-introspection-1.0.pc
+%{_libdir}/pkgconfig/gobject-introspection-no-export-1.0.pc
--- /dev/null
+%__gobjectintrospection_provides %{_rpmconfigdir}/gi-find-deps.sh -P
+%__gobjectintrospection_requires %{_rpmconfigdir}/gi-find-deps.sh -R
+%__gobjectintrospection_path ^(%{_libdir}/.*\.typelib)|(.*\.py)|(.*\.js)$
+%__gobjectintrospection_exclude_path ^/usr/share/doc/packages/
--- /dev/null
+
+/* -*- Mode: C; c-file-style: "gnu"; -*- */
+/* GObject introspection: typelib dependency scanner
+ *
+ * Copyright (C) 2011 Dominique Leuenberger
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include <glib.h>
+#include <girepository.h>
+
+int main(int argc, char *argv[]) {
+ GError *err = NULL;
+ GITypelib *typelib;
+ gchar **deps;
+ const gchar *shlibs;
+ int i;
+ const char *namespace = argv[1];
+ const char *version = argv[2];
+
+ g_type_init();
+
+ if (argc < 2 || argc > 3) {
+ g_print ("Usage: %s <typelib> [<version>]\n\n", argv[0]);
+ g_print (" typelib: The namespace of the typelib to inspect\n");
+ g_print (" version: The version of the typelib to inspect\n");
+ return 1;
+ }
+
+ /* Try to load the typelib specified as parameter */
+ typelib = g_irepository_require (NULL, namespace, version, 0, &err);
+
+ if (!typelib) {
+ g_printerr ("ERROR: Failed to load typelib '%s'\n", namespace);
+ return 2;
+ }
+
+ /* Finding all the typelib based Requires */
+ deps = g_irepository_get_dependencies (NULL, namespace);
+ if (deps) {
+ for (i=0; deps[i]; i++) {
+ g_print ("typelib: %s\n", deps[i]);
+ }
+ g_strfreev (deps);
+ }
+
+ /* Finding the shared library we depend on (if any) */
+ shlibs = g_irepository_get_shared_library (NULL, namespace);
+
+ if (shlibs != NULL && shlibs[0] != '\0')
+ {
+ /* libs is a comma-separated list of libraries */
+ gchar **libs = g_strsplit (shlibs, ",", 0);
+
+ for (i = 0; libs[i]; i++)
+ {
+ g_print ("shlib: %s\n", libs[i]);
+ }
+ }
+
+ g_typelib_free (typelib);
+
+ return 0;
+}