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

Unified Diff: visual_studio/NativeClientVSAddIn/InstallerResources/create_ppapi_platform.py

Issue 14122017: [VS Addin] Add visual studio 2012 support (Closed) Base URL: https://nativeclient-sdk.googlecode.com/svn/trunk/src
Patch Set: Created 7 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: visual_studio/NativeClientVSAddIn/InstallerResources/create_ppapi_platform.py
diff --git a/visual_studio/NativeClientVSAddIn/InstallerResources/create_ppapi_platform.py b/visual_studio/NativeClientVSAddIn/InstallerResources/create_ppapi_platform.py
index 252ae5a5ec559e251e7837013b91f217d65f8bef..085ed4bde0d1b81d6946694349d632e56cff4b83 100644
--- a/visual_studio/NativeClientVSAddIn/InstallerResources/create_ppapi_platform.py
+++ b/visual_studio/NativeClientVSAddIn/InstallerResources/create_ppapi_platform.py
@@ -17,7 +17,7 @@ import shutil
import string
import xml_patch
import third_party.etree.ElementTree as ElementTree
-
+import sys
PEPPER_PLATFORM_NAME = 'PPAPI'
@@ -25,23 +25,37 @@ DEFAULT_MS_BUILD_DIRECTORY = os.path.expandvars('%ProgramFiles(x86)%\\MSBuild')
SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
-PLATFORM_FILES = [
+PLATFORM_FILES_2010 = [
('Microsoft.Cpp.Win32.default.props',
- 'Microsoft.Cpp.[platform].default.props.patch',
+ 'Microsoft.Cpp.Win32.default.props.patch',
'Microsoft.Cpp.PPAPI.default.props'),
('Microsoft.Cpp.Win32.props',
- 'Microsoft.Cpp.[platform].props.patch',
+ 'Microsoft.Cpp.Win32.props.patch',
'Microsoft.Cpp.PPAPI.props'),
('Microsoft.Cpp.Win32.targets',
- 'Microsoft.Cpp.[platform].targets.patch',
+ 'Microsoft.Cpp.Win32.targets.patch',
'Microsoft.Cpp.PPAPI.targets'),
('PlatformToolsets\\v100\\Microsoft.Cpp.Win32.v100.props',
- 'PlatformToolsets\\v100\\Microsoft.Cpp.[platform].v100.props.patch',
+ 'PlatformToolsets\\v100\\Microsoft.Cpp.Win32.v100.props.patch',
'PlatformToolsets\\v100\\Microsoft.Cpp.PPAPI.v100.props'),
('PlatformToolsets\\v100\\Microsoft.Cpp.Win32.v100.targets',
- 'PlatformToolsets\\v100\\Microsoft.Cpp.[platform].v100.targets.patch',
+ 'PlatformToolsets\\v100\\Microsoft.Cpp.Win32.v100.targets.patch',
'PlatformToolsets\\v100\\Microsoft.Cpp.PPAPI.v100.targets')]
+PLATFORM_FILES_2012 = [
+ ('Microsoft.Cpp.Win32.default.props',
+ 'V110/Microsoft.Cpp.Win32.default.props.patch',
+ 'Microsoft.Cpp.PPAPI.default.props'),
+ ('Microsoft.Cpp.Win32.targets',
+ 'V110/Microsoft.Cpp.Win32.targets.patch',
+ 'Microsoft.Cpp.PPAPI.targets'),
+ ('PlatformToolsets\\v110\\Microsoft.Cpp.Win32.v110.props',
+ 'V110\\PlatformToolsets\\v110\\Microsoft.Cpp.Win32.v110.props.patch',
+ 'PlatformToolsets\\v110\\Microsoft.Cpp.PPAPI.v110.props'),
+ ('PlatformToolsets\\v110\\Microsoft.Cpp.Win32.v110.targets',
+ 'V110\\PlatformToolsets\\v110\\Microsoft.Cpp.Win32.v110.targets.patch',
+ 'PlatformToolsets\\v110\\Microsoft.Cpp.PPAPI.v110.targets')]
+
UI_FILES = [
('general.xml',
'Props\\ppapi_general.xml.patch',
@@ -50,10 +64,14 @@ UI_FILES = [
'Props\\ppapi_general_ps.xml.patch',
'Props\\ppapi_general_ps.xml')]
-COPY_FILES = [
+ADD_FILES = [
'ImportAfter\\PPAPI.override.props']
+class Error(Exception):
+ pass
+
+
def PrependCopyright(source_file_name, dest_file_name):
"""Adds the copyright notice from source file to the dest file.
@@ -102,7 +120,11 @@ def CreateTemplateFile(source, patch, dest):
"""
source_xml = ElementTree.parse(source)
patch_xml = ElementTree.parse(patch)
- modified_xml = xml_patch.PatchXML(source_xml, patch_xml)
+ print "Patching: %s" % dest
+ try:
+ modified_xml = xml_patch.PatchXML(source_xml, patch_xml)
+ except Exception as e:
+ raise Error("Error patching file: %s: %s" % (source, e))
if not os.path.exists(os.path.dirname(dest)):
os.makedirs(os.path.dirname(dest))
@@ -143,34 +165,41 @@ def FixAttributesNamespace(tree):
elem.attrib = new_attrib
-def CreatePPAPI(msbuild_dir):
- """Creates the PPAPI template.
+def CreatePPAPIPlatform(install_dir):
+ if not os.path.exists(install_dir):
+ raise Error('install directory was not found: %s' % install_dir)
- Args:
- msbuild_dir: The path to the MSBuild installation.
-
- Returns:
- Nothing.
-
- Raises:
- Exception indicating Win32 platform was not found.
- """
- if not os.path.exists(msbuild_dir):
- raise Exception('MSBuild directory was not found!')
-
- install_dir = os.path.join(msbuild_dir, 'Microsoft.Cpp\\v4.0\\Platforms')
# Note 1033 is code for the english language.
- ui_xml_dir = os.path.join(msbuild_dir, 'Microsoft.Cpp\\v4.0\\1033')
+ ui_xml_dir = os.path.join(os.path.dirname(install_dir), '1033')
win32_dir = os.path.join(install_dir, 'Win32')
ppapi_dir = os.path.join(install_dir, PEPPER_PLATFORM_NAME)
patch_dir = os.path.join(SCRIPT_DIR, 'PPAPI_Patch')
if not os.path.exists(win32_dir):
- raise Exception('Win32 platform is not installed on this machine!')
+ raise Error('Win32 MSBuild folder not found: %s' % win32_dir)
binji 2013/05/25 00:02:55 s/folder/directory/
Sam Clegg 2013/05/29 04:58:33 Done.
+
+ print "Cloning Win32 platform from: %s" % win32_dir
+
+ for root, dirs, files in os.walk(win32_dir):
+ root = root.replace(win32_dir, '')[1:]
- for template_creation in PLATFORM_FILES:
+ if not os.path.exists(os.path.join(ppapi_dir, root)):
+ os.makedirs(os.path.join(ppapi_dir, root))
+
+ for filename in files:
+ src = os.path.join(win32_dir, root, filename)
+ dest = os.path.join(ppapi_dir, root, filename.replace('Win32', 'PPAPI'))
+ #print "duplicating: %s" % dest
binji 2013/05/25 00:02:55 remove
Sam Clegg 2013/05/29 04:58:33 Done.
+ shutil.copyfile(src, dest)
+
+ if 'V110' in install_dir:
+ platform_files = PLATFORM_FILES_2012
+ else:
+ platform_files = PLATFORM_FILES_2010
+
+ for template_creation in platform_files:
CreateTemplateFile(
os.path.join(win32_dir, template_creation[0]),
os.path.join(patch_dir, template_creation[1]),
@@ -182,25 +211,53 @@ def CreatePPAPI(msbuild_dir):
os.path.join(patch_dir, template_creation[1]),
os.path.join(ppapi_dir, template_creation[2]))
- for file_name in COPY_FILES:
+ for file_name in ADD_FILES:
copy_from = os.path.join(patch_dir, file_name)
copy_to = os.path.join(ppapi_dir, file_name)
if not os.path.exists(os.path.dirname(copy_to)):
os.makedirs(os.path.dirname(copy_to))
shutil.copyfile(copy_from, copy_to)
- shutil.copyfile(
- os.path.join(win32_dir, 'Microsoft.Build.CPPTasks.Win32.dll'),
- os.path.join(ppapi_dir, 'Microsoft.Build.CPPTasks.PPAPI.dll'))
+def CreatePPAPI(msbuild_dir):
+ """Creates the PPAPI template.
+
+ Args:
+ msbuild_dir: The path to the MSBuild installation.
+
+ Returns:
+ Nothing.
+
+ Raises:
+ Error indicating Win32 platform was not found.
+ """
+
+ if not os.path.exists(msbuild_dir):
+ raise Error('MSBuild directory was not found: %s' % msbuild_dir)
+
+ install_dir = os.path.join(msbuild_dir, 'Microsoft.Cpp\\v4.0\\Platforms')
binji 2013/05/25 00:02:55 vs 2012 has this directory too?
Sam Clegg 2013/05/29 04:58:33 Done.
+ CreatePPAPIPlatform(install_dir)
+
+ install_dir = os.path.join(msbuild_dir,
+ 'Microsoft.Cpp\\v4.0\\V110\\Platforms')
+ if os.path.exists(install_dir):
+ CreatePPAPIPlatform(install_dir)
+
+
+def main(args):
+ try:
+ parser = optparse.OptionParser(usage='Usage: %prog [options]')
+ parser.add_option('-b', '--msbuild-path',
+ default=DEFAULT_MS_BUILD_DIRECTORY,
+ help='Provide the path to the MSBuild directory', metavar='PATH')
+ options, args = parser.parse_args(args)
+ CreatePPAPI(options.msbuild_path)
+
+ except Error as e:
+ sys.stderr.write("error: %s\n" % e)
+ return 1
-def main():
- parser = optparse.OptionParser(usage='Usage: %prog [options]')
- parser.add_option('-b', '--msbuild-path', dest='msbuild_path',
- default=DEFAULT_MS_BUILD_DIRECTORY,
- help='Provide the path to the MSBuild directory', metavar='PATH')
- (options, args) = parser.parse_args()
- CreatePPAPI(options.msbuild_path)
+ return 0
if __name__ == '__main__':
- main()
+ sys.exit(main(sys.argv[1:]))

Powered by Google App Engine
This is Rietveld 408576698