~ubuntu-branches/ubuntu/oneiric/mozc/oneiric

« back to all changes in this revision

Viewing changes to mozc_build_tools/gyp/pylib/gyp/MSVSToolFile.py

  • Committer: Bazaar Package Importer
  • Author(s): Nobuhiro Iwamatsu
  • Date: 2010-07-14 03:26:47 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20100714032647-13qjisj6m8cm8jdx
Tags: 0.12.410.102-1
* New upstream release (Closes: #588971).
  - Add mozc-server, mozc-utils-gui and scim-mozc packages.
* Update debian/rules.
  Add --gypdir option to build_mozc.py.
* Update debian/control.
  - Bumped standards-version to 3.9.0.
  - Update description.
* Add mozc icon (Closes: #588972).
* Add patch which revises issue 18.
  ibus_mozc_issue18.patch
* kFreeBSD build support.
  support_kfreebsd.patch

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/python2.4
 
2
 
 
3
# Copyright (c) 2009 Google Inc. All rights reserved.
 
4
# Use of this source code is governed by a BSD-style license that can be
 
5
# found in the LICENSE file.
 
6
 
 
7
"""Visual Studio project reader/writer."""
 
8
 
 
9
import common
 
10
import xml.dom
 
11
import xml.dom.minidom
 
12
 
 
13
 
 
14
#------------------------------------------------------------------------------
 
15
 
 
16
 
 
17
class Writer(object):
 
18
  """Visual Studio XML tool file writer."""
 
19
 
 
20
  def __init__(self, tool_file_path):
 
21
    """Initializes the tool file.
 
22
 
 
23
    Args:
 
24
      tool_file_path: Path to the tool file.
 
25
    """
 
26
    self.tool_file_path = tool_file_path
 
27
    self.doc = None
 
28
 
 
29
  def Create(self, name):
 
30
    """Creates the tool file document.
 
31
 
 
32
    Args:
 
33
      name: Name of the tool file.
 
34
    """
 
35
    self.name = name
 
36
 
 
37
    # Create XML doc
 
38
    xml_impl = xml.dom.getDOMImplementation()
 
39
    self.doc = xml_impl.createDocument(None, 'VisualStudioToolFile', None)
 
40
 
 
41
    # Add attributes to root element
 
42
    self.n_root = self.doc.documentElement
 
43
    self.n_root.setAttribute('Version', '8.00')
 
44
    self.n_root.setAttribute('Name', self.name)
 
45
 
 
46
    # Add rules section
 
47
    self.n_rules = self.doc.createElement('Rules')
 
48
    self.n_root.appendChild(self.n_rules)
 
49
 
 
50
  def AddCustomBuildRule(self, name, cmd, description,
 
51
                         additional_dependencies,
 
52
                         outputs, extensions):
 
53
    """Adds a rule to the tool file.
 
54
 
 
55
    Args:
 
56
      name: Name of the rule.
 
57
      description: Description of the rule.
 
58
      cmd: Command line of the rule.
 
59
      additional_dependencies: other files which may trigger the rule.
 
60
      outputs: outputs of the rule.
 
61
      extensions: extensions handled by the rule.
 
62
    """
 
63
    n_rule = self.doc.createElement('CustomBuildRule')
 
64
    n_rule.setAttribute('Name', name)
 
65
    n_rule.setAttribute('ExecutionDescription', description)
 
66
    n_rule.setAttribute('CommandLine', cmd)
 
67
    n_rule.setAttribute('Outputs', ';'.join(outputs))
 
68
    n_rule.setAttribute('FileExtensions', ';'.join(extensions))
 
69
    n_rule.setAttribute('AdditionalDependencies',
 
70
                        ';'.join(additional_dependencies))
 
71
    self.n_rules.appendChild(n_rule)
 
72
 
 
73
  def Write(self, writer=common.WriteOnDiff):
 
74
    """Writes the tool file."""
 
75
    f = writer(self.tool_file_path)
 
76
    self.doc.writexml(f, encoding='Windows-1252', addindent='  ', newl='\r\n')
 
77
    f.close()
 
78
 
 
79
#------------------------------------------------------------------------------