redsnow 0.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (174) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +34 -0
  3. data/.gitmodules +3 -0
  4. data/.travis.yml +20 -0
  5. data/CHANGELOG.md +4 -0
  6. data/Gemfile +4 -0
  7. data/LICENSE +21 -0
  8. data/README.md +62 -0
  9. data/Rakefile +36 -0
  10. data/Vagrantfile +20 -0
  11. data/ext/snowcrash/Makefile +64 -0
  12. data/ext/snowcrash/Vagrantfile +20 -0
  13. data/ext/snowcrash/bin/snowcrash +0 -0
  14. data/ext/snowcrash/common.gypi +163 -0
  15. data/ext/snowcrash/config.gypi +10 -0
  16. data/ext/snowcrash/config.mk +5 -0
  17. data/ext/snowcrash/configure +213 -0
  18. data/ext/snowcrash/provisioning.sh +15 -0
  19. data/ext/snowcrash/snowcrash.gyp +141 -0
  20. data/ext/snowcrash/src/ActionParser.h +503 -0
  21. data/ext/snowcrash/src/AssetParser.h +215 -0
  22. data/ext/snowcrash/src/BlockUtility.h +186 -0
  23. data/ext/snowcrash/src/Blueprint.h +283 -0
  24. data/ext/snowcrash/src/BlueprintParser.h +347 -0
  25. data/ext/snowcrash/src/BlueprintParserCore.h +190 -0
  26. data/ext/snowcrash/src/BlueprintSection.h +140 -0
  27. data/ext/snowcrash/src/BlueprintUtility.h +126 -0
  28. data/ext/snowcrash/src/CBlueprint.cc +600 -0
  29. data/ext/snowcrash/src/CBlueprint.h +354 -0
  30. data/ext/snowcrash/src/CSourceAnnotation.cc +140 -0
  31. data/ext/snowcrash/src/CSourceAnnotation.h +106 -0
  32. data/ext/snowcrash/src/CodeBlockUtility.h +189 -0
  33. data/ext/snowcrash/src/DescriptionSectionUtility.h +156 -0
  34. data/ext/snowcrash/src/HTTP.cc +46 -0
  35. data/ext/snowcrash/src/HTTP.h +105 -0
  36. data/ext/snowcrash/src/HeaderParser.h +289 -0
  37. data/ext/snowcrash/src/ListBlockUtility.h +273 -0
  38. data/ext/snowcrash/src/ListUtility.h +95 -0
  39. data/ext/snowcrash/src/MarkdownBlock.cc +176 -0
  40. data/ext/snowcrash/src/MarkdownBlock.h +93 -0
  41. data/ext/snowcrash/src/MarkdownParser.cc +266 -0
  42. data/ext/snowcrash/src/MarkdownParser.h +88 -0
  43. data/ext/snowcrash/src/ParameterDefinitonParser.h +570 -0
  44. data/ext/snowcrash/src/ParametersParser.h +252 -0
  45. data/ext/snowcrash/src/Parser.cc +71 -0
  46. data/ext/snowcrash/src/Parser.h +29 -0
  47. data/ext/snowcrash/src/ParserCore.cc +120 -0
  48. data/ext/snowcrash/src/ParserCore.h +82 -0
  49. data/ext/snowcrash/src/PayloadParser.h +672 -0
  50. data/ext/snowcrash/src/Platform.h +54 -0
  51. data/ext/snowcrash/src/RegexMatch.h +32 -0
  52. data/ext/snowcrash/src/ResourceGroupParser.h +195 -0
  53. data/ext/snowcrash/src/ResourceParser.h +584 -0
  54. data/ext/snowcrash/src/SectionUtility.h +142 -0
  55. data/ext/snowcrash/src/Serialize.cc +52 -0
  56. data/ext/snowcrash/src/Serialize.h +69 -0
  57. data/ext/snowcrash/src/SerializeJSON.cc +601 -0
  58. data/ext/snowcrash/src/SerializeJSON.h +21 -0
  59. data/ext/snowcrash/src/SerializeYAML.cc +336 -0
  60. data/ext/snowcrash/src/SerializeYAML.h +21 -0
  61. data/ext/snowcrash/src/SourceAnnotation.h +177 -0
  62. data/ext/snowcrash/src/StringUtility.h +109 -0
  63. data/ext/snowcrash/src/SymbolTable.h +83 -0
  64. data/ext/snowcrash/src/UriTemplateParser.cc +195 -0
  65. data/ext/snowcrash/src/UriTemplateParser.h +243 -0
  66. data/ext/snowcrash/src/Version.h +39 -0
  67. data/ext/snowcrash/src/csnowcrash.cc +23 -0
  68. data/ext/snowcrash/src/csnowcrash.h +38 -0
  69. data/ext/snowcrash/src/posix/RegexMatch.cc +99 -0
  70. data/ext/snowcrash/src/snowcrash.cc +18 -0
  71. data/ext/snowcrash/src/snowcrash.h +41 -0
  72. data/ext/snowcrash/src/snowcrash/snowcrash.cc +170 -0
  73. data/ext/snowcrash/src/win/RegexMatch.cc +78 -0
  74. data/ext/snowcrash/sundown/CONTRIBUTING.md +10 -0
  75. data/ext/snowcrash/sundown/Makefile +83 -0
  76. data/ext/snowcrash/sundown/Makefile.win +33 -0
  77. data/ext/snowcrash/sundown/examples/smartypants.c +72 -0
  78. data/ext/snowcrash/sundown/examples/sundown.c +80 -0
  79. data/ext/snowcrash/sundown/html/houdini.h +37 -0
  80. data/ext/snowcrash/sundown/html/houdini_href_e.c +108 -0
  81. data/ext/snowcrash/sundown/html/houdini_html_e.c +84 -0
  82. data/ext/snowcrash/sundown/html/html.c +647 -0
  83. data/ext/snowcrash/sundown/html/html.h +77 -0
  84. data/ext/snowcrash/sundown/html/html_smartypants.c +389 -0
  85. data/ext/snowcrash/sundown/html_block_names.txt +25 -0
  86. data/ext/snowcrash/sundown/src/autolink.c +297 -0
  87. data/ext/snowcrash/sundown/src/autolink.h +51 -0
  88. data/ext/snowcrash/sundown/src/buffer.c +225 -0
  89. data/ext/snowcrash/sundown/src/buffer.h +96 -0
  90. data/ext/snowcrash/sundown/src/html_blocks.h +206 -0
  91. data/ext/snowcrash/sundown/src/markdown.c +2701 -0
  92. data/ext/snowcrash/sundown/src/markdown.h +147 -0
  93. data/ext/snowcrash/sundown/src/src_map.c +200 -0
  94. data/ext/snowcrash/sundown/src/src_map.h +58 -0
  95. data/ext/snowcrash/sundown/src/stack.c +81 -0
  96. data/ext/snowcrash/sundown/src/stack.h +29 -0
  97. data/ext/snowcrash/sundown/sundown.def +20 -0
  98. data/ext/snowcrash/tools/gyp/AUTHORS +11 -0
  99. data/ext/snowcrash/tools/gyp/DEPS +24 -0
  100. data/ext/snowcrash/tools/gyp/OWNERS +1 -0
  101. data/ext/snowcrash/tools/gyp/PRESUBMIT.py +120 -0
  102. data/ext/snowcrash/tools/gyp/buildbot/buildbot_run.py +190 -0
  103. data/ext/snowcrash/tools/gyp/codereview.settings +10 -0
  104. data/ext/snowcrash/tools/gyp/data/win/large-pdb-shim.cc +12 -0
  105. data/ext/snowcrash/tools/gyp/gyp +8 -0
  106. data/ext/snowcrash/tools/gyp/gyp.bat +5 -0
  107. data/ext/snowcrash/tools/gyp/gyp_main.py +18 -0
  108. data/ext/snowcrash/tools/gyp/pylib/gyp/MSVSNew.py +340 -0
  109. data/ext/snowcrash/tools/gyp/pylib/gyp/MSVSProject.py +208 -0
  110. data/ext/snowcrash/tools/gyp/pylib/gyp/MSVSSettings.py +1063 -0
  111. data/ext/snowcrash/tools/gyp/pylib/gyp/MSVSToolFile.py +58 -0
  112. data/ext/snowcrash/tools/gyp/pylib/gyp/MSVSUserFile.py +147 -0
  113. data/ext/snowcrash/tools/gyp/pylib/gyp/MSVSUtil.py +267 -0
  114. data/ext/snowcrash/tools/gyp/pylib/gyp/MSVSVersion.py +409 -0
  115. data/ext/snowcrash/tools/gyp/pylib/gyp/__init__.py +537 -0
  116. data/ext/snowcrash/tools/gyp/pylib/gyp/__init__.pyc +0 -0
  117. data/ext/snowcrash/tools/gyp/pylib/gyp/common.py +521 -0
  118. data/ext/snowcrash/tools/gyp/pylib/gyp/common.pyc +0 -0
  119. data/ext/snowcrash/tools/gyp/pylib/gyp/easy_xml.py +157 -0
  120. data/ext/snowcrash/tools/gyp/pylib/gyp/flock_tool.py +49 -0
  121. data/ext/snowcrash/tools/gyp/pylib/gyp/generator/__init__.py +0 -0
  122. data/ext/snowcrash/tools/gyp/pylib/gyp/generator/__init__.pyc +0 -0
  123. data/ext/snowcrash/tools/gyp/pylib/gyp/generator/android.py +1069 -0
  124. data/ext/snowcrash/tools/gyp/pylib/gyp/generator/cmake.py +1143 -0
  125. data/ext/snowcrash/tools/gyp/pylib/gyp/generator/dump_dependency_json.py +81 -0
  126. data/ext/snowcrash/tools/gyp/pylib/gyp/generator/eclipse.py +335 -0
  127. data/ext/snowcrash/tools/gyp/pylib/gyp/generator/gypd.py +87 -0
  128. data/ext/snowcrash/tools/gyp/pylib/gyp/generator/gypsh.py +56 -0
  129. data/ext/snowcrash/tools/gyp/pylib/gyp/generator/make.py +2181 -0
  130. data/ext/snowcrash/tools/gyp/pylib/gyp/generator/make.pyc +0 -0
  131. data/ext/snowcrash/tools/gyp/pylib/gyp/generator/msvs.py +3335 -0
  132. data/ext/snowcrash/tools/gyp/pylib/gyp/generator/ninja.py +2156 -0
  133. data/ext/snowcrash/tools/gyp/pylib/gyp/generator/xcode.py +1224 -0
  134. data/ext/snowcrash/tools/gyp/pylib/gyp/generator/xcode.pyc +0 -0
  135. data/ext/snowcrash/tools/gyp/pylib/gyp/input.py +2809 -0
  136. data/ext/snowcrash/tools/gyp/pylib/gyp/input.pyc +0 -0
  137. data/ext/snowcrash/tools/gyp/pylib/gyp/mac_tool.py +510 -0
  138. data/ext/snowcrash/tools/gyp/pylib/gyp/msvs_emulation.py +972 -0
  139. data/ext/snowcrash/tools/gyp/pylib/gyp/ninja_syntax.py +160 -0
  140. data/ext/snowcrash/tools/gyp/pylib/gyp/ordered_dict.py +289 -0
  141. data/ext/snowcrash/tools/gyp/pylib/gyp/win_tool.py +292 -0
  142. data/ext/snowcrash/tools/gyp/pylib/gyp/xcode_emulation.py +1440 -0
  143. data/ext/snowcrash/tools/gyp/pylib/gyp/xcode_emulation.pyc +0 -0
  144. data/ext/snowcrash/tools/gyp/pylib/gyp/xcodeproj_file.py +2889 -0
  145. data/ext/snowcrash/tools/gyp/pylib/gyp/xcodeproj_file.pyc +0 -0
  146. data/ext/snowcrash/tools/gyp/pylib/gyp/xml_fix.py +69 -0
  147. data/ext/snowcrash/tools/gyp/pylintrc +307 -0
  148. data/ext/snowcrash/tools/gyp/samples/samples +81 -0
  149. data/ext/snowcrash/tools/gyp/samples/samples.bat +5 -0
  150. data/ext/snowcrash/tools/gyp/setup.py +19 -0
  151. data/ext/snowcrash/tools/gyp/tools/Xcode/Specifications/gyp.pbfilespec +27 -0
  152. data/ext/snowcrash/tools/gyp/tools/Xcode/Specifications/gyp.xclangspec +226 -0
  153. data/ext/snowcrash/tools/gyp/tools/emacs/gyp.el +252 -0
  154. data/ext/snowcrash/tools/gyp/tools/graphviz.py +100 -0
  155. data/ext/snowcrash/tools/gyp/tools/pretty_gyp.py +155 -0
  156. data/ext/snowcrash/tools/gyp/tools/pretty_sln.py +168 -0
  157. data/ext/snowcrash/tools/gyp/tools/pretty_vcproj.py +329 -0
  158. data/ext/snowcrash/tools/homebrew/snowcrash.rb +11 -0
  159. data/ext/snowcrash/vcbuild.bat +184 -0
  160. data/lib/redsnow.rb +31 -0
  161. data/lib/redsnow/binding.rb +132 -0
  162. data/lib/redsnow/blueprint.rb +365 -0
  163. data/lib/redsnow/object.rb +18 -0
  164. data/lib/redsnow/parseresult.rb +107 -0
  165. data/lib/redsnow/version.rb +4 -0
  166. data/provisioning.sh +20 -0
  167. data/redsnow.gemspec +35 -0
  168. data/test/_helper.rb +15 -0
  169. data/test/fixtures/sample-api-ast.json +97 -0
  170. data/test/fixtures/sample-api.apib +20 -0
  171. data/test/redsnow_binding_test.rb +35 -0
  172. data/test/redsnow_parseresult_test.rb +50 -0
  173. data/test/redsnow_test.rb +285 -0
  174. metadata +358 -0
@@ -0,0 +1,58 @@
1
+ # Copyright (c) 2012 Google Inc. All rights reserved.
2
+ # Use of this source code is governed by a BSD-style license that can be
3
+ # found in the LICENSE file.
4
+
5
+ """Visual Studio project reader/writer."""
6
+
7
+ import gyp.common
8
+ import gyp.easy_xml as easy_xml
9
+
10
+
11
+ class Writer(object):
12
+ """Visual Studio XML tool file writer."""
13
+
14
+ def __init__(self, tool_file_path, name):
15
+ """Initializes the tool file.
16
+
17
+ Args:
18
+ tool_file_path: Path to the tool file.
19
+ name: Name of the tool file.
20
+ """
21
+ self.tool_file_path = tool_file_path
22
+ self.name = name
23
+ self.rules_section = ['Rules']
24
+
25
+ def AddCustomBuildRule(self, name, cmd, description,
26
+ additional_dependencies,
27
+ outputs, extensions):
28
+ """Adds a rule to the tool file.
29
+
30
+ Args:
31
+ name: Name of the rule.
32
+ description: Description of the rule.
33
+ cmd: Command line of the rule.
34
+ additional_dependencies: other files which may trigger the rule.
35
+ outputs: outputs of the rule.
36
+ extensions: extensions handled by the rule.
37
+ """
38
+ rule = ['CustomBuildRule',
39
+ {'Name': name,
40
+ 'ExecutionDescription': description,
41
+ 'CommandLine': cmd,
42
+ 'Outputs': ';'.join(outputs),
43
+ 'FileExtensions': ';'.join(extensions),
44
+ 'AdditionalDependencies':
45
+ ';'.join(additional_dependencies)
46
+ }]
47
+ self.rules_section.append(rule)
48
+
49
+ def WriteIfChanged(self):
50
+ """Writes the tool file."""
51
+ content = ['VisualStudioToolFile',
52
+ {'Version': '8.00',
53
+ 'Name': self.name
54
+ },
55
+ self.rules_section
56
+ ]
57
+ easy_xml.WriteXmlIfChanged(content, self.tool_file_path,
58
+ encoding="Windows-1252")
@@ -0,0 +1,147 @@
1
+ # Copyright (c) 2012 Google Inc. All rights reserved.
2
+ # Use of this source code is governed by a BSD-style license that can be
3
+ # found in the LICENSE file.
4
+
5
+ """Visual Studio user preferences file writer."""
6
+
7
+ import os
8
+ import re
9
+ import socket # for gethostname
10
+
11
+ import gyp.common
12
+ import gyp.easy_xml as easy_xml
13
+
14
+
15
+ #------------------------------------------------------------------------------
16
+
17
+ def _FindCommandInPath(command):
18
+ """If there are no slashes in the command given, this function
19
+ searches the PATH env to find the given command, and converts it
20
+ to an absolute path. We have to do this because MSVS is looking
21
+ for an actual file to launch a debugger on, not just a command
22
+ line. Note that this happens at GYP time, so anything needing to
23
+ be built needs to have a full path."""
24
+ if '/' in command or '\\' in command:
25
+ # If the command already has path elements (either relative or
26
+ # absolute), then assume it is constructed properly.
27
+ return command
28
+ else:
29
+ # Search through the path list and find an existing file that
30
+ # we can access.
31
+ paths = os.environ.get('PATH','').split(os.pathsep)
32
+ for path in paths:
33
+ item = os.path.join(path, command)
34
+ if os.path.isfile(item) and os.access(item, os.X_OK):
35
+ return item
36
+ return command
37
+
38
+ def _QuoteWin32CommandLineArgs(args):
39
+ new_args = []
40
+ for arg in args:
41
+ # Replace all double-quotes with double-double-quotes to escape
42
+ # them for cmd shell, and then quote the whole thing if there
43
+ # are any.
44
+ if arg.find('"') != -1:
45
+ arg = '""'.join(arg.split('"'))
46
+ arg = '"%s"' % arg
47
+
48
+ # Otherwise, if there are any spaces, quote the whole arg.
49
+ elif re.search(r'[ \t\n]', arg):
50
+ arg = '"%s"' % arg
51
+ new_args.append(arg)
52
+ return new_args
53
+
54
+ class Writer(object):
55
+ """Visual Studio XML user user file writer."""
56
+
57
+ def __init__(self, user_file_path, version, name):
58
+ """Initializes the user file.
59
+
60
+ Args:
61
+ user_file_path: Path to the user file.
62
+ version: Version info.
63
+ name: Name of the user file.
64
+ """
65
+ self.user_file_path = user_file_path
66
+ self.version = version
67
+ self.name = name
68
+ self.configurations = {}
69
+
70
+ def AddConfig(self, name):
71
+ """Adds a configuration to the project.
72
+
73
+ Args:
74
+ name: Configuration name.
75
+ """
76
+ self.configurations[name] = ['Configuration', {'Name': name}]
77
+
78
+ def AddDebugSettings(self, config_name, command, environment = {},
79
+ working_directory=""):
80
+ """Adds a DebugSettings node to the user file for a particular config.
81
+
82
+ Args:
83
+ command: command line to run. First element in the list is the
84
+ executable. All elements of the command will be quoted if
85
+ necessary.
86
+ working_directory: other files which may trigger the rule. (optional)
87
+ """
88
+ command = _QuoteWin32CommandLineArgs(command)
89
+
90
+ abs_command = _FindCommandInPath(command[0])
91
+
92
+ if environment and isinstance(environment, dict):
93
+ env_list = ['%s="%s"' % (key, val)
94
+ for (key,val) in environment.iteritems()]
95
+ environment = ' '.join(env_list)
96
+ else:
97
+ environment = ''
98
+
99
+ n_cmd = ['DebugSettings',
100
+ {'Command': abs_command,
101
+ 'WorkingDirectory': working_directory,
102
+ 'CommandArguments': " ".join(command[1:]),
103
+ 'RemoteMachine': socket.gethostname(),
104
+ 'Environment': environment,
105
+ 'EnvironmentMerge': 'true',
106
+ # Currently these are all "dummy" values that we're just setting
107
+ # in the default manner that MSVS does it. We could use some of
108
+ # these to add additional capabilities, I suppose, but they might
109
+ # not have parity with other platforms then.
110
+ 'Attach': 'false',
111
+ 'DebuggerType': '3', # 'auto' debugger
112
+ 'Remote': '1',
113
+ 'RemoteCommand': '',
114
+ 'HttpUrl': '',
115
+ 'PDBPath': '',
116
+ 'SQLDebugging': '',
117
+ 'DebuggerFlavor': '0',
118
+ 'MPIRunCommand': '',
119
+ 'MPIRunArguments': '',
120
+ 'MPIRunWorkingDirectory': '',
121
+ 'ApplicationCommand': '',
122
+ 'ApplicationArguments': '',
123
+ 'ShimCommand': '',
124
+ 'MPIAcceptMode': '',
125
+ 'MPIAcceptFilter': ''
126
+ }]
127
+
128
+ # Find the config, and add it if it doesn't exist.
129
+ if config_name not in self.configurations:
130
+ self.AddConfig(config_name)
131
+
132
+ # Add the DebugSettings onto the appropriate config.
133
+ self.configurations[config_name].append(n_cmd)
134
+
135
+ def WriteIfChanged(self):
136
+ """Writes the user file."""
137
+ configs = ['Configurations']
138
+ for config, spec in sorted(self.configurations.iteritems()):
139
+ configs.append(spec)
140
+
141
+ content = ['VisualStudioUserFile',
142
+ {'Version': self.version.ProjectVersion(),
143
+ 'Name': self.name
144
+ },
145
+ configs]
146
+ easy_xml.WriteXmlIfChanged(content, self.user_file_path,
147
+ encoding="Windows-1252")
@@ -0,0 +1,267 @@
1
+ # Copyright (c) 2013 Google Inc. All rights reserved.
2
+ # Use of this source code is governed by a BSD-style license that can be
3
+ # found in the LICENSE file.
4
+
5
+ """Utility functions shared amongst the Windows generators."""
6
+
7
+ import copy
8
+ import os
9
+
10
+
11
+ _TARGET_TYPE_EXT = {
12
+ 'executable': '.exe',
13
+ 'loadable_module': '.dll',
14
+ 'shared_library': '.dll',
15
+ }
16
+
17
+
18
+ def _GetLargePdbShimCcPath():
19
+ """Returns the path of the large_pdb_shim.cc file."""
20
+ this_dir = os.path.abspath(os.path.dirname(__file__))
21
+ src_dir = os.path.abspath(os.path.join(this_dir, '..', '..'))
22
+ win_data_dir = os.path.join(src_dir, 'data', 'win')
23
+ large_pdb_shim_cc = os.path.join(win_data_dir, 'large-pdb-shim.cc')
24
+ return large_pdb_shim_cc
25
+
26
+
27
+ def _DeepCopySomeKeys(in_dict, keys):
28
+ """Performs a partial deep-copy on |in_dict|, only copying the keys in |keys|.
29
+
30
+ Arguments:
31
+ in_dict: The dictionary to copy.
32
+ keys: The keys to be copied. If a key is in this list and doesn't exist in
33
+ |in_dict| this is not an error.
34
+ Returns:
35
+ The partially deep-copied dictionary.
36
+ """
37
+ d = {}
38
+ for key in keys:
39
+ if key not in in_dict:
40
+ continue
41
+ d[key] = copy.deepcopy(in_dict[key])
42
+ return d
43
+
44
+
45
+ def _SuffixName(name, suffix):
46
+ """Add a suffix to the end of a target.
47
+
48
+ Arguments:
49
+ name: name of the target (foo#target)
50
+ suffix: the suffix to be added
51
+ Returns:
52
+ Target name with suffix added (foo_suffix#target)
53
+ """
54
+ parts = name.rsplit('#', 1)
55
+ parts[0] = '%s_%s' % (parts[0], suffix)
56
+ return '#'.join(parts)
57
+
58
+
59
+ def _ShardName(name, number):
60
+ """Add a shard number to the end of a target.
61
+
62
+ Arguments:
63
+ name: name of the target (foo#target)
64
+ number: shard number
65
+ Returns:
66
+ Target name with shard added (foo_1#target)
67
+ """
68
+ return _SuffixName(name, str(number))
69
+
70
+
71
+ def ShardTargets(target_list, target_dicts):
72
+ """Shard some targets apart to work around the linkers limits.
73
+
74
+ Arguments:
75
+ target_list: List of target pairs: 'base/base.gyp:base'.
76
+ target_dicts: Dict of target properties keyed on target pair.
77
+ Returns:
78
+ Tuple of the new sharded versions of the inputs.
79
+ """
80
+ # Gather the targets to shard, and how many pieces.
81
+ targets_to_shard = {}
82
+ for t in target_dicts:
83
+ shards = int(target_dicts[t].get('msvs_shard', 0))
84
+ if shards:
85
+ targets_to_shard[t] = shards
86
+ # Shard target_list.
87
+ new_target_list = []
88
+ for t in target_list:
89
+ if t in targets_to_shard:
90
+ for i in range(targets_to_shard[t]):
91
+ new_target_list.append(_ShardName(t, i))
92
+ else:
93
+ new_target_list.append(t)
94
+ # Shard target_dict.
95
+ new_target_dicts = {}
96
+ for t in target_dicts:
97
+ if t in targets_to_shard:
98
+ for i in range(targets_to_shard[t]):
99
+ name = _ShardName(t, i)
100
+ new_target_dicts[name] = copy.copy(target_dicts[t])
101
+ new_target_dicts[name]['target_name'] = _ShardName(
102
+ new_target_dicts[name]['target_name'], i)
103
+ sources = new_target_dicts[name].get('sources', [])
104
+ new_sources = []
105
+ for pos in range(i, len(sources), targets_to_shard[t]):
106
+ new_sources.append(sources[pos])
107
+ new_target_dicts[name]['sources'] = new_sources
108
+ else:
109
+ new_target_dicts[t] = target_dicts[t]
110
+ # Shard dependencies.
111
+ for t in new_target_dicts:
112
+ dependencies = copy.copy(new_target_dicts[t].get('dependencies', []))
113
+ new_dependencies = []
114
+ for d in dependencies:
115
+ if d in targets_to_shard:
116
+ for i in range(targets_to_shard[d]):
117
+ new_dependencies.append(_ShardName(d, i))
118
+ else:
119
+ new_dependencies.append(d)
120
+ new_target_dicts[t]['dependencies'] = new_dependencies
121
+
122
+ return (new_target_list, new_target_dicts)
123
+
124
+
125
+ def _GetPdbPath(target_dict, config_name, vars):
126
+ """Returns the path to the PDB file that will be generated by a given
127
+ configuration.
128
+
129
+ The lookup proceeds as follows:
130
+ - Look for an explicit path in the VCLinkerTool configuration block.
131
+ - Look for an 'msvs_large_pdb_path' variable.
132
+ - Use '<(PRODUCT_DIR)/<(product_name).(exe|dll).pdb' if 'product_name' is
133
+ specified.
134
+ - Use '<(PRODUCT_DIR)/<(target_name).(exe|dll).pdb'.
135
+
136
+ Arguments:
137
+ target_dict: The target dictionary to be searched.
138
+ config_name: The name of the configuration of interest.
139
+ vars: A dictionary of common GYP variables with generator-specific values.
140
+ Returns:
141
+ The path of the corresponding PDB file.
142
+ """
143
+ config = target_dict['configurations'][config_name]
144
+ msvs = config.setdefault('msvs_settings', {})
145
+
146
+ linker = msvs.get('VCLinkerTool', {})
147
+
148
+ pdb_path = linker.get('ProgramDatabaseFile')
149
+ if pdb_path:
150
+ return pdb_path
151
+
152
+ variables = target_dict.get('variables', {})
153
+ pdb_path = variables.get('msvs_large_pdb_path', None)
154
+ if pdb_path:
155
+ return pdb_path
156
+
157
+
158
+ pdb_base = target_dict.get('product_name', target_dict['target_name'])
159
+ pdb_base = '%s%s.pdb' % (pdb_base, _TARGET_TYPE_EXT[target_dict['type']])
160
+ pdb_path = vars['PRODUCT_DIR'] + '/' + pdb_base
161
+
162
+ return pdb_path
163
+
164
+
165
+ def InsertLargePdbShims(target_list, target_dicts, vars):
166
+ """Insert a shim target that forces the linker to use 4KB pagesize PDBs.
167
+
168
+ This is a workaround for targets with PDBs greater than 1GB in size, the
169
+ limit for the 1KB pagesize PDBs created by the linker by default.
170
+
171
+ Arguments:
172
+ target_list: List of target pairs: 'base/base.gyp:base'.
173
+ target_dicts: Dict of target properties keyed on target pair.
174
+ vars: A dictionary of common GYP variables with generator-specific values.
175
+ Returns:
176
+ Tuple of the shimmed version of the inputs.
177
+ """
178
+ # Determine which targets need shimming.
179
+ targets_to_shim = []
180
+ for t in target_dicts:
181
+ target_dict = target_dicts[t]
182
+
183
+ # We only want to shim targets that have msvs_large_pdb enabled.
184
+ if not int(target_dict.get('msvs_large_pdb', 0)):
185
+ continue
186
+ # This is intended for executable, shared_library and loadable_module
187
+ # targets where every configuration is set up to produce a PDB output.
188
+ # If any of these conditions is not true then the shim logic will fail
189
+ # below.
190
+ targets_to_shim.append(t)
191
+
192
+ large_pdb_shim_cc = _GetLargePdbShimCcPath()
193
+
194
+ for t in targets_to_shim:
195
+ target_dict = target_dicts[t]
196
+ target_name = target_dict.get('target_name')
197
+
198
+ base_dict = _DeepCopySomeKeys(target_dict,
199
+ ['configurations', 'default_configuration', 'toolset'])
200
+
201
+ # This is the dict for copying the source file (part of the GYP tree)
202
+ # to the intermediate directory of the project. This is necessary because
203
+ # we can't always build a relative path to the shim source file (on Windows
204
+ # GYP and the project may be on different drives), and Ninja hates absolute
205
+ # paths (it ends up generating the .obj and .obj.d alongside the source
206
+ # file, polluting GYPs tree).
207
+ copy_suffix = 'large_pdb_copy'
208
+ copy_target_name = target_name + '_' + copy_suffix
209
+ full_copy_target_name = _SuffixName(t, copy_suffix)
210
+ shim_cc_basename = os.path.basename(large_pdb_shim_cc)
211
+ shim_cc_dir = vars['SHARED_INTERMEDIATE_DIR'] + '/' + copy_target_name
212
+ shim_cc_path = shim_cc_dir + '/' + shim_cc_basename
213
+ copy_dict = copy.deepcopy(base_dict)
214
+ copy_dict['target_name'] = copy_target_name
215
+ copy_dict['type'] = 'none'
216
+ copy_dict['sources'] = [ large_pdb_shim_cc ]
217
+ copy_dict['copies'] = [{
218
+ 'destination': shim_cc_dir,
219
+ 'files': [ large_pdb_shim_cc ]
220
+ }]
221
+
222
+ # This is the dict for the PDB generating shim target. It depends on the
223
+ # copy target.
224
+ shim_suffix = 'large_pdb_shim'
225
+ shim_target_name = target_name + '_' + shim_suffix
226
+ full_shim_target_name = _SuffixName(t, shim_suffix)
227
+ shim_dict = copy.deepcopy(base_dict)
228
+ shim_dict['target_name'] = shim_target_name
229
+ shim_dict['type'] = 'static_library'
230
+ shim_dict['sources'] = [ shim_cc_path ]
231
+ shim_dict['dependencies'] = [ full_copy_target_name ]
232
+
233
+ # Set up the shim to output its PDB to the same location as the final linker
234
+ # target.
235
+ for config_name, config in shim_dict.get('configurations').iteritems():
236
+ pdb_path = _GetPdbPath(target_dict, config_name, vars)
237
+
238
+ # A few keys that we don't want to propagate.
239
+ for key in ['msvs_precompiled_header', 'msvs_precompiled_source', 'test']:
240
+ config.pop(key, None)
241
+
242
+ msvs = config.setdefault('msvs_settings', {})
243
+
244
+ # Update the compiler directives in the shim target.
245
+ compiler = msvs.setdefault('VCCLCompilerTool', {})
246
+ compiler['DebugInformationFormat'] = '3'
247
+ compiler['ProgramDataBaseFileName'] = pdb_path
248
+
249
+ # Set the explicit PDB path in the appropriate configuration of the
250
+ # original target.
251
+ config = target_dict['configurations'][config_name]
252
+ msvs = config.setdefault('msvs_settings', {})
253
+ linker = msvs.setdefault('VCLinkerTool', {})
254
+ linker['GenerateDebugInformation'] = 'true'
255
+ linker['ProgramDatabaseFile'] = pdb_path
256
+
257
+ # Add the new targets. They must go to the beginning of the list so that
258
+ # the dependency generation works as expected in ninja.
259
+ target_list.insert(0, full_copy_target_name)
260
+ target_list.insert(0, full_shim_target_name)
261
+ target_dicts[full_copy_target_name] = copy_dict
262
+ target_dicts[full_shim_target_name] = shim_dict
263
+
264
+ # Update the original target to depend on the shim target.
265
+ target_dict.setdefault('dependencies', []).append(full_shim_target_name)
266
+
267
+ return (target_list, target_dicts)