Package list mozc / d46f3fa
Imported Upstream version 1.3.911.102 Nobuhiro Iwamatsu 9 years ago
56 changed file(s) with 1622 addition(s) and 21782 deletion(s). Raw diff Collapse all Expand all
6262 {
6363 # Protobuf compiler / generator for the mozc inputmethod commands
6464 # protocol buffer.
65 'target_name': 'mozc_commands_proto',
66 'type': 'static_library',
65 'target_name': 'gen_candidates_proto',
66 'type': 'none',
6767 'sources': [
6868 '<(third_party_dir)/mozc/session/candidates_lite.proto',
6969 ],
105105 '<(third_party_dir)/protobuf/protobuf.gyp:protobuf_lite',
106106 ],
107107 },
108 {
109 'target_name': 'mozc_candidates_proto',
110 'type': 'static_library',
111 'sources': [
112 '<(protoc_out_dir)/third_party/mozc/session/candidates_lite.pb.cc',
113 ],
114 'dependencies': [
115 'gen_candidates_proto',
116 ],
117 },
108118 ]
109119 }
+0
-6
third_party/gyp/AUTHORS less more
0 # Names should be added to this file like so:
1 # Name or Organization <email address>
2
3 Google Inc.
4 Steven Knight <knight@baldmt.com>
5 Ryan Norton <rnorton10@gmail.com>
+0
-8
third_party/gyp/DEPS less more
0 # DEPS file for gclient use in buildbot execution of gyp tests.
1 #
2 # (You don't need to use gclient for normal GYP development work.)
3
4 deps = {
5 "scons":
6 "http://src.chromium.org/svn/trunk/src/third_party/scons@44099",
7 }
+0
-27
third_party/gyp/LICENSE less more
0 Copyright (c) 2009 Google Inc. All rights reserved.
1
2 Redistribution and use in source and binary forms, with or without
3 modification, are permitted provided that the following conditions are
4 met:
5
6 * Redistributions of source code must retain the above copyright
7 notice, this list of conditions and the following disclaimer.
8 * Redistributions in binary form must reproduce the above
9 copyright notice, this list of conditions and the following disclaimer
10 in the documentation and/or other materials provided with the
11 distribution.
12 * Neither the name of Google Inc. nor the names of its
13 contributors may be used to endorse or promote products derived from
14 this software without specific prior written permission.
15
16 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+0
-21
third_party/gyp/MANIFEST less more
0 setup.py
1 gyp
2 LICENSE
3 AUTHORS
4 pylib/gyp/MSVSNew.py
5 pylib/gyp/MSVSProject.py
6 pylib/gyp/MSVSToolFile.py
7 pylib/gyp/MSVSUserFile.py
8 pylib/gyp/MSVSVersion.py
9 pylib/gyp/SCons.py
10 pylib/gyp/__init__.py
11 pylib/gyp/common.py
12 pylib/gyp/input.py
13 pylib/gyp/xcodeproj_file.py
14 pylib/gyp/generator/__init__.py
15 pylib/gyp/generator/gypd.py
16 pylib/gyp/generator/gypsh.py
17 pylib/gyp/generator/make.py
18 pylib/gyp/generator/msvs.py
19 pylib/gyp/generator/scons.py
20 pylib/gyp/generator/xcode.py
+0
-1
third_party/gyp/OWNERS less more
0 *
+0
-41
third_party/gyp/PRESUBMIT.py less more
0 # Copyright (c) 2011 Google Inc. All rights reserved.
1 # Use of this source code is governed by a BSD-style license that can be
2 # found in the LICENSE file.
3
4
5 """Top-level presubmit script for GYP.
6
7 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts
8 for more details about the presubmit API built into gcl.
9 """
10
11
12 def CheckChangeOnUpload(input_api, output_api):
13 report = []
14 report.extend(input_api.canned_checks.PanProjectChecks(
15 input_api, output_api))
16 return report
17
18
19 def CheckChangeOnCommit(input_api, output_api):
20 report = []
21 license = (
22 r'.*? Copyright \(c\) %(year)s Google Inc\. All rights reserved\.\n'
23 r'.*? Use of this source code is governed by a BSD-style license that '
24 r'can be\n'
25 r'.*? found in the LICENSE file\.\n'
26 ) % {
27 'year': input_api.time.strftime('%Y'),
28 }
29
30 report.extend(input_api.canned_checks.PanProjectChecks(
31 input_api, output_api, license_header=license))
32 report.extend(input_api.canned_checks.CheckTreeIsOpen(
33 input_api, output_api,
34 'http://gyp-status.appspot.com/status',
35 'http://gyp-status.appspot.com/current'))
36 return report
37
38
39 def GetPreferredTrySlaves():
40 return ['gyp-win32', 'gyp-win64', 'gyp-linux', 'gyp-mac']
+0
-12
third_party/gyp/README.mozc less more
0 URL: http://code.google.com/p/gyp/
1 Version: r1034
2 License: New BSD License
3 License File: LICENSE
4
5 Description:
6 This is Mozc's local copy of gyp, a tool that generates native Visual Studio,
7 Xcode and SCons and/or make build files from a platform-independent input
8 format.
9
10 Local Modifications:
11 test directory is removed.
+0
-79
third_party/gyp/buildbot/buildbot_run.py less more
0 #!/usr/bin/python
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
6 """Argument-less script to select what to run on the buildbots."""
7
8
9 import os
10 import shutil
11 import subprocess
12 import sys
13
14
15 def GypTestFormat(title, format, msvs_version=None):
16 """Run the gyp tests for a given format, emitting annotator tags.
17
18 See annotator docs at:
19 https://sites.google.com/a/chromium.org/dev/developers/testing/chromium-build-infrastructure/buildbot-annotations
20 Args:
21 format: gyp format to test.
22 Returns:
23 0 for sucesss, 1 for failure.
24 """
25 print '@@@BUILD_STEP ' + title + '@@@'
26 sys.stdout.flush()
27 buildbot_dir = os.path.dirname(os.path.abspath(__file__))
28 trunk_dir = os.path.dirname(buildbot_dir)
29 root_dir = os.path.dirname(trunk_dir)
30 env = os.environ.copy()
31 if msvs_version:
32 env['GYP_MSVS_VERSION'] = msvs_version
33 retcode = subprocess.call(' '.join(
34 [sys.executable, 'trunk/gyptest.py',
35 '--all',
36 '--passed',
37 '--format', format,
38 '--chdir', 'trunk',
39 '--path', '../scons']),
40 cwd=root_dir, env=env, shell=True)
41 if retcode:
42 # Emit failure tag, and keep going.
43 print '@@@STEP_FAILURE@@@'
44 return 1
45 return 0
46
47
48 def GypBuild():
49 # Dump out/ directory.
50 print '@@@BUILD_STEP cleanup@@@'
51 print 'Removing out/ ...'
52 shutil.rmtree('out', ignore_errors=True)
53 print 'Done.'
54
55 retcode = 0
56 if sys.platform.startswith('linux'):
57 retcode += GypTestFormat('scons', format='scons')
58 retcode += GypTestFormat('make', format='make')
59 elif sys.platform == 'darwin':
60 retcode += GypTestFormat('xcode', format='xcode')
61 retcode += GypTestFormat('make', format='make')
62 elif sys.platform == 'win32':
63 retcode += GypTestFormat('msvs-2008', format='msvs', msvs_version='2008')
64 if os.environ['BUILDBOT_BUILDERNAME'] == 'gyp-win64':
65 retcode += GypTestFormat('msvs-2010', format='msvs', msvs_version='2010')
66 else:
67 raise Exception('Unknown platform')
68 if retcode:
69 # TODO(bradnelson): once the annotator supports a postscript (section for
70 # after the build proper that could be used for cumulative failures),
71 # use that instead of this. This isolates the final return value so
72 # that it isn't misattributed to the last stage.
73 print '@@@BUILD_STEP failures@@@'
74 sys.exit(retcode)
75
76
77 if __name__ == '__main__':
78 GypBuild()
+0
-10
third_party/gyp/codereview.settings less more
0 # This file is used by gcl to get repository specific information.
1 CODE_REVIEW_SERVER: codereview.chromium.org
2 CC_LIST: gyp-developer@googlegroups.com
3 VIEW_VC: http://code.google.com/p/gyp/source/detail?r=
4 TRY_ON_UPLOAD: True
5 TRYSERVER_PROJECT: gyp
6 TRYSERVER_PATCHLEVEL: 0
7 TRYSERVER_ROOT: trunk
8 TRYSERVER_SVN_URL: svn://svn.chromium.org/chrome-try/try-nacl
9
+0
-18
third_party/gyp/gyp less more
0 #!/usr/bin/env python
1
2 # Copyright (c) 2009 Google Inc. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
5
6 import sys
7
8 # TODO(mark): sys.path manipulation is some temporary testing stuff.
9 try:
10 import gyp
11 except ImportError, e:
12 import os.path
13 sys.path.append(os.path.join(os.path.dirname(sys.argv[0]), 'pylib'))
14 import gyp
15
16 if __name__ == '__main__':
17 sys.exit(gyp.main(sys.argv[1:]))
+0
-5
third_party/gyp/gyp.bat less more
0 @rem Copyright (c) 2009 Google Inc. All rights reserved.
1 @rem Use of this source code is governed by a BSD-style license that can be
2 @rem found in the LICENSE file.
3
4 @python "%~dp0/gyp" %*
+0
-7
third_party/gyp/gyp_dummy.c less more
0 /* Copyright (c) 2009 Google Inc. All rights reserved.
1 * Use of this source code is governed by a BSD-style license that can be
2 * found in the LICENSE file. */
3
4 int main() {
5 return 0;
6 }
+0
-256
third_party/gyp/gyptest.py less more
0 #!/usr/bin/env python
1
2 # Copyright (c) 2011 Google Inc. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
5
6 __doc__ = """
7 gyptest.py -- test runner for GYP tests.
8 """
9
10 import os
11 import optparse
12 import subprocess
13 import sys
14
15 class CommandRunner:
16 """
17 Executor class for commands, including "commands" implemented by
18 Python functions.
19 """
20 verbose = True
21 active = True
22
23 def __init__(self, dictionary={}):
24 self.subst_dictionary(dictionary)
25
26 def subst_dictionary(self, dictionary):
27 self._subst_dictionary = dictionary
28
29 def subst(self, string, dictionary=None):
30 """
31 Substitutes (via the format operator) the values in the specified
32 dictionary into the specified command.
33
34 The command can be an (action, string) tuple. In all cases, we
35 perform substitution on strings and don't worry if something isn't
36 a string. (It's probably a Python function to be executed.)
37 """
38 if dictionary is None:
39 dictionary = self._subst_dictionary
40 if dictionary:
41 try:
42 string = string % dictionary
43 except TypeError:
44 pass
45 return string
46
47 def display(self, command, stdout=None, stderr=None):
48 if not self.verbose:
49 return
50 if type(command) == type(()):
51 func = command[0]
52 args = command[1:]
53 s = '%s(%s)' % (func.__name__, ', '.join(map(repr, args)))
54 if type(command) == type([]):
55 # TODO: quote arguments containing spaces
56 # TODO: handle meta characters?
57 s = ' '.join(command)
58 else:
59 s = self.subst(command)
60 if not s.endswith('\n'):
61 s += '\n'
62 sys.stdout.write(s)
63 sys.stdout.flush()
64
65 def execute(self, command, stdout=None, stderr=None):
66 """
67 Executes a single command.
68 """
69 if not self.active:
70 return 0
71 if type(command) == type(''):
72 command = self.subst(command)
73 cmdargs = shlex.split(command)
74 if cmdargs[0] == 'cd':
75 command = (os.chdir,) + tuple(cmdargs[1:])
76 if type(command) == type(()):
77 func = command[0]
78 args = command[1:]
79 return func(*args)
80 else:
81 if stdout is sys.stdout:
82 # Same as passing sys.stdout, except python2.4 doesn't fail on it.
83 subout = None
84 else:
85 # Open pipe for anything else so Popen works on python2.4.
86 subout = subprocess.PIPE
87 if stderr is sys.stderr:
88 # Same as passing sys.stderr, except python2.4 doesn't fail on it.
89 suberr = None
90 elif stderr is None:
91 # Merge with stdout if stderr isn't specified.
92 suberr = subprocess.STDOUT
93 else:
94 # Open pipe for anything else so Popen works on python2.4.
95 suberr = subprocess.PIPE
96 p = subprocess.Popen(command,
97 shell=(sys.platform == 'win32'),
98 stdout=subout,
99 stderr=suberr)
100 p.wait()
101 if stdout is None:
102 self.stdout = p.stdout.read()
103 elif stdout is not sys.stdout:
104 stdout.write(p.stdout.read())
105 if stderr not in (None, sys.stderr):
106 stderr.write(p.stderr.read())
107 return p.returncode
108
109 def run(self, command, display=None, stdout=None, stderr=None):
110 """
111 Runs a single command, displaying it first.
112 """
113 if display is None:
114 display = command
115 self.display(display)
116 return self.execute(command, stdout, stderr)
117
118
119 class Unbuffered:
120 def __init__(self, fp):
121 self.fp = fp
122 def write(self, arg):
123 self.fp.write(arg)
124 self.fp.flush()
125 def __getattr__(self, attr):
126 return getattr(self.fp, attr)
127
128 sys.stdout = Unbuffered(sys.stdout)
129 sys.stderr = Unbuffered(sys.stderr)
130
131
132 def find_all_gyptest_files(directory):
133 result = []
134 for root, dirs, files in os.walk(directory):
135 if '.svn' in dirs:
136 dirs.remove('.svn')
137 result.extend([ os.path.join(root, f) for f in files
138 if f.startswith('gyptest') and f.endswith('.py') ])
139 result.sort()
140 return result
141
142
143 def main(argv=None):
144 if argv is None:
145 argv = sys.argv
146
147 usage = "gyptest.py [-ahlnq] [-f formats] [test ...]"
148 parser = optparse.OptionParser(usage=usage)
149 parser.add_option("-a", "--all", action="store_true",
150 help="run all tests")
151 parser.add_option("-C", "--chdir", action="store", default=None,
152 help="chdir to the specified directory")
153 parser.add_option("-f", "--format", action="store", default='',
154 help="run tests with the specified formats")
155 parser.add_option("-l", "--list", action="store_true",
156 help="list available tests and exit")
157 parser.add_option("-n", "--no-exec", action="store_true",
158 help="no execute, just print the command line")
159 parser.add_option("--passed", action="store_true",
160 help="report passed tests")
161 parser.add_option("--path", action="append", default=[],
162 help="additional $PATH directory")
163 parser.add_option("-q", "--quiet", action="store_true",
164 help="quiet, don't print test command lines")
165 opts, args = parser.parse_args(argv[1:])
166
167 if opts.chdir:
168 os.chdir(opts.chdir)
169
170 if opts.path:
171 os.environ['PATH'] += ':' + ':'.join(opts.path)
172
173 if not args:
174 if not opts.all:
175 sys.stderr.write('Specify -a to get all tests.\n')
176 return 1
177 args = ['test']
178
179 tests = []
180 for arg in args:
181 if os.path.isdir(arg):
182 tests.extend(find_all_gyptest_files(os.path.normpath(arg)))
183 else:
184 tests.append(arg)
185
186 if opts.list:
187 for test in tests:
188 print test
189 sys.exit(0)
190
191 CommandRunner.verbose = not opts.quiet
192 CommandRunner.active = not opts.no_exec
193 cr = CommandRunner()
194
195 os.environ['PYTHONPATH'] = os.path.abspath('test/lib')
196 if not opts.quiet:
197 sys.stdout.write('PYTHONPATH=%s\n' % os.environ['PYTHONPATH'])
198
199 passed = []
200 failed = []
201 no_result = []
202
203 if opts.format:
204 format_list = opts.format.split(',')
205 else:
206 # TODO: not duplicate this mapping from pylib/gyp/__init__.py
207 format_list = {
208 'freebsd7': ['make'],
209 'freebsd8': ['make'],
210 'cygwin': ['msvs'],
211 'win32': ['msvs'],
212 'linux2': ['make', 'ninja'],
213 'linux3': ['make', 'ninja'],
214 'darwin': ['make', 'xcode'],
215 }[sys.platform]
216
217 for format in format_list:
218 os.environ['TESTGYP_FORMAT'] = format
219 if not opts.quiet:
220 sys.stdout.write('TESTGYP_FORMAT=%s\n' % format)
221
222 for test in tests:
223 status = cr.run([sys.executable, test],
224 stdout=sys.stdout,
225 stderr=sys.stderr)
226 if status == 2:
227 no_result.append(test)
228 elif status:
229 failed.append(test)
230 else:
231 passed.append(test)
232
233 if not opts.quiet:
234 def report(description, tests):
235 if tests:
236 if len(tests) == 1:
237 sys.stdout.write("\n%s the following test:\n" % description)
238 else:
239 fmt = "\n%s the following %d tests:\n"
240 sys.stdout.write(fmt % (description, len(tests)))
241 sys.stdout.write("\t" + "\n\t".join(tests) + "\n")
242
243 if opts.passed:
244 report("Passed", passed)
245 report("Failed", failed)
246 report("No result from", no_result)
247
248 if failed:
249 return 1
250 else:
251 return 0
252
253
254 if __name__ == "__main__":
255 sys.exit(main())
+0
-340
third_party/gyp/pylib/gyp/MSVSNew.py less more
0 #!/usr/bin/python2.4
1
2 # Copyright (c) 2009 Google Inc. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
5
6 """New implementation of Visual Studio project generation for SCons."""
7
8 import common
9 import os
10 import random
11
12 import gyp.common
13
14 # hashlib is supplied as of Python 2.5 as the replacement interface for md5
15 # and other secure hashes. In 2.6, md5 is deprecated. Import hashlib if
16 # available, avoiding a deprecation warning under 2.6. Import md5 otherwise,
17 # preserving 2.4 compatibility.
18 try:
19 import hashlib
20 _new_md5 = hashlib.md5
21 except ImportError:
22 import md5
23 _new_md5 = md5.new
24
25
26 # Initialize random number generator
27 random.seed()
28
29 # GUIDs for project types
30 ENTRY_TYPE_GUIDS = {
31 'project': '{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}',
32 'folder': '{2150E333-8FDC-42A3-9474-1A3956D46DE8}',
33 }
34
35 #------------------------------------------------------------------------------
36 # Helper functions
37
38
39 def MakeGuid(name, seed='msvs_new'):
40 """Returns a GUID for the specified target name.
41
42 Args:
43 name: Target name.
44 seed: Seed for MD5 hash.
45 Returns:
46 A GUID-line string calculated from the name and seed.
47
48 This generates something which looks like a GUID, but depends only on the
49 name and seed. This means the same name/seed will always generate the same
50 GUID, so that projects and solutions which refer to each other can explicitly
51 determine the GUID to refer to explicitly. It also means that the GUID will
52 not change when the project for a target is rebuilt.
53 """
54 # Calculate a MD5 signature for the seed and name.
55 d = _new_md5(str(seed) + str(name)).hexdigest().upper()
56 # Convert most of the signature to GUID form (discard the rest)
57 guid = ('{' + d[:8] + '-' + d[8:12] + '-' + d[12:16] + '-' + d[16:20]
58 + '-' + d[20:32] + '}')
59 return guid
60
61 #------------------------------------------------------------------------------
62
63
64 class MSVSFolder:
65 """Folder in a Visual Studio project or solution."""
66
67 def __init__(self, path, name = None, entries = None,
68 guid = None, items = None):
69 """Initializes the folder.
70
71 Args:
72 path: Full path to the folder.
73 name: Name of the folder.
74 entries: List of folder entries to nest inside this folder. May contain
75 Folder or Project objects. May be None, if the folder is empty.
76 guid: GUID to use for folder, if not None.
77 items: List of solution items to include in the folder project. May be
78 None, if the folder does not directly contain items.
79 """
80 if name:
81 self.name = name
82 else:
83 # Use last layer.
84 self.name = os.path.basename(path)
85
86 self.path = path
87 self.guid = guid
88
89 # Copy passed lists (or set to empty lists)
90 self.entries = list(entries or [])
91 self.items = list(items or [])
92
93 self.entry_type_guid = ENTRY_TYPE_GUIDS['folder']
94
95 def get_guid(self):
96 if self.guid is None:
97 # Use consistent guids for folders (so things don't regenerate).
98 self.guid = MakeGuid(self.path, seed='msvs_folder')
99 return self.guid
100
101
102 #------------------------------------------------------------------------------
103
104
105 class MSVSProject:
106 """Visual Studio project."""
107
108 def __init__(self, path, name = None, dependencies = None, guid = None,
109 spec = None, build_file = None, config_platform_overrides = None,
110 fixpath_prefix = None):
111 """Initializes the project.
112
113 Args:
114 path: Absolute path to the project file.
115 name: Name of project. If None, the name will be the same as the base
116 name of the project file.
117 dependencies: List of other Project objects this project is dependent
118 upon, if not None.
119 guid: GUID to use for project, if not None.
120 spec: Dictionary specifying how to build this project.
121 build_file: Filename of the .gyp file that the vcproj file comes from.
122 config_platform_overrides: optional dict of configuration platforms to
123 used in place of the default for this target.
124 fixpath_prefix: the path used to adjust the behavior of _fixpath
125 """
126 self.path = path
127 self.guid = guid
128 self.spec = spec
129 self.build_file = build_file
130 # Use project filename if name not specified
131 self.name = name or os.path.splitext(os.path.basename(path))[0]
132
133 # Copy passed lists (or set to empty lists)
134 self.dependencies = list(dependencies or [])
135
136 self.entry_type_guid = ENTRY_TYPE_GUIDS['project']
137
138 if config_platform_overrides:
139 self.config_platform_overrides = config_platform_overrides
140 else:
141 self.config_platform_overrides = {}
142 self.fixpath_prefix = fixpath_prefix
143
144 def set_dependencies(self, dependencies):
145 self.dependencies = list(dependencies or [])
146
147 def get_guid(self):
148 if self.guid is None:
149 # Set GUID from path
150 # TODO(rspangler): This is fragile.
151 # 1. We can't just use the project filename sans path, since there could
152 # be multiple projects with the same base name (for example,
153 # foo/unittest.vcproj and bar/unittest.vcproj).
154 # 2. The path needs to be relative to $SOURCE_ROOT, so that the project
155 # GUID is the same whether it's included from base/base.sln or
156 # foo/bar/baz/baz.sln.
157 # 3. The GUID needs to be the same each time this builder is invoked, so
158 # that we don't need to rebuild the solution when the project changes.
159 # 4. We should be able to handle pre-built project files by reading the
160 # GUID from the files.
161 self.guid = MakeGuid(self.name)
162 return self.guid
163
164 #------------------------------------------------------------------------------
165
166
167 class MSVSSolution:
168 """Visual Studio solution."""
169
170 def __init__(self, path, version, entries=None, variants=None,
171 websiteProperties=True):
172 """Initializes the solution.
173
174 Args:
175 path: Path to solution file.
176 version: Format version to emit.
177 entries: List of entries in solution. May contain Folder or Project
178 objects. May be None, if the folder is empty.
179 variants: List of build variant strings. If none, a default list will
180 be used.
181 websiteProperties: Flag to decide if the website properties section
182 is generated.
183 """
184 self.path = path
185 self.websiteProperties = websiteProperties
186 self.version = version
187
188 # Copy passed lists (or set to empty lists)
189 self.entries = list(entries or [])
190
191 if variants:
192 # Copy passed list
193 self.variants = variants[:]
194 else:
195 # Use default
196 self.variants = ['Debug|Win32', 'Release|Win32']
197 # TODO(rspangler): Need to be able to handle a mapping of solution config
198 # to project config. Should we be able to handle variants being a dict,
199 # or add a separate variant_map variable? If it's a dict, we can't
200 # guarantee the order of variants since dict keys aren't ordered.
201
202
203 # TODO(rspangler): Automatically write to disk for now; should delay until
204 # node-evaluation time.
205 self.Write()
206
207
208 def Write(self, writer=common.WriteOnDiff):
209 """Writes the solution file to disk.
210
211 Raises:
212 IndexError: An entry appears multiple times.
213 """
214 # Walk the entry tree and collect all the folders and projects.
215 all_entries = set()
216 entries_to_check = self.entries[:]
217 while entries_to_check:
218 e = entries_to_check.pop(0)
219
220 # If this entry has been visited, nothing to do.
221 if e in all_entries:
222 continue
223
224 all_entries.add(e)
225
226 # If this is a folder, check its entries too.
227 if isinstance(e, MSVSFolder):
228 entries_to_check += e.entries
229
230 # Sort by name then guid (so things are in order on vs2008).
231 def NameThenGuid(a, b):
232 if a.name < b.name: return -1
233 if a.name > b.name: return 1
234 if a.get_guid() < b.get_guid(): return -1
235 if a.get_guid() > b.get_guid(): return 1
236 return 0
237
238 all_entries = sorted(all_entries, NameThenGuid)
239
240 # Open file and print header
241 f = writer(self.path)
242 f.write('Microsoft Visual Studio Solution File, '
243 'Format Version %s\r\n' % self.version.SolutionVersion())
244 f.write('# %s\r\n' % self.version.Description())
245
246 # Project entries
247 sln_root = os.path.split(self.path)[0]
248 for e in all_entries:
249 relative_path = gyp.common.RelativePath(e.path, sln_root)
250 # msbuild does not accept an empty folder_name.
251 # use '.' in case relative_path is empty.
252 folder_name = relative_path.replace('/', '\\') or '.'
253 f.write('Project("%s") = "%s", "%s", "%s"\r\n' % (
254 e.entry_type_guid, # Entry type GUID
255 e.name, # Folder name
256 folder_name, # Folder name (again)
257 e.get_guid(), # Entry GUID
258 ))
259
260 # TODO(rspangler): Need a way to configure this stuff
261 if self.websiteProperties:
262 f.write('\tProjectSection(WebsiteProperties) = preProject\r\n'
263 '\t\tDebug.AspNetCompiler.Debug = "True"\r\n'
264 '\t\tRelease.AspNetCompiler.Debug = "False"\r\n'
265 '\tEndProjectSection\r\n')
266
267 if isinstance(e, MSVSFolder):
268 if e.items:
269 f.write('\tProjectSection(SolutionItems) = preProject\r\n')
270 for i in e.items:
271 f.write('\t\t%s = %s\r\n' % (i, i))
272 f.write('\tEndProjectSection\r\n')
273
274 if isinstance(e, MSVSProject):
275 if e.dependencies:
276 f.write('\tProjectSection(ProjectDependencies) = postProject\r\n')
277 for d in e.dependencies:
278 f.write('\t\t%s = %s\r\n' % (d.get_guid(), d.get_guid()))
279 f.write('\tEndProjectSection\r\n')
280
281 f.write('EndProject\r\n')
282
283 # Global section
284 f.write('Global\r\n')
285
286 # Configurations (variants)
287 f.write('\tGlobalSection(SolutionConfigurationPlatforms) = preSolution\r\n')
288 for v in self.variants:
289 f.write('\t\t%s = %s\r\n' % (v, v))
290 f.write('\tEndGlobalSection\r\n')
291
292 # Sort config guids for easier diffing of solution changes.
293 config_guids = []
294 config_guids_overrides = {}
295 for e in all_entries:
296 if isinstance(e, MSVSProject):
297 config_guids.append(e.get_guid())
298 config_guids_overrides[e.get_guid()] = e.config_platform_overrides
299 config_guids.sort()
300
301 f.write('\tGlobalSection(ProjectConfigurationPlatforms) = postSolution\r\n')
302 for g in config_guids:
303 for v in self.variants:
304 nv = config_guids_overrides[g].get(v, v)
305 # Pick which project configuration to build for this solution
306 # configuration.
307 f.write('\t\t%s.%s.ActiveCfg = %s\r\n' % (
308 g, # Project GUID
309 v, # Solution build configuration
310 nv, # Project build config for that solution config
311 ))
312
313 # Enable project in this solution configuration.
314 f.write('\t\t%s.%s.Build.0 = %s\r\n' % (
315 g, # Project GUID
316 v, # Solution build configuration
317 nv, # Project build config for that solution config
318 ))
319 f.write('\tEndGlobalSection\r\n')
320
321 # TODO(rspangler): Should be able to configure this stuff too (though I've
322 # never seen this be any different)
323 f.write('\tGlobalSection(SolutionProperties) = preSolution\r\n')
324 f.write('\t\tHideSolutionNode = FALSE\r\n')
325 f.write('\tEndGlobalSection\r\n')
326
327 # Folder mappings
328 # TODO(rspangler): Should omit this section if there are no folders
329 f.write('\tGlobalSection(NestedProjects) = preSolution\r\n')
330 for e in all_entries:
331 if not isinstance(e, MSVSFolder):
332 continue # Does not apply to projects, only folders
333 for subentry in e.entries:
334 f.write('\t\t%s = %s\r\n' % (subentry.get_guid(), e.get_guid()))
335 f.write('\tEndGlobalSection\r\n')
336
337 f.write('EndGlobal\r\n')
338
339 f.close()
+0
-212
third_party/gyp/pylib/gyp/MSVSProject.py less more
0 #!/usr/bin/python2.4
1
2 # Copyright (c) 2009 Google Inc. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
5
6 """Visual Studio project reader/writer."""
7
8 import common
9 import gyp.easy_xml as easy_xml
10
11 #------------------------------------------------------------------------------
12
13
14 class Tool(object):
15 """Visual Studio tool."""
16
17 def __init__(self, name, attrs=None):
18 """Initializes the tool.
19
20 Args:
21 name: Tool name.
22 attrs: Dict of tool attributes; may be None.
23 """
24 self._attrs = attrs or {}
25 self._attrs['Name'] = name
26
27 def _GetSpecification(self):
28 """Creates an element for the tool.
29
30 Returns:
31 A new xml.dom.Element for the tool.
32 """
33 return ['Tool', self._attrs]
34
35 class Filter(object):
36 """Visual Studio filter - that is, a virtual folder."""
37
38 def __init__(self, name, contents=None):
39 """Initializes the folder.
40
41 Args:
42 name: Filter (folder) name.
43 contents: List of filenames and/or Filter objects contained.
44 """
45 self.name = name
46 self.contents = list(contents or [])
47
48
49 #------------------------------------------------------------------------------
50
51
52 class Writer(object):
53 """Visual Studio XML project writer."""
54
55 def __init__(self, project_path, version, name, guid=None, platforms=None):
56 """Initializes the project.
57
58 Args:
59 project_path: Path to the project file.
60 version: Format version to emit.
61 name: Name of the project.
62 guid: GUID to use for project, if not None.
63 platforms: Array of string, the supported platforms. If null, ['Win32']
64 """
65 self.project_path = project_path
66 self.version = version
67 self.name = name
68 self.guid = guid
69
70 # Default to Win32 for platforms.
71 if not platforms:
72 platforms = ['Win32']
73
74 # Initialize the specifications of the various sections.
75 self.platform_section = ['Platforms']
76 for platform in platforms:
77 self.platform_section.append(['Platform', {'Name': platform}])
78 self.tool_files_section = ['ToolFiles']
79 self.configurations_section = ['Configurations']
80 self.files_section = ['Files']
81
82 # Keep a dict keyed on filename to speed up access.
83 self.files_dict = dict()
84
85 def AddToolFile(self, path):
86 """Adds a tool file to the project.
87
88 Args:
89 path: Relative path from project to tool file.
90 """
91 self.tool_files_section.append(['ToolFile', {'RelativePath': path}])
92
93 def _GetSpecForConfiguration(self, config_type, config_name, attrs, tools):
94 """Returns the specification for a configuration.
95
96 Args:
97 config_type: Type of configuration node.
98 config_name: Configuration name.
99 attrs: Dict of configuration attributes; may be None.
100 tools: List of tools (strings or Tool objects); may be None.
101 Returns:
102 """
103 # Handle defaults
104 if not attrs:
105 attrs = {}
106 if not tools:
107 tools = []
108
109 # Add configuration node and its attributes
110 node_attrs = attrs.copy()
111 node_attrs['Name'] = config_name
112 specification = [config_type, node_attrs]
113
114 # Add tool nodes and their attributes
115 if tools:
116 for t in tools:
117 if isinstance(t, Tool):
118 specification.append(t._GetSpecification())
119 else:
120 specification.append(Tool(t)._GetSpecification())
121 return specification
122
123
124 def AddConfig(self, name, attrs=None, tools=None):
125 """Adds a configuration to the project.
126
127 Args:
128 name: Configuration name.
129 attrs: Dict of configuration attributes; may be None.
130 tools: List of tools (strings or Tool objects); may be None.
131 """
132 spec = self._GetSpecForConfiguration('Configuration', name, attrs, tools)
133 self.configurations_section.append(spec)
134
135 def _AddFilesToNode(self, parent, files):
136 """Adds files and/or filters to the parent node.
137
138 Args:
139 parent: Destination node
140 files: A list of Filter objects and/or relative paths to files.
141
142 Will call itself recursively, if the files list contains Filter objects.
143 """
144 for f in files:
145 if isinstance(f, Filter):
146 node = ['Filter', {'Name': f.name}]
147 self._AddFilesToNode(node, f.contents)
148 else:
149 node = ['File', {'RelativePath': f}]
150 self.files_dict[f] = node
151 parent.append(node)
152
153 def AddFiles(self, files):
154 """Adds files to the project.
155
156 Args:
157 files: A list of Filter objects and/or relative paths to files.
158
159 This makes a copy of the file/filter tree at the time of this call. If you
160 later add files to a Filter object which was passed into a previous call
161 to AddFiles(), it will not be reflected in this project.
162 """
163 self._AddFilesToNode(self.files_section, files)
164 # TODO(rspangler) This also doesn't handle adding files to an existing
165 # filter. That is, it doesn't merge the trees.
166
167 def AddFileConfig(self, path, config, attrs=None, tools=None):
168 """Adds a configuration to a file.
169
170 Args:
171 path: Relative path to the file.
172 config: Name of configuration to add.
173 attrs: Dict of configuration attributes; may be None.
174 tools: List of tools (strings or Tool objects); may be None.
175
176 Raises:
177 ValueError: Relative path does not match any file added via AddFiles().
178 """
179 # Find the file node with the right relative path
180 parent = self.files_dict.get(path)
181 if not parent:
182 raise ValueError('AddFileConfig: file "%s" not in project.' % path)
183
184 # Add the config to the file node
185 spec = self._GetSpecForConfiguration('FileConfiguration', config, attrs,
186 tools)
187 parent.append(spec)
188
189 def WriteIfChanged(self):
190 """Writes the project file."""
191 # First create XML content definition
192 content = [
193 'VisualStudioProject',
194 {'ProjectType': 'Visual C++',
195 'Version': self.version.ProjectVersion(),
196 'Name': self.name,
197 'ProjectGUID': self.guid,
198 'RootNamespace': self.name,
199 'Keyword': 'Win32Proj'
200 },
201 self.platform_section,
202 self.tool_files_section,
203 self.configurations_section,
204 ['References'], # empty section
205 self.files_section,
206 ['Globals'] # empty section
207 ]
208 easy_xml.WriteXmlIfChanged(content, self.project_path,
209 encoding="Windows-1252")
210
211 #------------------------------------------------------------------------------
+0
-1033
third_party/gyp/pylib/gyp/MSVSSettings.py less more
0 #!/usr/bin/python
1 # Copyright (c) 2011 The Chromium Authors. 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 """Code to validate and convert settings of the Microsoft build tools.
6
7 This file contains code to validate and convert settings of the Microsoft
8 build tools. The function ConvertToMSBuildSettings(), ValidateMSVSSettings(),
9 and ValidateMSBuildSettings() are the entry points.
10
11 This file was created by comparing the projects created by Visual Studio 2008
12 and Visual Studio 2010 for all available settings through the user interface.
13 The MSBuild schemas were also considered. They are typically found in the
14 MSBuild install directory, e.g. c:\Program Files (x86)\MSBuild
15 """
16
17 import sys
18
19
20 # Dictionaries of settings validators. The key is the tool name, the value is
21 # a dictionary mapping setting names to validation functions.
22 _msvs_validators = {}
23 _msbuild_validators = {}
24
25
26 # A dictionary of settings converters. The key is the tool name, the value is
27 # a dictionary mapping setting names to conversion functions.
28 _msvs_to_msbuild_converters = {}
29
30
31 # Tool name mapping from MSVS to MSBuild.
32 _msbuild_name_of_tool = {}
33
34
35 class _Tool(object):
36 """Represents a tool used by MSVS or MSBuild.
37
38 Attributes:
39 msvs_name: The name of the tool in MSVS.
40 msbuild_name: The name of the tool in MSBuild.
41 """
42
43 def __init__(self, msvs_name, msbuild_name):
44 self.msvs_name = msvs_name
45 self.msbuild_name = msbuild_name
46
47
48 def _AddTool(tool):
49 """Adds a tool to the four dictionaries used to process settings.
50
51 This only defines the tool. Each setting also needs to be added.
52
53 Args:
54 tool: The _Tool object to be added.
55 """
56 _msvs_validators[tool.msvs_name] = {}
57 _msbuild_validators[tool.msbuild_name] = {}
58 _msvs_to_msbuild_converters[tool.msvs_name] = {}
59 _msbuild_name_of_tool[tool.msvs_name] = tool.msbuild_name
60
61
62 def _GetMSBuildToolSettings(msbuild_settings, tool):
63 """Returns an MSBuild tool dictionary. Creates it if needed."""
64 return msbuild_settings.setdefault(tool.msbuild_name, {})
65
66
67 class _Type(object):
68 """Type of settings (Base class)."""
69
70 def ValidateMSVS(self, value):
71 """Verifies that the value is legal for MSVS.
72
73 Args:
74 value: the value to check for this type.
75
76 Raises:
77 ValueError if value is not valid for MSVS.
78 """
79
80 def ValidateMSBuild(self, value):
81 """Verifies that the value is legal for MSBuild.
82
83 Args:
84 value: the value to check for this type.
85
86 Raises:
87 ValueError if value is not valid for MSBuild.
88 """
89
90 def ConvertToMSBuild(self, value):
91 """Returns the MSBuild equivalent of the MSVS value given.
92
93 Args:
94 value: the MSVS value to convert.
95
96 Returns:
97 the MSBuild equivalent.
98
99 Raises:
100 ValueError if value is not valid.
101 """
102 return value
103
104
105 class _String(_Type):
106 """A setting that's just a string."""
107
108 def ValidateMSVS(self, value):
109 if not isinstance(value, basestring):
110 raise ValueError('expected string; got %r' % value)
111
112 def ValidateMSBuild(self, value):
113 if not isinstance(value, basestring):
114 raise ValueError('expected string; got %r' % value)
115
116 def ConvertToMSBuild(self, value):
117 # Convert the macros
118 return ConvertVCMacrosToMSBuild(value)
119
120
121 class _StringList(_Type):
122 """A settings that's a list of strings."""
123
124 def ValidateMSVS(self, value):
125 if not isinstance(value, basestring) and not isinstance(value, list):
126 raise ValueError('expected string list; got %r' % value)
127
128 def ValidateMSBuild(self, value):
129 if not isinstance(value, basestring) and not isinstance(value, list):
130 raise ValueError('expected string list; got %r' % value)
131
132 def ConvertToMSBuild(self, value):
133 # Convert the macros
134 if isinstance(value, list):
135 return [ConvertVCMacrosToMSBuild(i) for i in value]
136 else:
137 return ConvertVCMacrosToMSBuild(value)
138
139
140 class _Boolean(_Type):
141 """Boolean settings, can have the values 'false' or 'true'."""
142
143 def _Validate(self, value):
144 if value != 'true' and value != 'false':
145 raise ValueError('expected bool; got %r' % value)
146
147 def ValidateMSVS(self, value):
148 self._Validate(value)
149
150 def ValidateMSBuild(self, value):
151 self._Validate(value)
152
153 def ConvertToMSBuild(self, value):
154 self._Validate(value)
155 return value
156
157
158 class _Integer(_Type):
159 """Integer settings."""
160
161 def __init__(self, msbuild_base=10):
162 _Type.__init__(self)
163 self._msbuild_base = msbuild_base
164
165 def ValidateMSVS(self, value):
166 # Try to convert, this will raise ValueError if invalid.
167 self.ConvertToMSBuild(value)
168
169 def ValidateMSBuild(self, value):
170 # Try to convert, this will raise ValueError if invalid.
171 int(value, self._msbuild_base)
172
173 def ConvertToMSBuild(self, value):
174 msbuild_format = (self._msbuild_base == 10) and '%d' or '0x%04x'
175 return msbuild_format % int(value)
176
177
178 class _Enumeration(_Type):
179 """Type of settings that is an enumeration.
180
181 In MSVS, the values are indexes like '0', '1', and '2'.
182 MSBuild uses text labels that are more representative, like 'Win32'.
183
184 Constructor args:
185 label_list: an array of MSBuild labels that correspond to the MSVS index.
186 In the rare cases where MSVS has skipped an index value, None is
187 used in the array to indicate the unused spot.
188 new: an array of labels that are new to MSBuild.
189 """
190
191 def __init__(self, label_list, new=None):
192 _Type.__init__(self)
193 self._label_list = label_list
194 self._msbuild_values = set(value for value in label_list
195 if value is not None)
196 if new is not None:
197 self._msbuild_values.update(new)
198
199 def ValidateMSVS(self, value):
200 # Try to convert. It will raise an exception if not valid.
201 self.ConvertToMSBuild(value)
202
203 def ValidateMSBuild(self, value):
204 if value not in self._msbuild_values:
205 raise ValueError('unrecognized enumerated value %s' % value)
206
207 def ConvertToMSBuild(self, value):
208 index = int(value)
209 if index < 0 or index >= len(self._label_list):
210 raise ValueError('index value (%d) not in expected range [0, %d)' %
211 (index, len(self._label_list)))
212 label = self._label_list[index]
213 if label is None:
214 raise ValueError('converted value for %s not specified.' % value)
215 return label
216
217
218 # Instantiate the various generic types.
219 _boolean = _Boolean()
220 _integer = _Integer()
221 # For now, we don't do any special validation on these types:
222 _string = _String()
223 _file_name = _String()
224 _folder_name = _String()
225 _file_list = _StringList()
226 _folder_list = _StringList()
227 _string_list = _StringList()
228 # Some boolean settings went from numerical values to boolean. The
229 # mapping is 0: default, 1: false, 2: true.
230 _newly_boolean = _Enumeration(['', 'false', 'true'])
231
232
233 def _Same(tool, name, setting_type):
234 """Defines a setting that has the same name in MSVS and MSBuild.
235
236 Args:
237 tool: a dictionary that gives the names of the tool for MSVS and MSBuild.
238 name: the name of the setting.
239 setting_type: the type of this setting.
240 """
241 _Renamed(tool, name, name, setting_type)
242
243
244 def _Renamed(tool, msvs_name, msbuild_name, setting_type):
245 """Defines a setting for which the name has changed.
246
247 Args:
248 tool: a dictionary that gives the names of the tool for MSVS and MSBuild.
249 msvs_name: the name of the MSVS setting.
250 msbuild_name: the name of the MSBuild setting.
251 setting_type: the type of this setting.
252 """
253
254 def _Translate(value, msbuild_settings):
255 msbuild_tool_settings = _GetMSBuildToolSettings(msbuild_settings, tool)
256 msbuild_tool_settings[msbuild_name] = setting_type.ConvertToMSBuild(value)
257
258 _msvs_validators[tool.msvs_name][msvs_name] = setting_type.ValidateMSVS
259 _msbuild_validators[tool.msbuild_name][msbuild_name] = (
260 setting_type.ValidateMSBuild)
261 _msvs_to_msbuild_converters[tool.msvs_name][msvs_name] = _Translate
262
263
264 def _Moved(tool, settings_name, msbuild_tool_name, setting_type):
265 _MovedAndRenamed(tool, settings_name, msbuild_tool_name, settings_name,
266 setting_type)
267
268
269 def _MovedAndRenamed(tool, msvs_settings_name, msbuild_tool_name,
270 msbuild_settings_name, setting_type):
271 """Defines a setting that may have moved to a new section.
272
273 Args:
274 tool: a dictionary that gives the names of the tool for MSVS and MSBuild.
275 msvs_settings_name: the MSVS name of the setting.
276 msbuild_tool_name: the name of the MSBuild tool to place the setting under.
277 msbuild_settings_name: the MSBuild name of the setting.
278 setting_type: the type of this setting.
279 """
280
281 def _Translate(value, msbuild_settings):
282 tool_settings = msbuild_settings.setdefault(msbuild_tool_name, {})
283 tool_settings[msbuild_settings_name] = setting_type.ConvertToMSBuild(value)
284
285 _msvs_validators[tool.msvs_name][msvs_settings_name] = (
286 setting_type.ValidateMSVS)
287 validator = setting_type.ValidateMSBuild
288 _msbuild_validators[msbuild_tool_name][msbuild_settings_name] = validator
289 _msvs_to_msbuild_converters[tool.msvs_name][msvs_settings_name] = _Translate
290
291
292 def _MSVSOnly(tool, name, setting_type):
293 """Defines a setting that is only found in MSVS.
294
295 Args:
296 tool: a dictionary that gives the names of the tool for MSVS and MSBuild.
297 name: the name of the setting.
298 setting_type: the type of this setting.
299 """
300
301 def _Translate(unused_value, unused_msbuild_settings):
302 # Since this is for MSVS only settings, no translation will happen.
303 pass
304
305 _msvs_validators[tool.msvs_name][name] = setting_type.ValidateMSVS
306 _msvs_to_msbuild_converters[tool.msvs_name][name] = _Translate
307
308
309 def _MSBuildOnly(tool, name, setting_type):
310 """Defines a setting that is only found in MSBuild.
311
312 Args:
313 tool: a dictionary that gives the names of the tool for MSVS and MSBuild.
314 name: the name of the setting.
315 setting_type: the type of this setting.
316 """
317 _msbuild_validators[tool.msbuild_name][name] = setting_type.ValidateMSBuild
318
319
320 def _ConvertedToAdditionalOption(tool, msvs_name, flag):
321 """Defines a setting that's handled via a command line option in MSBuild.
322
323 Args:
324 tool: a dictionary that gives the names of the tool for MSVS and MSBuild.
325 msvs_name: the name of the MSVS setting that if 'true' becomes a flag
326 flag: the flag to insert at the end of the AdditionalOptions
327 """
328
329 def _Translate(value, msbuild_settings):
330 if value == 'true':
331 tool_settings = _GetMSBuildToolSettings(msbuild_settings, tool)
332 if 'AdditionalOptions' in tool_settings:
333 new_flags = '%s %s' % (tool_settings['AdditionalOptions'], flag)
334 else:
335 new_flags = flag
336 tool_settings['AdditionalOptions'] = new_flags
337 _msvs_validators[tool.msvs_name][msvs_name] = _boolean.ValidateMSVS
338 _msvs_to_msbuild_converters[tool.msvs_name][msvs_name] = _Translate
339
340
341 def _CustomGeneratePreprocessedFile(tool, msvs_name):
342 def _Translate(value, msbuild_settings):
343 tool_settings = _GetMSBuildToolSettings(msbuild_settings, tool)
344 if value == '0':
345 tool_settings['PreprocessToFile'] = 'false'
346 tool_settings['PreprocessSuppressLineNumbers'] = 'false'
347 elif value == '1': # /P
348 tool_settings['PreprocessToFile'] = 'true'
349 tool_settings['PreprocessSuppressLineNumbers'] = 'false'
350 elif value == '2': # /EP /P
351 tool_settings['PreprocessToFile'] = 'true'
352 tool_settings['PreprocessSuppressLineNumbers'] = 'true'
353 else:
354 raise ValueError('value must be one of [0, 1, 2]; got %s' % value)
355 # Create a bogus validator that looks for '0', '1', or '2'
356 msvs_validator = _Enumeration(['a', 'b', 'c']).ValidateMSVS
357 _msvs_validators[tool.msvs_name][msvs_name] = msvs_validator
358 msbuild_validator = _boolean.ValidateMSBuild
359 msbuild_tool_validators = _msbuild_validators[tool.msbuild_name]
360 msbuild_tool_validators['PreprocessToFile'] = msbuild_validator
361 msbuild_tool_validators['PreprocessSuppressLineNumbers'] = msbuild_validator
362 _msvs_to_msbuild_converters[tool.msvs_name][msvs_name] = _Translate
363
364
365 def ConvertVCMacrosToMSBuild(s):
366 """Convert the the MSVS macros found in the string to the MSBuild equivalent.
367
368 This list is probably not exhaustive. Add as needed.
369 """
370 if '$' in s:
371 replace_map = {
372 '$(ConfigurationName)': '$(Configuration)',
373 '$(InputDir)': '%(RootDir)%(Directory)',
374 '$(InputExt)': '%(Extension)',
375 '$(InputFileName)': '%(Filename)%(Extension)',
376 '$(InputName)': '%(Filename)',
377 '$(InputPath)': '%(FullPath)',
378 '$(ParentName)': '$(ProjectFileName)',
379 '$(PlatformName)': '$(Platform)',
380 '$(SafeInputName)': '%(Filename)',
381
382 '$(IntDir)\\': '$(IntDir)',
383 '$(OutDir)\\': '$(OutDir)',
384 '$(IntDir)/': '$(IntDir)',
385 '$(OutDir)/': '$(OutDir)',
386 }
387 for old, new in replace_map.iteritems():
388 s = s.replace(old, new)
389 return s
390
391
392 def ConvertToMSBuildSettings(msvs_settings, stderr=sys.stderr):
393 """Converts MSVS settings (VS2008 and earlier) to MSBuild settings (VS2010+).
394
395 Args:
396 msvs_settings: A dictionary. The key is the tool name. The values are
397 themselves dictionaries of settings and their values.
398 stderr: The stream receiving the error messages.
399
400 Returns:
401 A dictionary of MSBuild settings. The key is either the MSBuild tool name
402 or the empty string (for the global settings). The values are themselves
403 dictionaries of settings and their values.
404 """
405 msbuild_settings = {}
406 for msvs_tool_name, msvs_tool_settings in msvs_settings.iteritems():
407 if msvs_tool_name in _msvs_to_msbuild_converters:
408 msvs_tool = _msvs_to_msbuild_converters[msvs_tool_name]
409 for msvs_setting, msvs_value in msvs_tool_settings.iteritems():
410 if msvs_setting in msvs_tool:
411 # Invoke the translation function.
412 try:
413 msvs_tool[msvs_setting](msvs_value, msbuild_settings)
414 except ValueError, e:
415 print >> stderr, ('Warning: while converting %s/%s to MSBuild, '
416 '%s' % (msvs_tool_name, msvs_setting, e))
417 else:
418 # We don't know this setting. Give a warning.
419 print >> stderr, ('Warning: unrecognized setting %s/%s '
420 'while converting to MSBuild.' %
421 (msvs_tool_name, msvs_setting))
422 else:
423 print >> stderr, ('Warning: unrecognized tool %s while converting to '
424 'MSBuild.' % msvs_tool_name)
425 return msbuild_settings
426
427
428 def ValidateMSVSSettings(settings, stderr=sys.stderr):
429 """Validates that the names of the settings are valid for MSVS.
430
431 Args:
432 settings: A dictionary. The key is the tool name. The values are
433 themselves dictionaries of settings and their values.
434 stderr: The stream receiving the error messages.
435 """
436 _ValidateSettings(_msvs_validators, settings, stderr)
437
438
439 def ValidateMSBuildSettings(settings, stderr=sys.stderr):
440 """Validates that the names of the settings are valid for MSBuild.
441
442 Args:
443 settings: A dictionary. The key is the tool name. The values are
444 themselves dictionaries of settings and their values.
445 stderr: The stream receiving the error messages.
446 """
447 _ValidateSettings(_msbuild_validators, settings, stderr)
448
449
450 def _ValidateSettings(validators, settings, stderr):
451 """Validates that the settings are valid for MSBuild or MSVS.
452
453 We currently only validate the names of the settings, not their values.
454
455 Args:
456 validators: A dictionary of tools and their validators.
457 settings: A dictionary. The key is the tool name. The values are
458 themselves dictionaries of settings and their values.
459 stderr: The stream receiving the error messages.
460 """
461 for tool_name in settings:
462 if tool_name in validators:
463 tool_validators = validators[tool_name]
464 for setting, value in settings[tool_name].iteritems():
465 if setting in tool_validators:
466 try:
467 tool_validators[setting](value)
468 except ValueError, e:
469 print >> stderr, ('Warning: for %s/%s, %s' %
470 (tool_name, setting, e))
471 else:
472 print >> stderr, ('Warning: unrecognized setting %s/%s' %
473 (tool_name, setting))
474 else:
475 print >> stderr, ('Warning: unrecognized tool %s' % tool_name)
476
477
478 # MSVS and MBuild names of the tools.
479 _compile = _Tool('VCCLCompilerTool', 'ClCompile')
480 _link = _Tool('VCLinkerTool', 'Link')
481 _midl = _Tool('VCMIDLTool', 'Midl')
482 _rc = _Tool('VCResourceCompilerTool', 'ResourceCompile')
483 _lib = _Tool('VCLibrarianTool', 'Lib')
484 _manifest = _Tool('VCManifestTool', 'Mt')
485
486
487 _AddTool(_compile)
488 _AddTool(_link)
489 _AddTool(_midl)
490 _AddTool(_rc)
491 _AddTool(_lib)
492 _AddTool(_manifest)
493 # Add sections only found in the MSBuild settings.
494 _msbuild_validators[''] = {}
495 _msbuild_validators['ProjectReference'] = {}
496 _msbuild_validators['ManifestResourceCompile'] = {}
497
498 # Descriptions of the compiler options, i.e. VCCLCompilerTool in MSVS and
499 # ClCompile in MSBuild.
500 # See "c:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\1033\cl.xml" for
501 # the schema of the MSBuild ClCompile settings.
502
503 # Options that have the same name in MSVS and MSBuild
504 _Same(_compile, 'AdditionalIncludeDirectories', _folder_list) # /I
505 _Same(_compile, 'AdditionalOptions', _string_list)
506 _Same(_compile, 'AdditionalUsingDirectories', _folder_list) # /AI
507 _Same(_compile, 'AssemblerListingLocation', _file_name) # /Fa
508 _Same(_compile, 'BrowseInformationFile', _file_name)
509 _Same(_compile, 'BufferSecurityCheck', _boolean) # /GS
510 _Same(_compile, 'DisableLanguageExtensions', _boolean) # /Za
511 _Same(_compile, 'DisableSpecificWarnings', _string_list) # /wd
512 _Same(_compile, 'EnableFiberSafeOptimizations', _boolean) # /GT
513 _Same(_compile, 'EnablePREfast', _boolean) # /analyze Visible='false'
514 _Same(_compile, 'ExpandAttributedSource', _boolean) # /Fx
515 _Same(_compile, 'FloatingPointExceptions', _boolean) # /fp:except
516 _Same(_compile, 'ForceConformanceInForLoopScope', _boolean) # /Zc:forScope
517 _Same(_compile, 'ForcedIncludeFiles', _file_list) # /FI
518 _Same(_compile, 'ForcedUsingFiles', _file_list) # /FU
519 _Same(_compile, 'GenerateXMLDocumentationFiles', _boolean) # /doc
520 _Same(_compile, 'IgnoreStandardIncludePath', _boolean) # /X
521 _Same(_compile, 'MinimalRebuild', _boolean) # /Gm
522 _Same(_compile, 'OmitDefaultLibName', _boolean) # /Zl
523 _Same(_compile, 'OmitFramePointers', _boolean) # /Oy
524 _Same(_compile, 'PreprocessorDefinitions', _string_list) # /D
525 _Same(_compile, 'ProgramDataBaseFileName', _file_name) # /Fd
526 _Same(_compile, 'RuntimeTypeInfo', _boolean) # /GR
527 _Same(_compile, 'ShowIncludes', _boolean) # /showIncludes
528 _Same(_compile, 'SmallerTypeCheck', _boolean) # /RTCc
529 _Same(_compile, 'StringPooling', _boolean) # /GF
530 _Same(_compile, 'SuppressStartupBanner', _boolean) # /nologo
531 _Same(_compile, 'TreatWChar_tAsBuiltInType', _boolean) # /Zc:wchar_t
532 _Same(_compile, 'UndefineAllPreprocessorDefinitions', _boolean) # /u
533 _Same(_compile, 'UndefinePreprocessorDefinitions', _string_list) # /U
534 _Same(_compile, 'UseFullPaths', _boolean) # /FC
535 _Same(_compile, 'WholeProgramOptimization', _boolean) # /GL
536 _Same(_compile, 'XMLDocumentationFileName', _file_name)
537
538 _Same(_compile, 'AssemblerOutput',
539 _Enumeration(['NoListing',
540 'AssemblyCode', # /FA
541 'All', # /FAcs
542 'AssemblyAndMachineCode', # /FAc
543 'AssemblyAndSourceCode'])) # /FAs
544 _Same(_compile, 'BasicRuntimeChecks',
545 _Enumeration(['Default',
546 'StackFrameRuntimeCheck', # /RTCs
547 'UninitializedLocalUsageCheck', # /RTCu
548 'EnableFastChecks'])) # /RTC1
549 _Same(_compile, 'BrowseInformation',
550 _Enumeration(['false',
551 'true', # /FR
552 'true'])) # /Fr
553 _Same(_compile, 'CallingConvention',
554 _Enumeration(['Cdecl', # /Gd
555 'FastCall', # /Gr
556 'StdCall'])) # /Gz
557 _Same(_compile, 'CompileAs',
558 _Enumeration(['Default',
559 'CompileAsC', # /TC
560 'CompileAsCpp'])) # /TP
561 _Same(_compile, 'DebugInformationFormat',
562 _Enumeration(['', # Disabled
563 'OldStyle', # /Z7
564 None,
565 'ProgramDatabase', # /Zi
566 'EditAndContinue'])) # /ZI
567 _Same(_compile, 'EnableEnhancedInstructionSet',
568 _Enumeration(['NotSet',
569 'StreamingSIMDExtensions', # /arch:SSE
570 'StreamingSIMDExtensions2'])) # /arch:SSE2
571 _Same(_compile, 'ErrorReporting',
572 _Enumeration(['None', # /errorReport:none
573 'Prompt', # /errorReport:prompt
574 'Queue'], # /errorReport:queue
575 new=['Send'])) # /errorReport:send"
576 _Same(_compile, 'ExceptionHandling',
577 _Enumeration(['false',
578 'Sync', # /EHsc
579 'Async'], # /EHa
580 new=['SyncCThrow'])) # /EHs
581 _Same(_compile, 'FavorSizeOrSpeed',
582 _Enumeration(['Neither',
583 'Speed', # /Ot
584 'Size'])) # /Os
585 _Same(_compile, 'FloatingPointModel',
586 _Enumeration(['Precise', # /fp:precise
587 'Strict', # /fp:strict
588 'Fast'])) # /fp:fast
589 _Same(_compile, 'InlineFunctionExpansion',
590 _Enumeration(['Default',
591 'OnlyExplicitInline', # /Ob1
592 'AnySuitable'], # /Ob2
593 new=['Disabled'])) # /Ob0
594 _Same(_compile, 'Optimization',
595 _Enumeration(['Disabled', # /Od
596 'MinSpace', # /O1
597 'MaxSpeed', # /O2
598 'Full'])) # /Ox
599 _Same(_compile, 'RuntimeLibrary',
600 _Enumeration(['MultiThreaded', # /MT
601 'MultiThreadedDebug', # /MTd
602 'MultiThreadedDLL', # /MD
603 'MultiThreadedDebugDLL'])) # /MDd
604 _Same(_compile, 'StructMemberAlignment',
605 _Enumeration(['Default',
606 '1Byte', # /Zp1
607 '2Bytes', # /Zp2
608 '4Bytes', # /Zp4
609 '8Bytes', # /Zp8
610 '16Bytes'])) # /Zp16
611 _Same(_compile, 'WarningLevel',
612 _Enumeration(['TurnOffAllWarnings', # /W0
613 'Level1', # /W1
614 'Level2', # /W2
615 'Level3', # /W3
616 'Level4'], # /W4
617 new=['EnableAllWarnings'])) # /Wall
618
619 # Options found in MSVS that have been renamed in MSBuild.
620 _Renamed(_compile, 'EnableFunctionLevelLinking', 'FunctionLevelLinking',
621 _boolean) # /Gy
622 _Renamed(_compile, 'EnableIntrinsicFunctions', 'IntrinsicFunctions',
623 _boolean) # /Oi
624 _Renamed(_compile, 'KeepComments', 'PreprocessKeepComments', _boolean) # /C
625 _Renamed(_compile, 'ObjectFile', 'ObjectFileName', _file_name) # /Fo
626 _Renamed(_compile, 'OpenMP', 'OpenMPSupport', _boolean) # /openmp
627 _Renamed(_compile, 'PrecompiledHeaderThrough', 'PrecompiledHeaderFile',
628 _file_name) # Used with /Yc and /Yu
629 _Renamed(_compile, 'PrecompiledHeaderFile', 'PrecompiledHeaderOutputFile',
630 _file_name) # /Fp
631 _Renamed(_compile, 'UsePrecompiledHeader', 'PrecompiledHeader',
632 _Enumeration(['NotUsing', # VS recognized '' for this value too.
633 'Create', # /Yc
634 'Use'])) # /Yu
635 _Renamed(_compile, 'WarnAsError', 'TreatWarningAsError', _boolean) # /WX
636
637 _ConvertedToAdditionalOption(_compile, 'DefaultCharIsUnsigned', '/J')
638
639 # MSVS options not found in MSBuild.
640 _MSVSOnly(_compile, 'Detect64BitPortabilityProblems', _boolean)
641 _MSVSOnly(_compile, 'UseUnicodeResponseFiles', _boolean)
642
643 # MSBuild options not found in MSVS.
644 _MSBuildOnly(_compile, 'BuildingInIDE', _boolean)
645 _MSBuildOnly(_compile, 'CompileAsManaged',
646 _Enumeration([], new=['false',
647 'true', # /clr
648 'Pure', # /clr:pure
649 'Safe', # /clr:safe
650 'OldSyntax'])) # /clr:oldSyntax
651 _MSBuildOnly(_compile, 'CreateHotpatchableImage', _boolean) # /hotpatch
652 _MSBuildOnly(_compile, 'MultiProcessorCompilation', _boolean) # /MP
653 _MSBuildOnly(_compile, 'PreprocessOutputPath', _string) # /Fi
654 _MSBuildOnly(_compile, 'ProcessorNumber', _integer) # the number of processors
655 _MSBuildOnly(_compile, 'TrackerLogDirectory', _folder_name)
656 _MSBuildOnly(_compile, 'TreatSpecificWarningsAsErrors', _string_list) # /we
657 _MSBuildOnly(_compile, 'UseUnicodeForAssemblerListing', _boolean) # /FAu
658
659 # Defines a setting that needs very customized processing
660 _CustomGeneratePreprocessedFile(_compile, 'GeneratePreprocessedFile')
661
662
663 # Directives for converting MSVS VCLinkerTool to MSBuild Link.
664 # See "c:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\1033\link.xml" for
665 # the schema of the MSBuild Link settings.
666
667 # Options that have the same name in MSVS and MSBuild
668 _Same(_link, 'AdditionalDependencies', _file_list)
669 _Same(_link, 'AdditionalLibraryDirectories', _folder_list) # /LIBPATH
670 # /MANIFESTDEPENDENCY:
671 _Same(_link, 'AdditionalManifestDependencies', _file_list)
672 _Same(_link, 'AdditionalOptions', _string_list)
673 _Same(_link, 'AddModuleNamesToAssembly', _file_list) # /ASSEMBLYMODULE
674 _Same(_link, 'AllowIsolation', _boolean) # /ALLOWISOLATION
675 _Same(_link, 'AssemblyLinkResource', _file_list) # /ASSEMBLYLINKRESOURCE
676 _Same(_link, 'BaseAddress', _string) # /BASE
677 _Same(_link, 'CLRUnmanagedCodeCheck', _boolean) # /CLRUNMANAGEDCODECHECK
678 _Same(_link, 'DelayLoadDLLs', _file_list) # /DELAYLOAD
679 _Same(_link, 'DelaySign', _boolean) # /DELAYSIGN
680 _Same(_link, 'EmbedManagedResourceFile', _file_list) # /ASSEMBLYRESOURCE
681 _Same(_link, 'EnableUAC', _boolean) # /MANIFESTUAC
682 _Same(_link, 'EntryPointSymbol', _string) # /ENTRY
683 _Same(_link, 'ForceSymbolReferences', _file_list) # /INCLUDE
684 _Same(_link, 'FunctionOrder', _file_name) # /ORDER
685 _Same(_link, 'GenerateDebugInformation', _boolean) # /DEBUG
686 _Same(_link, 'GenerateMapFile', _boolean) # /MAP
687 _Same(_link, 'HeapCommitSize', _string)
688 _Same(_link, 'HeapReserveSize', _string) # /HEAP
689 _Same(_link, 'IgnoreAllDefaultLibraries', _boolean) # /NODEFAULTLIB
690 _Same(_link, 'IgnoreEmbeddedIDL', _boolean) # /IGNOREIDL
691 _Same(_link, 'ImportLibrary', _file_name) # /IMPLIB
692 _Same(_link, 'KeyContainer', _file_name) # /KEYCONTAINER
693 _Same(_link, 'KeyFile', _file_name) # /KEYFILE
694 _Same(_link, 'ManifestFile', _file_name) # /ManifestFile
695 _Same(_link, 'MapExports', _boolean) # /MAPINFO:EXPORTS
696 _Same(_link, 'MapFileName', _file_name)
697 _Same(_link, 'MergedIDLBaseFileName', _file_name) # /IDLOUT
698 _Same(_link, 'MergeSections', _string) # /MERGE
699 _Same(_link, 'MidlCommandFile', _file_name) # /MIDL
700 _Same(_link, 'ModuleDefinitionFile', _file_name) # /DEF
701 _Same(_link, 'OutputFile', _file_name) # /OUT
702 _Same(_link, 'PerUserRedirection', _boolean)
703 _Same(_link, 'Profile', _boolean) # /PROFILE
704 _Same(_link, 'ProfileGuidedDatabase', _file_name) # /PGD
705 _Same(_link, 'ProgramDatabaseFile', _file_name) # /PDB
706 _Same(_link, 'RegisterOutput', _boolean)
707 _Same(_link, 'SetChecksum', _boolean) # /RELEASE
708 _Same(_link, 'StackCommitSize', _string)
709 _Same(_link, 'StackReserveSize', _string) # /STACK
710 _Same(_link, 'StripPrivateSymbols', _file_name) # /PDBSTRIPPED
711 _Same(_link, 'SupportUnloadOfDelayLoadedDLL', _boolean) # /DELAY:UNLOAD
712 _Same(_link, 'SuppressStartupBanner', _boolean) # /NOLOGO
713 _Same(_link, 'SwapRunFromCD', _boolean) # /SWAPRUN:CD
714 _Same(_link, 'TurnOffAssemblyGeneration', _boolean) # /NOASSEMBLY
715 _Same(_link, 'TypeLibraryFile', _file_name) # /TLBOUT
716 _Same(_link, 'TypeLibraryResourceID', _integer) # /TLBID
717 _Same(_link, 'UACUIAccess', _boolean) # /uiAccess='true'
718 _Same(_link, 'Version', _string) # /VERSION
719
720 _Same(_link, 'EnableCOMDATFolding', _newly_boolean) # /OPT:ICF
721 _Same(_link, 'FixedBaseAddress', _newly_boolean) # /FIXED
722 _Same(_link, 'LargeAddressAware', _newly_boolean) # /LARGEADDRESSAWARE
723 _Same(_link, 'OptimizeReferences', _newly_boolean) # /OPT:REF
724 _Same(_link, 'RandomizedBaseAddress', _newly_boolean) # /DYNAMICBASE
725 _Same(_link, 'TerminalServerAware', _newly_boolean) # /TSAWARE
726
727 _subsystem_enumeration = _Enumeration(
728 ['NotSet',
729 'Console', # /SUBSYSTEM:CONSOLE
730 'Windows', # /SUBSYSTEM:WINDOWS
731 'Native', # /SUBSYSTEM:NATIVE
732 'EFI Application', # /SUBSYSTEM:EFI_APPLICATION
733 'EFI Boot Service Driver', # /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER
734 'EFI ROM', # /SUBSYSTEM:EFI_ROM
735 'EFI Runtime', # /SUBSYSTEM:EFI_RUNTIME_DRIVER
736 'WindowsCE'], # /SUBSYSTEM:WINDOWSCE
737 new=['POSIX']) # /SUBSYSTEM:POSIX
738
739 _target_machine_enumeration = _Enumeration(
740 ['NotSet',
741 'MachineX86', # /MACHINE:X86
742 None,
743 'MachineARM', # /MACHINE:ARM
744 'MachineEBC', # /MACHINE:EBC
745 'MachineIA64', # /MACHINE:IA64
746 None,
747 'MachineMIPS', # /MACHINE:MIPS
748 'MachineMIPS16', # /MACHINE:MIPS16
749 'MachineMIPSFPU', # /MACHINE:MIPSFPU
750 'MachineMIPSFPU16', # /MACHINE:MIPSFPU16
751 None,
752 None,
753 None,
754 'MachineSH4', # /MACHINE:SH4
755 None,
756 'MachineTHUMB', # /MACHINE:THUMB
757 'MachineX64']) # /MACHINE:X64
758
759 _Same(_link, 'AssemblyDebug',
760 _Enumeration(['',
761 'true', # /ASSEMBLYDEBUG
762 'false'])) # /ASSEMBLYDEBUG:DISABLE
763 _Same(_link, 'CLRImageType',
764 _Enumeration(['Default',
765 'ForceIJWImage', # /CLRIMAGETYPE:IJW
766 'ForcePureILImage', # /Switch="CLRIMAGETYPE:PURE
767 'ForceSafeILImage'])) # /Switch="CLRIMAGETYPE:SAFE
768 _Same(_link, 'CLRThreadAttribute',
769 _Enumeration(['DefaultThreadingAttribute', # /CLRTHREADATTRIBUTE:NONE
770 'MTAThreadingAttribute', # /CLRTHREADATTRIBUTE:MTA
771 'STAThreadingAttribute'])) # /CLRTHREADATTRIBUTE:STA
772 _Same(_link, 'DataExecutionPrevention',
773 _Enumeration(['',
774 'false', # /NXCOMPAT:NO
775 'true'])) # /NXCOMPAT
776 _Same(_link, 'Driver',
777 _Enumeration(['NotSet',
778 'Driver', # /Driver
779 'UpOnly', # /DRIVER:UPONLY
780 'WDM'])) # /DRIVER:WDM
781 _Same(_link, 'LinkTimeCodeGeneration',
782 _Enumeration(['Default',
783 'UseLinkTimeCodeGeneration', # /LTCG
784 'PGInstrument', # /LTCG:PGInstrument
785 'PGOptimization', # /LTCG:PGOptimize
786 'PGUpdate'])) # /LTCG:PGUpdate
787 _Same(_link, 'ShowProgress',
788 _Enumeration(['NotSet',
789 'LinkVerbose', # /VERBOSE
790 'LinkVerboseLib'], # /VERBOSE:Lib
791 new=['LinkVerboseICF', # /VERBOSE:ICF
792 'LinkVerboseREF', # /VERBOSE:REF
793 'LinkVerboseSAFESEH', # /VERBOSE:SAFESEH
794 'LinkVerboseCLR'])) # /VERBOSE:CLR
795 _Same(_link, 'SubSystem', _subsystem_enumeration)
796 _Same(_link, 'TargetMachine', _target_machine_enumeration)
797 _Same(_link, 'UACExecutionLevel',
798 _Enumeration(['AsInvoker', # /level='asInvoker'
799 'HighestAvailable', # /level='highestAvailable'
800 'RequireAdministrator'])) # /level='requireAdministrator'
801
802
803 # Options found in MSVS that have been renamed in MSBuild.
804 _Renamed(_link, 'ErrorReporting', 'LinkErrorReporting',
805 _Enumeration(['NoErrorReport', # /ERRORREPORT:NONE
806 'PromptImmediately', # /ERRORREPORT:PROMPT
807 'QueueForNextLogin'], # /ERRORREPORT:QUEUE
808 new=['SendErrorReport'])) # /ERRORREPORT:SEND
809 _Renamed(_link, 'IgnoreDefaultLibraryNames', 'IgnoreSpecificDefaultLibraries',
810 _file_list) # /NODEFAULTLIB
811 _Renamed(_link, 'ResourceOnlyDLL', 'NoEntryPoint', _boolean) # /NOENTRY
812 _Renamed(_link, 'SwapRunFromNet', 'SwapRunFromNET', _boolean) # /SWAPRUN:NET
813
814 _Moved(_link, 'GenerateManifest', '', _boolean)
815 _Moved(_link, 'IgnoreImportLibrary', '', _boolean)
816 _Moved(_link, 'LinkIncremental', '', _newly_boolean)
817 _Moved(_link, 'LinkLibraryDependencies', 'ProjectReference', _boolean)
818 _Moved(_link, 'UseLibraryDependencyInputs', 'ProjectReference', _boolean)
819
820 # MSVS options not found in MSBuild.
821 _MSVSOnly(_link, 'OptimizeForWindows98', _newly_boolean)
822 _MSVSOnly(_link, 'UseUnicodeResponseFiles', _boolean)
823 # TODO(jeanluc) I don't think these are genuine settings but byproducts of Gyp.
824 _MSVSOnly(_link, 'AdditionalLibraryDirectories_excluded', _folder_list)
825
826 # MSBuild options not found in MSVS.
827 _MSBuildOnly(_link, 'BuildingInIDE', _boolean)
828 _MSBuildOnly(_link, 'ImageHasSafeExceptionHandlers', _boolean) # /SAFESEH
829 _MSBuildOnly(_link, 'LinkDLL', _boolean) # /DLL Visible='false'
830 _MSBuildOnly(_link, 'LinkStatus', _boolean) # /LTCG:STATUS
831 _MSBuildOnly(_link, 'PreventDllBinding', _boolean) # /ALLOWBIND
832 _MSBuildOnly(_link, 'SupportNobindOfDelayLoadedDLL', _boolean) # /DELAY:NOBIND
833 _MSBuildOnly(_link, 'TrackerLogDirectory', _folder_name)
834 _MSBuildOnly(_link, 'TreatLinkerWarningAsErrors', _boolean) # /WX
835 _MSBuildOnly(_link, 'MinimumRequiredVersion', _string)
836 _MSBuildOnly(_link, 'MSDOSStubFileName', _file_name) # /STUB Visible='false'
837 _MSBuildOnly(_link, 'SectionAlignment', _integer) # /ALIGN
838 _MSBuildOnly(_link, 'SpecifySectionAttributes', _string) # /SECTION
839 _MSBuildOnly(_link, 'ForceFileOutput',
840 _Enumeration([], new=['Enabled', # /FORCE
841 # /FORCE:MULTIPLE
842 'MultiplyDefinedSymbolOnly',
843 'UndefinedSymbolOnly'])) # /FORCE:UNRESOLVED
844 _MSBuildOnly(_link, 'CreateHotPatchableImage',
845 _Enumeration([], new=['Enabled', # /FUNCTIONPADMIN
846 'X86Image', # /FUNCTIONPADMIN:5
847 'X64Image', # /FUNCTIONPADMIN:6
848 'ItaniumImage'])) # /FUNCTIONPADMIN:16
849 _MSBuildOnly(_link, 'CLRSupportLastError',
850 _Enumeration([], new=['Enabled', # /CLRSupportLastError
851 'Disabled', # /CLRSupportLastError:NO
852 # /CLRSupportLastError:SYSTEMDLL
853 'SystemDlls']))
854
855
856 # Directives for converting VCResourceCompilerTool to ResourceCompile.
857 # See "c:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\1033\rc.xml" for
858 # the schema of the MSBuild ResourceCompile settings.
859
860 _Same(_rc, 'AdditionalOptions', _string_list)
861 _Same(_rc, 'AdditionalIncludeDirectories', _folder_list) # /I
862 _Same(_rc, 'Culture', _Integer(msbuild_base=16))
863 _Same(_rc, 'IgnoreStandardIncludePath', _boolean) # /X
864 _Same(_rc, 'PreprocessorDefinitions', _string_list) # /D
865 _Same(_rc, 'ResourceOutputFileName', _string) # /fo
866 _Same(_rc, 'ShowProgress', _boolean) # /v
867 # There is no UI in VisualStudio 2008 to set the following properties.
868 # However they are found in CL and other tools. Include them here for
869 # completeness, as they are very likely to have the same usage pattern.
870 _Same(_rc, 'SuppressStartupBanner', _boolean) # /nologo
871 _Same(_rc, 'UndefinePreprocessorDefinitions', _string_list) # /u
872
873 # MSBuild options not found in MSVS.
874 _MSBuildOnly(_rc, 'NullTerminateStrings', _boolean) # /n
875 _MSBuildOnly(_rc, 'TrackerLogDirectory', _folder_name)
876
877
878 # Directives for converting VCMIDLTool to Midl.
879 # See "c:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\1033\midl.xml" for
880 # the schema of the MSBuild Midl settings.
881
882 _Same(_midl, 'AdditionalIncludeDirectories', _folder_list) # /I
883 _Same(_midl, 'AdditionalOptions', _string_list)
884 _Same(_midl, 'CPreprocessOptions', _string) # /cpp_opt
885 _Same(_midl, 'ErrorCheckAllocations', _boolean) # /error allocation
886 _Same(_midl, 'ErrorCheckBounds', _boolean) # /error bounds_check
887 _Same(_midl, 'ErrorCheckEnumRange', _boolean) # /error enum
888 _Same(_midl, 'ErrorCheckRefPointers', _boolean) # /error ref
889 _Same(_midl, 'ErrorCheckStubData', _boolean) # /error stub_data
890 _Same(_midl, 'GenerateStublessProxies', _boolean) # /Oicf
891 _Same(_midl, 'GenerateTypeLibrary', _boolean)
892 _Same(_midl, 'HeaderFileName', _file_name) # /h
893 _Same(_midl, 'IgnoreStandardIncludePath', _boolean) # /no_def_idir
894 _Same(_midl, 'InterfaceIdentifierFileName', _file_name) # /iid
895 _Same(_midl, 'MkTypLibCompatible', _boolean) # /mktyplib203
896 _Same(_midl, 'OutputDirectory', _string) # /out
897 _Same(_midl, 'PreprocessorDefinitions', _string_list) # /D
898 _Same(_midl, 'ProxyFileName', _file_name) # /proxy
899 _Same(_midl, 'RedirectOutputAndErrors', _file_name) # /o
900 _Same(_midl, 'SuppressStartupBanner', _boolean) # /nologo
901 _Same(_midl, 'TypeLibraryName', _file_name) # /tlb
902 _Same(_midl, 'UndefinePreprocessorDefinitions', _string_list) # /U
903 _Same(_midl, 'WarnAsError', _boolean) # /WX
904
905 _Same(_midl, 'DefaultCharType',
906 _Enumeration(['Unsigned', # /char unsigned
907 'Signed', # /char signed
908 'Ascii'])) # /char ascii7
909 _Same(_midl, 'TargetEnvironment',
910 _Enumeration(['NotSet',
911 'Win32', # /env win32
912 'Itanium', # /env ia64
913 'X64'])) # /env x64
914 _Same(_midl, 'EnableErrorChecks',
915 _Enumeration(['EnableCustom',
916 'None', # /error none
917 'All'])) # /error all
918 _Same(_midl, 'StructMemberAlignment',
919 _Enumeration(['NotSet',
920 '1', # Zp1
921 '2', # Zp2
922 '4', # Zp4
923 '8'])) # Zp8
924 _Same(_midl, 'WarningLevel',
925 _Enumeration(['0', # /W0
926 '1', # /W1
927 '2', # /W2
928 '3', # /W3
929 '4'])) # /W4
930
931 _Renamed(_midl, 'DLLDataFileName', 'DllDataFileName', _file_name) # /dlldata
932 _Renamed(_midl, 'ValidateParameters', 'ValidateAllParameters',
933 _boolean) # /robust
934
935 # MSBuild options not found in MSVS.
936 _MSBuildOnly(_midl, 'ApplicationConfigurationMode', _boolean) # /app_config
937 _MSBuildOnly(_midl, 'ClientStubFile', _file_name) # /cstub
938 _MSBuildOnly(_midl, 'GenerateClientFiles',
939 _Enumeration([], new=['Stub', # /client stub
940 'None'])) # /client none
941 _MSBuildOnly(_midl, 'GenerateServerFiles',
942 _Enumeration([], new=['Stub', # /client stub
943 'None'])) # /client none
944 _MSBuildOnly(_midl, 'LocaleID', _integer) # /lcid DECIMAL
945 _MSBuildOnly(_midl, 'ServerStubFile', _file_name) # /sstub
946 _MSBuildOnly(_midl, 'SuppressCompilerWarnings', _boolean) # /no_warn
947 _MSBuildOnly(_midl, 'TrackerLogDirectory', _folder_name)
948 _MSBuildOnly(_midl, 'TypeLibFormat',
949 _Enumeration([], new=['NewFormat', # /newtlb
950 'OldFormat'])) # /oldtlb
951
952
953 # Directives for converting VCLibrarianTool to Lib.
954 # See "c:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\1033\lib.xml" for
955 # the schema of the MSBuild Lib settings.
956
957 _Same(_lib, 'AdditionalDependencies', _file_list)
958 _Same(_lib, 'AdditionalLibraryDirectories', _folder_list) # /LIBPATH
959 _Same(_lib, 'AdditionalOptions', _string_list)
960 _Same(_lib, 'ExportNamedFunctions', _string_list) # /EXPORT
961 _Same(_lib, 'ForceSymbolReferences', _string) # /INCLUDE
962 _Same(_lib, 'IgnoreAllDefaultLibraries', _boolean) # /NODEFAULTLIB
963 _Same(_lib, 'IgnoreSpecificDefaultLibraries', _file_list) # /NODEFAULTLIB
964 _Same(_lib, 'ModuleDefinitionFile', _file_name) # /DEF
965 _Same(_lib, 'OutputFile', _file_name) # /OUT
966 _Same(_lib, 'SuppressStartupBanner', _boolean) # /NOLOGO
967 _Same(_lib, 'UseUnicodeResponseFiles', _boolean)
968
969 # TODO(jeanluc) _link defines the same value that gets moved to
970 # ProjectReference. We may want to validate that they are consistent.
971 _Moved(_lib, 'LinkLibraryDependencies', 'ProjectReference', _boolean)
972
973 # TODO(jeanluc) I don't think these are genuine settings but byproducts of Gyp.
974 _MSVSOnly(_lib, 'AdditionalLibraryDirectories_excluded', _folder_list)
975
976 _MSBuildOnly(_lib, 'DisplayLibrary', _string) # /LIST Visible='false'
977 _MSBuildOnly(_lib, 'ErrorReporting',
978 _Enumeration([], new=['PromptImmediately', # /ERRORREPORT:PROMPT
979 'QueueForNextLogin', # /ERRORREPORT:QUEUE
980 'SendErrorReport', # /ERRORREPORT:SEND
981 'NoErrorReport'])) # /ERRORREPORT:NONE
982 _MSBuildOnly(_lib, 'LinkTimeCodeGeneration', _boolean) # /LTCG
983 _MSBuildOnly(_lib, 'MinimumRequiredVersion', _string)
984 _MSBuildOnly(_lib, 'Name', _file_name) # /NAME
985 _MSBuildOnly(_lib, 'RemoveObjects', _file_list) # /REMOVE
986 _MSBuildOnly(_lib, 'SubSystem', _subsystem_enumeration)
987 _MSBuildOnly(_lib, 'TargetMachine', _target_machine_enumeration)
988 _MSBuildOnly(_lib, 'TrackerLogDirectory', _folder_name)
989 _MSBuildOnly(_lib, 'TreatLibWarningAsErrors', _boolean) # /WX
990 _MSBuildOnly(_lib, 'Verbose', _boolean)
991
992
993 # Directives for converting VCManifestTool to Mt.
994 # See "c:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\1033\mt.xml" for
995 # the schema of the MSBuild Lib settings.
996
997 # Options that have the same name in MSVS and MSBuild
998 _Same(_manifest, 'AdditionalManifestFiles', _file_list) # /manifest
999 _Same(_manifest, 'AdditionalOptions', _string_list)
1000 _Same(_manifest, 'AssemblyIdentity', _string) # /identity:
1001 _Same(_manifest, 'ComponentFileName', _file_name) # /dll
1002 _Same(_manifest, 'GenerateCatalogFiles', _boolean) # /makecdfs
1003 _Same(_manifest, 'InputResourceManifests', _string) # /inputresource
1004 _Same(_manifest, 'OutputManifestFile', _file_name) # /out
1005 _Same(_manifest, 'RegistrarScriptFile', _file_name) # /rgs
1006 _Same(_manifest, 'ReplacementsFile', _file_name) # /replacements
1007 _Same(_manifest, 'SuppressStartupBanner', _boolean) # /nologo
1008 _Same(_manifest, 'TypeLibraryFile', _file_name) # /tlb:
1009 _Same(_manifest, 'UpdateFileHashes', _boolean) # /hashupdate
1010 _Same(_manifest, 'UpdateFileHashesSearchPath', _file_name)
1011 _Same(_manifest, 'VerboseOutput', _boolean) # /verbose
1012
1013 # Options that have moved location.
1014 _MovedAndRenamed(_manifest, 'ManifestResourceFile',
1015 'ManifestResourceCompile',
1016 'ResourceOutputFileName',
1017 _file_name)
1018 _Moved(_manifest, 'EmbedManifest', '', _boolean)
1019
1020 # MSVS options not found in MSBuild.
1021 _MSVSOnly(_manifest, 'DependencyInformationFile', _file_name)
1022 _MSVSOnly(_manifest, 'UseFAT32Workaround', _boolean)
1023 _MSVSOnly(_manifest, 'UseUnicodeResponseFiles', _boolean)
1024
1025 # MSBuild options not found in MSVS.
1026 _MSBuildOnly(_manifest, 'EnableDPIAwareness', _boolean)
1027 _MSBuildOnly(_manifest, 'GenerateCategoryTags', _boolean) # /category
1028 _MSBuildOnly(_manifest, 'ManifestFromManagedAssembly',
1029 _file_name) # /managedassemblyname
1030 _MSBuildOnly(_manifest, 'OutputResourceManifests', _string) # /outputresource
1031 _MSBuildOnly(_manifest, 'SuppressDependencyElement', _boolean) # /nodependency
1032 _MSBuildOnly(_manifest, 'TrackerLogDirectory', _folder_name)
+0
-1480
third_party/gyp/pylib/gyp/MSVSSettings_test.py less more
0 #!/usr/bin/python
1
2 # Copyright (c) 2011 Google Inc. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
5
6 """Unit tests for the MSVSSettings.py file."""
7
8 import StringIO
9 import unittest
10 import gyp.MSVSSettings as MSVSSettings
11
12
13 class TestSequenceFunctions(unittest.TestCase):
14
15 def setUp(self):
16 self.stderr = StringIO.StringIO()
17
18 def _ExpectedWarnings(self, expected):
19 """Compares recorded lines to expected warnings."""
20 self.stderr.seek(0)
21 actual = self.stderr.read().split('\n')
22 actual = [line for line in actual if line]
23 self.assertEqual(sorted(expected), sorted(actual))
24
25 def testValidateMSVSSettings_tool_names(self):
26 """Tests that only MSVS tool names are allowed."""
27 MSVSSettings.ValidateMSVSSettings(
28 {'VCCLCompilerTool': {},
29 'VCLinkerTool': {},
30 'VCMIDLTool': {},
31 'foo': {},
32 'VCResourceCompilerTool': {},
33 'VCLibrarianTool': {},
34 'VCManifestTool': {},
35 'ClCompile': {}},
36 self.stderr)
37 self._ExpectedWarnings([
38 'Warning: unrecognized tool foo',
39 'Warning: unrecognized tool ClCompile'])
40
41 def testValidateMSVSSettings_settings(self):
42 """Tests that for invalid MSVS settings."""
43 MSVSSettings.ValidateMSVSSettings(
44 {'VCCLCompilerTool': {
45 'AdditionalIncludeDirectories': 'folder1;folder2',
46 'AdditionalOptions': ['string1', 'string2'],
47 'AdditionalUsingDirectories': 'folder1;folder2',
48 'AssemblerListingLocation': 'a_file_name',
49 'AssemblerOutput': '0',
50 'BasicRuntimeChecks': '5',
51 'BrowseInformation': 'fdkslj',
52 'BrowseInformationFile': 'a_file_name',
53 'BufferSecurityCheck': 'true',
54 'CallingConvention': '-1',
55 'CompileAs': '1',
56 'DebugInformationFormat': '2',
57 'DefaultCharIsUnsigned': 'true',
58 'Detect64BitPortabilityProblems': 'true',
59 'DisableLanguageExtensions': 'true',
60 'DisableSpecificWarnings': 'string1;string2',
61 'EnableEnhancedInstructionSet': '1',
62 'EnableFiberSafeOptimizations': 'true',
63 'EnableFunctionLevelLinking': 'true',
64 'EnableIntrinsicFunctions': 'true',
65 'EnablePREfast': 'true',
66 'Enableprefast': 'bogus',
67 'ErrorReporting': '1',
68 'ExceptionHandling': '1',
69 'ExpandAttributedSource': 'true',
70 'FavorSizeOrSpeed': '1',
71 'FloatingPointExceptions': 'true',
72 'FloatingPointModel': '1',
73 'ForceConformanceInForLoopScope': 'true',
74 'ForcedIncludeFiles': 'file1;file2',
75 'ForcedUsingFiles': 'file1;file2',
76 'GeneratePreprocessedFile': '1',
77 'GenerateXMLDocumentationFiles': 'true',
78 'IgnoreStandardIncludePath': 'true',
79 'InlineFunctionExpansion': '1',
80 'KeepComments': 'true',
81 'MinimalRebuild': 'true',
82 'ObjectFile': 'a_file_name',
83 'OmitDefaultLibName': 'true',
84 'OmitFramePointers': 'true',
85 'OpenMP': 'true',
86 'Optimization': '1',
87 'PrecompiledHeaderFile': 'a_file_name',
88 'PrecompiledHeaderThrough': 'a_file_name',
89 'PreprocessorDefinitions': 'string1;string2',
90 'ProgramDataBaseFileName': 'a_file_name',
91 'RuntimeLibrary': '1',
92 'RuntimeTypeInfo': 'true',
93 'ShowIncludes': 'true',
94 'SmallerTypeCheck': 'true',
95 'StringPooling': 'true',
96 'StructMemberAlignment': '1',
97 'SuppressStartupBanner': 'true',
98 'TreatWChar_tAsBuiltInType': 'true',
99 'UndefineAllPreprocessorDefinitions': 'true',
100 'UndefinePreprocessorDefinitions': 'string1;string2',
101 'UseFullPaths': 'true',
102 'UsePrecompiledHeader': '1',
103 'UseUnicodeResponseFiles': 'true',
104 'WarnAsError': 'true',
105 'WarningLevel': '1',
106 'WholeProgramOptimization': 'true',
107 'XMLDocumentationFileName': 'a_file_name',
108 'ZZXYZ': 'bogus'},
109 'VCLinkerTool': {
110 'AdditionalDependencies': 'file1;file2',
111 'AdditionalLibraryDirectories': 'folder1;folder2',
112 'AdditionalManifestDependencies': 'file1;file2',
113 'AdditionalOptions': 'a string1',
114 'AddModuleNamesToAssembly': 'file1;file2',
115 'AllowIsolation': 'true',
116 'AssemblyDebug': '2',
117 'AssemblyLinkResource': 'file1;file2',
118 'BaseAddress': 'a string1',
119 'CLRImageType': '2',
120 'CLRThreadAttribute': '2',
121 'CLRUnmanagedCodeCheck': 'true',
122 'DataExecutionPrevention': '2',
123 'DelayLoadDLLs': 'file1;file2',
124 'DelaySign': 'true',
125 'Driver': '2',
126 'EmbedManagedResourceFile': 'file1;file2',
127 'EnableCOMDATFolding': '2',
128 'EnableUAC': 'true',
129 'EntryPointSymbol': 'a string1',
130 'ErrorReporting': '2',
131 'FixedBaseAddress': '2',
132 'ForceSymbolReferences': 'file1;file2',
133 'FunctionOrder': 'a_file_name',
134 'GenerateDebugInformation': 'true',
135 'GenerateManifest': 'true',
136 'GenerateMapFile': 'true',
137 'HeapCommitSize': 'a string1',
138 'HeapReserveSize': 'a string1',
139 'IgnoreAllDefaultLibraries': 'true',
140 'IgnoreDefaultLibraryNames': 'file1;file2',
141 'IgnoreEmbeddedIDL': 'true',
142 'IgnoreImportLibrary': 'true',
143 'ImportLibrary': 'a_file_name',
144 'KeyContainer': 'a_file_name',
145 'KeyFile': 'a_file_name',
146 'LargeAddressAware': '2',
147 'LinkIncremental': '2',
148 'LinkLibraryDependencies': 'true',
149 'LinkTimeCodeGeneration': '2',
150 'ManifestFile': 'a_file_name',
151 'MapExports': 'true',
152 'MapFileName': 'a_file_name',
153 'MergedIDLBaseFileName': 'a_file_name',
154 'MergeSections': 'a string1',
155 'MidlCommandFile': 'a_file_name',
156 'ModuleDefinitionFile': 'a_file_name',
157 'OptimizeForWindows98': '1',
158 'OptimizeReferences': '2',
159 'OutputFile': 'a_file_name',
160 'PerUserRedirection': 'true',
161 'Profile': 'true',
162 'ProfileGuidedDatabase': 'a_file_name',
163 'ProgramDatabaseFile': 'a_file_name',
164 'RandomizedBaseAddress': '2',
165 'RegisterOutput': 'true',
166 'ResourceOnlyDLL': 'true',
167 'SetChecksum': 'true',
168 'ShowProgress': '2',
169 'StackCommitSize': 'a string1',
170 'StackReserveSize': 'a string1',
171 'StripPrivateSymbols': 'a_file_name',
172 'SubSystem': '2',
173 'SupportUnloadOfDelayLoadedDLL': 'true',
174 'SuppressStartupBanner': 'true',
175 'SwapRunFromCD': 'true',
176 'SwapRunFromNet': 'true',
177 'TargetMachine': '2',
178 'TerminalServerAware': '2',
179 'TurnOffAssemblyGeneration': 'true',
180 'TypeLibraryFile': 'a_file_name',
181 'TypeLibraryResourceID': '33',
182 'UACExecutionLevel': '2',
183 'UACUIAccess': 'true',
184 'UseLibraryDependencyInputs': 'true',
185 'UseUnicodeResponseFiles': 'true',
186 'Version': 'a string1'},
187 'VCMIDLTool': {
188 'AdditionalIncludeDirectories': 'folder1;folder2',
189 'AdditionalOptions': 'a string1',
190 'CPreprocessOptions': 'a string1',
191 'DefaultCharType': '1',
192 'DLLDataFileName': 'a_file_name',
193 'EnableErrorChecks': '1',
194 'ErrorCheckAllocations': 'true',
195 'ErrorCheckBounds': 'true',
196 'ErrorCheckEnumRange': 'true',
197 'ErrorCheckRefPointers': 'true',
198 'ErrorCheckStubData': 'true',
199 'GenerateStublessProxies': 'true',
200 'GenerateTypeLibrary': 'true',
201 'HeaderFileName': 'a_file_name',
202 'IgnoreStandardIncludePath': 'true',
203 'InterfaceIdentifierFileName': 'a_file_name',
204 'MkTypLibCompatible': 'true',
205 'notgood': 'bogus',
206 'OutputDirectory': 'a string1',
207 'PreprocessorDefinitions': 'string1;string2',
208 'ProxyFileName': 'a_file_name',
209 'RedirectOutputAndErrors': 'a_file_name',
210 'StructMemberAlignment': '1',
211 'SuppressStartupBanner': 'true',
212 'TargetEnvironment': '1',
213 'TypeLibraryName': 'a_file_name',
214 'UndefinePreprocessorDefinitions': 'string1;string2',
215 'ValidateParameters': 'true',
216 'WarnAsError': 'true',
217 'WarningLevel': '1'},
218 'VCResourceCompilerTool': {
219 'AdditionalOptions': 'a string1',
220 'AdditionalIncludeDirectories': 'folder1;folder2',
221 'Culture': '1003',
222 'IgnoreStandardIncludePath': 'true',
223 'notgood2': 'bogus',
224 'PreprocessorDefinitions': 'string1;string2',
225 'ResourceOutputFileName': 'a string1',
226 'ShowProgress': 'true',
227 'SuppressStartupBanner': 'true',
228 'UndefinePreprocessorDefinitions': 'string1;string2'},
229 'VCLibrarianTool': {
230 'AdditionalDependencies': 'file1;file2',
231 'AdditionalLibraryDirectories': 'folder1;folder2',
232 'AdditionalOptions': 'a string1',
233 'ExportNamedFunctions': 'string1;string2',
234 'ForceSymbolReferences': 'a string1',
235 'IgnoreAllDefaultLibraries': 'true',
236 'IgnoreSpecificDefaultLibraries': 'file1;file2',
237 'LinkLibraryDependencies': 'true',
238 'ModuleDefinitionFile': 'a_file_name',
239 'OutputFile': 'a_file_name',
240 'SuppressStartupBanner': 'true',
241 'UseUnicodeResponseFiles': 'true'},
242 'VCManifestTool': {
243 'AdditionalManifestFiles': 'file1;file2',
244 'AdditionalOptions': 'a string1',
245 'AssemblyIdentity': 'a string1',
246 'ComponentFileName': 'a_file_name',
247 'DependencyInformationFile': 'a_file_name',
248 'GenerateCatalogFiles': 'true',
249 'InputResourceManifests': 'a string1',
250 'ManifestResourceFile': 'a_file_name',
251 'OutputManifestFile': 'a_file_name',
252 'RegistrarScriptFile': 'a_file_name',
253 'ReplacementsFile': 'a_file_name',
254 'SuppressStartupBanner': 'true',
255 'TypeLibraryFile': 'a_file_name',
256 'UpdateFileHashes': 'truel',
257 'UpdateFileHashesSearchPath': 'a_file_name',
258 'UseFAT32Workaround': 'true',
259 'UseUnicodeResponseFiles': 'true',
260 'VerboseOutput': 'true'}},
261 self.stderr)
262 self._ExpectedWarnings([
263 'Warning: for VCCLCompilerTool/BasicRuntimeChecks, '
264 'index value (5) not in expected range [0, 4)',
265 'Warning: for VCCLCompilerTool/BrowseInformation, '
266 "invalid literal for int() with base 10: 'fdkslj'",
267 'Warning: for VCCLCompilerTool/CallingConvention, '
268 'index value (-1) not in expected range [0, 3)',
269 'Warning: for VCCLCompilerTool/DebugInformationFormat, '
270 'converted value for 2 not specified.',
271 'Warning: unrecognized setting VCCLCompilerTool/Enableprefast',
272 'Warning: unrecognized setting VCCLCompilerTool/ZZXYZ',
273 'Warning: for VCLinkerTool/TargetMachine, '
274 'converted value for 2 not specified.',
275 'Warning: unrecognized setting VCMIDLTool/notgood',
276 'Warning: unrecognized setting VCResourceCompilerTool/notgood2',
277 'Warning: for VCManifestTool/UpdateFileHashes, '
278 "expected bool; got 'truel'"
279 ''])
280
281 def testValidateMSBuildSettings_settings(self):
282 """Tests that for invalid MSBuild settings."""
283 MSVSSettings.ValidateMSBuildSettings(
284 {'ClCompile': {
285 'AdditionalIncludeDirectories': 'folder1;folder2',
286 'AdditionalOptions': ['string1', 'string2'],
287 'AdditionalUsingDirectories': 'folder1;folder2',
288 'AssemblerListingLocation': 'a_file_name',
289 'AssemblerOutput': 'NoListing',
290 'BasicRuntimeChecks': 'StackFrameRuntimeCheck',
291 'BrowseInformation': 'false',
292 'BrowseInformationFile': 'a_file_name',
293 'BufferSecurityCheck': 'true',
294 'BuildingInIDE': 'true',
295 'CallingConvention': 'Cdecl',
296 'CompileAs': 'CompileAsC',
297 'CompileAsManaged': 'Pure',
298 'CreateHotpatchableImage': 'true',
299 'DebugInformationFormat': 'ProgramDatabase',
300 'DisableLanguageExtensions': 'true',
301 'DisableSpecificWarnings': 'string1;string2',
302 'EnableEnhancedInstructionSet': 'StreamingSIMDExtensions',
303 'EnableFiberSafeOptimizations': 'true',
304 'EnablePREfast': 'true',
305 'Enableprefast': 'bogus',
306 'ErrorReporting': 'Prompt',
307 'ExceptionHandling': 'SyncCThrow',
308 'ExpandAttributedSource': 'true',
309 'FavorSizeOrSpeed': 'Neither',
310 'FloatingPointExceptions': 'true',
311 'FloatingPointModel': 'Precise',
312 'ForceConformanceInForLoopScope': 'true',
313 'ForcedIncludeFiles': 'file1;file2',
314 'ForcedUsingFiles': 'file1;file2',
315 'FunctionLevelLinking': 'false',
316 'GenerateXMLDocumentationFiles': 'true',
317 'IgnoreStandardIncludePath': 'true',
318 'InlineFunctionExpansion': 'OnlyExplicitInline',
319 'IntrinsicFunctions': 'false',
320 'MinimalRebuild': 'true',
321 'MultiProcessorCompilation': 'true',
322 'ObjectFileName': 'a_file_name',
323 'OmitDefaultLibName': 'true',
324 'OmitFramePointers': 'true',
325 'OpenMPSupport': 'true',
326 'Optimization': 'Disabled',
327 'PrecompiledHeader': 'NotUsing',
328 'PrecompiledHeaderFile': 'a_file_name',
329 'PrecompiledHeaderOutputFile': 'a_file_name',
330 'PreprocessKeepComments': 'true',
331 'PreprocessorDefinitions': 'string1;string2',
332 'PreprocessOutputPath': 'a string1',
333 'PreprocessSuppressLineNumbers': 'false',
334 'PreprocessToFile': 'false',
335 'ProcessorNumber': '33',
336 'ProgramDataBaseFileName': 'a_file_name',
337 'RuntimeLibrary': 'MultiThreaded',
338 'RuntimeTypeInfo': 'true',
339 'ShowIncludes': 'true',
340 'SmallerTypeCheck': 'true',
341 'StringPooling': 'true',
342 'StructMemberAlignment': '1Byte',
343 'SuppressStartupBanner': 'true',
344 'TrackerLogDirectory': 'a_folder',
345 'TreatSpecificWarningsAsErrors': 'string1;string2',
346 'TreatWarningAsError': 'true',
347 'TreatWChar_tAsBuiltInType': 'true',
348 'UndefineAllPreprocessorDefinitions': 'true',
349 'UndefinePreprocessorDefinitions': 'string1;string2',
350 'UseFullPaths': 'true',
351 'UseUnicodeForAssemblerListing': 'true',
352 'WarningLevel': 'TurnOffAllWarnings',
353 'WholeProgramOptimization': 'true',
354 'XMLDocumentationFileName': 'a_file_name',
355 'ZZXYZ': 'bogus'},
356 'Link': {
357 'AdditionalDependencies': 'file1;file2',
358 'AdditionalLibraryDirectories': 'folder1;folder2',
359 'AdditionalManifestDependencies': 'file1;file2',
360 'AdditionalOptions': 'a string1',
361 'AddModuleNamesToAssembly': 'file1;file2',
362 'AllowIsolation': 'true',
363 'AssemblyDebug': '',
364 'AssemblyLinkResource': 'file1;file2',
365 'BaseAddress': 'a string1',
366 'BuildingInIDE': 'true',
367 'CLRImageType': 'ForceIJWImage',
368 'CLRSupportLastError': 'Enabled',
369 'CLRThreadAttribute': 'MTAThreadingAttribute',
370 'CLRUnmanagedCodeCheck': 'true',
371 'CreateHotPatchableImage': 'X86Image',
372 'DataExecutionPrevention': 'false',
373 'DelayLoadDLLs': 'file1;file2',
374 'DelaySign': 'true',
375 'Driver': 'NotSet',
376 'EmbedManagedResourceFile': 'file1;file2',
377 'EnableCOMDATFolding': 'false',
378 'EnableUAC': 'true',
379 'EntryPointSymbol': 'a string1',
380 'FixedBaseAddress': 'false',
381 'ForceFileOutput': 'Enabled',
382 'ForceSymbolReferences': 'file1;file2',
383 'FunctionOrder': 'a_file_name',
384 'GenerateDebugInformation': 'true',
385 'GenerateMapFile': 'true',
386 'HeapCommitSize': 'a string1',
387 'HeapReserveSize': 'a string1',
388 'IgnoreAllDefaultLibraries': 'true',
389 'IgnoreEmbeddedIDL': 'true',
390 'IgnoreSpecificDefaultLibraries': 'a_file_list',
391 'ImageHasSafeExceptionHandlers': 'true',
392 'ImportLibrary': 'a_file_name',
393 'KeyContainer': 'a_file_name',
394 'KeyFile': 'a_file_name',
395 'LargeAddressAware': 'false',
396 'LinkDLL': 'true',
397 'LinkErrorReporting': 'SendErrorReport',
398 'LinkStatus': 'true',
399 'LinkTimeCodeGeneration': 'UseLinkTimeCodeGeneration',
400 'ManifestFile': 'a_file_name',
401 'MapExports': 'true',
402 'MapFileName': 'a_file_name',
403 'MergedIDLBaseFileName': 'a_file_name',
404 'MergeSections': 'a string1',
405 'MidlCommandFile': 'a_file_name',
406 'MinimumRequiredVersion': 'a string1',
407 'ModuleDefinitionFile': 'a_file_name',
408 'MSDOSStubFileName': 'a_file_name',
409 'NoEntryPoint': 'true',
410 'OptimizeReferences': 'false',
411 'OutputFile': 'a_file_name',
412 'PerUserRedirection': 'true',
413 'PreventDllBinding': 'true',
414 'Profile': 'true',
415 'ProfileGuidedDatabase': 'a_file_name',
416 'ProgramDatabaseFile': 'a_file_name',
417 'RandomizedBaseAddress': 'false',
418 'RegisterOutput': 'true',
419 'SectionAlignment': '33',
420 'SetChecksum': 'true',
421 'ShowProgress': 'LinkVerboseREF',
422 'SpecifySectionAttributes': 'a string1',
423 'StackCommitSize': 'a string1',
424 'StackReserveSize': 'a string1',
425 'StripPrivateSymbols': 'a_file_name',
426 'SubSystem': 'Console',
427 'SupportNobindOfDelayLoadedDLL': 'true',
428 'SupportUnloadOfDelayLoadedDLL': 'true',
429 'SuppressStartupBanner': 'true',
430 'SwapRunFromCD': 'true',
431 'SwapRunFromNET': 'true',
432 'TargetMachine': 'MachineX86',
433 'TerminalServerAware': 'false',
434 'TrackerLogDirectory': 'a_folder',
435 'TreatLinkerWarningAsErrors': 'true',
436 'TurnOffAssemblyGeneration': 'true',
437 'TypeLibraryFile': 'a_file_name',
438 'TypeLibraryResourceID': '33',
439 'UACExecutionLevel': 'AsInvoker',
440 'UACUIAccess': 'true',
441 'Version': 'a string1'},
442 'ResourceCompile': {
443 'AdditionalIncludeDirectories': 'folder1;folder2',
444 'AdditionalOptions': 'a string1',
445 'Culture': '0x236',
446 'IgnoreStandardIncludePath': 'true',
447 'NullTerminateStrings': 'true',
448 'PreprocessorDefinitions': 'string1;string2',
449 'ResourceOutputFileName': 'a string1',
450 'ShowProgress': 'true',
451 'SuppressStartupBanner': 'true',
452 'TrackerLogDirectory': 'a_folder',
453 'UndefinePreprocessorDefinitions': 'string1;string2'},
454 'Midl': {
455 'AdditionalIncludeDirectories': 'folder1;folder2',
456 'AdditionalOptions': 'a string1',
457 'ApplicationConfigurationMode': 'true',
458 'ClientStubFile': 'a_file_name',
459 'CPreprocessOptions': 'a string1',
460 'DefaultCharType': 'Signed',
461 'DllDataFileName': 'a_file_name',
462 'EnableErrorChecks': 'EnableCustom',
463 'ErrorCheckAllocations': 'true',
464 'ErrorCheckBounds': 'true',
465 'ErrorCheckEnumRange': 'true',
466 'ErrorCheckRefPointers': 'true',
467 'ErrorCheckStubData': 'true',
468 'GenerateClientFiles': 'Stub',
469 'GenerateServerFiles': 'None',
470 'GenerateStublessProxies': 'true',
471 'GenerateTypeLibrary': 'true',
472 'HeaderFileName': 'a_file_name',
473 'IgnoreStandardIncludePath': 'true',
474 'InterfaceIdentifierFileName': 'a_file_name',
475 'LocaleID': '33',
476 'MkTypLibCompatible': 'true',
477 'OutputDirectory': 'a string1',
478 'PreprocessorDefinitions': 'string1;string2',
479 'ProxyFileName': 'a_file_name',
480 'RedirectOutputAndErrors': 'a_file_name',
481 'ServerStubFile': 'a_file_name',
482 'StructMemberAlignment': 'NotSet',
483 'SuppressCompilerWarnings': 'true',
484 'SuppressStartupBanner': 'true',
485 'TargetEnvironment': 'Itanium',
486 'TrackerLogDirectory': 'a_folder',
487 'TypeLibFormat': 'NewFormat',
488 'TypeLibraryName': 'a_file_name',
489 'UndefinePreprocessorDefinitions': 'string1;string2',
490 'ValidateAllParameters': 'true',
491 'WarnAsError': 'true',
492 'WarningLevel': '1'},
493 'Lib': {
494 'AdditionalDependencies': 'file1;file2',
495 'AdditionalLibraryDirectories': 'folder1;folder2',
496 'AdditionalOptions': 'a string1',
497 'DisplayLibrary': 'a string1',
498 'ErrorReporting': 'PromptImmediately',
499 'ExportNamedFunctions': 'string1;string2',
500 'ForceSymbolReferences': 'a string1',
501 'IgnoreAllDefaultLibraries': 'true',
502 'IgnoreSpecificDefaultLibraries': 'file1;file2',
503 'LinkTimeCodeGeneration': 'true',
504 'MinimumRequiredVersion': 'a string1',
505 'ModuleDefinitionFile': 'a_file_name',
506 'Name': 'a_file_name',
507 'OutputFile': 'a_file_name',
508 'RemoveObjects': 'file1;file2',
509 'SubSystem': 'Console',
510 'SuppressStartupBanner': 'true',
511 'TargetMachine': 'MachineX86i',
512 'TrackerLogDirectory': 'a_folder',
513 'TreatLibWarningAsErrors': 'true',
514 'UseUnicodeResponseFiles': 'true',
515 'Verbose': 'true'},
516 'Mt': {
517 'AdditionalManifestFiles': 'file1;file2',
518 'AdditionalOptions': 'a string1',
519 'AssemblyIdentity': 'a string1',
520 'ComponentFileName': 'a_file_name',
521 'EnableDPIAwareness': 'fal',
522 'GenerateCatalogFiles': 'truel',
523 'GenerateCategoryTags': 'true',
524 'InputResourceManifests': 'a string1',
525 'ManifestFromManagedAssembly': 'a_file_name',
526 'notgood3': 'bogus',
527 'OutputManifestFile': 'a_file_name',
528 'OutputResourceManifests': 'a string1',
529 'RegistrarScriptFile': 'a_file_name',
530 'ReplacementsFile': 'a_file_name',
531 'SuppressDependencyElement': 'true',
532 'SuppressStartupBanner': 'true',
533 'TrackerLogDirectory': 'a_folder',
534 'TypeLibraryFile': 'a_file_name',
535 'UpdateFileHashes': 'true',
536 'UpdateFileHashesSearchPath': 'a_file_name',
537 'VerboseOutput': 'true'},
538 'ProjectReference': {
539 'LinkLibraryDependencies': 'true',
540 'UseLibraryDependencyInputs': 'true'},
541 'ManifestResourceCompile': {
542 'ResourceOutputFileName': 'a_file_name'},
543 '': {
544 'EmbedManifest': 'true',
545 'GenerateManifest': 'true',
546 'IgnoreImportLibrary': 'true',
547 'LinkIncremental': 'false'}},
548 self.stderr)
549 self._ExpectedWarnings([
550 'Warning: unrecognized setting ClCompile/Enableprefast',
551 'Warning: unrecognized setting ClCompile/ZZXYZ',
552 'Warning: unrecognized setting Mt/notgood3',
553 "Warning: for Mt/GenerateCatalogFiles, expected bool; got 'truel'",
554 'Warning: for Lib/TargetMachine, unrecognized enumerated value '
555 'MachineX86i',
556 "Warning: for Mt/EnableDPIAwareness, expected bool; got 'fal'"])
557
558 def testConvertToMSBuildSettings_empty(self):
559 """Tests an empty conversion."""
560 msvs_settings = {}
561 expected_msbuild_settings = {}
562 actual_msbuild_settings = MSVSSettings.ConvertToMSBuildSettings(
563 msvs_settings,
564 self.stderr)
565 self.assertEqual(expected_msbuild_settings, actual_msbuild_settings)
566 self._ExpectedWarnings([])
567
568 def testConvertToMSBuildSettings_minimal(self):
569 """Tests a minimal conversion."""
570 msvs_settings = {
571 'VCCLCompilerTool': {
572 'AdditionalIncludeDirectories': 'dir1',
573 'AdditionalOptions': '/foo',
574 'BasicRuntimeChecks': '0',
575 },
576 'VCLinkerTool': {
577 'LinkTimeCodeGeneration': '1',
578 'ErrorReporting': '1',
579 'DataExecutionPrevention': '2',
580 },
581 }
582 expected_msbuild_settings = {
583 'ClCompile': {
584 'AdditionalIncludeDirectories': 'dir1',
585 'AdditionalOptions': '/foo',
586 'BasicRuntimeChecks': 'Default',
587 },
588 'Link': {
589 'LinkTimeCodeGeneration': 'UseLinkTimeCodeGeneration',
590 'LinkErrorReporting': 'PromptImmediately',
591 'DataExecutionPrevention': 'true',
592 },
593 }
594 actual_msbuild_settings = MSVSSettings.ConvertToMSBuildSettings(
595 msvs_settings,
596 self.stderr)
597 self.assertEqual(expected_msbuild_settings, actual_msbuild_settings)
598 self._ExpectedWarnings([])
599
600 def testConvertToMSBuildSettings_warnings(self):
601 """Tests conversion that generates warnings."""
602 msvs_settings = {
603 'VCCLCompilerTool': {
604 'AdditionalIncludeDirectories': '1',
605 'AdditionalOptions': '2',
606 # These are incorrect values:
607 'BasicRuntimeChecks': '12',
608 'BrowseInformation': '21',
609 'UsePrecompiledHeader': '13',
610 'GeneratePreprocessedFile': '14'},
611 'VCLinkerTool': {
612 # These are incorrect values:
613 'Driver': '10',
614 'LinkTimeCodeGeneration': '31',
615 'ErrorReporting': '21',
616 'FixedBaseAddress': '6'},
617 'VCResourceCompilerTool': {
618 # Custom
619 'Culture': '1003'}}
620 expected_msbuild_settings = {
621 'ClCompile': {
622 'AdditionalIncludeDirectories': '1',
623 'AdditionalOptions': '2'},
624 'Link': {},
625 'ResourceCompile': {
626 # Custom
627 'Culture': '0x03eb'}}
628 actual_msbuild_settings = MSVSSettings.ConvertToMSBuildSettings(
629 msvs_settings,
630 self.stderr)
631 self.assertEqual(expected_msbuild_settings, actual_msbuild_settings)
632 self._ExpectedWarnings([
633 'Warning: while converting VCCLCompilerTool/BasicRuntimeChecks to '
634 'MSBuild, index value (12) not in expected range [0, 4)',
635 'Warning: while converting VCCLCompilerTool/BrowseInformation to '
636 'MSBuild, index value (21) not in expected range [0, 3)',
637 'Warning: while converting VCCLCompilerTool/UsePrecompiledHeader to '
638 'MSBuild, index value (13) not in expected range [0, 3)',
639 'Warning: while converting VCCLCompilerTool/GeneratePreprocessedFile to '
640 'MSBuild, value must be one of [0, 1, 2]; got 14',
641
642 'Warning: while converting VCLinkerTool/Driver to '
643 'MSBuild, index value (10) not in expected range [0, 4)',
644 'Warning: while converting VCLinkerTool/LinkTimeCodeGeneration to '
645 'MSBuild, index value (31) not in expected range [0, 5)',
646 'Warning: while converting VCLinkerTool/ErrorReporting to '
647 'MSBuild, index value (21) not in expected range [0, 3)',
648 'Warning: while converting VCLinkerTool/FixedBaseAddress to '
649 'MSBuild, index value (6) not in expected range [0, 3)',
650 ])
651
652 def testConvertToMSBuildSettings_full_synthetic(self):
653 """Tests conversion of all the MSBuild settings."""
654 msvs_settings = {
655 'VCCLCompilerTool': {
656 'AdditionalIncludeDirectories': 'folder1;folder2;folder3',
657 'AdditionalOptions': 'a_string',
658 'AdditionalUsingDirectories': 'folder1;folder2;folder3',
659 'AssemblerListingLocation': 'a_file_name',
660 'AssemblerOutput': '0',
661 'BasicRuntimeChecks': '1',
662 'BrowseInformation': '2',
663 'BrowseInformationFile': 'a_file_name',
664 'BufferSecurityCheck': 'true',
665 'CallingConvention': '0',
666 'CompileAs': '1',
667 'DebugInformationFormat': '4',
668 'DefaultCharIsUnsigned': 'true',
669 'Detect64BitPortabilityProblems': 'true',
670 'DisableLanguageExtensions': 'true',
671 'DisableSpecificWarnings': 'd1;d2;d3',
672 'EnableEnhancedInstructionSet': '0',
673 'EnableFiberSafeOptimizations': 'true',
674 'EnableFunctionLevelLinking': 'true',
675 'EnableIntrinsicFunctions': 'true',
676 'EnablePREfast': 'true',
677 'ErrorReporting': '1',
678 'ExceptionHandling': '2',
679 'ExpandAttributedSource': 'true',
680 'FavorSizeOrSpeed': '0',
681 'FloatingPointExceptions': 'true',
682 'FloatingPointModel': '1',
683 'ForceConformanceInForLoopScope': 'true',
684 'ForcedIncludeFiles': 'file1;file2;file3',
685 'ForcedUsingFiles': 'file1;file2;file3',
686 'GeneratePreprocessedFile': '1',
687 'GenerateXMLDocumentationFiles': 'true',
688 'IgnoreStandardIncludePath': 'true',
689 'InlineFunctionExpansion': '2',
690 'KeepComments': 'true',
691 'MinimalRebuild': 'true',
692 'ObjectFile': 'a_file_name',
693 'OmitDefaultLibName': 'true',
694 'OmitFramePointers': 'true',
695 'OpenMP': 'true',
696 'Optimization': '3',
697 'PrecompiledHeaderFile': 'a_file_name',
698 'PrecompiledHeaderThrough': 'a_file_name',
699 'PreprocessorDefinitions': 'd1;d2;d3',
700 'ProgramDataBaseFileName': 'a_file_name',
701 'RuntimeLibrary': '0',
702 'RuntimeTypeInfo': 'true',
703 'ShowIncludes': 'true',
704 'SmallerTypeCheck': 'true',
705 'StringPooling': 'true',
706 'StructMemberAlignment': '1',
707 'SuppressStartupBanner': 'true',
708 'TreatWChar_tAsBuiltInType': 'true',
709 'UndefineAllPreprocessorDefinitions': 'true',
710 'UndefinePreprocessorDefinitions': 'd1;d2;d3',
711 'UseFullPaths': 'true',
712 'UsePrecompiledHeader': '1',
713 'UseUnicodeResponseFiles': 'true',
714 'WarnAsError': 'true',
715 'WarningLevel': '2',
716 'WholeProgramOptimization': 'true',
717 'XMLDocumentationFileName': 'a_file_name'},
718 'VCLinkerTool': {
719 'AdditionalDependencies': 'file1;file2;file3',
720 'AdditionalLibraryDirectories': 'folder1;folder2;folder3',
721 'AdditionalLibraryDirectories_excluded': 'folder1;folder2;folder3',
722 'AdditionalManifestDependencies': 'file1;file2;file3',
723 'AdditionalOptions': 'a_string',
724 'AddModuleNamesToAssembly': 'file1;file2;file3',
725 'AllowIsolation': 'true',
726 'AssemblyDebug': '0',
727 'AssemblyLinkResource': 'file1;file2;file3',
728 'BaseAddress': 'a_string',
729 'CLRImageType': '1',
730 'CLRThreadAttribute': '2',
731 'CLRUnmanagedCodeCheck': 'true',
732 'DataExecutionPrevention': '0',
733 'DelayLoadDLLs': 'file1;file2;file3',
734 'DelaySign': 'true',
735 'Driver': '1',
736 'EmbedManagedResourceFile': 'file1;file2;file3',
737 'EnableCOMDATFolding': '0',
738 'EnableUAC': 'true',
739 'EntryPointSymbol': 'a_string',
740 'ErrorReporting': '0',
741 'FixedBaseAddress': '1',
742 'ForceSymbolReferences': 'file1;file2;file3',
743 'FunctionOrder': 'a_file_name',
744 'GenerateDebugInformation': 'true',
745 'GenerateManifest': 'true',
746 'GenerateMapFile': 'true',
747 'HeapCommitSize': 'a_string',
748 'HeapReserveSize': 'a_string',
749 'IgnoreAllDefaultLibraries': 'true',
750 'IgnoreDefaultLibraryNames': 'file1;file2;file3',
751 'IgnoreEmbeddedIDL': 'true',
752 'IgnoreImportLibrary': 'true',
753 'ImportLibrary': 'a_file_name',
754 'KeyContainer': 'a_file_name',
755 'KeyFile': 'a_file_name',
756 'LargeAddressAware': '2',
757 'LinkIncremental': '1',
758 'LinkLibraryDependencies': 'true',
759 'LinkTimeCodeGeneration': '2',
760 'ManifestFile': 'a_file_name',
761 'MapExports': 'true',
762 'MapFileName': 'a_file_name',
763 'MergedIDLBaseFileName': 'a_file_name',
764 'MergeSections': 'a_string',
765 'MidlCommandFile': 'a_file_name',
766 'ModuleDefinitionFile': 'a_file_name',
767 'OptimizeForWindows98': '1',
768 'OptimizeReferences': '0',
769 'OutputFile': 'a_file_name',
770 'PerUserRedirection': 'true',
771 'Profile': 'true',
772 'ProfileGuidedDatabase': 'a_file_name',
773 'ProgramDatabaseFile': 'a_file_name',
774 'RandomizedBaseAddress': '1',
775 'RegisterOutput': 'true',
776 'ResourceOnlyDLL': 'true',
777 'SetChecksum': 'true',
778 'ShowProgress': '0',
779 'StackCommitSize': 'a_string',
780 'StackReserveSize': 'a_string',
781 'StripPrivateSymbols': 'a_file_name',
782 'SubSystem': '2',
783 'SupportUnloadOfDelayLoadedDLL': 'true',
784 'SuppressStartupBanner': 'true',
785 'SwapRunFromCD': 'true',
786 'SwapRunFromNet': 'true',
787 'TargetMachine': '3',
788 'TerminalServerAware': '2',
789 'TurnOffAssemblyGeneration': 'true',
790 'TypeLibraryFile': 'a_file_name',
791 'TypeLibraryResourceID': '33',
792 'UACExecutionLevel': '1',
793 'UACUIAccess': 'true',
794 'UseLibraryDependencyInputs': 'false',
795 'UseUnicodeResponseFiles': 'true',
796 'Version': 'a_string'},
797 'VCResourceCompilerTool': {
798 'AdditionalIncludeDirectories': 'folder1;folder2;folder3',
799 'AdditionalOptions': 'a_string',
800 'Culture': '1003',
801 'IgnoreStandardIncludePath': 'true',
802 'PreprocessorDefinitions': 'd1;d2;d3',
803 'ResourceOutputFileName': 'a_string',
804 'ShowProgress': 'true',
805 'SuppressStartupBanner': 'true',
806 'UndefinePreprocessorDefinitions': 'd1;d2;d3'},
807 'VCMIDLTool': {
808 'AdditionalIncludeDirectories': 'folder1;folder2;folder3',
809 'AdditionalOptions': 'a_string',
810 'CPreprocessOptions': 'a_string',
811 'DefaultCharType': '0',
812 'DLLDataFileName': 'a_file_name',
813 'EnableErrorChecks': '2',
814 'ErrorCheckAllocations': 'true',
815 'ErrorCheckBounds': 'true',
816 'ErrorCheckEnumRange': 'true',
817 'ErrorCheckRefPointers': 'true',
818 'ErrorCheckStubData': 'true',
819 'GenerateStublessProxies': 'true',
820 'GenerateTypeLibrary': 'true',
821 'HeaderFileName': 'a_file_name',
822 'IgnoreStandardIncludePath': 'true',
823 'InterfaceIdentifierFileName': 'a_file_name',
824 'MkTypLibCompatible': 'true',
825 'OutputDirectory': 'a_string',
826 'PreprocessorDefinitions': 'd1;d2;d3',
827 'ProxyFileName': 'a_file_name',
828 'RedirectOutputAndErrors': 'a_file_name',
829 'StructMemberAlignment': '3',
830 'SuppressStartupBanner': 'true',
831 'TargetEnvironment': '1',
832 'TypeLibraryName': 'a_file_name',
833 'UndefinePreprocessorDefinitions': 'd1;d2;d3',
834 'ValidateParameters': 'true',
835 'WarnAsError': 'true',
836 'WarningLevel': '4'},
837 'VCLibrarianTool': {
838 'AdditionalDependencies': 'file1;file2;file3',
839 'AdditionalLibraryDirectories': 'folder1;folder2;folder3',
840 'AdditionalLibraryDirectories_excluded': 'folder1;folder2;folder3',
841 'AdditionalOptions': 'a_string',
842 'ExportNamedFunctions': 'd1;d2;d3',
843 'ForceSymbolReferences': 'a_string',
844 'IgnoreAllDefaultLibraries': 'true',
845 'IgnoreSpecificDefaultLibraries': 'file1;file2;file3',
846 'LinkLibraryDependencies': 'true',
847 'ModuleDefinitionFile': 'a_file_name',
848 'OutputFile': 'a_file_name',
849 'SuppressStartupBanner': 'true',
850 'UseUnicodeResponseFiles': 'true'},
851 'VCManifestTool': {
852 'AdditionalManifestFiles': 'file1;file2;file3',
853 'AdditionalOptions': 'a_string',
854 'AssemblyIdentity': 'a_string',
855 'ComponentFileName': 'a_file_name',
856 'DependencyInformationFile': 'a_file_name',
857 'EmbedManifest': 'true',
858 'GenerateCatalogFiles': 'true',
859 'InputResourceManifests': 'a_string',
860 'ManifestResourceFile': 'my_name',
861 'OutputManifestFile': 'a_file_name',
862 'RegistrarScriptFile': 'a_file_name',
863 'ReplacementsFile': 'a_file_name',
864 'SuppressStartupBanner': 'true',
865 'TypeLibraryFile': 'a_file_name',
866 'UpdateFileHashes': 'true',
867 'UpdateFileHashesSearchPath': 'a_file_name',
868 'UseFAT32Workaround': 'true',
869 'UseUnicodeResponseFiles': 'true',
870 'VerboseOutput': 'true'}}
871 expected_msbuild_settings = {
872 'ClCompile': {
873 'AdditionalIncludeDirectories': 'folder1;folder2;folder3',
874 'AdditionalOptions': 'a_string /J',
875 'AdditionalUsingDirectories': 'folder1;folder2;folder3',
876 'AssemblerListingLocation': 'a_file_name',
877 'AssemblerOutput': 'NoListing',
878 'BasicRuntimeChecks': 'StackFrameRuntimeCheck',
879 'BrowseInformation': 'true',
880 'BrowseInformationFile': 'a_file_name',
881 'BufferSecurityCheck': 'true',
882 'CallingConvention': 'Cdecl',
883 'CompileAs': 'CompileAsC',
884 'DebugInformationFormat': 'EditAndContinue',
885 'DisableLanguageExtensions': 'true',
886 'DisableSpecificWarnings': 'd1;d2;d3',
887 'EnableEnhancedInstructionSet': 'NotSet',
888 'EnableFiberSafeOptimizations': 'true',
889 'EnablePREfast': 'true',
890 'ErrorReporting': 'Prompt',
891 'ExceptionHandling': 'Async',
892 'ExpandAttributedSource': 'true',
893 'FavorSizeOrSpeed': 'Neither',
894 'FloatingPointExceptions': 'true',
895 'FloatingPointModel': 'Strict',
896 'ForceConformanceInForLoopScope': 'true',
897 'ForcedIncludeFiles': 'file1;file2;file3',
898 'ForcedUsingFiles': 'file1;file2;file3',
899 'FunctionLevelLinking': 'true',
900 'GenerateXMLDocumentationFiles': 'true',
901 'IgnoreStandardIncludePath': 'true',
902 'InlineFunctionExpansion': 'AnySuitable',
903 'IntrinsicFunctions': 'true',
904 'MinimalRebuild': 'true',
905 'ObjectFileName': 'a_file_name',
906 'OmitDefaultLibName': 'true',
907 'OmitFramePointers': 'true',
908 'OpenMPSupport': 'true',
909 'Optimization': 'Full',
910 'PrecompiledHeader': 'Create',
911 'PrecompiledHeaderFile': 'a_file_name',
912 'PrecompiledHeaderOutputFile': 'a_file_name',
913 'PreprocessKeepComments': 'true',
914 'PreprocessorDefinitions': 'd1;d2;d3',
915 'PreprocessSuppressLineNumbers': 'false',
916 'PreprocessToFile': 'true',
917 'ProgramDataBaseFileName': 'a_file_name',
918 'RuntimeLibrary': 'MultiThreaded',
919 'RuntimeTypeInfo': 'true',
920 'ShowIncludes': 'true',
921 'SmallerTypeCheck': 'true',
922 'StringPooling': 'true',
923 'StructMemberAlignment': '1Byte',
924 'SuppressStartupBanner': 'true',
925 'TreatWarningAsError': 'true',
926 'TreatWChar_tAsBuiltInType': 'true',
927 'UndefineAllPreprocessorDefinitions': 'true',
928 'UndefinePreprocessorDefinitions': 'd1;d2;d3',
929 'UseFullPaths': 'true',
930 'WarningLevel': 'Level2',
931 'WholeProgramOptimization': 'true',
932 'XMLDocumentationFileName': 'a_file_name'},
933 'Link': {
934 'AdditionalDependencies': 'file1;file2;file3',
935 'AdditionalLibraryDirectories': 'folder1;folder2;folder3',
936 'AdditionalManifestDependencies': 'file1;file2;file3',
937 'AdditionalOptions': 'a_string',
938 'AddModuleNamesToAssembly': 'file1;file2;file3',
939 'AllowIsolation': 'true',
940 'AssemblyDebug': '',
941 'AssemblyLinkResource': 'file1;file2;file3',
942 'BaseAddress': 'a_string',
943 'CLRImageType': 'ForceIJWImage',
944 'CLRThreadAttribute': 'STAThreadingAttribute',
945 'CLRUnmanagedCodeCheck': 'true',
946 'DataExecutionPrevention': '',
947 'DelayLoadDLLs': 'file1;file2;file3',
948 'DelaySign': 'true',
949 'Driver': 'Driver',
950 'EmbedManagedResourceFile': 'file1;file2;file3',
951 'EnableCOMDATFolding': '',
952 'EnableUAC': 'true',
953 'EntryPointSymbol': 'a_string',
954 'FixedBaseAddress': 'false',
955 'ForceSymbolReferences': 'file1;file2;file3',
956 'FunctionOrder': 'a_file_name',
957 'GenerateDebugInformation': 'true',
958 'GenerateMapFile': 'true',
959 'HeapCommitSize': 'a_string',
960 'HeapReserveSize': 'a_string',
961 'IgnoreAllDefaultLibraries': 'true',
962 'IgnoreEmbeddedIDL': 'true',
963 'IgnoreSpecificDefaultLibraries': 'file1;file2;file3',
964 'ImportLibrary': 'a_file_name',
965 'KeyContainer': 'a_file_name',
966 'KeyFile': 'a_file_name',
967 'LargeAddressAware': 'true',
968 'LinkErrorReporting': 'NoErrorReport',
969 'LinkTimeCodeGeneration': 'PGInstrument',
970 'ManifestFile': 'a_file_name',
971 'MapExports': 'true',
972 'MapFileName': 'a_file_name',
973 'MergedIDLBaseFileName': 'a_file_name',
974 'MergeSections': 'a_string',
975 'MidlCommandFile': 'a_file_name',
976 'ModuleDefinitionFile': 'a_file_name',
977 'NoEntryPoint': 'true',
978 'OptimizeReferences': '',
979 'OutputFile': 'a_file_name',
980 'PerUserRedirection': 'true',
981 'Profile': 'true',
982 'ProfileGuidedDatabase': 'a_file_name',
983 'ProgramDatabaseFile': 'a_file_name',
984 'RandomizedBaseAddress': 'false',
985 'RegisterOutput': 'true',
986 'SetChecksum': 'true',
987 'ShowProgress': 'NotSet',
988 'StackCommitSize': 'a_string',
989 'StackReserveSize': 'a_string',
990 'StripPrivateSymbols': 'a_file_name',
991 'SubSystem': 'Windows',
992 'SupportUnloadOfDelayLoadedDLL': 'true',
993 'SuppressStartupBanner': 'true',
994 'SwapRunFromCD': 'true',
995 'SwapRunFromNET': 'true',
996 'TargetMachine': 'MachineARM',
997 'TerminalServerAware': 'true',
998 'TurnOffAssemblyGeneration': 'true',
999 'TypeLibraryFile': 'a_file_name',
1000 'TypeLibraryResourceID': '33',
1001 'UACExecutionLevel': 'HighestAvailable',
1002 'UACUIAccess': 'true',
1003 'Version': 'a_string'},
1004 'ResourceCompile': {
1005 'AdditionalIncludeDirectories': 'folder1;folder2;folder3',
1006 'AdditionalOptions': 'a_string',
1007 'Culture': '0x03eb',
1008 'IgnoreStandardIncludePath': 'true',
1009 'PreprocessorDefinitions': 'd1;d2;d3',
1010 'ResourceOutputFileName': 'a_string',
1011 'ShowProgress': 'true',
1012 'SuppressStartupBanner': 'true',
1013 'UndefinePreprocessorDefinitions': 'd1;d2;d3'},
1014 'Midl': {
1015 'AdditionalIncludeDirectories': 'folder1;folder2;folder3',
1016 'AdditionalOptions': 'a_string',
1017 'CPreprocessOptions': 'a_string',
1018 'DefaultCharType': 'Unsigned',
1019 'DllDataFileName': 'a_file_name',
1020 'EnableErrorChecks': 'All',
1021 'ErrorCheckAllocations': 'true',
1022 'ErrorCheckBounds': 'true',
1023 'ErrorCheckEnumRange': 'true',
1024 'ErrorCheckRefPointers': 'true',
1025 'ErrorCheckStubData': 'true',
1026 'GenerateStublessProxies': 'true',
1027 'GenerateTypeLibrary': 'true',
1028 'HeaderFileName': 'a_file_name',
1029 'IgnoreStandardIncludePath': 'true',
1030 'InterfaceIdentifierFileName': 'a_file_name',
1031 'MkTypLibCompatible': 'true',
1032 'OutputDirectory': 'a_string',
1033 'PreprocessorDefinitions': 'd1;d2;d3',
1034 'ProxyFileName': 'a_file_name',
1035 'RedirectOutputAndErrors': 'a_file_name',
1036 'StructMemberAlignment': '4',
1037 'SuppressStartupBanner': 'true',
1038 'TargetEnvironment': 'Win32',
1039 'TypeLibraryName': 'a_file_name',
1040 'UndefinePreprocessorDefinitions': 'd1;d2;d3',
1041 'ValidateAllParameters': 'true',
1042 'WarnAsError': 'true',
1043 'WarningLevel': '4'},
1044 'Lib': {
1045 'AdditionalDependencies': 'file1;file2;file3',
1046 'AdditionalLibraryDirectories': 'folder1;folder2;folder3',
1047 'AdditionalOptions': 'a_string',
1048 'ExportNamedFunctions': 'd1;d2;d3',
1049 'ForceSymbolReferences': 'a_string',
1050 'IgnoreAllDefaultLibraries': 'true',
1051 'IgnoreSpecificDefaultLibraries': 'file1;file2;file3',
1052 'ModuleDefinitionFile': 'a_file_name',
1053 'OutputFile': 'a_file_name',
1054 'SuppressStartupBanner': 'true',
1055 'UseUnicodeResponseFiles': 'true'},
1056 'Mt': {
1057 'AdditionalManifestFiles': 'file1;file2;file3',
1058 'AdditionalOptions': 'a_string',
1059 'AssemblyIdentity': 'a_string',
1060 'ComponentFileName': 'a_file_name',
1061 'GenerateCatalogFiles': 'true',
1062 'InputResourceManifests': 'a_string',
1063 'OutputManifestFile': 'a_file_name',
1064 'RegistrarScriptFile': 'a_file_name',
1065 'ReplacementsFile': 'a_file_name',
1066 'SuppressStartupBanner': 'true',
1067 'TypeLibraryFile': 'a_file_name',
1068 'UpdateFileHashes': 'true',
1069 'UpdateFileHashesSearchPath': 'a_file_name',
1070 'VerboseOutput': 'true'},
1071 'ManifestResourceCompile': {
1072 'ResourceOutputFileName': 'my_name'},
1073 'ProjectReference': {
1074 'LinkLibraryDependencies': 'true',
1075 'UseLibraryDependencyInputs': 'false'},
1076 '': {
1077 'EmbedManifest': 'true',
1078 'GenerateManifest': 'true',
1079 'IgnoreImportLibrary': 'true',
1080 'LinkIncremental': 'false'}}
1081 actual_msbuild_settings = MSVSSettings.ConvertToMSBuildSettings(
1082 msvs_settings,
1083 self.stderr)
1084 self.assertEqual(expected_msbuild_settings, actual_msbuild_settings)
1085 self._ExpectedWarnings([])
1086
1087 def testConvertToMSBuildSettings_actual(self):
1088 """Tests the conversion of an actual project.
1089
1090 A VS2008 project with most of the options defined was created through the
1091 VS2008 IDE. It was then converted to VS2010. The tool settings found in
1092 the .vcproj and .vcxproj files were converted to the two dictionaries
1093 msvs_settings and expected_msbuild_settings.
1094
1095 Note that for many settings, the VS2010 converter adds macros like
1096 %(AdditionalIncludeDirectories) to make sure than inherited values are
1097 included. Since the Gyp projects we generate do not use inheritance,
1098 we removed these macros. They were:
1099 ClCompile:
1100 AdditionalIncludeDirectories: ';%(AdditionalIncludeDirectories)'
1101 AdditionalOptions: ' %(AdditionalOptions)'
1102 AdditionalUsingDirectories: ';%(AdditionalUsingDirectories)'
1103 DisableSpecificWarnings: ';%(DisableSpecificWarnings)',
1104 ForcedIncludeFiles: ';%(ForcedIncludeFiles)',
1105 ForcedUsingFiles: ';%(ForcedUsingFiles)',
1106 PreprocessorDefinitions: ';%(PreprocessorDefinitions)',
1107 UndefinePreprocessorDefinitions:
1108 ';%(UndefinePreprocessorDefinitions)',
1109 Link:
1110 AdditionalDependencies: ';%(AdditionalDependencies)',
1111 AdditionalLibraryDirectories: ';%(AdditionalLibraryDirectories)',
1112 AdditionalManifestDependencies:
1113 ';%(AdditionalManifestDependencies)',
1114 AdditionalOptions: ' %(AdditionalOptions)',
1115 AddModuleNamesToAssembly: ';%(AddModuleNamesToAssembly)',
1116 AssemblyLinkResource: ';%(AssemblyLinkResource)',
1117 DelayLoadDLLs: ';%(DelayLoadDLLs)',
1118 EmbedManagedResourceFile: ';%(EmbedManagedResourceFile)',
1119 ForceSymbolReferences: ';%(ForceSymbolReferences)',
1120 IgnoreSpecificDefaultLibraries:
1121 ';%(IgnoreSpecificDefaultLibraries)',
1122 ResourceCompile:
1123 AdditionalIncludeDirectories: ';%(AdditionalIncludeDirectories)',
1124 AdditionalOptions: ' %(AdditionalOptions)',
1125 PreprocessorDefinitions: ';%(PreprocessorDefinitions)',
1126 Mt:
1127 AdditionalManifestFiles: ';%(AdditionalManifestFiles)',
1128 AdditionalOptions: ' %(AdditionalOptions)',
1129 InputResourceManifests: ';%(InputResourceManifests)',
1130 """
1131 msvs_settings = {
1132 'VCCLCompilerTool': {
1133 'AdditionalIncludeDirectories': 'dir1',
1134 'AdditionalOptions': '/more',
1135 'AdditionalUsingDirectories': 'test',
1136 'AssemblerListingLocation': '$(IntDir)\\a',
1137 'AssemblerOutput': '1',
1138 'BasicRuntimeChecks': '3',
1139 'BrowseInformation': '1',
1140 'BrowseInformationFile': '$(IntDir)\\e',
1141 'BufferSecurityCheck': 'false',
1142 'CallingConvention': '1',
1143 'CompileAs': '1',
1144 'DebugInformationFormat': '4',
1145 'DefaultCharIsUnsigned': 'true',
1146 'Detect64BitPortabilityProblems': 'true',
1147 'DisableLanguageExtensions': 'true',
1148 'DisableSpecificWarnings': 'abc',
1149 'EnableEnhancedInstructionSet': '1',
1150 'EnableFiberSafeOptimizations': 'true',
1151 'EnableFunctionLevelLinking': 'true',
1152 'EnableIntrinsicFunctions': 'true',
1153 'EnablePREfast': 'true',
1154 'ErrorReporting': '2',
1155 'ExceptionHandling': '2',
1156 'ExpandAttributedSource': 'true',
1157 'FavorSizeOrSpeed': '2',
1158 'FloatingPointExceptions': 'true',
1159 'FloatingPointModel': '1',
1160 'ForceConformanceInForLoopScope': 'false',
1161 'ForcedIncludeFiles': 'def',
1162 'ForcedUsingFiles': 'ge',
1163 'GeneratePreprocessedFile': '2',
1164 'GenerateXMLDocumentationFiles': 'true',
1165 'IgnoreStandardIncludePath': 'true',
1166 'InlineFunctionExpansion': '1',
1167 'KeepComments': 'true',
1168 'MinimalRebuild': 'true',
1169 'ObjectFile': '$(IntDir)\\b',
1170 'OmitDefaultLibName': 'true',
1171 'OmitFramePointers': 'true',
1172 'OpenMP': 'true',
1173 'Optimization': '3',
1174 'PrecompiledHeaderFile': '$(IntDir)\\$(TargetName).pche',
1175 'PrecompiledHeaderThrough': 'StdAfx.hd',
1176 'PreprocessorDefinitions': 'WIN32;_DEBUG;_CONSOLE',
1177 'ProgramDataBaseFileName': '$(IntDir)\\vc90b.pdb',
1178 'RuntimeLibrary': '3',
1179 'RuntimeTypeInfo': 'false',
1180 'ShowIncludes': 'true',
1181 'SmallerTypeCheck': 'true',
1182 'StringPooling': 'true',
1183 'StructMemberAlignment': '3',
1184 'SuppressStartupBanner': 'false',
1185 'TreatWChar_tAsBuiltInType': 'false',
1186 'UndefineAllPreprocessorDefinitions': 'true',
1187 'UndefinePreprocessorDefinitions': 'wer',
1188 'UseFullPaths': 'true',
1189 'UsePrecompiledHeader': '0',
1190 'UseUnicodeResponseFiles': 'false',
1191 'WarnAsError': 'true',
1192 'WarningLevel': '3',
1193 'WholeProgramOptimization': 'true',
1194 'XMLDocumentationFileName': '$(IntDir)\\c'},
1195 'VCLinkerTool': {
1196 'AdditionalDependencies': 'zx',
1197 'AdditionalLibraryDirectories': 'asd',
1198 'AdditionalManifestDependencies': 's2',
1199 'AdditionalOptions': '/mor2',
1200 'AddModuleNamesToAssembly': 'd1',
1201 'AllowIsolation': 'false',
1202 'AssemblyDebug': '1',
1203 'AssemblyLinkResource': 'd5',
1204 'BaseAddress': '23423',
1205 'CLRImageType': '3',
1206 'CLRThreadAttribute': '1',
1207 'CLRUnmanagedCodeCheck': 'true',
1208 'DataExecutionPrevention': '0',
1209 'DelayLoadDLLs': 'd4',
1210 'DelaySign': 'true',
1211 'Driver': '2',
1212 'EmbedManagedResourceFile': 'd2',
1213 'EnableCOMDATFolding': '1',
1214 'EnableUAC': 'false',
1215 'EntryPointSymbol': 'f5',
1216 'ErrorReporting': '2',
1217 'FixedBaseAddress': '1',
1218 'ForceSymbolReferences': 'd3',
1219 'FunctionOrder': 'fssdfsd',
1220 'GenerateDebugInformation': 'true',
1221 'GenerateManifest': 'false',
1222 'GenerateMapFile': 'true',
1223 'HeapCommitSize': '13',
1224 'HeapReserveSize': '12',
1225 'IgnoreAllDefaultLibraries': 'true',
1226 'IgnoreDefaultLibraryNames': 'flob;flok',
1227 'IgnoreEmbeddedIDL': 'true',
1228 'IgnoreImportLibrary': 'true',
1229 'ImportLibrary': 'f4',
1230 'KeyContainer': 'f7',
1231 'KeyFile': 'f6',
1232 'LargeAddressAware': '2',
1233 'LinkIncremental': '0',
1234 'LinkLibraryDependencies': 'false',
1235 'LinkTimeCodeGeneration': '1',
1236 'ManifestFile':
1237 '$(IntDir)\\$(TargetFileName).2intermediate.manifest',
1238 'MapExports': 'true',
1239 'MapFileName': 'd5',
1240 'MergedIDLBaseFileName': 'f2',
1241 'MergeSections': 'f5',
1242 'MidlCommandFile': 'f1',
1243 'ModuleDefinitionFile': 'sdsd',
1244 'OptimizeForWindows98': '2',
1245 'OptimizeReferences': '2',
1246 'OutputFile': '$(OutDir)\\$(ProjectName)2.exe',
1247 'PerUserRedirection': 'true',
1248 'Profile': 'true',
1249 'ProfileGuidedDatabase': '$(TargetDir)$(TargetName).pgdd',
1250 'ProgramDatabaseFile': 'Flob.pdb',
1251 'RandomizedBaseAddress': '1',
1252 'RegisterOutput': 'true',
1253 'ResourceOnlyDLL': 'true',
1254 'SetChecksum': 'false',
1255 'ShowProgress': '1',
1256 'StackCommitSize': '15',
1257 'StackReserveSize': '14',
1258 'StripPrivateSymbols': 'd3',
1259 'SubSystem': '1',
1260 'SupportUnloadOfDelayLoadedDLL': 'true',
1261 'SuppressStartupBanner': 'false',
1262 'SwapRunFromCD': 'true',
1263 'SwapRunFromNet': 'true',
1264 'TargetMachine': '1',
1265 'TerminalServerAware': '1',
1266 'TurnOffAssemblyGeneration': 'true',
1267 'TypeLibraryFile': 'f3',
1268 'TypeLibraryResourceID': '12',
1269 'UACExecutionLevel': '2',
1270 'UACUIAccess': 'true',
1271 'UseLibraryDependencyInputs': 'true',
1272 'UseUnicodeResponseFiles': 'false',
1273 'Version': '333'},
1274 'VCResourceCompilerTool': {
1275 'AdditionalIncludeDirectories': 'f3',
1276 'AdditionalOptions': '/more3',
1277 'Culture': '3084',
1278 'IgnoreStandardIncludePath': 'true',
1279 'PreprocessorDefinitions': '_UNICODE;UNICODE2',
1280 'ResourceOutputFileName': '$(IntDir)/$(InputName)3.res',
1281 'ShowProgress': 'true'},
1282 'VCManifestTool': {
1283 'AdditionalManifestFiles': 'sfsdfsd',
1284 'AdditionalOptions': 'afdsdafsd',
1285 'AssemblyIdentity': 'sddfdsadfsa',
1286 'ComponentFileName': 'fsdfds',
1287 'DependencyInformationFile': '$(IntDir)\\mt.depdfd',
1288 'EmbedManifest': 'false',
1289 'GenerateCatalogFiles': 'true',
1290 'InputResourceManifests': 'asfsfdafs',
1291 'ManifestResourceFile':
1292 '$(IntDir)\\$(TargetFileName).embed.manifest.resfdsf',
1293 'OutputManifestFile': '$(TargetPath).manifestdfs',
1294 'RegistrarScriptFile': 'sdfsfd',
1295 'ReplacementsFile': 'sdffsd',
1296 'SuppressStartupBanner': 'false',
1297 'TypeLibraryFile': 'sfsd',
1298 'UpdateFileHashes': 'true',
1299 'UpdateFileHashesSearchPath': 'sfsd',
1300 'UseFAT32Workaround': 'true',
1301 'UseUnicodeResponseFiles': 'false',
1302 'VerboseOutput': 'true'}}
1303 expected_msbuild_settings = {
1304 'ClCompile': {
1305 'AdditionalIncludeDirectories': 'dir1',
1306 'AdditionalOptions': '/more /J',
1307 'AdditionalUsingDirectories': 'test',
1308 'AssemblerListingLocation': '$(IntDir)a',
1309 'AssemblerOutput': 'AssemblyCode',
1310 'BasicRuntimeChecks': 'EnableFastChecks',
1311 'BrowseInformation': 'true',
1312 'BrowseInformationFile': '$(IntDir)e',
1313 'BufferSecurityCheck': 'false',
1314 'CallingConvention': 'FastCall',
1315 'CompileAs': 'CompileAsC',
1316 'DebugInformationFormat': 'EditAndContinue',
1317 'DisableLanguageExtensions': 'true',
1318 'DisableSpecificWarnings': 'abc',
1319 'EnableEnhancedInstructionSet': 'StreamingSIMDExtensions',
1320 'EnableFiberSafeOptimizations': 'true',
1321 'EnablePREfast': 'true',
1322 'ErrorReporting': 'Queue',
1323 'ExceptionHandling': 'Async',
1324 'ExpandAttributedSource': 'true',
1325 'FavorSizeOrSpeed': 'Size',
1326 'FloatingPointExceptions': 'true',
1327 'FloatingPointModel': 'Strict',
1328 'ForceConformanceInForLoopScope': 'false',
1329 'ForcedIncludeFiles': 'def',
1330 'ForcedUsingFiles': 'ge',
1331 'FunctionLevelLinking': 'true',
1332 'GenerateXMLDocumentationFiles': 'true',
1333 'IgnoreStandardIncludePath': 'true',
1334 'InlineFunctionExpansion': 'OnlyExplicitInline',
1335 'IntrinsicFunctions': 'true',
1336 'MinimalRebuild': 'true',
1337 'ObjectFileName': '$(IntDir)b',
1338 'OmitDefaultLibName': 'true',
1339 'OmitFramePointers': 'true',
1340 'OpenMPSupport': 'true',
1341 'Optimization': 'Full',
1342 'PrecompiledHeader': 'NotUsing', # Actual conversion gives ''
1343 'PrecompiledHeaderFile': 'StdAfx.hd',
1344 'PrecompiledHeaderOutputFile': '$(IntDir)$(TargetName).pche',
1345 'PreprocessKeepComments': 'true',
1346 'PreprocessorDefinitions': 'WIN32;_DEBUG;_CONSOLE',
1347 'PreprocessSuppressLineNumbers': 'true',
1348 'PreprocessToFile': 'true',
1349 'ProgramDataBaseFileName': '$(IntDir)vc90b.pdb',
1350 'RuntimeLibrary': 'MultiThreadedDebugDLL',
1351 'RuntimeTypeInfo': 'false',
1352 'ShowIncludes': 'true',
1353 'SmallerTypeCheck': 'true',
1354 'StringPooling': 'true',
1355 'StructMemberAlignment': '4Bytes',
1356 'SuppressStartupBanner': 'false',
1357 'TreatWarningAsError': 'true',
1358 'TreatWChar_tAsBuiltInType': 'false',
1359 'UndefineAllPreprocessorDefinitions': 'true',
1360 'UndefinePreprocessorDefinitions': 'wer',
1361 'UseFullPaths': 'true',
1362 'WarningLevel': 'Level3',
1363 'WholeProgramOptimization': 'true',
1364 'XMLDocumentationFileName': '$(IntDir)c'},
1365 'Link': {
1366 'AdditionalDependencies': 'zx',
1367 'AdditionalLibraryDirectories': 'asd',
1368 'AdditionalManifestDependencies': 's2',
1369 'AdditionalOptions': '/mor2',
1370 'AddModuleNamesToAssembly': 'd1',
1371 'AllowIsolation': 'false',
1372 'AssemblyDebug': 'true',
1373 'AssemblyLinkResource': 'd5',
1374 'BaseAddress': '23423',
1375 'CLRImageType': 'ForceSafeILImage',
1376 'CLRThreadAttribute': 'MTAThreadingAttribute',
1377 'CLRUnmanagedCodeCheck': 'true',
1378 'DataExecutionPrevention': '',
1379 'DelayLoadDLLs': 'd4',
1380 'DelaySign': 'true',
1381 'Driver': 'UpOnly',
1382 'EmbedManagedResourceFile': 'd2',
1383 'EnableCOMDATFolding': 'false',
1384 'EnableUAC': 'false',
1385 'EntryPointSymbol': 'f5',
1386 'FixedBaseAddress': 'false',
1387 'ForceSymbolReferences': 'd3',
1388 'FunctionOrder': 'fssdfsd',
1389 'GenerateDebugInformation': 'true',
1390 'GenerateMapFile': 'true',
1391 'HeapCommitSize': '13',
1392 'HeapReserveSize': '12',
1393 'IgnoreAllDefaultLibraries': 'true',
1394 'IgnoreEmbeddedIDL': 'true',
1395 'IgnoreSpecificDefaultLibraries': 'flob;flok',
1396 'ImportLibrary': 'f4',
1397 'KeyContainer': 'f7',
1398 'KeyFile': 'f6',
1399 'LargeAddressAware': 'true',
1400 'LinkErrorReporting': 'QueueForNextLogin',
1401 'LinkTimeCodeGeneration': 'UseLinkTimeCodeGeneration',
1402 'ManifestFile': '$(IntDir)$(TargetFileName).2intermediate.manifest',
1403 'MapExports': 'true',
1404 'MapFileName': 'd5',
1405 'MergedIDLBaseFileName': 'f2',
1406 'MergeSections': 'f5',
1407 'MidlCommandFile': 'f1',
1408 'ModuleDefinitionFile': 'sdsd',
1409 'NoEntryPoint': 'true',
1410 'OptimizeReferences': 'true',
1411 'OutputFile': '$(OutDir)$(ProjectName)2.exe',
1412 'PerUserRedirection': 'true',
1413 'Profile': 'true',
1414 'ProfileGuidedDatabase': '$(TargetDir)$(TargetName).pgdd',
1415 'ProgramDatabaseFile': 'Flob.pdb',
1416 'RandomizedBaseAddress': 'false',
1417 'RegisterOutput': 'true',
1418 'SetChecksum': 'false',
1419 'ShowProgress': 'LinkVerbose',
1420 'StackCommitSize': '15',
1421 'StackReserveSize': '14',
1422 'StripPrivateSymbols': 'd3',
1423 'SubSystem': 'Console',
1424 'SupportUnloadOfDelayLoadedDLL': 'true',
1425 'SuppressStartupBanner': 'false',
1426 'SwapRunFromCD': 'true',
1427 'SwapRunFromNET': 'true',
1428 'TargetMachine': 'MachineX86',
1429 'TerminalServerAware': 'false',
1430 'TurnOffAssemblyGeneration': 'true',
1431 'TypeLibraryFile': 'f3',
1432 'TypeLibraryResourceID': '12',
1433 'UACExecutionLevel': 'RequireAdministrator',
1434 'UACUIAccess': 'true',
1435 'Version': '333'},
1436 'ResourceCompile': {
1437 'AdditionalIncludeDirectories': 'f3',
1438 'AdditionalOptions': '/more3',
1439 'Culture': '0x0c0c',
1440 'IgnoreStandardIncludePath': 'true',
1441 'PreprocessorDefinitions': '_UNICODE;UNICODE2',
1442 'ResourceOutputFileName': '$(IntDir)%(Filename)3.res',
1443 'ShowProgress': 'true'},
1444 'Mt': {
1445 'AdditionalManifestFiles': 'sfsdfsd',
1446 'AdditionalOptions': 'afdsdafsd',
1447 'AssemblyIdentity': 'sddfdsadfsa',
1448 'ComponentFileName': 'fsdfds',
1449 'GenerateCatalogFiles': 'true',
1450 'InputResourceManifests': 'asfsfdafs',
1451 'OutputManifestFile': '$(TargetPath).manifestdfs',
1452 'RegistrarScriptFile': 'sdfsfd',
1453 'ReplacementsFile': 'sdffsd',
1454 'SuppressStartupBanner': 'false',
1455 'TypeLibraryFile': 'sfsd',
1456 'UpdateFileHashes': 'true',
1457 'UpdateFileHashesSearchPath': 'sfsd',
1458 'VerboseOutput': 'true'},
1459 'ProjectReference': {
1460 'LinkLibraryDependencies': 'false',
1461 'UseLibraryDependencyInputs': 'true'},
1462 '': {
1463 'EmbedManifest': 'false',
1464 'GenerateManifest': 'false',
1465 'IgnoreImportLibrary': 'true',
1466 'LinkIncremental': ''
1467 },
1468 'ManifestResourceCompile': {
1469 'ResourceOutputFileName':
1470 '$(IntDir)$(TargetFileName).embed.manifest.resfdsf'}
1471 }
1472 actual_msbuild_settings = MSVSSettings.ConvertToMSBuildSettings(
1473 msvs_settings,
1474 self.stderr)
1475 self.assertEqual(expected_msbuild_settings, actual_msbuild_settings)
1476 self._ExpectedWarnings([])
1477
1478 if __name__ == '__main__':
1479 unittest.main()