comparison mxtool/mx.py @ 15364:9693513ce95c

mx exportlibs: add option to include all defined libaries
author Bernhard Urban <bernhard.urban@jku.at>
date Thu, 24 Apr 2014 17:09:39 +0200
parents f14192b72692
children b3cd96f137a6
comparison
equal deleted inserted replaced
15363:c279c6773799 15364:9693513ce95c
4343 def exportlibs(args): 4343 def exportlibs(args):
4344 """export libraries to an archive file""" 4344 """export libraries to an archive file"""
4345 4345
4346 parser = ArgumentParser(prog='exportlibs') 4346 parser = ArgumentParser(prog='exportlibs')
4347 parser.add_argument('-b', '--base', action='store', help='base name of archive (default: libs)', default='libs', metavar='<path>') 4347 parser.add_argument('-b', '--base', action='store', help='base name of archive (default: libs)', default='libs', metavar='<path>')
4348 parser.add_argument('-a', '--include-all', action='store_true', help="include all defined libaries")
4348 parser.add_argument('--arc', action='store', choices=['tgz', 'tbz2', 'tar', 'zip'], default='tgz', help='the type of the archive to create') 4349 parser.add_argument('--arc', action='store', choices=['tgz', 'tbz2', 'tar', 'zip'], default='tgz', help='the type of the archive to create')
4349 parser.add_argument('--no-sha1', action='store_false', dest='sha1', help='do not create SHA1 signature of archive') 4350 parser.add_argument('--no-sha1', action='store_false', dest='sha1', help='do not create SHA1 signature of archive')
4350 parser.add_argument('--no-md5', action='store_false', dest='md5', help='do not create MD5 signature of archive') 4351 parser.add_argument('--no-md5', action='store_false', dest='md5', help='do not create MD5 signature of archive')
4351 parser.add_argument('--include-system-libs', action='store_true', help='include system libraries (i.e., those not downloaded from URLs)') 4352 parser.add_argument('--include-system-libs', action='store_true', help='include system libraries (i.e., those not downloaded from URLs)')
4352 parser.add_argument('extras', nargs=REMAINDER, help='extra files and directories to add to archive', metavar='files...') 4353 parser.add_argument('extras', nargs=REMAINDER, help='extra files and directories to add to archive', metavar='files...')
4364 logv('[warning: ' + apath + ' collides with ' + entries[arcname] + ' as ' + arcname + ']') 4365 logv('[warning: ' + apath + ' collides with ' + entries[arcname] + ' as ' + arcname + ']')
4365 else: 4366 else:
4366 logv('[already added ' + path + ']') 4367 logv('[already added ' + path + ']')
4367 4368
4368 libsToExport = set() 4369 libsToExport = set()
4369 def isValidLibrary(dep): 4370 if args.include_all:
4370 if dep in _libs.iterkeys(): 4371 for lib in _libs.itervalues():
4371 lib = _libs[dep] 4372 libsToExport.add(lib)
4372 if len(lib.urls) != 0 or args.include_system_libs: 4373 else:
4373 return lib 4374 def isValidLibrary(dep):
4374 return None 4375 if dep in _libs.iterkeys():
4375 4376 lib = _libs[dep]
4376 # iterate over all project dependencies and find used libraries 4377 if len(lib.urls) != 0 or args.include_system_libs:
4377 for p in _projects.itervalues(): 4378 return lib
4378 for dep in p.deps: 4379 return None
4379 r = isValidLibrary(dep) 4380
4380 if r: 4381 # iterate over all project dependencies and find used libraries
4381 libsToExport.add(r) 4382 for p in _projects.itervalues():
4382 4383 for dep in p.deps:
4383 # a library can have other libraries as dependency
4384 size = 0
4385 while size != len(libsToExport):
4386 size = len(libsToExport)
4387 for lib in libsToExport.copy():
4388 for dep in lib.deps:
4389 r = isValidLibrary(dep) 4384 r = isValidLibrary(dep)
4390 if r: 4385 if r:
4391 libsToExport.add(r) 4386 libsToExport.add(r)
4387
4388 # a library can have other libraries as dependency
4389 size = 0
4390 while size != len(libsToExport):
4391 size = len(libsToExport)
4392 for lib in libsToExport.copy():
4393 for dep in lib.deps:
4394 r = isValidLibrary(dep)
4395 if r:
4396 libsToExport.add(r)
4392 4397
4393 for lib in libsToExport: 4398 for lib in libsToExport:
4394 add(lib.get_path(resolve=True), lib.path) 4399 add(lib.get_path(resolve=True), lib.path)
4395 if lib.sha1: 4400 if lib.sha1:
4396 add(lib.get_path(resolve=True) + ".sha1", lib.path + ".sha1") 4401 add(lib.get_path(resolve=True) + ".sha1", lib.path + ".sha1")