OSDN Git Service

Converted source/generateComInterfaces.py to an sconscript file (source/comInterfaces...
authorMichael Curran <mick@kulgan.net>
Wed, 30 Jan 2013 01:16:45 +0000 (11:16 +1000)
committerMichael Curran <mick@kulgan.net>
Wed, 30 Jan 2013 01:16:45 +0000 (11:16 +1000)
sconstruct
source/comInterfaces_sconscript [new file with mode: 0755]
source/generateComInterfaces.py [deleted file]

index 9a42ddf..23b883c 100755 (executable)
@@ -119,6 +119,8 @@ outFilePrefix = "nvda{type}_{version}".format(type="" if release else "_snapshot
 outputDir=Dir(env['outputDir'])\r
 devDocsOutputDir=outputDir.Dir('devDocs')\r
 \r
+env.SConscript('source/comInterfaces_sconscript',exports=['env'])\r
+\r
 #Process nvdaHelper scons files\r
 env.SConscript('nvdaHelper/sconscript',exports=['env'])\r
 \r
@@ -154,13 +156,13 @@ devGuide=env.Command(devDocsOutputDir.File('developerGuide.html'),htmlFile,Move(
 env.Alias("developerGuide",devGuide)\r
 \r
 #Generate all needed comtypes COM interfaces\r
-command = ['cd', sourceDir.path, '&&', sys.executable]\r
-if release:\r
-       command.append('-O')\r
-command.append('generateComInterfaces.py')\r
-comInterfaces = env.Command(sourceDir.Dir('comInterfaces'), None, [command])\r
-env.AlwaysBuild(comInterfaces)\r
-env.Depends(comInterfaces,sourceDir.Dir('typelibs'))\r
+#command = ['cd', sourceDir.path, '&&', sys.executable]\r
+#if release:\r
+#      command.append('-O')\r
+#command.append('generateComInterfaces.py')\r
+#comInterfaces = env.Command(sourceDir.Dir('comInterfaces'), None, [command])\r
+#env.AlwaysBuild(comInterfaces)\r
+#env.Depends(comInterfaces,sourceDir.Dir('typelibs'))\r
 \r
 \r
 # A builder to generate an NVDA distribution.\r
diff --git a/source/comInterfaces_sconscript b/source/comInterfaces_sconscript
new file mode 100755 (executable)
index 0000000..1204606
--- /dev/null
@@ -0,0 +1,57 @@
+###\r
+#This file is a part of the NVDA project.\r
+#URL: http://www.nvda-project.org/\r
+#Copyright 2006-2010 NVDA contributers.\r
+#This program is free software: you can redistribute it and/or modify\r
+#it under the terms of the GNU General Public License version 2.0, as published by\r
+#the Free Software Foundation.\r
+#This program is distributed in the hope that it will be useful,\r
+#but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\r
+#This license can be found at:\r
+#http://www.gnu.org/licenses/old-licenses/gpl-2.0.html\r
+###\r
+\r
+Import(\r
+       'env',\r
+)\r
+\r
+def interfaceAction(target,source,env):\r
+       clsid=env.get('clsid')\r
+       if clsid:\r
+               source=(clsid,env['majorVersion'],env['minorVersion'])\r
+       else:\r
+               source=str(source[0])\r
+       comtypes.client.GetModule(source)\r
+\r
+interfaceBuilder=env.Builder(\r
+       action=env.Action(interfaceAction),\r
+)\r
+env['BUILDERS']['comtypesInterface']=interfaceBuilder\r
+\r
+       #Bit of a dance to force comtypes generated interfaces in to our directory\r
+import comtypes.client\r
+comtypes.client.gen_dir=Dir('comInterfaces').abspath\r
+import sys\r
+sys.modules['comtypes.gen']=comtypes.gen=__import__("comInterfaces",globals(),locals(),[])\r
+\r
+COM_INTERFACES = {\r
+       "UIAutomationClient.py": ('{944de083-8fb8-45cf-bcb7-c477acb2f897}',1,0),\r
+       "IAccessible2Lib.py": "typelibs/ia2.tlb",\r
+       #"Accessibility.py": ('{1EA4DBF0-3C3B-11CF-810C-00AA00389B71}',1,0),\r
+       "tom.py": ('{8CC497C9-A1DF-11CE-8098-00AA0047BE5D}',1,0),\r
+       "SpeechLib.py": ('{C866CA3A-32F7-11D2-9602-00C04F8EE628}',5,0),\r
+       "AcrobatAccessLib.py": "typelibs/AcrobatAccess.tlb",\r
+       "FlashAccessibility.py": "typelibs/FlashAccessibility.tlb",\r
+}\r
+\r
+for k,v in COM_INTERFACES.iteritems():\r
+       target=Dir('comInterfaces').File(k)\r
+       source=clsid=majorVersion=None\r
+       if isinstance(v,basestring):\r
+               env.comtypesInterface(target,v)\r
+       else:\r
+               env.comtypesInterface(target,Dir('comInterfaces').File('__init__.py'),clsid=v[0],majorVersion=v[1],minorVersion=v[2])\r
+\r
+#When cleaning comInterfaces get rid of everything except for things starting with __ (e.g. __init__.py)\r
+env.Clean(Dir('comInterfaces'),Glob('comInterfaces/[!_]*')+Glob('comInterfaces/_[!_]*'))\r
diff --git a/source/generateComInterfaces.py b/source/generateComInterfaces.py
deleted file mode 100755 (executable)
index 2d242e0..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-#generateComInterfaces.py\r
-#A part of NonVisual Desktop Access (NVDA)\r
-#This file is covered by the GNU General Public License.\r
-#See the file COPYING for more details.\r
-#Copyright (C) 2006-2010 Michael Curran <mick@kulgan.net>, James Teh <jamie@jantrid.net>\r
-\r
-"""Script to generate Python code for required COM interfaces.\r
-This script will be run by SCons as appropriate.\r
-"""\r
-\r
-#Bit of a dance to force comtypes generated interfaces in to our directory\r
-import comtypes.client\r
-comtypes.client.gen_dir='.\\comInterfaces'\r
-import sys\r
-sys.modules['comtypes.gen']=comtypes.gen=__import__("comInterfaces",globals(),locals(),[])\r
-\r
-COM_INTERFACES = (\r
-       ("UI Automation", comtypes.client.GetModule, "UIAutomationCore.dll"),\r
-       ("IAccessible 2", comtypes.client.GetModule, "typelibs/ia2.tlb"),\r
-       ("MS Active Accessibility", comtypes.client.GetModule, "oleacc.dll"),\r
-       ("Rich Edit library", comtypes.client.GetModule, "msftedit.dll"),\r
-       ("SAPI 5", comtypes.client.CreateObject, "Sapi.SPVoice"),\r
-       ("Acrobat Access", comtypes.client.GetModule, "typelibs/AcrobatAccess.tlb"),\r
-       ("Flash Accessibility", comtypes.client.GetModule, "typelibs/FlashAccessibility.tlb"),\r
-)\r
-\r
-def main():\r
-       print "COM interfaces:"\r
-       for desc, func, interface in COM_INTERFACES:\r
-               print "%s:" % desc,\r
-               try:\r
-                       func(interface)\r
-                       print "done."\r
-               except:\r
-                       print "not found."\r
-       print\r
-\r
-if __name__ == "__main__":\r
-       main()\r