[gobject-introspection/wip/dieterv/drive-by-review: 2/13] tools: make g-ir-annotiotion-tool, g-ir-doc-tool and g-ir-scanner 'relocatable' at runtime.



commit 1994fad6a977669969066fe26508e600e5bd18d8
Author: Dieter Verfaillie <dieterv optionexplicit be>
Date:   Thu Sep 8 07:37:38 2011 +0200

    tools: make g-ir-annotiotion-tool, g-ir-doc-tool and g-ir-scanner 'relocatable' at runtime.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=620566

 tools/g-ir-annotation-tool.in |   28 +++++++++++-----------------
 tools/g-ir-doc-tool.in        |   28 +++++++++++-----------------
 tools/g-ir-scanner.in         |   28 +++++++++++-----------------
 3 files changed, 33 insertions(+), 51 deletions(-)
---
diff --git a/tools/g-ir-annotation-tool.in b/tools/g-ir-annotation-tool.in
index 03d1137..811e915 100755
--- a/tools/g-ir-annotation-tool.in
+++ b/tools/g-ir-annotation-tool.in
@@ -23,12 +23,6 @@ import os
 import sys
 import __builtin__
 
-if os.name == 'nt':
-    datadir = os.path.join(os.path.dirname(__file__), '..', 'share')
-else:
-    datadir = "@datarootdir@"
-
-__builtin__.__dict__['DATADIR'] = datadir
 
 if 'GI_SCANNER_DEBUG' in os.environ:
     def on_exception(exctype, value, tb):
@@ -37,19 +31,19 @@ if 'GI_SCANNER_DEBUG' in os.environ:
         pdb.pm()
     sys.excepthook = on_exception
 
+if os.name == 'nt':
+    datadir = os.path.join(os.path.dirname(__file__), '..', 'share')
+    pylibdir = os.path.join(os.path.dirname(__file__), '..', 'lib', 'gobject-introspection')
+else:
+    datadir = "@datarootdir@"
+    pylibdir = os.path.join('@libdir@', 'gobject-introspection')
+
 srcdir = os.getenv('UNINSTALLED_INTROSPECTION_SRCDIR', None)
 if srcdir is not None:
-    path = srcdir
-else:
-    # This is a private directory, we don't want to pollute the global
-    # namespace.
-    if os.name == 'nt':
-        # Makes g-ir-annotation-tool 'relocatable' at runtime on Windows.
-        path = os.path.join(os.path.dirname(__file__), '..', 'lib', 'gobject-introspection')
-    else:
-        path = os.path.join('@libdir@', 'gobject-introspection')
-sys.path.insert(0, path)
+    pylibdir = srcdir
 
-from giscanner.annotationmain import annotation_main
+__builtin__.__dict__['DATADIR'] = datadir
+sys.path.insert(0, pylibdir)
 
+from giscanner.annotationmain import annotation_main
 sys.exit(annotation_main(sys.argv))
diff --git a/tools/g-ir-doc-tool.in b/tools/g-ir-doc-tool.in
index 241d030..db389ba 100644
--- a/tools/g-ir-doc-tool.in
+++ b/tools/g-ir-doc-tool.in
@@ -23,12 +23,6 @@ import os
 import sys
 import __builtin__
 
-if os.name == 'nt':
-    datadir = os.path.join(os.path.dirname(__file__), '..', 'share')
-else:
-    datadir = "@datarootdir@"
-
-__builtin__.__dict__['DATADIR'] = datadir
 
 if 'GI_SCANNER_DEBUG' in os.environ:
     def on_exception(exctype, value, tb):
@@ -37,19 +31,19 @@ if 'GI_SCANNER_DEBUG' in os.environ:
         pdb.pm()
     sys.excepthook = on_exception
 
+if os.name == 'nt':
+    datadir = os.path.join(os.path.dirname(__file__), '..', 'share')
+    pylibdir = os.path.join(os.path.dirname(__file__), '..', 'lib', 'gobject-introspection')
+else:
+    datadir = "@datarootdir@"
+    pylibdir = os.path.join('@libdir@', 'gobject-introspection')
+
 srcdir = os.getenv('UNINSTALLED_INTROSPECTION_SRCDIR', None)
 if srcdir is not None:
-    path = srcdir
-else:
-    # This is a private directory, we don't want to pollute the global
-    # namespace.
-    if os.name == 'nt':
-        # Makes g-ir-doc-tool 'relocatable' at runtime on Windows.
-        path = os.path.join(os.path.dirname(__file__), '..', 'lib', 'gobject-introspection')
-    else:
-        path = os.path.join('@libdir@', 'gobject-introspection')
-sys.path.insert(0, path)
+    pylibdir = srcdir
 
-from giscanner.docmain import doc_main
+__builtin__.__dict__['DATADIR'] = datadir
+sys.path.insert(0, pylibdir)
 
+from giscanner.docmain import doc_main
 sys.exit(doc_main(sys.argv))
diff --git a/tools/g-ir-scanner.in b/tools/g-ir-scanner.in
index 6f8e70f..420d435 100755
--- a/tools/g-ir-scanner.in
+++ b/tools/g-ir-scanner.in
@@ -23,12 +23,6 @@ import os
 import sys
 import __builtin__
 
-if os.name == 'nt':
-    datadir = os.path.join(os.path.dirname(__file__), '..', 'share')
-else:
-    datadir = "@datarootdir@"
-
-__builtin__.__dict__['DATADIR'] = datadir
 
 if 'GI_SCANNER_DEBUG' in os.environ:
     def on_exception(exctype, value, tb):
@@ -37,19 +31,19 @@ if 'GI_SCANNER_DEBUG' in os.environ:
         pdb.pm()
     sys.excepthook = on_exception
 
+if os.name == 'nt':
+    datadir = os.path.join(os.path.dirname(__file__), '..', 'share')
+    pylibdir = os.path.join(os.path.dirname(__file__), '..', 'lib', 'gobject-introspection')
+else:
+    datadir = "@datarootdir@"
+    pylibdir = os.path.join('@libdir@', 'gobject-introspection')
+
 srcdir = os.getenv('UNINSTALLED_INTROSPECTION_SRCDIR', None)
 if srcdir is not None:
-    path = srcdir
-else:
-    # This is a private directory, we don't want to pollute the global
-    # namespace.
-    if os.name == 'nt':
-        # Makes g-ir-scanner 'relocatable' at runtime on Windows.
-        path = os.path.join(os.path.dirname(__file__), '..', 'lib', 'gobject-introspection')
-    else:
-        path = os.path.join('@libdir@', 'gobject-introspection')
-sys.path.insert(0, path)
+    pylibdir = srcdir
 
-from giscanner.scannermain import scanner_main
+__builtin__.__dict__['DATADIR'] = datadir
+sys.path.insert(0, pylibdir)
 
+from giscanner.scannermain import scanner_main
 sys.exit(scanner_main(sys.argv))


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]