@@ -654,15 +654,15 @@ def get_vbox_version(config_kmk):
654654 return "." .join ([major , minor , build ])
655655
656656def download_master (downloads ):
657- "Download the master xidl"
657+ print ( "Download the master xidl" )
658658 for dest , code in downloads :
659659 url = "http://www.virtualbox.org/svn/vbox/trunk/%s" % code
660660 if 0 != os .system ('wget -O %s %s' % (dest , url )):
661661 assert 0 == os .system ('curl %s > %s' % (url , dest ) )
662662 assert os .path .exists (dest ), "Failed to download %s" % url
663663
664664def download_stable (downloads ):
665- "Download latest tarball for stable release then unpack xidl"
665+ print ( "Download latest tarball for stable release then unpack xidl" )
666666 url = urllib2 .urlopen ('https://www.virtualbox.org/wiki/Downloads' )
667667 page = url .read ()
668668 match = re .search ("http://download.virtualbox.org/virtualbox/"
@@ -683,6 +683,7 @@ def download_stable(downloads):
683683 source_dir = os .path .splitext (tarname )[0 ]
684684 for dest , code in downloads :
685685 path = './%s/%s' % (source_dir , code )
686+ path .replace ('/' , os .path .sep )
686687 assert os .path .exists (path ), "Source file not found at %s" % path
687688 shutil .copy (path , dest )
688689
@@ -720,12 +721,30 @@ def main(virtualbox_xidl='VirtualBox.xidl',
720721 lib_doc = '''__doc__ = """\\ \n %s\n """\n \n ''' % get_doc (idl , 0 )
721722
722723 # Process the library
724+
723725 library = xml .getElementsByTagName ('library' )
724726 assert len (library ) == 1
725727 library = library [0 ]
726728
729+ # 5.2 introduced <library><application> ... </application></library>
730+ applications = xml .getElementsByTagName ('application' )
731+ if applications :
732+ for application in applications :
733+ name = application .attributes .get ('name' , None )
734+ if name is not None :
735+ if "VirtualBox" == name .value :
736+ break
737+ else :
738+ raise ValueError ("Failed to find VirtualBox application" )
739+ app_uuid = application .getAttribute ('uuid' )
740+ virtualbox_application = application
741+ else :
742+ app_uuid = library .getAttribute ('appUuid' )
743+ virtualbox_application = library
744+
745+ # Iterate each element under the virtualbox application node
727746 source = dict (result = [], enum = [], interface = [])
728- for node in library .childNodes :
747+ for node in virtualbox_application .childNodes :
729748 name = getattr (node , 'tagName' , None )
730749 if name is None :
731750 continue
@@ -744,7 +763,6 @@ def main(virtualbox_xidl='VirtualBox.xidl',
744763 vbox_version = get_vbox_version (config_kmk )
745764 uuid = library .getAttribute ('uuid' )
746765 version = library .getAttribute ('version' )
747- app_uuid = library .getAttribute ('appUuid' )
748766 xidl_hash = hashlib .md5 (xidl ).hexdigest ()
749767 lib_meta = LIB_META % dict (vbox_version = vbox_version ,
750768 uuid = uuid ,
@@ -765,6 +783,9 @@ def main(virtualbox_xidl='VirtualBox.xidl',
765783 print (" xidl hash : %s" % xidl_hash )
766784 print (" version : %s" % version )
767785 print (" line count : %s" % code .count ("\n " ))
768- with open ('virtualbox/library.py' , 'wb' ) as f :
786+ library_path = os .path .join ('.' , 'virtualbox' , 'library.py' )
787+ if os .path .exists (library_path ):
788+ os .unlink (library_path )
789+ with open (library_path , 'w' ) as f :
769790 f .write (code )
770791
0 commit comments