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
This commit is contained in:
Nirbheek Chauhan 2017-09-12 15:46:57 +05:30 committed by Philip Withnall
parent 62dedcb099
commit b9f2ea4235
3 changed files with 11 additions and 1 deletions

View File

@ -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:

View File

@ -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

View File

@ -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