[glib] gdbus-codegen: Don't assume bindir and datadir share prefix
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] gdbus-codegen: Don't assume bindir and datadir share prefix
- Date: Wed, 11 Oct 2017 08:48:52 +0000 (UTC)
commit b9f2ea423526735f7fe7371fb1339eae91a618c2
Author: Nirbheek Chauhan <nirbheek centricular com>
Date: Tue Sep 12 15:46:57 2017 +0530
gdbus-codegen: Don't assume bindir and datadir share prefix
This assumption breaks when, for instance:
* Called as /bin/gdbus-codegen
* Installed on Windows in a directory that is not `bin/`
For such cases, we cannot make any assumptions about the directory
structure, and must hard-code the datadir.
https://bugzilla.gnome.org/show_bug.cgi?id=786785
gio/gdbus-2.0/codegen/Makefile.am | 2 +-
gio/gdbus-2.0/codegen/gdbus-codegen.in | 9 +++++++++
gio/gdbus-2.0/codegen/meson.build | 1 +
3 files changed, 11 insertions(+), 1 deletions(-)
---
diff --git a/gio/gdbus-2.0/codegen/Makefile.am b/gio/gdbus-2.0/codegen/Makefile.am
index b3fb2c2..b4e500c 100644
--- a/gio/gdbus-2.0/codegen/Makefile.am
+++ b/gio/gdbus-2.0/codegen/Makefile.am
@@ -21,7 +21,7 @@ CLEANFILES += gdbus-codegen
EXTRA_DIST += gdbus-codegen.in
gdbus-codegen: gdbus-codegen.in Makefile $(codegen_PYTHON)
- $(AM_V_GEN) sed -e 's,@datadir\@,$(datadir),' -e 's,@PYTHON\@,$(PYTHON),' $< > $@.tmp && mv $@.tmp $@
+ $(AM_V_GEN) sed -e 's,@DATADIR\@,$(datadir),' -e 's,@PYTHON\@,$(PYTHON),' $< > $@.tmp && mv $@.tmp $@
@chmod a+x $@
clean-local:
diff --git a/gio/gdbus-2.0/codegen/gdbus-codegen.in b/gio/gdbus-2.0/codegen/gdbus-codegen.in
index 8050981..e3f4f00 100644
--- a/gio/gdbus-2.0/codegen/gdbus-codegen.in
+++ b/gio/gdbus-2.0/codegen/gdbus-codegen.in
@@ -37,6 +37,15 @@ else:
# parent directory to the python path.
path = os.path.join(filedir, '..')
+# If the above path detection failed, use the hard-coded datadir. This can
+# happen when, for instance, bindir and datadir are not in the same prefix or
+# on Windows where we cannot make any guarantees about the directory structure.
+#
+# In these cases our installation cannot be relocatable, but at least we should
+# be able to find the codegen module.
+if not os.path.isfile(os.path.join(path, 'codegen', 'codegen_main.py')):
+ path = os.path.join('@DATADIR@', 'glib-2.0')
+
sys.path.insert(0, os.path.abspath(path))
from codegen import codegen_main
diff --git a/gio/gdbus-2.0/codegen/meson.build b/gio/gdbus-2.0/codegen/meson.build
index 0e9ffbd..aacaac1 100644
--- a/gio/gdbus-2.0/codegen/meson.build
+++ b/gio/gdbus-2.0/codegen/meson.build
@@ -11,6 +11,7 @@ gdbus_codegen_files = [
gdbus_codegen_conf = configuration_data()
gdbus_codegen_conf.set('VERSION', glib_version)
gdbus_codegen_conf.set('PYTHON', python.path())
+gdbus_codegen_conf.set('DATADIR', glib_datadir)
# Install gdbus-codegen executable
# FIXME: Set permissions
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]