1 # Copyright (c) 2012 Google Inc. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
5 """Visual Studio project reader/writer."""
8 import gyp.easy_xml as easy_xml
12 """Visual Studio XML tool file writer."""
14 def __init__(self, tool_file_path, name):
15 """Initializes the tool file.
18 tool_file_path: Path to the tool file.
19 name: Name of the tool file.
21 self.tool_file_path = tool_file_path
23 self.rules_section = ['Rules']
25 def AddCustomBuildRule(self, name, cmd, description,
26 additional_dependencies,
28 """Adds a rule to the tool file.
31 name: Name of the rule.
32 description: Description of the rule.
33 cmd: Command line of the rule.
34 additional_dependencies: other files which may trigger the rule.
35 outputs: outputs of the rule.
36 extensions: extensions handled by the rule.
38 rule = ['CustomBuildRule',
40 'ExecutionDescription': description,
42 'Outputs': ';'.join(outputs),
43 'FileExtensions': ';'.join(extensions),
44 'AdditionalDependencies':
45 ';'.join(additional_dependencies)
47 self.rules_section.append(rule)
49 def WriteIfChanged(self):
50 """Writes the tool file."""
51 content = ['VisualStudioToolFile',
57 easy_xml.WriteXmlIfChanged(content, self.tool_file_path,
58 encoding="Windows-1252")