Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(97)

Side by Side Diff: visual_studio/NativeClientVSAddIn/InstallerResources/create_ppapi_platform.py

Issue 10831030: NaCl settings and completed install scripts. (Closed) Base URL: https://nativeclient-sdk.googlecode.com/svn/trunk/src
Patch Set: Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """ This script creates the PPAPI project settings template. 6 """ This script creates the PPAPI project settings template.
7 7
8 For copyright reasons, we should not directly distribute the PPAPI template 8 For copyright reasons, we should not directly distribute the PPAPI template
9 because it is nearly a clone of the Win32 template which is Copyrighted. 9 because it is nearly a clone of the Win32 template which is Copyrighted.
10 Instead, this script copies the existing Win32 template from the user's system 10 Instead, this script copies the existing Win32 template from the user's system
11 and intelligently modifies the copy to be the PPAPI template. 11 and intelligently modifies the copy to be the PPAPI template.
12 """ 12 """
13 13
14 import os 14 import os
15 import optparse
15 import shutil 16 import shutil
16 import string 17 import string
17 import xml_patch 18 import xml_patch
18 import xml.etree.ElementTree 19 import third_party.etree.ElementTree as ElementTree
20
21
22 PEPPER_PLATFORM_NAME = 'PPAPI'
23
24 DEFAULT_MS_BUILD_DIRECTORY = os.path.expandvars('%ProgramFiles(x86)%\\MSBuild')
19 25
20 SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) 26 SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
21 27
22 PLATFORM_FILES = [ 28 PLATFORM_FILES = [
23 ('Microsoft.Cpp.Win32.default.props', 29 ('Microsoft.Cpp.Win32.default.props',
24 'Microsoft.Cpp.[platform].default.props.patch', 30 'Microsoft.Cpp.[platform].default.props.patch',
25 'Microsoft.Cpp.PPAPI.default.props'), 31 'Microsoft.Cpp.PPAPI.default.props'),
26 ('Microsoft.Cpp.Win32.props', 32 ('Microsoft.Cpp.Win32.props',
27 'Microsoft.Cpp.[platform].props.patch', 33 'Microsoft.Cpp.[platform].props.patch',
28 'Microsoft.Cpp.PPAPI.props'), 34 'Microsoft.Cpp.PPAPI.props'),
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 def CreateTemplateFile(source, patch, dest): 93 def CreateTemplateFile(source, patch, dest):
88 """Creates a single PPAPI template file. 94 """Creates a single PPAPI template file.
89 95
90 Args: 96 Args:
91 source: The path source file to create from. 97 source: The path source file to create from.
92 patch: The path to the patch file to apply. 98 patch: The path to the patch file to apply.
93 dest: The path to the file to create. 99 dest: The path to the file to create.
94 Returns: 100 Returns:
95 None. 101 None.
96 """ 102 """
97 source_xml = xml.etree.ElementTree.parse(source) 103 source_xml = ElementTree.parse(source)
98 patch_xml = xml.etree.ElementTree.parse(patch) 104 patch_xml = ElementTree.parse(patch)
99 modified_xml = xml_patch.PatchXML(source_xml, patch_xml) 105 modified_xml = xml_patch.PatchXML(source_xml, patch_xml)
100 106
101 if not os.path.exists(os.path.dirname(dest)): 107 if not os.path.exists(os.path.dirname(dest)):
102 os.makedirs(os.path.dirname(dest)) 108 os.makedirs(os.path.dirname(dest))
103 109
104 FixAttributesNamespace(modified_xml) 110 FixAttributesNamespace(modified_xml)
105 default_namespace = GetDefaultNamespace(modified_xml) 111 default_namespace = GetDefaultNamespace(modified_xml)
106 modified_xml.write(dest, default_namespace=default_namespace) 112 modified_xml.write(dest, default_namespace=default_namespace)
107 PrependCopyright(source, dest) 113 PrependCopyright(source, dest)
108 114
(...skipping 21 matching lines...) Expand all
130 for key, value in elem.attrib.items(): 136 for key, value in elem.attrib.items():
131 # If the attribute does not have a namespace yet then give it one. 137 # If the attribute does not have a namespace yet then give it one.
132 if key[:1] != "{": 138 if key[:1] != "{":
133 new_key = "{%s}%s" % (default_namespace, key) 139 new_key = "{%s}%s" % (default_namespace, key)
134 new_attrib[new_key] = value 140 new_attrib[new_key] = value
135 else: 141 else:
136 new_attrib[key] = value 142 new_attrib[key] = value
137 elem.attrib = new_attrib 143 elem.attrib = new_attrib
138 144
139 145
140 def main(): 146 def CreatePPAPI(msbuild_dir):
141 install_dir = os.path.expandvars( 147 """Creates the PPAPI template.
142 '%ProgramFiles(x86)%\\MSBuild\\Microsoft.Cpp\\v4.0\\Platforms') 148
149 Args:
150 msbuild_dir: The path to the MSBuild installation.
151
152 Returns:
153 Nothing.
154
155 Raises:
156 Exception indicating Win32 platform was not found.
157 """
158 if not os.path.exists(msbuild_dir):
159 raise Exception('MSBuild directory was not found!')
160
161 install_dir = os.path.join(msbuild_dir, 'Microsoft.Cpp\\v4.0\\Platforms')
143 162
144 # Note 1033 is code for the english language. 163 # Note 1033 is code for the english language.
145 ui_xml_dir = os.path.expandvars( 164 ui_xml_dir = os.path.join(msbuild_dir, 'Microsoft.Cpp\\v4.0\\1033')
146 '%ProgramFiles(x86)%\\MSBuild\\Microsoft.Cpp\\v4.0\\1033')
147 165
148 win32_dir = os.path.join(install_dir, 'Win32') 166 win32_dir = os.path.join(install_dir, 'Win32')
149 ppapi_dir = os.path.join(install_dir, 'PPAPI') 167 ppapi_dir = os.path.join(install_dir, PEPPER_PLATFORM_NAME)
150 patch_dir = os.path.join(SCRIPT_DIR, 'PPAPI_Patch') 168 patch_dir = os.path.join(SCRIPT_DIR, 'PPAPI_Patch')
151 169
152 if not os.path.exists(win32_dir): 170 if not os.path.exists(win32_dir):
153 raise Exception('Win32 platform is not installed on this machine!') 171 raise Exception('Win32 platform is not installed on this machine!')
154 172
155 for template_creation in PLATFORM_FILES: 173 for template_creation in PLATFORM_FILES:
156 CreateTemplateFile( 174 CreateTemplateFile(
157 os.path.join(win32_dir, template_creation[0]), 175 os.path.join(win32_dir, template_creation[0]),
158 os.path.join(patch_dir, template_creation[1]), 176 os.path.join(patch_dir, template_creation[1]),
159 os.path.join(ppapi_dir, template_creation[2])) 177 os.path.join(ppapi_dir, template_creation[2]))
160 178
161 for template_creation in UI_FILES: 179 for template_creation in UI_FILES:
162 CreateTemplateFile( 180 CreateTemplateFile(
163 os.path.join(ui_xml_dir, template_creation[0]), 181 os.path.join(ui_xml_dir, template_creation[0]),
164 os.path.join(patch_dir, template_creation[1]), 182 os.path.join(patch_dir, template_creation[1]),
165 os.path.join(ppapi_dir, template_creation[2])) 183 os.path.join(ppapi_dir, template_creation[2]))
166 184
167 for file_name in COPY_FILES: 185 for file_name in COPY_FILES:
168 copy_from = os.path.join(patch_dir, file_name) 186 copy_from = os.path.join(patch_dir, file_name)
169 copy_to = os.path.join(ppapi_dir, file_name) 187 copy_to = os.path.join(ppapi_dir, file_name)
170 if not os.path.exists(os.path.dirname(copy_to)): 188 if not os.path.exists(os.path.dirname(copy_to)):
171 os.makedirs(os.path.dirname(copy_to)) 189 os.makedirs(os.path.dirname(copy_to))
172 shutil.copyfile(copy_from, copy_to) 190 shutil.copyfile(copy_from, copy_to)
173 191
174 shutil.copyfile( 192 shutil.copyfile(
175 os.path.join(win32_dir, 'Microsoft.Build.CPPTasks.Win32.dll'), 193 os.path.join(win32_dir, 'Microsoft.Build.CPPTasks.Win32.dll'),
176 os.path.join(ppapi_dir, 'Microsoft.Build.CPPTasks.PPAPI.dll')) 194 os.path.join(ppapi_dir, 'Microsoft.Build.CPPTasks.PPAPI.dll'))
177 195
178 196
197 def main():
198 parser = optparse.OptionParser(usage='Usage: %prog [options]')
199 parser.add_option('-b', '--msbuild-path', dest='msbuild_path',
200 default=DEFAULT_MS_BUILD_DIRECTORY,
201 help='Provide the path to the MSBuild directory', metavar='PATH')
202 (options, args) = parser.parse_args()
203 CreatePPAPI(options.msbuild_path)
204
179 if __name__ == '__main__': 205 if __name__ == '__main__':
180 main() 206 main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698