[gtksourceview/gnome-3-24] Visual Studio builds: Add scripts to generate .pc files



commit 68d596e037e50717542893d41ddfb008bcb7702e
Author: Chun-wei Fan <fanchunwei src gnome org>
Date:   Mon Mar 6 17:10:26 2017 +0800

    Visual Studio builds: Add scripts to generate .pc files
    
    This will allow gtksourceview-3.0.pc to be generated quite easily for
    Visual Studio builds, where this will be integrated into the project files
    later.

 win32/Makefile.am        |    2 +
 win32/gtksourceviewpc.py |   42 ++++++++++++++++
 win32/pc_base.py         |  124 ++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 168 insertions(+), 0 deletions(-)
---
diff --git a/win32/Makefile.am b/win32/Makefile.am
index 0ed6123..7cbb9b9 100644
--- a/win32/Makefile.am
+++ b/win32/Makefile.am
@@ -31,6 +31,8 @@ EXTRA_DIST = \
        gtksourceview-introspection-msvc.mak    \
        introspection-msvc.mak  \
        gen-enums.batin \
+       pc_base.py      \
+       gtksourceviewpc.py      \
        $(GENERATED_ITEMS)
 
 gen-enums.bat: $(top_srcdir)/win32/gen-enums.batin enum.headers
diff --git a/win32/gtksourceviewpc.py b/win32/gtksourceviewpc.py
new file mode 100644
index 0000000..c1b4e77
--- /dev/null
+++ b/win32/gtksourceviewpc.py
@@ -0,0 +1,42 @@
+#!/usr/bin/python
+#
+# Utility script to generate .pc files for GLib
+# for Visual Studio builds, to be used for
+# building introspection files
+
+# Author: Fan, Chun-wei
+# Date: March 10, 2016
+
+import os
+import sys
+
+from replace import replace_multi
+from pc_base import BasePCItems
+
+def main(argv):
+    base_pc = BasePCItems()
+
+    base_pc.setup(argv)
+
+    glib_req_ver = '2.48'
+    gtk_req_ver = '3.20'
+    libxml2_req_ver = '2.6'
+    API_VERSION = '3.0'
+
+    pkg_replace_items = {'@PACKAGE_NAME@': 'gtksourceview',
+                         '@AX_PACKAGE_REQUIRES@': 'glib-2.0 >= ' + glib_req_ver + ' ' +
+                                                     'gio-2.0 >= ' + glib_req_ver + ' ' +
+                                                  'gtk+-3.0 >= ' + gtk_req_ver,
+                         '@AX_PACKAGE_REQUIRES_PRIVATE@': 'libxml-2.0 >= ' + libxml2_req_ver,
+                         '@GSV_API_VERSION@': API_VERSION,
+                         '@PACKAGE_VERSION@': base_pc.version}
+
+    pkg_replace_items.update(base_pc.base_replace_items)
+
+    # Generate gtksourceview-3.0.pc
+    replace_multi(base_pc.top_srcdir + '/gtksourceview.pc.in',
+                  base_pc.srcdir + '/gtksourceview-' + API_VERSION + '.pc',
+                  pkg_replace_items)
+
+if __name__ == '__main__':
+    sys.exit(main(sys.argv))
diff --git a/win32/pc_base.py b/win32/pc_base.py
new file mode 100644
index 0000000..f7976e8
--- /dev/null
+++ b/win32/pc_base.py
@@ -0,0 +1,124 @@
+#!/usr/bin/python
+#
+# Simple utility script to generate the basic info
+# needed in a .pc (pkg-config) file, used especially
+# for introspection purposes
+
+# This can be used in various projects where
+# there is the need to generate .pc files,
+# and is copied from GLib's $(srcroot)/win32
+
+# Author: Fan, Chun-wei
+# Date: March 10, 2016
+
+import os
+import sys
+import argparse
+
+class BasePCItems:
+    def __init__(self):
+        self.base_replace_items = {}
+        self.exec_prefix = ''
+        self.includedir = ''
+        self.libdir = ''
+        self.prefix = ''
+        self.srcdir = os.path.dirname(__file__)
+        self.top_srcdir = self.srcdir + '\\..'
+        self.version = ''
+
+    def setup(self, argv, parser=None):
+        if parser is None:
+            parser = argparse.ArgumentParser(description='Setup basic .pc file info')
+        parser.add_argument('--prefix', help='prefix of the installed library',
+                            required=True)
+        parser.add_argument('--exec-prefix',
+                            help='prefix of the installed programs, \
+                                  if different from the prefix')
+        parser.add_argument('--includedir',
+                            help='includedir of the installed library, \
+                                  if different from ${prefix}/include')
+        parser.add_argument('--libdir',
+                            help='libdir of the installed library, \
+                                  if different from ${prefix}/lib')
+        parser.add_argument('--version', help='Version of the package',
+                            required=True)
+        args = parser.parse_args()
+
+        self.version = args.version
+
+        # check whether the prefix and exec_prefix are valid
+        if not os.path.exists(args.prefix):
+            raise SystemExit('Specified prefix \'%s\' is invalid' % args.prefix)
+
+        # use absolute paths for prefix
+        self.prefix = os.path.abspath(args.prefix).replace('\\','/')
+
+        # check and setup the exec_prefix
+        if getattr(args, 'exec_prefix', None) is None:
+            exec_prefix_use_shorthand = True
+            self.exec_prefix = '${prefix}'
+        else:
+            if args.exec_prefix.startswith('${prefix}'):
+                exec_prefix_use_shorthand = True
+                input_exec_prefix = args.prefix + args.exec_prefix[len('${prefix}'):]
+            else:
+                exec_prefix_use_shorthand = False
+                input_exec_prefix = args.exec_prefix
+            if not os.path.exists(input_exec_prefix):
+                raise SystemExit('Specified exec_prefix \'%s\' is invalid' %
+                                  args.exec_prefix)
+            if exec_prefix_use_shorthand is True:
+                self.exec_prefix = args.exec_prefix.replace('\\','/')
+            else:
+                self.exec_prefix = os.path.abspath(input_exec_prefix).replace('\\','/')
+
+        # check and setup the includedir
+        if getattr(args, 'includedir', None) is None:
+            self.includedir = '${prefix}/include'
+        else:
+            if args.includedir.startswith('${prefix}'):
+                includedir_use_shorthand = True
+                input_includedir = args.prefix + args.includedir[len('${prefix}'):]
+            else:
+                if args.includedir.startswith('${exec_prefix}'):
+                    includedir_use_shorthand = True
+                    input_includedir = input_exec_prefix + args.includedir[len('${exec_prefix}'):]
+                else:
+                    includedir_use_shorthand = False
+                    input_includedir = args.includedir
+            if not os.path.exists(input_includedir):
+                raise SystemExit('Specified includedir \'%s\' is invalid' %
+                                  args.includedir)
+            if includedir_use_shorthand is True:
+                self.includedir = args.includedir.replace('\\','/')
+            else:
+                self.includedir = os.path.abspath(input_includedir).replace('\\','/')
+
+        # check and setup the libdir
+        if getattr(args, 'libdir', None) is None:
+            self.libdir = '${prefix}/lib'
+        else:
+            if args.libdir.startswith('${prefix}'):
+                libdir_use_shorthand = True
+                input_libdir = args.prefix + args.libdir[len('${prefix}'):]
+            else:
+                if args.libdir.startswith('${exec_prefix}'):
+                    libdir_use_shorthand = True
+                    input_libdir = input_exec_prefix + args.libdir[len('${exec_prefix}'):]
+                else:
+                    libdir_use_shorthand = False
+                    input_libdir = args.libdir
+            if not os.path.exists(input_libdir):
+                raise SystemExit('Specified libdir \'%s\' is invalid' %
+                                             args.libdir)
+            if libdir_use_shorthand is True:
+                self.libdir = args.libdir.replace('\\','/')
+            else:
+                self.libdir = os.path.abspath(input_libdir).replace('\\','/')
+
+        # setup dictionary for replacing items in *.pc.in
+        self.base_replace_items.update({'@VERSION@': self.version})
+        self.base_replace_items.update({'@prefix@': self.prefix})
+        self.base_replace_items.update({'@exec_prefix@': self.exec_prefix})
+        self.base_replace_items.update({'@libdir@': self.libdir})
+        self.base_replace_items.update({'@includedir@': self.includedir})


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