From 9fcd8fa140030a270507fba0915aafa4df0933e0 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Wed, 27 Jul 2011 09:11:02 -0400 Subject: Kill off config.py Generating Python source code is problematic for srcdir != builddir; steal a the trick of putting global data in __builtins__ from jhbuild. --- Makefile-giscanner.am | 1 - Makefile-tools.am | 6 ++++-- configure.ac | 1 - giscanner/config.py.in | 25 ------------------------- giscanner/dumper.py | 1 - giscanner/transformer.py | 5 ++--- tools/g-ir-annotation-tool.in | 3 +++ tools/g-ir-scanner.in | 3 +++ 8 files changed, 12 insertions(+), 33 deletions(-) delete mode 100644 giscanner/config.py.in diff --git a/Makefile-giscanner.am b/Makefile-giscanner.am index 8a8c7edb..0ca98f6c 100644 --- a/Makefile-giscanner.am +++ b/Makefile-giscanner.am @@ -33,7 +33,6 @@ pkgpyexec_PYTHON = \ giscanner/ast.py \ giscanner/cachestore.py \ giscanner/codegen.py \ - giscanner/config.py \ giscanner/dumper.py \ giscanner/introspectablepass.py \ giscanner/girparser.py \ diff --git a/Makefile-tools.am b/Makefile-tools.am index 31e6e711..c0dd7887 100644 --- a/Makefile-tools.am +++ b/Makefile-tools.am @@ -2,12 +2,14 @@ bin_PROGRAMS += g-ir-compiler g-ir-generate bin_SCRIPTS += g-ir-scanner g-ir-annotation-tool EXTRA_DIST += tools/g-ir-scanner.in tools/g-ir-annotation-tool.in +TOOL_SUBSTITUTIONS = sed -e s,@libdir\@,$(libdir), -e s,@pkgdatadir\@,$(pkgdatadir), -e s,@PYTHON\@,$(PYTHON), + g-ir-scanner: tools/g-ir-scanner.in _giscanner.la Makefile - $(AM_V_GEN) sed -e s,@libdir\@,$(libdir), -e s,@PYTHON\@,$(PYTHON), $< > $@.tmp && mv $@.tmp $@ + $(AM_V_GEN) $(TOOL_SUBSTITUTIONS) $< > $@.tmp && mv $@.tmp $@ @chmod a+x $@ g-ir-annotation-tool: tools/g-ir-annotation-tool.in _giscanner.la Makefile - $(AM_V_GEN) sed -e s,@libdir\@,$(libdir), -e s,@PYTHON\@,$(PYTHON), $< > $@.tmp && mv $@.tmp $@ + $(AM_V_GEN) $(TOOL_SUBSTITUTIONS) $< > $@.tmp && mv $@.tmp $@ @chmod a+x $@ g_ir_compiler_SOURCES = tools/compiler.c diff --git a/configure.ac b/configure.ac index 0366aa1f..6d29ff25 100644 --- a/configure.ac +++ b/configure.ac @@ -270,7 +270,6 @@ AC_MSG_RESULT([$GLIBSRC]) AC_CONFIG_FILES([ Makefile -giscanner/config.py m4/Makefile tests/Makefile tests/offsets/Makefile diff --git a/giscanner/config.py.in b/giscanner/config.py.in deleted file mode 100644 index 9de1f48c..00000000 --- a/giscanner/config.py.in +++ /dev/null @@ -1,25 +0,0 @@ -# -*- Mode: Python -*- -# GObject-Introspection - a framework for introspecting GObject libraries -# Copyright (C) 2008 Johan Dahlin -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program 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 General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -# 02110-1301, USA. -# - -DATADIR = "@datarootdir@" -DATADIR = DATADIR.replace( - "${prefix}", "@prefix@") -GIR_DIR = "@GIR_DIR@" -GIR_SUFFIX = "@GIR_SUFFIX@" diff --git a/giscanner/dumper.py b/giscanner/dumper.py index b8449384..615b3fc5 100644 --- a/giscanner/dumper.py +++ b/giscanner/dumper.py @@ -27,7 +27,6 @@ import tempfile from .gdumpparser import IntrospectionBinary from . import utils -from .config import DATADIR # bugzilla.gnome.org/558436 # Compile a binary program which is then linked to a library diff --git a/giscanner/transformer.py b/giscanner/transformer.py index a651649a..7db79828 100644 --- a/giscanner/transformer.py +++ b/giscanner/transformer.py @@ -24,7 +24,6 @@ import sys from . import ast from . import message from .cachestore import CacheStore -from .config import DATADIR, GIR_DIR, GIR_SUFFIX from .girparser import GIRParser from .sourcescanner import ( SourceSymbol, ctype_name, CTYPE_POINTER, @@ -163,8 +162,8 @@ None.""" def _find_include(self, include): searchdirs = self._includepaths[:] for path in _xdg_data_dirs: - searchdirs.append(os.path.join(path, GIR_SUFFIX)) - searchdirs.append(GIR_DIR) + searchdirs.append(os.path.join(path, 'gir-1.0')) + searchdirs.append(os.path.join(DATADIR, 'gir-1.0')) girname = '%s-%s.gir' % (include.name, include.version) for d in searchdirs: diff --git a/tools/g-ir-annotation-tool.in b/tools/g-ir-annotation-tool.in index 4ad19761..49d0b99f 100755 --- a/tools/g-ir-annotation-tool.in +++ b/tools/g-ir-annotation-tool.in @@ -21,6 +21,9 @@ import os import sys +import __builtin__ + +__builtin__.__dict__['DATADIR'] = "@pkgdatadir@" if 'GI_SCANNER_DEBUG' in os.environ: def on_exception(exctype, value, tb): diff --git a/tools/g-ir-scanner.in b/tools/g-ir-scanner.in index ba2999c5..6f2b83e5 100755 --- a/tools/g-ir-scanner.in +++ b/tools/g-ir-scanner.in @@ -21,6 +21,9 @@ import os import sys +import __builtin__ + +__builtin__.__dict__['DATADIR'] = "@pkgdatadir@" if 'GI_SCANNER_DEBUG' in os.environ: def on_exception(exctype, value, tb): -- cgit v1.2.1