gobject-introspection 3.0.7-x64-mingw32 → 3.0.8-x64-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (126) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +2 -2
  3. data/ext/gobject-introspection/extconf.rb +1 -0
  4. data/ext/gobject-introspection/rb-gi-argument.c +123 -26
  5. data/ext/gobject-introspection/rb-gi-function-info.c +558 -19
  6. data/ext/gobject-introspection/rb-gi-repository.c +9 -0
  7. data/ext/gobject-introspection/rb-gobject-introspection.h +3 -0
  8. data/lib/2.2/gobject_introspection.so +0 -0
  9. data/lib/2.3/gobject_introspection.so +0 -0
  10. data/lib/gobject-introspection/loader.rb +1 -1
  11. data/vendor/local/bin/g-ir-compiler.exe +0 -0
  12. data/vendor/local/bin/g-ir-generate.exe +0 -0
  13. data/vendor/local/bin/libgirepository-1.0-1.dll +0 -0
  14. data/vendor/local/include/gobject-introspection-1.0/gistructinfo.h +4 -0
  15. data/vendor/local/lib/girepository-1.0/GIRepository-2.0.typelib +0 -0
  16. data/vendor/local/lib/girepository-1.0/GLib-2.0.typelib +0 -0
  17. data/vendor/local/lib/girepository-1.0/GModule-2.0.typelib +0 -0
  18. data/vendor/local/lib/girepository-1.0/GObject-2.0.typelib +0 -0
  19. data/vendor/local/lib/girepository-1.0/Gio-2.0.typelib +0 -0
  20. data/vendor/local/lib/gobject-introspection/giscanner/__init__.py +1 -1
  21. data/vendor/local/lib/gobject-introspection/giscanner/__init__.pyc +0 -0
  22. data/vendor/local/lib/gobject-introspection/giscanner/__init__.pyo +0 -0
  23. data/vendor/local/lib/gobject-introspection/giscanner/annotationmain.py +39 -11
  24. data/vendor/local/lib/gobject-introspection/giscanner/annotationmain.pyc +0 -0
  25. data/vendor/local/lib/gobject-introspection/giscanner/annotationmain.pyo +0 -0
  26. data/vendor/local/lib/gobject-introspection/giscanner/annotationparser.py +187 -164
  27. data/vendor/local/lib/gobject-introspection/giscanner/annotationparser.pyc +0 -0
  28. data/vendor/local/lib/gobject-introspection/giscanner/annotationparser.pyo +0 -0
  29. data/vendor/local/lib/gobject-introspection/giscanner/ast.py +191 -58
  30. data/vendor/local/lib/gobject-introspection/giscanner/ast.pyc +0 -0
  31. data/vendor/local/lib/gobject-introspection/giscanner/ast.pyo +0 -0
  32. data/vendor/local/lib/gobject-introspection/giscanner/cachestore.py +42 -54
  33. data/vendor/local/lib/gobject-introspection/giscanner/cachestore.pyc +0 -0
  34. data/vendor/local/lib/gobject-introspection/giscanner/cachestore.pyo +0 -0
  35. data/vendor/local/lib/gobject-introspection/giscanner/ccompiler.py +272 -82
  36. data/vendor/local/lib/gobject-introspection/giscanner/ccompiler.pyc +0 -0
  37. data/vendor/local/lib/gobject-introspection/giscanner/ccompiler.pyo +0 -0
  38. data/vendor/local/lib/gobject-introspection/giscanner/codegen.py +18 -11
  39. data/vendor/local/lib/gobject-introspection/giscanner/codegen.pyc +0 -0
  40. data/vendor/local/lib/gobject-introspection/giscanner/codegen.pyo +0 -0
  41. data/vendor/local/lib/gobject-introspection/giscanner/collections/__init__.py +4 -0
  42. data/vendor/local/lib/gobject-introspection/giscanner/collections/__init__.pyc +0 -0
  43. data/vendor/local/lib/gobject-introspection/giscanner/collections/__init__.pyo +0 -0
  44. data/vendor/local/lib/gobject-introspection/giscanner/collections/counter.pyc +0 -0
  45. data/vendor/local/lib/gobject-introspection/giscanner/collections/counter.pyo +0 -0
  46. data/vendor/local/lib/gobject-introspection/giscanner/collections/ordereddict.py +25 -13
  47. data/vendor/local/lib/gobject-introspection/giscanner/collections/ordereddict.pyc +0 -0
  48. data/vendor/local/lib/gobject-introspection/giscanner/collections/ordereddict.pyo +0 -0
  49. data/vendor/local/lib/gobject-introspection/giscanner/docmain.py +21 -19
  50. data/vendor/local/lib/gobject-introspection/giscanner/docmain.pyc +0 -0
  51. data/vendor/local/lib/gobject-introspection/giscanner/docmain.pyo +0 -0
  52. data/vendor/local/lib/gobject-introspection/giscanner/docwriter.py +19 -16
  53. data/vendor/local/lib/gobject-introspection/giscanner/docwriter.pyc +0 -0
  54. data/vendor/local/lib/gobject-introspection/giscanner/docwriter.pyo +0 -0
  55. data/vendor/local/lib/gobject-introspection/giscanner/dumper.py +148 -158
  56. data/vendor/local/lib/gobject-introspection/giscanner/dumper.pyc +0 -0
  57. data/vendor/local/lib/gobject-introspection/giscanner/dumper.pyo +0 -0
  58. data/vendor/local/lib/gobject-introspection/giscanner/gdumpparser.py +31 -21
  59. data/vendor/local/lib/gobject-introspection/giscanner/gdumpparser.pyc +0 -0
  60. data/vendor/local/lib/gobject-introspection/giscanner/gdumpparser.pyo +0 -0
  61. data/vendor/local/lib/gobject-introspection/giscanner/girparser.py +13 -5
  62. data/vendor/local/lib/gobject-introspection/giscanner/girparser.pyc +0 -0
  63. data/vendor/local/lib/gobject-introspection/giscanner/girparser.pyo +0 -0
  64. data/vendor/local/lib/gobject-introspection/giscanner/girwriter.py +12 -13
  65. data/vendor/local/lib/gobject-introspection/giscanner/girwriter.pyc +0 -0
  66. data/vendor/local/lib/gobject-introspection/giscanner/girwriter.pyo +0 -0
  67. data/vendor/local/lib/gobject-introspection/giscanner/introspectablepass.py +5 -1
  68. data/vendor/local/lib/gobject-introspection/giscanner/introspectablepass.pyc +0 -0
  69. data/vendor/local/lib/gobject-introspection/giscanner/introspectablepass.pyo +0 -0
  70. data/vendor/local/lib/gobject-introspection/giscanner/libtoolimporter.py +11 -9
  71. data/vendor/local/lib/gobject-introspection/giscanner/libtoolimporter.pyc +0 -0
  72. data/vendor/local/lib/gobject-introspection/giscanner/libtoolimporter.pyo +0 -0
  73. data/vendor/local/lib/gobject-introspection/giscanner/maintransformer.py +150 -45
  74. data/vendor/local/lib/gobject-introspection/giscanner/maintransformer.pyc +0 -0
  75. data/vendor/local/lib/gobject-introspection/giscanner/maintransformer.pyo +0 -0
  76. data/vendor/local/lib/gobject-introspection/giscanner/message.py +56 -19
  77. data/vendor/local/lib/gobject-introspection/giscanner/message.pyc +0 -0
  78. data/vendor/local/lib/gobject-introspection/giscanner/message.pyo +0 -0
  79. data/vendor/local/lib/gobject-introspection/giscanner/msvccompiler.py +101 -0
  80. data/vendor/local/lib/gobject-introspection/giscanner/msvccompiler.pyc +0 -0
  81. data/vendor/local/lib/gobject-introspection/giscanner/msvccompiler.pyo +0 -0
  82. data/vendor/local/lib/gobject-introspection/giscanner/scannermain.py +41 -22
  83. data/vendor/local/lib/gobject-introspection/giscanner/scannermain.pyc +0 -0
  84. data/vendor/local/lib/gobject-introspection/giscanner/scannermain.pyo +0 -0
  85. data/vendor/local/lib/gobject-introspection/giscanner/sectionparser.py +6 -1
  86. data/vendor/local/lib/gobject-introspection/giscanner/sectionparser.pyc +0 -0
  87. data/vendor/local/lib/gobject-introspection/giscanner/sectionparser.pyo +0 -0
  88. data/vendor/local/lib/gobject-introspection/giscanner/shlibs.py +8 -2
  89. data/vendor/local/lib/gobject-introspection/giscanner/shlibs.pyc +0 -0
  90. data/vendor/local/lib/gobject-introspection/giscanner/shlibs.pyo +0 -0
  91. data/vendor/local/lib/gobject-introspection/giscanner/sourcescanner.py +42 -56
  92. data/vendor/local/lib/gobject-introspection/giscanner/sourcescanner.pyc +0 -0
  93. data/vendor/local/lib/gobject-introspection/giscanner/sourcescanner.pyo +0 -0
  94. data/vendor/local/lib/gobject-introspection/giscanner/testcodegen.py +19 -5
  95. data/vendor/local/lib/gobject-introspection/giscanner/testcodegen.pyc +0 -0
  96. data/vendor/local/lib/gobject-introspection/giscanner/testcodegen.pyo +0 -0
  97. data/vendor/local/lib/gobject-introspection/giscanner/transformer.py +73 -37
  98. data/vendor/local/lib/gobject-introspection/giscanner/transformer.pyc +0 -0
  99. data/vendor/local/lib/gobject-introspection/giscanner/transformer.pyo +0 -0
  100. data/vendor/local/lib/gobject-introspection/giscanner/utils.py +92 -14
  101. data/vendor/local/lib/gobject-introspection/giscanner/utils.pyc +0 -0
  102. data/vendor/local/lib/gobject-introspection/giscanner/utils.pyo +0 -0
  103. data/vendor/local/lib/gobject-introspection/giscanner/xmlwriter.py +30 -11
  104. data/vendor/local/lib/gobject-introspection/giscanner/xmlwriter.pyc +0 -0
  105. data/vendor/local/lib/gobject-introspection/giscanner/xmlwriter.pyo +0 -0
  106. data/vendor/local/lib/libgirepository-1.0.a +0 -0
  107. data/vendor/local/lib/libgirepository-1.0.dll.a +0 -0
  108. data/vendor/local/lib/libgirepository-1.0.la +1 -1
  109. data/vendor/local/lib/pkgconfig/gobject-introspection-1.0.pc +1 -1
  110. data/vendor/local/lib/pkgconfig/gobject-introspection-no-export-1.0.pc +1 -1
  111. data/vendor/local/share/gir-1.0/GIRepository-2.0.gir +57 -13
  112. data/vendor/local/share/gir-1.0/GLib-2.0.gir +2017 -893
  113. data/vendor/local/share/gir-1.0/GModule-2.0.gir +2 -1
  114. data/vendor/local/share/gir-1.0/GObject-2.0.gir +1107 -674
  115. data/vendor/local/share/gir-1.0/Gio-2.0.gir +5589 -1287
  116. data/vendor/local/share/gobject-introspection-1.0/Makefile.introspection +4 -2
  117. data/vendor/local/share/gobject-introspection-1.0/gdump.c +8 -0
  118. data/vendor/local/share/gobject-introspection-1.0/tests/everything.c +273 -323
  119. data/vendor/local/share/gobject-introspection-1.0/tests/everything.h +58 -38
  120. data/vendor/local/share/gobject-introspection-1.0/tests/gimarshallingtests.c +1 -1
  121. data/vendor/local/share/gobject-introspection-1.0/tests/regress.c +177 -23
  122. data/vendor/local/share/gobject-introspection-1.0/tests/regress.h +40 -0
  123. data/vendor/local/share/man/man1/g-ir-compiler.1 +7 -7
  124. metadata +9 -7
  125. data/lib/2.0/gobject_introspection.so +0 -0
  126. data/lib/2.1/gobject_introspection.so +0 -0
@@ -18,6 +18,10 @@
18
18
  # 02110-1301, USA.
19
19
  #
20
20
 
21
+ from __future__ import absolute_import
22
+ from __future__ import division
23
+ from __future__ import print_function
24
+ from __future__ import unicode_literals
21
25
 
22
26
  from .counter import Counter
23
27
  from .ordereddict import OrderedDict
@@ -30,9 +30,20 @@
30
30
  # the MIT License: http://www.opensource.org/licenses/mit-license.php
31
31
 
32
32
 
33
+ import sys
34
+
35
+
36
+ py2k = sys.version_info < (3, 0)
37
+
38
+
33
39
  class OrderedDict(dict):
34
40
  """A dict that returns keys/values/items in the order they were added."""
35
41
 
42
+ __slots__ = '_list',
43
+
44
+ def __reduce__(self):
45
+ return OrderedDict, (self.items(),)
46
+
36
47
  def __init__(self, ____sequence=None, **kwargs):
37
48
  self._list = []
38
49
  if ____sequence is None:
@@ -75,25 +86,26 @@ class OrderedDict(dict):
75
86
  def __iter__(self):
76
87
  return iter(self._list)
77
88
 
89
+ def keys(self):
90
+ return list(self)
91
+
78
92
  def values(self):
79
93
  return [self[key] for key in self._list]
80
94
 
81
- def itervalues(self):
82
- return iter([self[key] for key in self._list])
83
-
84
- def keys(self):
85
- return list(self._list)
95
+ def items(self):
96
+ return [(key, self[key]) for key in self._list]
86
97
 
87
- def iterkeys(self):
88
- return iter(self.keys())
98
+ if py2k:
99
+ def itervalues(self):
100
+ return iter(self.values())
89
101
 
90
- def items(self):
91
- return [(key, self[key]) for key in self.keys()]
102
+ def iterkeys(self):
103
+ return iter(self)
92
104
 
93
- def iteritems(self):
94
- return iter(self.items())
105
+ def iteritems(self):
106
+ return iter(self.items())
95
107
 
96
- def __setitem__(self, key, obj):
108
+ def __setitem__(self, key, object):
97
109
  if key not in self:
98
110
  try:
99
111
  self._list.append(key)
@@ -101,7 +113,7 @@ class OrderedDict(dict):
101
113
  # work around Python pickle loads() with
102
114
  # dict subclass (seems to ignore __setstate__?)
103
115
  self._list = [key]
104
- dict.__setitem__(self, key, obj)
116
+ dict.__setitem__(self, key, object)
105
117
 
106
118
  def __delitem__(self, key):
107
119
  dict.__delitem__(self, key)
@@ -18,8 +18,13 @@
18
18
  # 02110-1301, USA.
19
19
  #
20
20
 
21
+ from __future__ import absolute_import
22
+ from __future__ import division
23
+ from __future__ import print_function
24
+ from __future__ import unicode_literals
25
+
21
26
  import os
22
- import optparse
27
+ import argparse
23
28
 
24
29
  from .docwriter import DocWriter
25
30
  from .sectionparser import generate_sections_file, write_sections_file
@@ -27,46 +32,43 @@ from .transformer import Transformer
27
32
 
28
33
 
29
34
  def doc_main(args):
30
- parser = optparse.OptionParser('%prog [options] GIR-file')
35
+ parser = argparse.ArgumentParser()
31
36
 
32
- parser.add_option("-o", "--output",
37
+ parser.add_argument("girfile")
38
+ parser.add_argument("-o", "--output",
33
39
  action="store", dest="output",
34
40
  help="Directory to write output to")
35
- parser.add_option("-l", "--language",
41
+ parser.add_argument("-l", "--language",
36
42
  action="store", dest="language",
37
43
  default="c",
38
44
  help="Output language")
39
- parser.add_option("", "--add-include-path",
45
+ parser.add_argument("-I", "--add-include-path",
40
46
  action="append", dest="include_paths", default=[],
41
47
  help="include paths for other GIR files")
42
- parser.add_option("", "--write-sections-file",
48
+ parser.add_argument("-s", "--write-sections-file",
43
49
  action="store_true", dest="write_sections",
44
50
  help="Generate and write out a sections file")
45
51
 
46
- options, args = parser.parse_args(args)
47
- if not options.output:
52
+ args = parser.parse_args(args[1:])
53
+ if not args.output:
48
54
  raise SystemExit("missing output parameter")
49
55
 
50
- if len(args) < 2:
51
- raise SystemExit("Need an input GIR filename")
52
-
53
56
  if 'UNINSTALLED_INTROSPECTION_SRCDIR' in os.environ:
54
57
  top_srcdir = os.environ['UNINSTALLED_INTROSPECTION_SRCDIR']
55
58
  top_builddir = os.environ['UNINSTALLED_INTROSPECTION_BUILDDIR']
56
59
  extra_include_dirs = [os.path.join(top_srcdir, 'gir'), top_builddir]
57
60
  else:
58
61
  extra_include_dirs = []
59
- extra_include_dirs.extend(options.include_paths)
60
- transformer = Transformer.parse_from_gir(args[1], extra_include_dirs)
62
+ extra_include_dirs.extend(args.include_paths)
63
+ transformer = Transformer.parse_from_gir(args.girfile, extra_include_dirs)
61
64
 
62
- if options.write_sections:
65
+ if args.write_sections:
63
66
  sections_file = generate_sections_file(transformer)
64
67
 
65
- fp = open(options.output, 'w')
66
- write_sections_file(fp, sections_file)
67
- fp.close()
68
+ with open(args.output, 'w') as fp:
69
+ write_sections_file(fp, sections_file)
68
70
  else:
69
- writer = DocWriter(transformer, options.language)
70
- writer.write(options.output)
71
+ writer = DocWriter(transformer, args.language)
72
+ writer.write(args.output)
71
73
 
72
74
  return 0
@@ -21,6 +21,11 @@
21
21
  # 02110-1301, USA.
22
22
  #
23
23
 
24
+ from __future__ import absolute_import
25
+ from __future__ import division
26
+ from __future__ import print_function
27
+ from __future__ import unicode_literals
28
+
24
29
  import os
25
30
  import re
26
31
  import tempfile
@@ -131,7 +136,7 @@ class TemplatedScanner(object):
131
136
  groupdict = match.groupdict()
132
137
  properties = {name: groupdict.pop(name)}
133
138
  name = name + "_"
134
- for group, value in groupdict.iteritems():
139
+ for group, value in groupdict.items():
135
140
  if group.startswith(name):
136
141
  key = group[len(name):]
137
142
  properties[key] = value
@@ -349,7 +354,7 @@ class DocFormatter(object):
349
354
 
350
355
  def format_xref(self, node, **attrdict):
351
356
  if node is None or not hasattr(node, 'namespace'):
352
- attrs = [('xref', 'index')] + attrdict.items()
357
+ attrs = [('xref', 'index')] + list(sorted(attrdict.items()))
353
358
  return xmlwriter.build_xml_tag('link', attrs)
354
359
  elif isinstance(node, ast.Member):
355
360
  # Enum/BitField members are linked to the main enum page.
@@ -360,14 +365,14 @@ class DocFormatter(object):
360
365
  return self.format_external_xref(node, attrdict)
361
366
 
362
367
  def format_internal_xref(self, node, attrdict):
363
- attrs = [('xref', make_page_id(node))] + attrdict.items()
368
+ attrs = [('xref', make_page_id(node))] + list(sorted(attrdict.items()))
364
369
  return xmlwriter.build_xml_tag('link', attrs)
365
370
 
366
371
  def format_external_xref(self, node, attrdict):
367
372
  ns = node.namespace
368
373
  attrs = [('href', '../%s-%s/%s.html' % (ns.name, str(ns.version),
369
374
  make_page_id(node)))]
370
- attrs += attrdict.items()
375
+ attrs += list(sorted(attrdict.items()))
371
376
  return xmlwriter.build_xml_tag('link', attrs, self.format_page_name(node))
372
377
 
373
378
  def field_is_writable(self, field):
@@ -435,7 +440,7 @@ class DocFormatter(object):
435
440
  node_name = node.namespace.name + '.' + node.name
436
441
  impl = []
437
442
 
438
- for c in node.namespace.itervalues():
443
+ for c in node.namespace.values():
439
444
  if not isinstance(c, ast.Class):
440
445
  continue
441
446
  for implemented in c.interfaces:
@@ -601,8 +606,8 @@ class DocFormatterGjs(DocFormatterIntrospectableBase):
601
606
  default_constructor = None
602
607
 
603
608
  introspectable_constructors = \
604
- filter(lambda c: getattr(c, 'introspectable', True),
605
- node.constructors)
609
+ list(filter(lambda c: getattr(c, 'introspectable', True),
610
+ node.constructors))
606
611
  for c in introspectable_constructors:
607
612
  if zero_args_constructor is None and \
608
613
  len(c.parameters) == 0:
@@ -859,12 +864,11 @@ class DocFormatterGjs(DocFormatterIntrospectableBase):
859
864
  if isinstance(node, ast.Compound):
860
865
  fields = filter(self.field_is_writable, node.fields)
861
866
  out = ''
862
- if len(fields) > 0:
863
- out += "{\n"
864
- for f in fields:
865
- out += " <link xref='%s.%s-%s'>%s</link>: value\n" % \
866
- (node.namespace.name, node.name, f.name, f.name)
867
- out += "}"
867
+ for f in fields:
868
+ out += " <link xref='%s.%s-%s'>%s</link>: value\n" % \
869
+ (node.namespace.name, node.name, f.name, f.name)
870
+ if out:
871
+ out = "{\n" + out + "}"
868
872
  return out
869
873
  else:
870
874
  return ''
@@ -953,6 +957,5 @@ class DocWriter(object):
953
957
 
954
958
  output_file_name = os.path.join(os.path.abspath(output),
955
959
  page_id + '.page')
956
- fp = open(output_file_name, 'w')
957
- fp.write(result)
958
- fp.close()
960
+ with open(output_file_name, 'wb') as fp:
961
+ fp.write(result)
@@ -19,11 +19,17 @@
19
19
  # Boston, MA 02111-1307, USA.
20
20
  #
21
21
 
22
+ from __future__ import absolute_import
23
+ from __future__ import division
24
+ from __future__ import print_function
25
+ from __future__ import unicode_literals
26
+
22
27
  import os
23
28
  import sys
24
29
  import subprocess
25
30
  import shutil
26
31
  import tempfile
32
+ from distutils.errors import LinkError
27
33
 
28
34
  from .gdumpparser import IntrospectionBinary
29
35
  from . import utils
@@ -78,25 +84,24 @@ class LinkerError(Exception):
78
84
 
79
85
  class DumpCompiler(object):
80
86
 
87
+ _compiler = None
88
+
81
89
  def __init__(self, options, get_type_functions, error_quark_functions):
82
90
  self._options = options
83
91
  self._get_type_functions = get_type_functions
84
92
  self._error_quark_functions = error_quark_functions
85
93
 
86
- self._compiler_cmd = os.environ.get('CC', 'cc')
87
- self._linker_cmd = os.environ.get('CC', self._compiler_cmd)
94
+ # Acquire the compiler (and linker) commands via the CCompiler class in ccompiler.py
95
+ self._compiler = CCompiler()
96
+
88
97
  self._pkgconfig_cmd = os.environ.get('PKG_CONFIG', 'pkg-config')
89
- self._pkgconfig_msvc_flags = ''
90
- # Enable the --msvc-syntax pkg-config flag when
91
- # the Microsoft compiler is used
92
- # (This is the other way to check whether Visual C++ is used subsequently)
93
- args = self._compiler_cmd.split()
94
- if 'cl.exe' in args or 'cl' in args:
95
- self._pkgconfig_msvc_flags = '--msvc-syntax'
96
- self._uninst_srcdir = os.environ.get(
97
- 'UNINSTALLED_INTROSPECTION_SRCDIR')
98
+ self._uninst_srcdir = os.environ.get('UNINSTALLED_INTROSPECTION_SRCDIR')
98
99
  self._packages = ['gio-2.0 gmodule-2.0']
99
100
  self._packages.extend(options.packages)
101
+ if hasattr(self._compiler.compiler, 'linker_exe'):
102
+ self._linker_cmd = self._compiler.compiler.linker_exe
103
+ else:
104
+ self._linker_cmd = []
100
105
 
101
106
  # Public API
102
107
 
@@ -114,68 +119,59 @@ class DumpCompiler(object):
114
119
  'gdump.c')
115
120
  if not os.path.isfile(gdump_path):
116
121
  raise SystemExit("Couldn't find %r" % (gdump_path, ))
117
- gdump_file = open(gdump_path)
118
- gdump_contents = gdump_file.read()
119
- gdump_file.close()
122
+ with open(gdump_path) as gdump_file:
123
+ gdump_contents = gdump_file.read()
120
124
  tpl_args['gdump_include'] = gdump_contents
121
125
  tpl_args['init_sections'] = "\n".join(self._options.init_sections)
122
126
 
123
127
  c_path = self._generate_tempfile(tmpdir, '.c')
124
- f = open(c_path, 'w')
125
- f.write(_PROGRAM_TEMPLATE % tpl_args)
126
-
127
- # We need to reference our get_type and error_quark functions
128
- # to make sure they are pulled in at the linking stage if the
129
- # library is a static library rather than a shared library.
130
- if len(self._get_type_functions) > 0:
131
- for func in self._get_type_functions:
132
- f.write("extern GType " + func + "(void);\n")
133
- f.write("GType (*GI_GET_TYPE_FUNCS_[])(void) = {\n")
134
- first = True
135
- for func in self._get_type_functions:
136
- if first:
137
- first = False
138
- else:
139
- f.write(",\n")
140
- f.write(" " + func)
141
- f.write("\n};\n")
142
- if len(self._error_quark_functions) > 0:
143
- for func in self._error_quark_functions:
144
- f.write("extern GQuark " + func + "(void);\n")
145
- f.write("GQuark (*GI_ERROR_QUARK_FUNCS_[])(void) = {\n")
146
- first = True
147
- for func in self._error_quark_functions:
148
- if first:
149
- first = False
150
- else:
151
- f.write(",\n")
152
- f.write(" " + func)
153
- f.write("\n};\n")
154
- f.close()
155
-
156
- # Microsoft compilers generate intermediate .obj files
157
- # during compilation, unlike .o files like GCC and others
158
- if self._pkgconfig_msvc_flags:
159
- o_path = self._generate_tempfile(tmpdir, '.obj')
160
- else:
161
- o_path = self._generate_tempfile(tmpdir, '.o')
162
-
163
- if os.name == 'nt':
164
- ext = '.exe'
128
+ with open(c_path, 'w') as f:
129
+ f.write(_PROGRAM_TEMPLATE % tpl_args)
130
+
131
+ # We need to reference our get_type and error_quark functions
132
+ # to make sure they are pulled in at the linking stage if the
133
+ # library is a static library rather than a shared library.
134
+ if len(self._get_type_functions) > 0:
135
+ for func in self._get_type_functions:
136
+ f.write("extern GType " + func + "(void);\n")
137
+ f.write("GType (*GI_GET_TYPE_FUNCS_[])(void) = {\n")
138
+ first = True
139
+ for func in self._get_type_functions:
140
+ if first:
141
+ first = False
142
+ else:
143
+ f.write(",\n")
144
+ f.write(" " + func)
145
+ f.write("\n};\n")
146
+ if len(self._error_quark_functions) > 0:
147
+ for func in self._error_quark_functions:
148
+ f.write("extern GQuark " + func + "(void);\n")
149
+ f.write("GQuark (*GI_ERROR_QUARK_FUNCS_[])(void) = {\n")
150
+ first = True
151
+ for func in self._error_quark_functions:
152
+ if first:
153
+ first = False
154
+ else:
155
+ f.write(",\n")
156
+ f.write(" " + func)
157
+ f.write("\n};\n")
158
+
159
+ if self._compiler.compiler.exe_extension:
160
+ ext = self._compiler.compiler.exe_extension
165
161
  else:
166
162
  ext = ''
167
163
 
168
164
  bin_path = self._generate_tempfile(tmpdir, ext)
169
165
 
170
166
  try:
171
- self._compile(o_path, c_path)
167
+ introspection_obj = self._compile(c_path)
172
168
  except CompilerError as e:
173
169
  if not utils.have_debug_flag('save-temps'):
174
170
  shutil.rmtree(tmpdir)
175
171
  raise SystemExit('compilation of temporary binary failed:' + str(e))
176
172
 
177
173
  try:
178
- self._link(bin_path, o_path)
174
+ self._link(bin_path, introspection_obj)
179
175
  except LinkerError as e:
180
176
  if not utils.have_debug_flag('save-temps'):
181
177
  shutil.rmtree(tmpdir)
@@ -193,143 +189,137 @@ class DumpCompiler(object):
193
189
  def _run_pkgconfig(self, flag):
194
190
  # Enable the --msvc-syntax pkg-config flag when
195
191
  # the Microsoft compiler is used
196
- if self._pkgconfig_msvc_flags:
197
- cmd = [self._pkgconfig_cmd, self._pkgconfig_msvc_flags, flag]
192
+ if self._compiler.check_is_msvc():
193
+ cmd = [self._pkgconfig_cmd, '--msvc-syntax', flag]
198
194
  else:
199
195
  cmd = [self._pkgconfig_cmd, flag]
200
196
  proc = subprocess.Popen(
201
197
  cmd + self._packages,
202
198
  stdout=subprocess.PIPE)
203
- return proc.communicate()[0].split()
204
-
205
- def _compile(self, output, *sources):
206
- # Not strictly speaking correct, but easier than parsing shell
207
- args = self._compiler_cmd.split()
208
- # Do not add -Wall when using init code as we do not include any
209
- # header of the library being introspected
210
- if self._compiler_cmd == 'gcc' and not self._options.init_sections:
211
- args.append('-Wall')
212
- # The Microsoft compiler uses different option flags for
213
- # silencing warnings on deprecated function usage
214
- if self._pkgconfig_msvc_flags:
215
- args.append("-wd4996")
216
- else:
217
- args.append("-Wno-deprecated-declarations")
199
+ out, err = proc.communicate()
200
+ return out.decode('ascii').split()
201
+
202
+ def _compile(self, *sources):
218
203
  pkgconfig_flags = self._run_pkgconfig('--cflags')
219
- args.extend([utils.cflag_real_include_path(f) for f in pkgconfig_flags])
220
- cppflags = os.environ.get('CPPFLAGS', '')
221
- for cppflag in cppflags.split():
222
- args.append(cppflag)
223
- cflags = os.environ.get('CFLAGS', '')
224
- for cflag in cflags.split():
225
- args.append(cflag)
226
- for include in self._options.cpp_includes:
227
- args.append('-I' + include)
228
- # The Microsoft compiler uses different option flags for
229
- # compilation result output
230
- if self._pkgconfig_msvc_flags:
231
- args.extend(['-c', '-Fe' + output, '-Fo' + output])
232
- else:
233
- args.extend(['-c', '-o', output])
234
- for source in sources:
235
- if not os.path.exists(source):
236
- raise CompilerError(
237
- "Could not find c source file: %s" % (source, ))
238
- args.extend(list(sources))
239
- if not self._options.quiet:
240
- print "g-ir-scanner: compile: %s" % (
241
- subprocess.list2cmdline(args), )
242
- sys.stdout.flush()
243
- try:
244
- subprocess.check_call(args)
245
- except subprocess.CalledProcessError as e:
246
- raise CompilerError(e)
204
+ return self._compiler.compile(pkgconfig_flags,
205
+ self._options.cpp_includes,
206
+ sources,
207
+ self._options.init_sections)
247
208
 
248
- def _link(self, output, *sources):
209
+ def _link(self, output, sources):
249
210
  args = []
250
211
  libtool = utils.get_libtool_command(self._options)
251
212
  if libtool:
213
+ # Note: MSVC Builds do not use libtool!
214
+ # In the libtool case, put together the linker command, as we did before.
215
+ # We aren't using distutils to link in this case.
252
216
  args.extend(libtool)
253
217
  args.append('--mode=link')
254
218
  args.append('--tag=CC')
255
219
  if self._options.quiet:
256
220
  args.append('--silent')
257
221
 
258
- args.extend(self._linker_cmd.split())
259
- # We can use -o for the Microsoft compiler/linker,
260
- # but it is considered deprecated usage with that
261
- if self._pkgconfig_msvc_flags:
262
- args.extend(['-Fe' + output])
263
- else:
222
+ args.extend(self._linker_cmd)
223
+
264
224
  args.extend(['-o', output])
265
- if libtool:
266
225
  if os.name == 'nt':
267
226
  args.append('-Wl,--export-all-symbols')
268
227
  else:
269
228
  args.append('-export-dynamic')
270
229
 
271
- cppflags = os.environ.get('CPPFLAGS', '')
272
- for cppflag in cppflags.split():
273
- args.append(cppflag)
274
- cflags = os.environ.get('CFLAGS', '')
275
- for cflag in cflags.split():
276
- args.append(cflag)
277
- ldflags = os.environ.get('LDFLAGS', '')
278
- for ldflag in ldflags.split():
279
- args.append(ldflag)
230
+ if not self._compiler.check_is_msvc():
231
+ # These envvars are not used for MSVC Builds!
232
+ # MSVC Builds use the INCLUDE, LIB envvars,
233
+ # which are automatically picked up during
234
+ # compilation and linking
235
+ cppflags = os.environ.get('CPPFLAGS', '')
236
+ for cppflag in cppflags.split():
237
+ args.append(cppflag)
238
+ cflags = os.environ.get('CFLAGS', '')
239
+ for cflag in cflags.split():
240
+ args.append(cflag)
241
+ ldflags = os.environ.get('LDFLAGS', '')
242
+ for ldflag in ldflags.split():
243
+ args.append(ldflag)
280
244
 
281
245
  # Make sure to list the library to be introspected first since it's
282
246
  # likely to be uninstalled yet and we want the uninstalled RPATHs have
283
247
  # priority (or we might run with installed library that is older)
284
-
285
248
  for source in sources:
286
249
  if not os.path.exists(source):
287
250
  raise CompilerError(
288
251
  "Could not find object file: %s" % (source, ))
289
- args.extend(list(sources))
290
252
 
291
- cc = CCompiler()
253
+ if libtool:
254
+ args.extend(sources)
255
+
256
+ pkg_config_libs = self._run_pkgconfig('--libs')
292
257
 
293
258
  if not self._options.external_library:
294
- cc.get_internal_link_flags(args,
295
- libtool,
296
- self._options.libraries,
297
- self._options.library_paths,
298
- self._pkgconfig_msvc_flags,
299
- self._options.namespace_name,
300
- self._options.namespace_version)
301
- args.extend(self._run_pkgconfig('--libs'))
259
+ self._compiler.get_internal_link_flags(args,
260
+ libtool,
261
+ self._options.libraries,
262
+ self._options.library_paths)
263
+ args.extend(pkg_config_libs)
302
264
 
303
265
  else:
304
- args.extend(self._run_pkgconfig('--libs'))
305
- cc.get_external_link_flags(args,
306
- self._options.libraries,
307
- self._pkgconfig_msvc_flags)
308
-
309
- if not self._options.quiet:
310
- print "g-ir-scanner: link: %s" % (
311
- subprocess.list2cmdline(args), )
312
- sys.stdout.flush()
313
- msys = os.environ.get('MSYSTEM', None)
314
- if msys:
315
- shell = os.environ.get('SHELL', 'sh.exe')
316
- # Create a temporary script file that
317
- # runs the command we want
318
- tf, tf_name = tempfile.mkstemp()
319
- f = os.fdopen(tf, 'wb')
320
- shellcontents = ' '.join([x.replace('\\', '/') for x in args])
321
- fcontents = '#!/bin/sh\nunset PWD\n{}\n'.format(shellcontents)
322
- f.write(fcontents)
323
- f.close()
324
- shell = utils.which(shell)
325
- args = [shell, tf_name.replace('\\', '/')]
326
- try:
327
- subprocess.check_call(args)
328
- except subprocess.CalledProcessError as e:
329
- raise LinkerError(e)
330
- finally:
266
+ args.extend(pkg_config_libs)
267
+ self._compiler.get_external_link_flags(args,
268
+ libtool,
269
+ self._options.libraries)
270
+
271
+ if not libtool:
272
+ # non-libtool: prepare distutils for linking the introspection
273
+ # dumper program...
274
+ try:
275
+ self._compiler.link(output,
276
+ sources,
277
+ args)
278
+
279
+ # Ignore failing to embed the manifest files, when the manifest
280
+ # file does not exist, especially for MSVC 2010 and later builds.
281
+ # If we are on Visual C++ 2005/2008, where
282
+ # this embedding is required, the build will fail anyway, as
283
+ # the dumper program will likely fail to run, and this means
284
+ # something went wrong with the build.
285
+ except LinkError as e:
286
+ if self._compiler.check_is_msvc():
287
+ msg = str(e)
288
+
289
+ if msg[msg.rfind('mt.exe'):] == 'mt.exe\' failed with exit status 31':
290
+ if sys.version_info < (3, 0):
291
+ sys.exc_clear()
292
+ pass
293
+ else:
294
+ raise LinkError(e)
295
+ else:
296
+ raise LinkError(e)
297
+ else:
298
+ # libtool: Run the assembled link command, we don't use distutils
299
+ # for linking here.
300
+ if not self._options.quiet:
301
+ print("g-ir-scanner: link: %s" % (
302
+ subprocess.list2cmdline(args), ))
303
+ sys.stdout.flush()
304
+ msys = os.environ.get('MSYSTEM', None)
331
305
  if msys:
332
- os.remove(tf_name)
306
+ shell = os.environ.get('SHELL', 'sh.exe')
307
+ # Create a temporary script file that
308
+ # runs the command we want
309
+ tf, tf_name = tempfile.mkstemp()
310
+ with os.fdopen(tf, 'wb') as f:
311
+ shellcontents = ' '.join([x.replace('\\', '/') for x in args])
312
+ fcontents = '#!/bin/sh\nunset PWD\n{}\n'.format(shellcontents)
313
+ f.write(fcontents)
314
+ shell = utils.which(shell)
315
+ args = [shell, tf_name.replace('\\', '/')]
316
+ try:
317
+ subprocess.check_call(args)
318
+ except subprocess.CalledProcessError as e:
319
+ raise LinkerError(e)
320
+ finally:
321
+ if msys:
322
+ os.remove(tf_name)
333
323
 
334
324
 
335
325
  def compile_introspection_binary(options, get_type_functions,