diff options
author | Alyssa Ross <hi@alyssa.is> | 2019-01-07 02:18:36 +0000 |
---|---|---|
committer | Alyssa Ross <hi@alyssa.is> | 2019-01-07 02:18:47 +0000 |
commit | 36f56d99fa0a0765c9f1de4a5f17a9b05830c3f2 (patch) | |
tree | b3faaf573407b32aa645237a4d16b82778a39a92 /nixpkgs/pkgs/development/libraries/gobject-introspection | |
parent | 4e31070265257dc67d120c27e0f75c2344fdfa9a (diff) | |
parent | abf060725d7614bd3b9f96764262dfbc2f9c2199 (diff) | |
download | nixlib-36f56d99fa0a0765c9f1de4a5f17a9b05830c3f2.tar nixlib-36f56d99fa0a0765c9f1de4a5f17a9b05830c3f2.tar.gz nixlib-36f56d99fa0a0765c9f1de4a5f17a9b05830c3f2.tar.bz2 nixlib-36f56d99fa0a0765c9f1de4a5f17a9b05830c3f2.tar.lz nixlib-36f56d99fa0a0765c9f1de4a5f17a9b05830c3f2.tar.xz nixlib-36f56d99fa0a0765c9f1de4a5f17a9b05830c3f2.tar.zst nixlib-36f56d99fa0a0765c9f1de4a5f17a9b05830c3f2.zip |
Add 'nixpkgs/' from commit 'abf060725d7614bd3b9f96764262dfbc2f9c2199'
git-subtree-dir: nixpkgs git-subtree-mainline: 4e31070265257dc67d120c27e0f75c2344fdfa9a git-subtree-split: abf060725d7614bd3b9f96764262dfbc2f9c2199
Diffstat (limited to 'nixpkgs/pkgs/development/libraries/gobject-introspection')
6 files changed, 339 insertions, 0 deletions
diff --git a/nixpkgs/pkgs/development/libraries/gobject-introspection/absolute_gir_path.patch b/nixpkgs/pkgs/development/libraries/gobject-introspection/absolute_gir_path.patch new file mode 100644 index 000000000000..d4160b51d68c --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/gobject-introspection/absolute_gir_path.patch @@ -0,0 +1,11 @@ +--- a/gir/cairo-1.0.gir.in ++++ b/gir/cairo-1.0.gir.in +@@ -5,7 +5,7 @@ + xmlns:glib="http://www.gtk.org/introspection/glib/1.0"> + <package name="@CAIRO_GIR_PACKAGE@"/> + <namespace name="cairo" version="1.0" +- shared-library="@CAIRO_SHARED_LIBRARY@" ++ shared-library="@cairoLib@/@CAIRO_SHARED_LIBRARY@" + c:identifier-prefixes="cairo" + c:symbol-prefixes="cairo"> + <record name="Context" c:type="cairo_t" foreign="1" diff --git a/nixpkgs/pkgs/development/libraries/gobject-introspection/absolute_shlib_path.patch b/nixpkgs/pkgs/development/libraries/gobject-introspection/absolute_shlib_path.patch new file mode 100644 index 000000000000..e2525d833f8f --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/gobject-introspection/absolute_shlib_path.patch @@ -0,0 +1,134 @@ +--- a/giscanner/scannermain.py ++++ b/giscanner/scannermain.py +@@ -101,6 +101,39 @@ + return group + + ++def _get_default_fallback_libpath(): ++ # Newer multiple-output-optimized stdenv has an environment variable ++ # $outputLib which in turn specifies another variable which then is used as ++ # the destination for the library contents (${!outputLib}/lib). ++ store_path = os.environ.get(os.environ.get("outputLib")) if "outputLib" in os.environ else None ++ if store_path is None: ++ outputs = os.environ.get("outputs", "out").split() ++ if "lib" in outputs: ++ # For multiple output derivations let's try whether there is a $lib ++ # environment variable and use that as the base store path. ++ store_path = os.environ.get("lib") ++ elif "out" in outputs: ++ # Otherwise we have a single output derivation, so the libraries ++ # most certainly will end up in "$out/lib". ++ store_path = os.environ.get("out") ++ ++ if store_path is not None: ++ # Even if we have a $lib as output, there still should be a $lib/lib ++ # directory. ++ return os.path.join(store_path, 'lib') ++ else: ++ # If we haven't found a possible scenario, let's return an empty string ++ # so that the shared library won't be prepended with a path. ++ # ++ # Note that this doesn't mean that all hope is lost, because after all ++ # we can still use --fallback-library-path to set one. ++ # ++ # Also, we're not returning None, because that would make it very ++ # difficult to disable adding fallback paths altogether using something ++ # like: --fallback-library-path="" ++ return "" ++ ++ + def _get_option_parser(): + parser = optparse.OptionParser('%prog [options] sources', + version='%prog ' + giscanner.__version__) +@@ -211,6 +244,10 @@ + parser.add_option("", "--filelist", + action="store", dest="filelist", default=[], + help="file containing headers and sources to be scanned") ++ parser.add_option("", "--fallback-library-path", ++ action="store", dest="fallback_libpath", ++ default=_get_default_fallback_libpath(), ++ help="Path to prepend to unknown shared libraries") + + group = get_preprocessor_option_group(parser) + parser.add_option_group(group) +--- a/giscanner/shlibs.py ++++ b/giscanner/shlibs.py +@@ -62,6 +62,12 @@ + $""" % re.escape(library_name), re.VERBOSE) + + ++def _ldd_library_nix_pattern(library_name): ++ nix_store_dir = re.escape('@nixStoreDir@'.rstrip('/')) ++ pattern = r'(%s(?:/[^/]*)+lib%s[^A-Za-z0-9_-][^\s\(\)]*)' ++ return re.compile(pattern % (nix_store_dir, re.escape(library_name))) ++ ++ + # This is a what we do for non-la files. We assume that we are on an + # ELF-like system where ldd exists and the soname extracted with ldd is + # a filename that can be opened with dlopen(). +@@ -110,17 +116,16 @@ def _resolve_non_libtool(options, binary, libraries): + if isinstance(output, bytes): + output = output.decode("utf-8", "replace") + +- # Use absolute paths on OS X to conform to how libraries are usually +- # referenced on OS X systems, and file names everywhere else. +- basename = platform.system() != 'Darwin' +- return resolve_from_ldd_output(libraries, output, basename=basename) ++ # Never strip away absolute paths in Nix ++ basename = False ++ return resolve_from_ldd_output(libraries, output, basename=basename, fallback_libpath=options.fallback_libpath) + + +-def resolve_from_ldd_output(libraries, output, basename=False): ++def resolve_from_ldd_output(libraries, output, basename=False, fallback_libpath=""): + patterns = {} + for library in libraries: + if not os.path.isfile(library): +- patterns[library] = _ldd_library_pattern(library) ++ patterns[library] = (_ldd_library_pattern(library), _ldd_library_nix_pattern(library)) + if len(patterns) == 0: + return [] + +@@ -129,11 +134,14 @@ def resolve_from_ldd_output(libraries, output, basename=False): + if line.endswith(':'): + continue + for word in line.split(): +- for library, pattern in patterns.items(): +- m = pattern.match(word) ++ for library, (pattern, nix_pattern) in patterns.items(): ++ if line.find('@nixStoreDir@') != -1: ++ m = nix_pattern.match(word) ++ else: ++ m = pattern.match(word) + if m: + del patterns[library] +- shlibs.append(_sanitize_install_name(m.group())) ++ shlibs.append(os.path.join(fallback_libpath, _sanitize_install_name(m.group()))) + break + + if len(patterns) > 0: +--- a/giscanner/utils.py ++++ b/giscanner/utils.py +@@ -116,17 +116,11 @@ + if dlname is None: + return None + +- # Darwin uses absolute paths where possible; since the libtool files never +- # contain absolute paths, use the libdir field +- if platform.system() == 'Darwin': +- dlbasename = os.path.basename(dlname) +- libdir = _extract_libdir_field(la_file) +- if libdir is None: +- return dlbasename +- return libdir + '/' + dlbasename +- # From the comments in extract_libtool(), older libtools had +- # a path rather than the raw dlname +- return os.path.basename(dlname) ++ dlbasename = os.path.basename(dlname) ++ libdir = _extract_libdir_field(la_file) ++ if libdir is None: ++ return dlbasename ++ return libdir + '/' + dlbasename + + + def extract_libtool(la_file): diff --git a/nixpkgs/pkgs/development/libraries/gobject-introspection/default.nix b/nixpkgs/pkgs/development/libraries/gobject-introspection/default.nix new file mode 100644 index 000000000000..3dc66aec1595 --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/gobject-introspection/default.nix @@ -0,0 +1,81 @@ +{ stdenv, fetchurl, glib, flex, bison, meson, ninja, pkgconfig, libffi, python3 +, libintl, cctools, cairo, gnome3, glibcLocales, fetchpatch +, substituteAll, nixStoreDir ? builtins.storeDir +, x11Support ? true +}: +# now that gobject-introspection creates large .gir files (eg gtk3 case) +# it may be worth thinking about using multiple derivation outputs +# In that case its about 6MB which could be separated + +let + pname = "gobject-introspection"; + version = "1.58.1"; +in +with stdenv.lib; +stdenv.mkDerivation rec { + name = "${pname}-${version}"; + + src = fetchurl { + url = "mirror://gnome/sources/${pname}/${stdenv.lib.versions.majorMinor version}/${name}.tar.xz"; + sha256 = "12fzs3044047icdfs7cb2lsmnfi6w6fyhkci3m2rbvf5llgnhm29"; + }; + + outputs = [ "out" "dev" "man" ]; + outputBin = "dev"; + + LC_ALL = "en_US.UTF-8"; # for tests + + nativeBuildInputs = [ meson ninja pkgconfig libintl glibcLocales ]; + buildInputs = [ flex bison python3 setupHook/*move .gir*/ ] + ++ stdenv.lib.optional stdenv.isDarwin cctools; + propagatedBuildInputs = [ libffi glib ]; + + mesonFlags = [ + "--datadir=${placeholder "dev"}/share" + ]; + + # outputs TODO: share/gobject-introspection-1.0/tests is needed during build + # by pygobject3 (and maybe others), but it's only searched in $out + + setupHook = ./setup-hook.sh; + + patches = [ + ./macos-shared-library.patch + (substituteAll { + src = ./test_shlibs.patch; + inherit nixStoreDir; + }) + (substituteAll { + src = ./absolute_shlib_path.patch; + inherit nixStoreDir; + }) + ] ++ stdenv.lib.optional x11Support # https://github.com/NixOS/nixpkgs/issues/34080 + (substituteAll { + src = ./absolute_gir_path.patch; + cairoLib = "${getLib cairo}/lib"; + }); + + doCheck = true; + + passthru = { + updateScript = gnome3.updateScript { + packageName = pname; + }; + }; + + meta = with stdenv.lib; { + description = "A middleware layer between C libraries and language bindings"; + homepage = http://live.gnome.org/GObjectIntrospection; + maintainers = with maintainers; [ lovek323 lethalman ]; + platforms = platforms.unix; + license = with licenses; [ gpl2 lgpl2 ]; + + longDescription = '' + GObject introspection is a middleware layer between C libraries (using + GObject) and language bindings. The C library can be scanned at compile + time and generate a metadata file, in addition to the actual native C + library. Then at runtime, language bindings can read this metadata and + automatically provide bindings to call into the C library. + ''; + }; +} diff --git a/nixpkgs/pkgs/development/libraries/gobject-introspection/macos-shared-library.patch b/nixpkgs/pkgs/development/libraries/gobject-introspection/macos-shared-library.patch new file mode 100644 index 000000000000..9941878c427b --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/gobject-introspection/macos-shared-library.patch @@ -0,0 +1,36 @@ +diff --git a/giscanner/shlibs.py b/giscanner/shlibs.py +index c93d20c..4d4915d 100644 +--- a/giscanner/shlibs.py ++++ b/giscanner/shlibs.py +@@ -43,6 +43,22 @@ def _resolve_libtool(options, binary, libraries): + + return shlibs + ++def _sanitize_install_name(install_name): ++ ''' ++ On macOS, the dylib can be built with install_name as @rpath/libfoo.so ++ instead of the absolute path to the library, so handle that. The name ++ can also be @loader_path or @executable_path. ++ ''' ++ if not install_name.startswith('@'): ++ return install_name ++ if install_name.startswith('@rpath/'): ++ return install_name[7:] ++ if install_name.startswith('@loader_path/'): ++ return install_name[13:] ++ if install_name.startswith('@executable_path/'): ++ return install_name[17:] ++ raise RuntimeError('Unknown install_name {!r}'.format(install_name)) ++ + + # Assume ldd output is something vaguely like + # +@@ -136,7 +152,7 @@ def resolve_from_ldd_output(libraries, output, basename=False): + m = pattern.match(word) + if m: + del patterns[library] +- shlibs.append(m.group()) ++ shlibs.append(_sanitize_install_name(m.group())) + break + + if len(patterns) > 0: diff --git a/nixpkgs/pkgs/development/libraries/gobject-introspection/setup-hook.sh b/nixpkgs/pkgs/development/libraries/gobject-introspection/setup-hook.sh new file mode 100644 index 000000000000..a79ce05a38df --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/gobject-introspection/setup-hook.sh @@ -0,0 +1,27 @@ +make_gobject_introspection_find_gir_files() { + # required for .typelib files, eg mypaint git version + if [ -d "$1/lib/girepository-1.0" ]; then + addToSearchPath GI_TYPELIB_PATH $1/lib/girepository-1.0 + fi + + # XDG_DATA_DIRS: required for .gir files? + if [ -d "$1/share" ]; then + addToSearchPath XDG_DATA_DIRS $1/share + fi +} + +addEnvHooks "$hostOffset" make_gobject_introspection_find_gir_files + +giDiscoverSelf() { + if [ -d "$prefix/lib/girepository-1.0" ]; then + addToSearchPath GI_TYPELIB_PATH $prefix/lib/girepository-1.0 + fi +} + +preFixupHooks+=(giDiscoverSelf) + +_multioutMoveGlibGir() { + moveToOutput share/gir-1.0 "${!outputDev}" +} + +preFixupHooks+=(_multioutMoveGlibGir) diff --git a/nixpkgs/pkgs/development/libraries/gobject-introspection/test_shlibs.patch b/nixpkgs/pkgs/development/libraries/gobject-introspection/test_shlibs.patch new file mode 100644 index 000000000000..c3152982d199 --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/gobject-introspection/test_shlibs.patch @@ -0,0 +1,50 @@ +--- a/tests/scanner/test_shlibs.py ++++ b/tests/scanner/test_shlibs.py +@@ -10,6 +10,46 @@ from giscanner.shlibs import resolve_from_ldd_output + + class TestLddParser(unittest.TestCase): + ++ def test_resolve_from_ldd_output_nix(self): ++ output = '''\ ++ libglib-2.0.so.0 => @nixStoreDir@/gmrf09y7sfxrr0mcx90dba7w41jj2kzk-glib-2.58.1/lib/libglib-2.0.so.0 (0x00007f0ee1b28000) ++ libgobject-2.0.so.0 => @nixStoreDir@/gmrf09y7sfxrr0mcx90dba7w41jj2kzk-glib-2.58.1/lib/libgobject-2.0.so.0 (0x00007f0ee18cf000) ++ libgio-2.0.so.0 => @nixStoreDir@/gmrf09y7sfxrr0mcx90dba7w41jj2kzk-glib-2.58.1/lib/libgio-2.0.so.0 (0x00007f0ee1502000) ++ libxml2.so.2 => @nixStoreDir@/72mxkk74cv266snkjpz1kwl1i2rg8rpc-libxml2-2.9.8/lib/libxml2.so.2 (0x00007f0ee119c000) ++ libsqlite3.so.0 => @nixStoreDir@/ck5ay23hsmlc67pg3m34kzd1k2hhvww0-sqlite-3.24.0/lib/libsqlite3.so.0 (0x00007f0ee0e98000) ++ libpsl.so.5 => @nixStoreDir@/qn3l2gn7m76f318676wflrs2z6d4rrkj-libpsl-0.20.2-list-2017-02-03/lib/libpsl.so.5 (0x00007f0ee0c88000) ++ libc.so.6 => @nixStoreDir@/g2yk54hifqlsjiha3szr4q3ccmdzyrdv-glibc-2.27/lib/libc.so.6 (0x00007f0ee08d4000) ++ libpcre.so.1 => @nixStoreDir@/hxbq8lpc53qsf1bc0dfcsm47wmcxzjvh-pcre-8.42/lib/libpcre.so.1 (0x00007f0ee0662000) ++ @nixStoreDir@/g2yk54hifqlsjiha3szr4q3ccmdzyrdv-glibc-2.27/lib64/ld-linux-x86-64.so.2 (0x00007f0ee20ff000) ++ libblkid.so.1 => @nixStoreDir@/q0kgnq21j0l2yd77gdlld371246cwghh-util-linux-2.32.1/lib/libblkid.so.1 (0x00007f0edd0cd000) ++ libuuid.so.1 => @nixStoreDir@/q0kgnq21j0l2yd77gdlld371246cwghh-util-linux-2.32.1/lib/libuuid.so.1 (0x00007f0edcec5000) ++ librt.so.1 => @nixStoreDir@/g2yk54hifqlsjiha3szr4q3ccmdzyrdv-glibc-2.27/lib/librt.so.1 (0x00007f0edccbd000) ++ libstdc++.so.6 => @nixStoreDir@/3v5r7fkrbkw2qajadvjbf6p6qriz9p1i-gcc-7.3.0-lib/lib/libstdc++.so.6 (0x00007f0edc936000) ++ libgcc_s.so.1 => @nixStoreDir@/g2yk54hifqlsjiha3szr4q3ccmdzyrdv-glibc-2.27/lib/libgcc_s.so.1 (0x00007f0edc720000) ++ ''' ++ libraries = ['glib-2.0', 'gio-2.0'] ++ ++ self.assertEqual( ++ ['@nixStoreDir@/gmrf09y7sfxrr0mcx90dba7w41jj2kzk-glib-2.58.1/lib/libglib-2.0.so.0', ++ '@nixStoreDir@/gmrf09y7sfxrr0mcx90dba7w41jj2kzk-glib-2.58.1/lib/libgio-2.0.so.0'], ++ resolve_from_ldd_output(libraries, output, basename=False)) ++ ++ def test_resolve_from_ldd_output_macos(self): ++ output = '''\ ++ @rpath/libatk-1.0.0.dylib ++ @rpath/libgstreamer-1.0.0.dylib (compatibility version 0.0.0, current version 0.0.0) ++ /Volumes/USB_SSD/cerbero/build/dist/darwin_x86_64/lib/libglib-2.0.0.dylib (compatibility version 0.0.0, current version 0.0.0) ++ /Volumes/USB_SSD/cerbero/build/dist/darwin_x86_64/lib/libintl.dylib (compatibility version 0.0.0, current version 0.0.0) ++ /Volumes/USB_SSD/cerbero/build/dist/darwin_x86_64/lib/libgobject-2.0.0.dylib (compatibility version 0.0.0, current version 0.0.0) ++ /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1252.50.4) ++ ''' ++ libraries = ['atk-1.0'] ++ fallback_libpath = '@nixStoreDir@/1ynd5b01z87c1nw75k5iy7sq49hpkw53-atk-2.30.0/lib' ++ ++ self.assertEqual( ++ [ '%s/libatk-1.0.0.dylib' % fallback_libpath ], ++ resolve_from_ldd_output(libraries, output, basename=False, fallback_libpath=fallback_libpath)) ++ + def test_resolve_from_ldd_output(self): + output = '''\ + libglib-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0 (0x00007fbe12d68000) + |