aboutsummaryrefslogtreecommitdiff
path: root/vcpkg/ports/gobject-introspection/0001-g-ir-tool-template.in.patch
blob: 617ecd798be1fd1cd25ca3fcba725264e0aec922 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
diff --git a/tools/g-ir-tool-template.in b/tools/g-ir-tool-template.in
index 469af0c..f165a98 100755
--- a/tools/g-ir-tool-template.in
+++ b/tools/g-ir-tool-template.in
@@ -1,4 +1,4 @@
-#!@PYTHON_CMD@
+#!/usr/bin/env python3
 # -*- Mode: Python -*-
 # GObject-Introspection - a framework for introspecting GObject libraries
 # Copyright (C) 2008  Johan Dahlin
@@ -46,22 +46,20 @@ if debug:
 filedir = os.path.dirname(__file__)
 
 # Try using relative paths first so that the installation prefix is relocatable
-datadir = os.path.abspath(os.path.join(filedir, '..', 'share'))
+datadir = os.path.abspath(os.path.join(filedir, '..', '..', 'share'))
 # Fallback to hard-coded paths if the relocatable paths are wrong
+datadir = os.getenv('VCPKG_GI_DATADIR', datadir)
 if not os.path.isdir(os.path.join(datadir, 'gir-1.0')):
-    datadir = "@datarootdir@"
+    raise Exception('Failed to determine datadir')
 
 builtins.__dict__['DATADIR'] = datadir
 
-gir_dir = os.path.abspath(os.path.join(filedir, '..', '@gir_dir_prefix@', 'gir-1.0'))
-# Fallback to hard-coded paths if the relocatable paths are wrong
-if not os.path.isdir(gir_dir):
-    gir_dir = "@GIR_DIR@"
+gir_dir = os.path.abspath(os.path.join(datadir, 'gir-1.0'))
 
 builtins.__dict__['GIR_DIR'] = gir_dir
 
 # Again, relative paths first so that the installation prefix is relocatable
-pylibdir = os.path.abspath(os.path.join(filedir, '..', 'lib', 'gobject-introspection'))
+pylibdir = os.path.abspath(os.path.join(filedir, '..', '..', 'lib', 'gobject-introspection'))
 
 # EXT_SUFFIX for py3 SO for py2
 py_mod_suffix = sysconfig.get_config_var('EXT_SUFFIX') or sysconfig.get_config_var('SO')
@@ -89,13 +87,19 @@ if not os.path.isfile(os.path.join(pylibdir, 'giscanner', '_giscanner' + py_mod_
         gdump_path = os.path.join(builddir, 'giscanner', 'gdump.c')
         if os.path.isfile(gdump_path):
             builtins.__dict__['GDUMP_PATH'] = gdump_path
     else:
-        # Okay, we're not running uninstalled and the prefix is not
-        # relocatable. Use hard-coded libdir.
-        pylibdir = os.path.join('@libdir@', 'gobject-introspection')
+        raise Exception('Could not determine pylibdir')
 
 sys.path.insert(0, pylibdir)
 
+vcpkg_gi_lib_path     = os.getenv('VCPKG_GI_LIBDIR', None)
+vcpkg_gi_lib_path_var = os.getenv('VCPKG_GI_LIBDIR_VAR', None)
+if vcpkg_gi_lib_path_var is not None and vcpkg_gi_lib_path is not None:
+    ld_lib_path = os.getenv(vcpkg_gi_lib_path_var, '')
+    if ld_lib_path != '':
+        ld_lib_path = os.pathsep + ld_lib_path
+    os.environ[vcpkg_gi_lib_path_var] = vcpkg_gi_lib_path + ld_lib_path
+
 from giscanner.utils import dll_dirs
 dll_dirs = dll_dirs()
 dll_dirs.add_dll_dirs(['gio-2.0'])