redsnow 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +34 -0
- data/.gitmodules +3 -0
- data/.travis.yml +20 -0
- data/CHANGELOG.md +4 -0
- data/Gemfile +4 -0
- data/LICENSE +21 -0
- data/README.md +62 -0
- data/Rakefile +36 -0
- data/Vagrantfile +20 -0
- data/ext/snowcrash/Makefile +64 -0
- data/ext/snowcrash/Vagrantfile +20 -0
- data/ext/snowcrash/bin/snowcrash +0 -0
- data/ext/snowcrash/common.gypi +163 -0
- data/ext/snowcrash/config.gypi +10 -0
- data/ext/snowcrash/config.mk +5 -0
- data/ext/snowcrash/configure +213 -0
- data/ext/snowcrash/provisioning.sh +15 -0
- data/ext/snowcrash/snowcrash.gyp +141 -0
- data/ext/snowcrash/src/ActionParser.h +503 -0
- data/ext/snowcrash/src/AssetParser.h +215 -0
- data/ext/snowcrash/src/BlockUtility.h +186 -0
- data/ext/snowcrash/src/Blueprint.h +283 -0
- data/ext/snowcrash/src/BlueprintParser.h +347 -0
- data/ext/snowcrash/src/BlueprintParserCore.h +190 -0
- data/ext/snowcrash/src/BlueprintSection.h +140 -0
- data/ext/snowcrash/src/BlueprintUtility.h +126 -0
- data/ext/snowcrash/src/CBlueprint.cc +600 -0
- data/ext/snowcrash/src/CBlueprint.h +354 -0
- data/ext/snowcrash/src/CSourceAnnotation.cc +140 -0
- data/ext/snowcrash/src/CSourceAnnotation.h +106 -0
- data/ext/snowcrash/src/CodeBlockUtility.h +189 -0
- data/ext/snowcrash/src/DescriptionSectionUtility.h +156 -0
- data/ext/snowcrash/src/HTTP.cc +46 -0
- data/ext/snowcrash/src/HTTP.h +105 -0
- data/ext/snowcrash/src/HeaderParser.h +289 -0
- data/ext/snowcrash/src/ListBlockUtility.h +273 -0
- data/ext/snowcrash/src/ListUtility.h +95 -0
- data/ext/snowcrash/src/MarkdownBlock.cc +176 -0
- data/ext/snowcrash/src/MarkdownBlock.h +93 -0
- data/ext/snowcrash/src/MarkdownParser.cc +266 -0
- data/ext/snowcrash/src/MarkdownParser.h +88 -0
- data/ext/snowcrash/src/ParameterDefinitonParser.h +570 -0
- data/ext/snowcrash/src/ParametersParser.h +252 -0
- data/ext/snowcrash/src/Parser.cc +71 -0
- data/ext/snowcrash/src/Parser.h +29 -0
- data/ext/snowcrash/src/ParserCore.cc +120 -0
- data/ext/snowcrash/src/ParserCore.h +82 -0
- data/ext/snowcrash/src/PayloadParser.h +672 -0
- data/ext/snowcrash/src/Platform.h +54 -0
- data/ext/snowcrash/src/RegexMatch.h +32 -0
- data/ext/snowcrash/src/ResourceGroupParser.h +195 -0
- data/ext/snowcrash/src/ResourceParser.h +584 -0
- data/ext/snowcrash/src/SectionUtility.h +142 -0
- data/ext/snowcrash/src/Serialize.cc +52 -0
- data/ext/snowcrash/src/Serialize.h +69 -0
- data/ext/snowcrash/src/SerializeJSON.cc +601 -0
- data/ext/snowcrash/src/SerializeJSON.h +21 -0
- data/ext/snowcrash/src/SerializeYAML.cc +336 -0
- data/ext/snowcrash/src/SerializeYAML.h +21 -0
- data/ext/snowcrash/src/SourceAnnotation.h +177 -0
- data/ext/snowcrash/src/StringUtility.h +109 -0
- data/ext/snowcrash/src/SymbolTable.h +83 -0
- data/ext/snowcrash/src/UriTemplateParser.cc +195 -0
- data/ext/snowcrash/src/UriTemplateParser.h +243 -0
- data/ext/snowcrash/src/Version.h +39 -0
- data/ext/snowcrash/src/csnowcrash.cc +23 -0
- data/ext/snowcrash/src/csnowcrash.h +38 -0
- data/ext/snowcrash/src/posix/RegexMatch.cc +99 -0
- data/ext/snowcrash/src/snowcrash.cc +18 -0
- data/ext/snowcrash/src/snowcrash.h +41 -0
- data/ext/snowcrash/src/snowcrash/snowcrash.cc +170 -0
- data/ext/snowcrash/src/win/RegexMatch.cc +78 -0
- data/ext/snowcrash/sundown/CONTRIBUTING.md +10 -0
- data/ext/snowcrash/sundown/Makefile +83 -0
- data/ext/snowcrash/sundown/Makefile.win +33 -0
- data/ext/snowcrash/sundown/examples/smartypants.c +72 -0
- data/ext/snowcrash/sundown/examples/sundown.c +80 -0
- data/ext/snowcrash/sundown/html/houdini.h +37 -0
- data/ext/snowcrash/sundown/html/houdini_href_e.c +108 -0
- data/ext/snowcrash/sundown/html/houdini_html_e.c +84 -0
- data/ext/snowcrash/sundown/html/html.c +647 -0
- data/ext/snowcrash/sundown/html/html.h +77 -0
- data/ext/snowcrash/sundown/html/html_smartypants.c +389 -0
- data/ext/snowcrash/sundown/html_block_names.txt +25 -0
- data/ext/snowcrash/sundown/src/autolink.c +297 -0
- data/ext/snowcrash/sundown/src/autolink.h +51 -0
- data/ext/snowcrash/sundown/src/buffer.c +225 -0
- data/ext/snowcrash/sundown/src/buffer.h +96 -0
- data/ext/snowcrash/sundown/src/html_blocks.h +206 -0
- data/ext/snowcrash/sundown/src/markdown.c +2701 -0
- data/ext/snowcrash/sundown/src/markdown.h +147 -0
- data/ext/snowcrash/sundown/src/src_map.c +200 -0
- data/ext/snowcrash/sundown/src/src_map.h +58 -0
- data/ext/snowcrash/sundown/src/stack.c +81 -0
- data/ext/snowcrash/sundown/src/stack.h +29 -0
- data/ext/snowcrash/sundown/sundown.def +20 -0
- data/ext/snowcrash/tools/gyp/AUTHORS +11 -0
- data/ext/snowcrash/tools/gyp/DEPS +24 -0
- data/ext/snowcrash/tools/gyp/OWNERS +1 -0
- data/ext/snowcrash/tools/gyp/PRESUBMIT.py +120 -0
- data/ext/snowcrash/tools/gyp/buildbot/buildbot_run.py +190 -0
- data/ext/snowcrash/tools/gyp/codereview.settings +10 -0
- data/ext/snowcrash/tools/gyp/data/win/large-pdb-shim.cc +12 -0
- data/ext/snowcrash/tools/gyp/gyp +8 -0
- data/ext/snowcrash/tools/gyp/gyp.bat +5 -0
- data/ext/snowcrash/tools/gyp/gyp_main.py +18 -0
- data/ext/snowcrash/tools/gyp/pylib/gyp/MSVSNew.py +340 -0
- data/ext/snowcrash/tools/gyp/pylib/gyp/MSVSProject.py +208 -0
- data/ext/snowcrash/tools/gyp/pylib/gyp/MSVSSettings.py +1063 -0
- data/ext/snowcrash/tools/gyp/pylib/gyp/MSVSToolFile.py +58 -0
- data/ext/snowcrash/tools/gyp/pylib/gyp/MSVSUserFile.py +147 -0
- data/ext/snowcrash/tools/gyp/pylib/gyp/MSVSUtil.py +267 -0
- data/ext/snowcrash/tools/gyp/pylib/gyp/MSVSVersion.py +409 -0
- data/ext/snowcrash/tools/gyp/pylib/gyp/__init__.py +537 -0
- data/ext/snowcrash/tools/gyp/pylib/gyp/__init__.pyc +0 -0
- data/ext/snowcrash/tools/gyp/pylib/gyp/common.py +521 -0
- data/ext/snowcrash/tools/gyp/pylib/gyp/common.pyc +0 -0
- data/ext/snowcrash/tools/gyp/pylib/gyp/easy_xml.py +157 -0
- data/ext/snowcrash/tools/gyp/pylib/gyp/flock_tool.py +49 -0
- data/ext/snowcrash/tools/gyp/pylib/gyp/generator/__init__.py +0 -0
- data/ext/snowcrash/tools/gyp/pylib/gyp/generator/__init__.pyc +0 -0
- data/ext/snowcrash/tools/gyp/pylib/gyp/generator/android.py +1069 -0
- data/ext/snowcrash/tools/gyp/pylib/gyp/generator/cmake.py +1143 -0
- data/ext/snowcrash/tools/gyp/pylib/gyp/generator/dump_dependency_json.py +81 -0
- data/ext/snowcrash/tools/gyp/pylib/gyp/generator/eclipse.py +335 -0
- data/ext/snowcrash/tools/gyp/pylib/gyp/generator/gypd.py +87 -0
- data/ext/snowcrash/tools/gyp/pylib/gyp/generator/gypsh.py +56 -0
- data/ext/snowcrash/tools/gyp/pylib/gyp/generator/make.py +2181 -0
- data/ext/snowcrash/tools/gyp/pylib/gyp/generator/make.pyc +0 -0
- data/ext/snowcrash/tools/gyp/pylib/gyp/generator/msvs.py +3335 -0
- data/ext/snowcrash/tools/gyp/pylib/gyp/generator/ninja.py +2156 -0
- data/ext/snowcrash/tools/gyp/pylib/gyp/generator/xcode.py +1224 -0
- data/ext/snowcrash/tools/gyp/pylib/gyp/generator/xcode.pyc +0 -0
- data/ext/snowcrash/tools/gyp/pylib/gyp/input.py +2809 -0
- data/ext/snowcrash/tools/gyp/pylib/gyp/input.pyc +0 -0
- data/ext/snowcrash/tools/gyp/pylib/gyp/mac_tool.py +510 -0
- data/ext/snowcrash/tools/gyp/pylib/gyp/msvs_emulation.py +972 -0
- data/ext/snowcrash/tools/gyp/pylib/gyp/ninja_syntax.py +160 -0
- data/ext/snowcrash/tools/gyp/pylib/gyp/ordered_dict.py +289 -0
- data/ext/snowcrash/tools/gyp/pylib/gyp/win_tool.py +292 -0
- data/ext/snowcrash/tools/gyp/pylib/gyp/xcode_emulation.py +1440 -0
- data/ext/snowcrash/tools/gyp/pylib/gyp/xcode_emulation.pyc +0 -0
- data/ext/snowcrash/tools/gyp/pylib/gyp/xcodeproj_file.py +2889 -0
- data/ext/snowcrash/tools/gyp/pylib/gyp/xcodeproj_file.pyc +0 -0
- data/ext/snowcrash/tools/gyp/pylib/gyp/xml_fix.py +69 -0
- data/ext/snowcrash/tools/gyp/pylintrc +307 -0
- data/ext/snowcrash/tools/gyp/samples/samples +81 -0
- data/ext/snowcrash/tools/gyp/samples/samples.bat +5 -0
- data/ext/snowcrash/tools/gyp/setup.py +19 -0
- data/ext/snowcrash/tools/gyp/tools/Xcode/Specifications/gyp.pbfilespec +27 -0
- data/ext/snowcrash/tools/gyp/tools/Xcode/Specifications/gyp.xclangspec +226 -0
- data/ext/snowcrash/tools/gyp/tools/emacs/gyp.el +252 -0
- data/ext/snowcrash/tools/gyp/tools/graphviz.py +100 -0
- data/ext/snowcrash/tools/gyp/tools/pretty_gyp.py +155 -0
- data/ext/snowcrash/tools/gyp/tools/pretty_sln.py +168 -0
- data/ext/snowcrash/tools/gyp/tools/pretty_vcproj.py +329 -0
- data/ext/snowcrash/tools/homebrew/snowcrash.rb +11 -0
- data/ext/snowcrash/vcbuild.bat +184 -0
- data/lib/redsnow.rb +31 -0
- data/lib/redsnow/binding.rb +132 -0
- data/lib/redsnow/blueprint.rb +365 -0
- data/lib/redsnow/object.rb +18 -0
- data/lib/redsnow/parseresult.rb +107 -0
- data/lib/redsnow/version.rb +4 -0
- data/provisioning.sh +20 -0
- data/redsnow.gemspec +35 -0
- data/test/_helper.rb +15 -0
- data/test/fixtures/sample-api-ast.json +97 -0
- data/test/fixtures/sample-api.apib +20 -0
- data/test/redsnow_binding_test.rb +35 -0
- data/test/redsnow_parseresult_test.rb +50 -0
- data/test/redsnow_test.rb +285 -0
- metadata +358 -0
@@ -0,0 +1,81 @@
|
|
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
|
+
import collections
|
6
|
+
import os
|
7
|
+
import gyp
|
8
|
+
import gyp.common
|
9
|
+
import gyp.msvs_emulation
|
10
|
+
import json
|
11
|
+
import sys
|
12
|
+
|
13
|
+
generator_supports_multiple_toolsets = True
|
14
|
+
|
15
|
+
generator_wants_static_library_dependencies_adjusted = False
|
16
|
+
|
17
|
+
generator_default_variables = {
|
18
|
+
}
|
19
|
+
for dirname in ['INTERMEDIATE_DIR', 'SHARED_INTERMEDIATE_DIR', 'PRODUCT_DIR',
|
20
|
+
'LIB_DIR', 'SHARED_LIB_DIR']:
|
21
|
+
# Some gyp steps fail if these are empty(!).
|
22
|
+
generator_default_variables[dirname] = 'dir'
|
23
|
+
for unused in ['RULE_INPUT_PATH', 'RULE_INPUT_ROOT', 'RULE_INPUT_NAME',
|
24
|
+
'RULE_INPUT_DIRNAME', 'RULE_INPUT_EXT',
|
25
|
+
'EXECUTABLE_PREFIX', 'EXECUTABLE_SUFFIX',
|
26
|
+
'STATIC_LIB_PREFIX', 'STATIC_LIB_SUFFIX',
|
27
|
+
'SHARED_LIB_PREFIX', 'SHARED_LIB_SUFFIX',
|
28
|
+
'CONFIGURATION_NAME']:
|
29
|
+
generator_default_variables[unused] = ''
|
30
|
+
|
31
|
+
|
32
|
+
def CalculateVariables(default_variables, params):
|
33
|
+
generator_flags = params.get('generator_flags', {})
|
34
|
+
for key, val in generator_flags.items():
|
35
|
+
default_variables.setdefault(key, val)
|
36
|
+
default_variables.setdefault('OS', gyp.common.GetFlavor(params))
|
37
|
+
|
38
|
+
flavor = gyp.common.GetFlavor(params)
|
39
|
+
if flavor =='win':
|
40
|
+
# Copy additional generator configuration data from VS, which is shared
|
41
|
+
# by the Windows Ninja generator.
|
42
|
+
import gyp.generator.msvs as msvs_generator
|
43
|
+
generator_additional_non_configuration_keys = getattr(msvs_generator,
|
44
|
+
'generator_additional_non_configuration_keys', [])
|
45
|
+
generator_additional_path_sections = getattr(msvs_generator,
|
46
|
+
'generator_additional_path_sections', [])
|
47
|
+
|
48
|
+
gyp.msvs_emulation.CalculateCommonVariables(default_variables, params)
|
49
|
+
|
50
|
+
|
51
|
+
def CalculateGeneratorInputInfo(params):
|
52
|
+
"""Calculate the generator specific info that gets fed to input (called by
|
53
|
+
gyp)."""
|
54
|
+
generator_flags = params.get('generator_flags', {})
|
55
|
+
if generator_flags.get('adjust_static_libraries', False):
|
56
|
+
global generator_wants_static_library_dependencies_adjusted
|
57
|
+
generator_wants_static_library_dependencies_adjusted = True
|
58
|
+
|
59
|
+
|
60
|
+
def GenerateOutput(target_list, target_dicts, data, params):
|
61
|
+
# Map of target -> list of targets it depends on.
|
62
|
+
edges = {}
|
63
|
+
|
64
|
+
# Queue of targets to visit.
|
65
|
+
targets_to_visit = target_list[:]
|
66
|
+
|
67
|
+
while len(targets_to_visit) > 0:
|
68
|
+
target = targets_to_visit.pop()
|
69
|
+
if target in edges:
|
70
|
+
continue
|
71
|
+
edges[target] = []
|
72
|
+
|
73
|
+
for dep in target_dicts[target].get('dependencies', []):
|
74
|
+
edges[target].append(dep)
|
75
|
+
targets_to_visit.append(dep)
|
76
|
+
|
77
|
+
filename = 'dump.json'
|
78
|
+
f = open(filename, 'w')
|
79
|
+
json.dump(edges, f)
|
80
|
+
f.close()
|
81
|
+
print 'Wrote json to %s.' % filename
|
@@ -0,0 +1,335 @@
|
|
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
|
+
"""GYP backend that generates Eclipse CDT settings files.
|
6
|
+
|
7
|
+
This backend DOES NOT generate Eclipse CDT projects. Instead, it generates XML
|
8
|
+
files that can be imported into an Eclipse CDT project. The XML file contains a
|
9
|
+
list of include paths and symbols (i.e. defines).
|
10
|
+
|
11
|
+
Because a full .cproject definition is not created by this generator, it's not
|
12
|
+
possible to properly define the include dirs and symbols for each file
|
13
|
+
individually. Instead, one set of includes/symbols is generated for the entire
|
14
|
+
project. This works fairly well (and is a vast improvement in general), but may
|
15
|
+
still result in a few indexer issues here and there.
|
16
|
+
|
17
|
+
This generator has no automated tests, so expect it to be broken.
|
18
|
+
"""
|
19
|
+
|
20
|
+
from xml.sax.saxutils import escape
|
21
|
+
import os.path
|
22
|
+
import subprocess
|
23
|
+
import gyp
|
24
|
+
import gyp.common
|
25
|
+
import gyp.msvs_emulation
|
26
|
+
import shlex
|
27
|
+
|
28
|
+
generator_wants_static_library_dependencies_adjusted = False
|
29
|
+
|
30
|
+
generator_default_variables = {
|
31
|
+
}
|
32
|
+
|
33
|
+
for dirname in ['INTERMEDIATE_DIR', 'PRODUCT_DIR', 'LIB_DIR', 'SHARED_LIB_DIR']:
|
34
|
+
# Some gyp steps fail if these are empty(!).
|
35
|
+
generator_default_variables[dirname] = 'dir'
|
36
|
+
|
37
|
+
for unused in ['RULE_INPUT_PATH', 'RULE_INPUT_ROOT', 'RULE_INPUT_NAME',
|
38
|
+
'RULE_INPUT_DIRNAME', 'RULE_INPUT_EXT',
|
39
|
+
'EXECUTABLE_PREFIX', 'EXECUTABLE_SUFFIX',
|
40
|
+
'STATIC_LIB_PREFIX', 'STATIC_LIB_SUFFIX',
|
41
|
+
'SHARED_LIB_PREFIX', 'SHARED_LIB_SUFFIX',
|
42
|
+
'CONFIGURATION_NAME']:
|
43
|
+
generator_default_variables[unused] = ''
|
44
|
+
|
45
|
+
# Include dirs will occasionally use the SHARED_INTERMEDIATE_DIR variable as
|
46
|
+
# part of the path when dealing with generated headers. This value will be
|
47
|
+
# replaced dynamically for each configuration.
|
48
|
+
generator_default_variables['SHARED_INTERMEDIATE_DIR'] = \
|
49
|
+
'$SHARED_INTERMEDIATE_DIR'
|
50
|
+
|
51
|
+
|
52
|
+
def CalculateVariables(default_variables, params):
|
53
|
+
generator_flags = params.get('generator_flags', {})
|
54
|
+
for key, val in generator_flags.items():
|
55
|
+
default_variables.setdefault(key, val)
|
56
|
+
flavor = gyp.common.GetFlavor(params)
|
57
|
+
default_variables.setdefault('OS', flavor)
|
58
|
+
if flavor == 'win':
|
59
|
+
# Copy additional generator configuration data from VS, which is shared
|
60
|
+
# by the Eclipse generator.
|
61
|
+
import gyp.generator.msvs as msvs_generator
|
62
|
+
generator_additional_non_configuration_keys = getattr(msvs_generator,
|
63
|
+
'generator_additional_non_configuration_keys', [])
|
64
|
+
generator_additional_path_sections = getattr(msvs_generator,
|
65
|
+
'generator_additional_path_sections', [])
|
66
|
+
|
67
|
+
gyp.msvs_emulation.CalculateCommonVariables(default_variables, params)
|
68
|
+
|
69
|
+
|
70
|
+
def CalculateGeneratorInputInfo(params):
|
71
|
+
"""Calculate the generator specific info that gets fed to input (called by
|
72
|
+
gyp)."""
|
73
|
+
generator_flags = params.get('generator_flags', {})
|
74
|
+
if generator_flags.get('adjust_static_libraries', False):
|
75
|
+
global generator_wants_static_library_dependencies_adjusted
|
76
|
+
generator_wants_static_library_dependencies_adjusted = True
|
77
|
+
|
78
|
+
|
79
|
+
def GetAllIncludeDirectories(target_list, target_dicts,
|
80
|
+
shared_intermediate_dirs, config_name, params,
|
81
|
+
compiler_path):
|
82
|
+
"""Calculate the set of include directories to be used.
|
83
|
+
|
84
|
+
Returns:
|
85
|
+
A list including all the include_dir's specified for every target followed
|
86
|
+
by any include directories that were added as cflag compiler options.
|
87
|
+
"""
|
88
|
+
|
89
|
+
gyp_includes_set = set()
|
90
|
+
compiler_includes_list = []
|
91
|
+
|
92
|
+
# Find compiler's default include dirs.
|
93
|
+
if compiler_path:
|
94
|
+
command = shlex.split(compiler_path)
|
95
|
+
command.extend(['-E', '-xc++', '-v', '-'])
|
96
|
+
proc = subprocess.Popen(args=command, stdin=subprocess.PIPE,
|
97
|
+
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
98
|
+
output = proc.communicate()[1]
|
99
|
+
# Extract the list of include dirs from the output, which has this format:
|
100
|
+
# ...
|
101
|
+
# #include "..." search starts here:
|
102
|
+
# #include <...> search starts here:
|
103
|
+
# /usr/include/c++/4.6
|
104
|
+
# /usr/local/include
|
105
|
+
# End of search list.
|
106
|
+
# ...
|
107
|
+
in_include_list = False
|
108
|
+
for line in output.splitlines():
|
109
|
+
if line.startswith('#include'):
|
110
|
+
in_include_list = True
|
111
|
+
continue
|
112
|
+
if line.startswith('End of search list.'):
|
113
|
+
break
|
114
|
+
if in_include_list:
|
115
|
+
include_dir = line.strip()
|
116
|
+
if include_dir not in compiler_includes_list:
|
117
|
+
compiler_includes_list.append(include_dir)
|
118
|
+
|
119
|
+
flavor = gyp.common.GetFlavor(params)
|
120
|
+
if flavor == 'win':
|
121
|
+
generator_flags = params.get('generator_flags', {})
|
122
|
+
for target_name in target_list:
|
123
|
+
target = target_dicts[target_name]
|
124
|
+
if config_name in target['configurations']:
|
125
|
+
config = target['configurations'][config_name]
|
126
|
+
|
127
|
+
# Look for any include dirs that were explicitly added via cflags. This
|
128
|
+
# may be done in gyp files to force certain includes to come at the end.
|
129
|
+
# TODO(jgreenwald): Change the gyp files to not abuse cflags for this, and
|
130
|
+
# remove this.
|
131
|
+
if flavor == 'win':
|
132
|
+
msvs_settings = gyp.msvs_emulation.MsvsSettings(target, generator_flags)
|
133
|
+
cflags = msvs_settings.GetCflags(config_name)
|
134
|
+
else:
|
135
|
+
cflags = config['cflags']
|
136
|
+
for cflag in cflags:
|
137
|
+
if cflag.startswith('-I'):
|
138
|
+
include_dir = cflag[2:]
|
139
|
+
if include_dir not in compiler_includes_list:
|
140
|
+
compiler_includes_list.append(include_dir)
|
141
|
+
|
142
|
+
# Find standard gyp include dirs.
|
143
|
+
if config.has_key('include_dirs'):
|
144
|
+
include_dirs = config['include_dirs']
|
145
|
+
for shared_intermediate_dir in shared_intermediate_dirs:
|
146
|
+
for include_dir in include_dirs:
|
147
|
+
include_dir = include_dir.replace('$SHARED_INTERMEDIATE_DIR',
|
148
|
+
shared_intermediate_dir)
|
149
|
+
if not os.path.isabs(include_dir):
|
150
|
+
base_dir = os.path.dirname(target_name)
|
151
|
+
|
152
|
+
include_dir = base_dir + '/' + include_dir
|
153
|
+
include_dir = os.path.abspath(include_dir)
|
154
|
+
|
155
|
+
gyp_includes_set.add(include_dir)
|
156
|
+
|
157
|
+
# Generate a list that has all the include dirs.
|
158
|
+
all_includes_list = list(gyp_includes_set)
|
159
|
+
all_includes_list.sort()
|
160
|
+
for compiler_include in compiler_includes_list:
|
161
|
+
if not compiler_include in gyp_includes_set:
|
162
|
+
all_includes_list.append(compiler_include)
|
163
|
+
|
164
|
+
# All done.
|
165
|
+
return all_includes_list
|
166
|
+
|
167
|
+
|
168
|
+
def GetCompilerPath(target_list, data):
|
169
|
+
"""Determine a command that can be used to invoke the compiler.
|
170
|
+
|
171
|
+
Returns:
|
172
|
+
If this is a gyp project that has explicit make settings, try to determine
|
173
|
+
the compiler from that. Otherwise, see if a compiler was specified via the
|
174
|
+
CC_target environment variable.
|
175
|
+
"""
|
176
|
+
|
177
|
+
# First, see if the compiler is configured in make's settings.
|
178
|
+
build_file, _, _ = gyp.common.ParseQualifiedTarget(target_list[0])
|
179
|
+
make_global_settings_dict = data[build_file].get('make_global_settings', {})
|
180
|
+
for key, value in make_global_settings_dict:
|
181
|
+
if key in ['CC', 'CXX']:
|
182
|
+
return value
|
183
|
+
|
184
|
+
# Check to see if the compiler was specified as an environment variable.
|
185
|
+
for key in ['CC_target', 'CC', 'CXX']:
|
186
|
+
compiler = os.environ.get(key)
|
187
|
+
if compiler:
|
188
|
+
return compiler
|
189
|
+
|
190
|
+
return 'gcc'
|
191
|
+
|
192
|
+
|
193
|
+
def GetAllDefines(target_list, target_dicts, data, config_name, params,
|
194
|
+
compiler_path):
|
195
|
+
"""Calculate the defines for a project.
|
196
|
+
|
197
|
+
Returns:
|
198
|
+
A dict that includes explict defines declared in gyp files along with all of
|
199
|
+
the default defines that the compiler uses.
|
200
|
+
"""
|
201
|
+
|
202
|
+
# Get defines declared in the gyp files.
|
203
|
+
all_defines = {}
|
204
|
+
flavor = gyp.common.GetFlavor(params)
|
205
|
+
if flavor == 'win':
|
206
|
+
generator_flags = params.get('generator_flags', {})
|
207
|
+
for target_name in target_list:
|
208
|
+
target = target_dicts[target_name]
|
209
|
+
|
210
|
+
if flavor == 'win':
|
211
|
+
msvs_settings = gyp.msvs_emulation.MsvsSettings(target, generator_flags)
|
212
|
+
extra_defines = msvs_settings.GetComputedDefines(config_name)
|
213
|
+
else:
|
214
|
+
extra_defines = []
|
215
|
+
if config_name in target['configurations']:
|
216
|
+
config = target['configurations'][config_name]
|
217
|
+
target_defines = config['defines']
|
218
|
+
else:
|
219
|
+
target_defines = []
|
220
|
+
for define in target_defines + extra_defines:
|
221
|
+
split_define = define.split('=', 1)
|
222
|
+
if len(split_define) == 1:
|
223
|
+
split_define.append('1')
|
224
|
+
if split_define[0].strip() in all_defines:
|
225
|
+
# Already defined
|
226
|
+
continue
|
227
|
+
all_defines[split_define[0].strip()] = split_define[1].strip()
|
228
|
+
# Get default compiler defines (if possible).
|
229
|
+
if flavor == 'win':
|
230
|
+
return all_defines # Default defines already processed in the loop above.
|
231
|
+
if compiler_path:
|
232
|
+
command = shlex.split(compiler_path)
|
233
|
+
command.extend(['-E', '-dM', '-'])
|
234
|
+
cpp_proc = subprocess.Popen(args=command, cwd='.',
|
235
|
+
stdin=subprocess.PIPE, stdout=subprocess.PIPE)
|
236
|
+
cpp_output = cpp_proc.communicate()[0]
|
237
|
+
cpp_lines = cpp_output.split('\n')
|
238
|
+
for cpp_line in cpp_lines:
|
239
|
+
if not cpp_line.strip():
|
240
|
+
continue
|
241
|
+
cpp_line_parts = cpp_line.split(' ', 2)
|
242
|
+
key = cpp_line_parts[1]
|
243
|
+
if len(cpp_line_parts) >= 3:
|
244
|
+
val = cpp_line_parts[2]
|
245
|
+
else:
|
246
|
+
val = '1'
|
247
|
+
all_defines[key] = val
|
248
|
+
|
249
|
+
return all_defines
|
250
|
+
|
251
|
+
|
252
|
+
def WriteIncludePaths(out, eclipse_langs, include_dirs):
|
253
|
+
"""Write the includes section of a CDT settings export file."""
|
254
|
+
|
255
|
+
out.write(' <section name="org.eclipse.cdt.internal.ui.wizards.' \
|
256
|
+
'settingswizards.IncludePaths">\n')
|
257
|
+
out.write(' <language name="holder for library settings"></language>\n')
|
258
|
+
for lang in eclipse_langs:
|
259
|
+
out.write(' <language name="%s">\n' % lang)
|
260
|
+
for include_dir in include_dirs:
|
261
|
+
out.write(' <includepath workspace_path="false">%s</includepath>\n' %
|
262
|
+
include_dir)
|
263
|
+
out.write(' </language>\n')
|
264
|
+
out.write(' </section>\n')
|
265
|
+
|
266
|
+
|
267
|
+
def WriteMacros(out, eclipse_langs, defines):
|
268
|
+
"""Write the macros section of a CDT settings export file."""
|
269
|
+
|
270
|
+
out.write(' <section name="org.eclipse.cdt.internal.ui.wizards.' \
|
271
|
+
'settingswizards.Macros">\n')
|
272
|
+
out.write(' <language name="holder for library settings"></language>\n')
|
273
|
+
for lang in eclipse_langs:
|
274
|
+
out.write(' <language name="%s">\n' % lang)
|
275
|
+
for key in sorted(defines.iterkeys()):
|
276
|
+
out.write(' <macro><name>%s</name><value>%s</value></macro>\n' %
|
277
|
+
(escape(key), escape(defines[key])))
|
278
|
+
out.write(' </language>\n')
|
279
|
+
out.write(' </section>\n')
|
280
|
+
|
281
|
+
|
282
|
+
def GenerateOutputForConfig(target_list, target_dicts, data, params,
|
283
|
+
config_name):
|
284
|
+
options = params['options']
|
285
|
+
generator_flags = params.get('generator_flags', {})
|
286
|
+
|
287
|
+
# build_dir: relative path from source root to our output files.
|
288
|
+
# e.g. "out/Debug"
|
289
|
+
build_dir = os.path.join(generator_flags.get('output_dir', 'out'),
|
290
|
+
config_name)
|
291
|
+
|
292
|
+
toplevel_build = os.path.join(options.toplevel_dir, build_dir)
|
293
|
+
# Ninja uses out/Debug/gen while make uses out/Debug/obj/gen as the
|
294
|
+
# SHARED_INTERMEDIATE_DIR. Include both possible locations.
|
295
|
+
shared_intermediate_dirs = [os.path.join(toplevel_build, 'obj', 'gen'),
|
296
|
+
os.path.join(toplevel_build, 'gen')]
|
297
|
+
|
298
|
+
out_name = os.path.join(toplevel_build, 'eclipse-cdt-settings.xml')
|
299
|
+
gyp.common.EnsureDirExists(out_name)
|
300
|
+
out = open(out_name, 'w')
|
301
|
+
|
302
|
+
out.write('<?xml version="1.0" encoding="UTF-8"?>\n')
|
303
|
+
out.write('<cdtprojectproperties>\n')
|
304
|
+
|
305
|
+
eclipse_langs = ['C++ Source File', 'C Source File', 'Assembly Source File',
|
306
|
+
'GNU C++', 'GNU C', 'Assembly']
|
307
|
+
compiler_path = GetCompilerPath(target_list, data)
|
308
|
+
include_dirs = GetAllIncludeDirectories(target_list, target_dicts,
|
309
|
+
shared_intermediate_dirs, config_name,
|
310
|
+
params, compiler_path)
|
311
|
+
WriteIncludePaths(out, eclipse_langs, include_dirs)
|
312
|
+
defines = GetAllDefines(target_list, target_dicts, data, config_name, params,
|
313
|
+
compiler_path)
|
314
|
+
WriteMacros(out, eclipse_langs, defines)
|
315
|
+
|
316
|
+
out.write('</cdtprojectproperties>\n')
|
317
|
+
out.close()
|
318
|
+
|
319
|
+
|
320
|
+
def GenerateOutput(target_list, target_dicts, data, params):
|
321
|
+
"""Generate an XML settings file that can be imported into a CDT project."""
|
322
|
+
|
323
|
+
if params['options'].generator_output:
|
324
|
+
raise NotImplementedError, "--generator_output not implemented for eclipse"
|
325
|
+
|
326
|
+
user_config = params.get('generator_flags', {}).get('config', None)
|
327
|
+
if user_config:
|
328
|
+
GenerateOutputForConfig(target_list, target_dicts, data, params,
|
329
|
+
user_config)
|
330
|
+
else:
|
331
|
+
config_names = target_dicts[target_list[0]]['configurations'].keys()
|
332
|
+
for config_name in config_names:
|
333
|
+
GenerateOutputForConfig(target_list, target_dicts, data, params,
|
334
|
+
config_name)
|
335
|
+
|
@@ -0,0 +1,87 @@
|
|
1
|
+
# Copyright (c) 2011 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
|
+
"""gypd output module
|
6
|
+
|
7
|
+
This module produces gyp input as its output. Output files are given the
|
8
|
+
.gypd extension to avoid overwriting the .gyp files that they are generated
|
9
|
+
from. Internal references to .gyp files (such as those found in
|
10
|
+
"dependencies" sections) are not adjusted to point to .gypd files instead;
|
11
|
+
unlike other paths, which are relative to the .gyp or .gypd file, such paths
|
12
|
+
are relative to the directory from which gyp was run to create the .gypd file.
|
13
|
+
|
14
|
+
This generator module is intended to be a sample and a debugging aid, hence
|
15
|
+
the "d" for "debug" in .gypd. It is useful to inspect the results of the
|
16
|
+
various merges, expansions, and conditional evaluations performed by gyp
|
17
|
+
and to see a representation of what would be fed to a generator module.
|
18
|
+
|
19
|
+
It's not advisable to rename .gypd files produced by this module to .gyp,
|
20
|
+
because they will have all merges, expansions, and evaluations already
|
21
|
+
performed and the relevant constructs not present in the output; paths to
|
22
|
+
dependencies may be wrong; and various sections that do not belong in .gyp
|
23
|
+
files such as such as "included_files" and "*_excluded" will be present.
|
24
|
+
Output will also be stripped of comments. This is not intended to be a
|
25
|
+
general-purpose gyp pretty-printer; for that, you probably just want to
|
26
|
+
run "pprint.pprint(eval(open('source.gyp').read()))", which will still strip
|
27
|
+
comments but won't do all of the other things done to this module's output.
|
28
|
+
|
29
|
+
The specific formatting of the output generated by this module is subject
|
30
|
+
to change.
|
31
|
+
"""
|
32
|
+
|
33
|
+
|
34
|
+
import gyp.common
|
35
|
+
import errno
|
36
|
+
import os
|
37
|
+
import pprint
|
38
|
+
|
39
|
+
|
40
|
+
# These variables should just be spit back out as variable references.
|
41
|
+
_generator_identity_variables = [
|
42
|
+
'EXECUTABLE_PREFIX',
|
43
|
+
'EXECUTABLE_SUFFIX',
|
44
|
+
'INTERMEDIATE_DIR',
|
45
|
+
'PRODUCT_DIR',
|
46
|
+
'RULE_INPUT_ROOT',
|
47
|
+
'RULE_INPUT_DIRNAME',
|
48
|
+
'RULE_INPUT_EXT',
|
49
|
+
'RULE_INPUT_NAME',
|
50
|
+
'RULE_INPUT_PATH',
|
51
|
+
'SHARED_INTERMEDIATE_DIR',
|
52
|
+
]
|
53
|
+
|
54
|
+
# gypd doesn't define a default value for OS like many other generator
|
55
|
+
# modules. Specify "-D OS=whatever" on the command line to provide a value.
|
56
|
+
generator_default_variables = {
|
57
|
+
}
|
58
|
+
|
59
|
+
# gypd supports multiple toolsets
|
60
|
+
generator_supports_multiple_toolsets = True
|
61
|
+
|
62
|
+
# TODO(mark): This always uses <, which isn't right. The input module should
|
63
|
+
# notify the generator to tell it which phase it is operating in, and this
|
64
|
+
# module should use < for the early phase and then switch to > for the late
|
65
|
+
# phase. Bonus points for carrying @ back into the output too.
|
66
|
+
for v in _generator_identity_variables:
|
67
|
+
generator_default_variables[v] = '<(%s)' % v
|
68
|
+
|
69
|
+
|
70
|
+
def GenerateOutput(target_list, target_dicts, data, params):
|
71
|
+
output_files = {}
|
72
|
+
for qualified_target in target_list:
|
73
|
+
[input_file, target] = \
|
74
|
+
gyp.common.ParseQualifiedTarget(qualified_target)[0:2]
|
75
|
+
|
76
|
+
if input_file[-4:] != '.gyp':
|
77
|
+
continue
|
78
|
+
input_file_stem = input_file[:-4]
|
79
|
+
output_file = input_file_stem + params['options'].suffix + '.gypd'
|
80
|
+
|
81
|
+
if not output_file in output_files:
|
82
|
+
output_files[output_file] = input_file
|
83
|
+
|
84
|
+
for output_file, input_file in output_files.iteritems():
|
85
|
+
output = open(output_file, 'w')
|
86
|
+
pprint.pprint(data[input_file], output)
|
87
|
+
output.close()
|