build-test.py - added MSVC/2003 support. Code polishing

v0.27.3
Robin Mills 13 years ago
parent f89e8e3e16
commit 2ff7390f51

@ -4,7 +4,7 @@
# build-test.py [--verbose] # build-test.py [--verbose]
# #
# reads the output of exiv2 -v -V and inspects it for sanity # reads the output of exiv2 -v -V and inspects it for sanity
# primary test is to inspect the loaded libraries # inspect run-library libraries platform/compiler/{debug|release}{shared|static}
# TODO: 1 report loaded libraries that we didn't expect # TODO: 1 report loaded libraries that we didn't expect
# 2 mingw support # 2 mingw support
## ##
@ -19,6 +19,21 @@ def error(msg):
print '***',msg,'***' print '***',msg,'***'
sys.exit(1) sys.exit(1)
##
# run a command and return output string
def runCommand(command):
##
# don't use check_output
# this is 2.7 feature.
# not available on cygwin's default python 2.6.8 interpreter
# result=subprocess.check_output( command.split(' '))
##
result =subprocess.Popen(command.split(' '), stdout=subprocess.PIPE).communicate()[0]
# ensure lines are \n terminated (remove \r bytes)
return result.replace('\r\n', '\n').replace('\r', '\n')
## ##
# process the version information dictionary # process the version information dictionary
def platform(dict): def platform(dict):
@ -37,14 +52,14 @@ def expect(dict,expects):
libs=dict['library'] libs=dict['library']
E={}; E={};
for e in expects: for e in expects:
e=e.lower().replace('-','.') # cygwin uses - in versioning e=e.lower().replace('-','.') # cygwin uses '-' in versioning
e=e.split('.')[0] e=e.split('.')[0]
if verbose: if verbose:
print 'expect library',e print 'expect library',e
E[e]=0 E[e]=0
for lib in libs: for lib in libs:
lib=lib.lower().replace('\\','/') # cygwin uses \ in pathnames lib=lib.lower().replace('\\','/') # cygwin uses '\' in pathnames
lib=lib.replace('-','.') lib=lib.replace('-','.')
lib=os.path.basename(lib).split('.')[0] lib=os.path.basename(lib).split('.')[0]
if E.has_key(lib): if E.has_key(lib):
@ -57,16 +72,6 @@ def expect(dict,expects):
## ##
def apple(dict): def apple(dict):
platform(dict)
# which version of MacOS-X ?
os_major=int(os.uname()[2].split('.')[0])
os_minor=int(os.uname()[2].split('.')[1])
NC=13;ML=12;LION=11;SL=10;LEO=9;
if dict['bits'] != 64:
print '*** expected 64 bit build ***'
expects= [ 'libSystem.B.dylib' expects= [ 'libSystem.B.dylib'
, 'libexpat.1.dylib' , 'libexpat.1.dylib'
, 'libz.1.dylib' , 'libz.1.dylib'
@ -75,27 +80,34 @@ def apple(dict):
, 'libdyld.dylib' , 'libdyld.dylib'
, 'libc++.1.dylib' , 'libc++.1.dylib'
] ; ] ;
# which version of MacOS-X ?
os_major=int(os.uname()[2].split('.')[0])
os_minor=int(os.uname()[2].split('.')[1])
NC=13;ML=12;LION=11;SL=10;LEO=9;
if dict['dll']: if dict['dll']:
expects.append('libexiv2.12.dylib') expects.append('libexiv2.12.dylib')
expect(dict,expects) ## Mountain Lion
if os_major==ML and dict['dll']:
expects.append('libexiv2.12.dylib')
expects.append('libSystem.B.dylib')
expects.append('libexpat.1.dylib')
expects.append('libz.1.dylib')
expects.append('libiconv.2.dylib')
expects.append('libstdc++.6.dylib')
expects.append('libdyld.dylib')
expects.append('libc++.1.dylib')
## Mountain lion dll build
if os_major == ML and dict['dll']==1:
expects= [ 'libexiv2.12.dylib'
, 'libSystem.B.dylib'
, 'libexpat.1.dylib'
, 'libz.1.dylib'
, 'libiconv.2.dylib'
, 'libstdc++.6.dylib'
, 'libdyld.dylib'
, 'libc++.1.dylib'
] ;
expect(dict,expects) expect(dict,expects)
expect_bits = 32 if os_major==LEO else 64
if expect_bits != dict['bits']:
error('*** expected %d bit build ***' % expect_bits)
## ##
def linux(dict): def linux(dict):
platform(dict)
expects = [ 'libdl.so.2' expects = [ 'libdl.so.2'
, 'libexiv2.so.12' , 'libexiv2.so.12'
, 'libstdc++.so.6' , 'libstdc++.so.6'
@ -109,39 +121,35 @@ def linux(dict):
## ##
def windows(dict): def windows(dict):
platform(dict)
expects = [ 'ntdll.dll' expects = [ 'ntdll.dll'
, 'kernel32.dll' , 'kernel32.dll'
, 'KERNELBASE.dll' , 'kernelbase.dll'
, 'PSAPI.DLL' , 'psapi.dll'
]; ];
expect(dict,expects) if dict['dll']:
dll='d.dll' if dict['debug'] else '.dll'
expects.append( 'exiv2' + dll )
expects.append( 'zlib1' + dll )
expects.append('libexpat.dll' )
if dict['dll']==1:
dll='d.dll' if dict['debug']==1 else '.dll'
expects = [ 'exiv2' + dll
, 'zlib1' + dll
, 'libexpat.dll'
]
# c run time libraries # c run time libraries
v=int(float(dict['version'])) # 7,8,9,10 etc # 2003=71, 2005=80, 2008=90, 2010=100
if v in range(8,10): v=int( float(dict['version'])*10 )
expects.append('msvcr%d0%s' % (v,dll) ) expects.append('msvcr%d%s' % (v,dll) )
expects.append('msvcp%d0%s' % (v,dll) ) expects.append('msvcp%d%s' % (v,dll) )
expect(dict,expects) expect(dict,expects)
## ##
def cygwin(dict): def cygwin(dict):
platform(dict)
expects = [ 'ntdll.dll' expects = [ 'ntdll.dll'
, 'kernel32.dll' , 'kernel32.dll'
, 'KERNELBASE.dll' , 'kernelbase.dll'
, 'cygexiv2-12.dll' , 'cygexiv2-12.dll'
, 'cygwin1.dll' , 'cygwin1.dll'
, 'cyggcc_s-1.dll' , 'cyggcc_s-1.dll'
, 'cygstdc++-6.dll' , 'cygstdc++-6.dll'
, 'PSAPI.DLL' , 'psapi.dll'
, 'cygexpat-1.dll' , 'cygexpat-1.dll'
, 'cygiconv-2.dll' , 'cygiconv-2.dll'
, 'cygintl-8.dll' , 'cygintl-8.dll'
@ -150,25 +158,12 @@ def cygwin(dict):
## ##
def mingw(dict): def mingw(dict):
platform(dict)
error("can't test platform mingw") error("can't test platform mingw")
## ##
def unknown(dict): def unknown(dict):
platform(dict)
error("can't test platform unknown") error("can't test platform unknown")
##
def runCommand(command):
##
# don't use check_output
# this is 2.7 feature.
# Not available cygwin's default python 2.6.8 interpreter
# result=subprocess.check_output( command.split(' '))
result =subprocess.Popen(command.split(' '), stdout=subprocess.PIPE).communicate()[0]
# ensure lines are \n terminated
return result.replace('\r\n', '\n').replace('\r', '\n')
## ##
def main(args): def main(args):
this=os.path.abspath(args[0]) this=os.path.abspath(args[0])
@ -209,6 +204,7 @@ def main(args):
if type(dict[k])==type([]): if type(dict[k])==type([]):
if len(dict[k])==1: if len(dict[k])==1:
dict[k]=dict[k][0] dict[k]=dict[k][0]
# convert numeric strings to ints # convert numeric strings to ints
dict['dll' ] = int(dict['dll']) dict['dll' ] = int(dict['dll'])
dict['debug'] = int(dict['debug']) dict['debug'] = int(dict['debug'])
@ -216,14 +212,16 @@ def main(args):
## ##
# analyse the version dictionary # analyse the version dictionary
platform(dict)
eval(dict['platform']+'(dict)') eval(dict['platform']+'(dict)')
## ##
# report success! # report
debug='debug';dll='dll';platform='platform';bits='bits' debug='debug'
dll='dll'
v='Release' if dict[debug]==0 else 'Debug' v='Release' if dict[debug]==0 else 'Debug'
d='DLL' if dict[dll ]==0 else '' d='DLL' if dict[dll ]==0 else ''
print "build %s %dbit %s%s looks good" % (dict[platform],dict[bits],v,d) print "build %dbit %-8s %-12s looks good" % (dict['bits'],dict['platform'],v+d)
else: else:
error("exiv2 not found!") error("exiv2 not found!")

Loading…
Cancel
Save