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

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 shutil 15 import shutil
16 import string 16 import string
17 import xml_patch 17 import xml_patch
18 import xml.etree.ElementTree 18 import xml.etree.ElementTree
19 19
20
21 PEPPER_PLATFORM_NAME = 'PPAPI'
22
20 SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) 23 SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
21 24
22 PLATFORM_FILES = [ 25 PLATFORM_FILES = [
23 ('Microsoft.Cpp.Win32.default.props', 26 ('Microsoft.Cpp.Win32.default.props',
24 'Microsoft.Cpp.[platform].default.props.patch', 27 'Microsoft.Cpp.[platform].default.props.patch',
25 'Microsoft.Cpp.PPAPI.default.props'), 28 'Microsoft.Cpp.PPAPI.default.props'),
26 ('Microsoft.Cpp.Win32.props', 29 ('Microsoft.Cpp.Win32.props',
27 'Microsoft.Cpp.[platform].props.patch', 30 'Microsoft.Cpp.[platform].props.patch',
28 'Microsoft.Cpp.PPAPI.props'), 31 'Microsoft.Cpp.PPAPI.props'),
29 ('Microsoft.Cpp.Win32.targets', 32 ('Microsoft.Cpp.Win32.targets',
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 for key, value in elem.attrib.items(): 133 for key, value in elem.attrib.items():
131 # If the attribute does not have a namespace yet then give it one. 134 # If the attribute does not have a namespace yet then give it one.
132 if key[:1] != "{": 135 if key[:1] != "{":
133 new_key = "{%s}%s" % (default_namespace, key) 136 new_key = "{%s}%s" % (default_namespace, key)
134 new_attrib[new_key] = value 137 new_attrib[new_key] = value
135 else: 138 else:
136 new_attrib[key] = value 139 new_attrib[key] = value
137 elem.attrib = new_attrib 140 elem.attrib = new_attrib
138 141
139 142
140 def main(): 143 def CreatePPAPI(msbuild_dir):
141 install_dir = os.path.expandvars( 144 """Creates the PPAPI template.
142 '%ProgramFiles(x86)%\\MSBuild\\Microsoft.Cpp\\v4.0\\Platforms') 145
146 Args:
147 msbuild_dir: The path to the MSBuild installation.
148
149 Returns:
150 Nothing.
151
152 Raises:
153 Exception indicating Win32 platform was not found.
154 """
155
156 install_dir = os.path.join(msbuild_dir, 'Microsoft.Cpp\\v4.0\\Platforms')
143 157
144 # Note 1033 is code for the english language. 158 # Note 1033 is code for the english language.
145 ui_xml_dir = os.path.expandvars( 159 ui_xml_dir = os.path.join(msbuild_dir, 'Microsoft.Cpp\\v4.0\\1033')
146 '%ProgramFiles(x86)%\\MSBuild\\Microsoft.Cpp\\v4.0\\1033')
147 160
148 win32_dir = os.path.join(install_dir, 'Win32') 161 win32_dir = os.path.join(install_dir, 'Win32')
149 ppapi_dir = os.path.join(install_dir, 'PPAPI') 162 ppapi_dir = os.path.join(install_dir, PEPPER_PLATFORM_NAME)
150 patch_dir = os.path.join(SCRIPT_DIR, 'PPAPI_Patch') 163 patch_dir = os.path.join(SCRIPT_DIR, 'PPAPI_Patch')
151 164
152 if not os.path.exists(win32_dir): 165 if not os.path.exists(win32_dir):
153 raise Exception('Win32 platform is not installed on this machine!') 166 raise Exception('Win32 platform is not installed on this machine!')
154 167
155 for template_creation in PLATFORM_FILES: 168 for template_creation in PLATFORM_FILES:
156 CreateTemplateFile( 169 CreateTemplateFile(
157 os.path.join(win32_dir, template_creation[0]), 170 os.path.join(win32_dir, template_creation[0]),
158 os.path.join(patch_dir, template_creation[1]), 171 os.path.join(patch_dir, template_creation[1]),
159 os.path.join(ppapi_dir, template_creation[2])) 172 os.path.join(ppapi_dir, template_creation[2]))
160 173
161 for template_creation in UI_FILES: 174 for template_creation in UI_FILES:
162 CreateTemplateFile( 175 CreateTemplateFile(
163 os.path.join(ui_xml_dir, template_creation[0]), 176 os.path.join(ui_xml_dir, template_creation[0]),
164 os.path.join(patch_dir, template_creation[1]), 177 os.path.join(patch_dir, template_creation[1]),
165 os.path.join(ppapi_dir, template_creation[2])) 178 os.path.join(ppapi_dir, template_creation[2]))
166 179
167 for file_name in COPY_FILES: 180 for file_name in COPY_FILES:
168 copy_from = os.path.join(patch_dir, file_name) 181 copy_from = os.path.join(patch_dir, file_name)
169 copy_to = os.path.join(ppapi_dir, file_name) 182 copy_to = os.path.join(ppapi_dir, file_name)
170 if not os.path.exists(os.path.dirname(copy_to)): 183 if not os.path.exists(os.path.dirname(copy_to)):
171 os.makedirs(os.path.dirname(copy_to)) 184 os.makedirs(os.path.dirname(copy_to))
172 shutil.copyfile(copy_from, copy_to) 185 shutil.copyfile(copy_from, copy_to)
173 186
174 shutil.copyfile( 187 shutil.copyfile(
175 os.path.join(win32_dir, 'Microsoft.Build.CPPTasks.Win32.dll'), 188 os.path.join(win32_dir, 'Microsoft.Build.CPPTasks.Win32.dll'),
176 os.path.join(ppapi_dir, 'Microsoft.Build.CPPTasks.PPAPI.dll')) 189 os.path.join(ppapi_dir, 'Microsoft.Build.CPPTasks.PPAPI.dll'))
177 190
178 191
192 def main(argv):
193 # Optionally pass in MS Build installation directory.
binji 2012/07/26 23:32:17 now that you have args, you should really add optp
tysand 2012/07/28 01:13:11 Done.
194 if len(argv) > 1:
195 msbuild_dir = argv[1]
196 else:
197 msbuild_dir = os.path.expandvars('%ProgramFiles(x86)%\\MSBuild')
198 CreatePPAPI(msbuild_dir)
199
179 if __name__ == '__main__': 200 if __name__ == '__main__':
180 main() 201 main(sys.argv)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698