mirror of
https://github.com/boostorg/python.git
synced 2026-01-24 06:02:14 +00:00
Added tests for linux.
[SVN r18809]
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
import sys
|
||||
sys.path.append('../src')
|
||||
import unittest
|
||||
|
||||
@@ -5,123 +5,65 @@ import glob
|
||||
import shutil
|
||||
import sys
|
||||
|
||||
# 3 functions are needed for each plataform:
|
||||
# build_pyste(multiple, module)
|
||||
# compile_single(module)
|
||||
# compile_multiple(module)
|
||||
#
|
||||
#=============================================================================
|
||||
# win32 configuration
|
||||
#=============================================================================
|
||||
if sys.platform == 'win32':
|
||||
|
||||
includes = '-ID:/programming/libraries/boost-cvs/boost -IC:/Python/include'
|
||||
lib_dirs = '/libpath:D:/programming/libraries/boost-cvs/lib /libpath:C:/Python/libs'
|
||||
libs = 'boost_python.lib python22.lib'
|
||||
build_pyste_cmd = 'python ../src/pyste.py %s ' % includes
|
||||
compile_single_cmd = 'icl /nologo /GR /GX -c %s -I. ' % includes
|
||||
link_single_cmd = 'link /nologo /DLL '\
|
||||
'/libpath:D:/programming/libraries/boost-cvs/lib /libpath:C:/Python/libs '\
|
||||
'boost_python.lib python22.lib /out:_%s.dll '
|
||||
obj_ext = 'obj'
|
||||
|
||||
def build_pyste(multiple, module):
|
||||
cmd = 'python ../src/pyste.py %s %s --module=%s %s.pyste'
|
||||
execute(cmd % (multiple, includes, '_' + module, module))
|
||||
|
||||
|
||||
def compile_single(module):
|
||||
start_building(module)
|
||||
cmd = 'icl /nologo /GR /GX -c %s -I.' % includes
|
||||
cmd += ' %s'
|
||||
module_obj = ''
|
||||
if os.path.isfile(module+'.cpp'):
|
||||
execute(cmd % (module+'.cpp'))
|
||||
module_obj = module + '.obj'
|
||||
execute(cmd % '_%s.cpp' % module)
|
||||
execute('link /nologo /DLL /out:_%s.dll %s %s %s %s' % \
|
||||
(module, lib_dirs, '_%s.obj' % module, module_obj, libs))
|
||||
end_building(module)
|
||||
|
||||
|
||||
def compile_multiple(module):
|
||||
start_building(module)
|
||||
cmd = 'icl /nologo /GR /GX -c %s -I.' % includes
|
||||
cmd += ' %s'
|
||||
module_obj = ''
|
||||
if os.path.isfile(module+'.cpp'):
|
||||
execute(cmd % (module+'.cpp'))
|
||||
module_obj = module + '.obj'
|
||||
files = glob.glob('_%s/*.cpp' % module)
|
||||
for f in files:
|
||||
execute(cmd % f)
|
||||
objs = [os.path.split(os.path.splitext(x)[0])[1] + '.obj' for x in files]
|
||||
objs.append(module_obj)
|
||||
execute('link /nologo /DLL /out:_%s.dll %s %s %s' % \
|
||||
(module, lib_dirs, ' '.join(objs), libs))
|
||||
end_building(module)
|
||||
|
||||
|
||||
def start_building(module):
|
||||
#print 'Building module %s...' % module,
|
||||
pass
|
||||
|
||||
|
||||
def end_building(module):
|
||||
pass
|
||||
#if os.path.isfile('_%s.dll' % module):
|
||||
# print ' done.'
|
||||
#else:
|
||||
# print 'FAILED!'
|
||||
#print
|
||||
|
||||
|
||||
elif sys.platform == 'posix':
|
||||
#=============================================================================
|
||||
# linux configuration
|
||||
#=============================================================================
|
||||
elif sys.platform == 'linux2':
|
||||
|
||||
def build_pyste(multiple, module):
|
||||
cmd = 'python ../src/pyste.py %s --module=%s %s.pyste'
|
||||
execute(cmd % (multiple, module))
|
||||
|
||||
build_pyste_cmd = 'python ../src/pyste.py -I. '
|
||||
compile_single_cmd = 'g++ -shared -c -I. -I/usr/include/python2.2 '
|
||||
link_single_cmd = 'g++ -shared -o _%s.so -lboost_python '
|
||||
obj_ext = 'o'
|
||||
|
||||
|
||||
|
||||
def build_pyste(multiple, module):
|
||||
rest = '%s --module=_%s %s.pyste' % (multiple, module, module)
|
||||
execute(build_pyste_cmd + rest)
|
||||
|
||||
|
||||
def compile_single(module):
|
||||
module_obj = ''
|
||||
if os.path.isfile(module+'.cpp'):
|
||||
execute(compile_single_cmd + module+'.cpp')
|
||||
module_obj = module + '.' + obj_ext
|
||||
execute(compile_single_cmd + ('_%s.cpp' % module))
|
||||
link = link_single_cmd % module
|
||||
execute(link + ('_%s.%s ' % (module, obj_ext)) + module_obj)
|
||||
|
||||
|
||||
def compile_multiple(module):
|
||||
module_obj = ''
|
||||
if os.path.isfile(module+'.cpp'):
|
||||
execute(compile_single_cmd + module+'.cpp')
|
||||
module_obj = module + '.' + obj_ext
|
||||
files = glob.glob('_%s/*.cpp' % module)
|
||||
for f in files:
|
||||
execute(compile_single_cmd + f)
|
||||
def basename(name):
|
||||
return os.path.basename(os.path.splitext(name)[0])
|
||||
objs = [basename(x) + '.' + obj_ext for x in files]
|
||||
objs.append(module_obj)
|
||||
execute((link_single_cmd % module) + ' '.join(objs))
|
||||
|
||||
|
||||
def execute(cmd):
|
||||
#output = os.popen(cmd).read()
|
||||
#f = file('build.log', 'a')
|
||||
#f.write(output)
|
||||
#f.close()
|
||||
os.system(cmd)
|
||||
|
||||
|
||||
|
||||
|
||||
def compile_pyste_files(multiple):
|
||||
pass
|
||||
#if not multiple:
|
||||
# ## compile each cpp into a shared library
|
||||
# #for cpp in glob.glob('*.cpp'):
|
||||
# # print
|
||||
# # print 'compiling', cpp
|
||||
# # out = os.path.splitext(cpp)[0] + '.so'
|
||||
# # cmdline = 'g++ -shared -o %s -I../example ' \
|
||||
# # '-I/usr/include/python2.2 -lboost_python %s' % (out, cpp)
|
||||
# # os.system(cmdline)
|
||||
#
|
||||
#else:
|
||||
# modules = get_modules()
|
||||
# # list cpp files in each module directory
|
||||
# print
|
||||
# for module in modules:
|
||||
# # compile each
|
||||
# for file in glob.glob(module+'/*.cpp'):
|
||||
# print 'compiling', file
|
||||
# out = os.path.splitext(file)[0] + '.obj'
|
||||
# cmdline = 'g++ -shared -c -o %s -I../example ' \
|
||||
# '-I/usr/include/python2.2 %s' % (out, file)
|
||||
# os.system(cmdline)
|
||||
# # generate a dynamic library
|
||||
# print 'linking'
|
||||
# objs = ' '.join([x for x in glob.glob(module+'/*.obj')])
|
||||
# out = module + '.so'
|
||||
# cmdline = 'g++ -shared -o %s -lboost_python %s' % (out, objs)
|
||||
# os.system(cmdline)
|
||||
|
||||
|
||||
def compile_file_posix(filename, outfilename):
|
||||
cmdline = 'g++ -shared -o %s -I../example ' \
|
||||
'-I/usr/include/python2.2 -lboost_python %s' % (outfilename, filename)
|
||||
execute(cmdline)
|
||||
|
||||
|
||||
|
||||
def run_tests():
|
||||
if os.system('python runtests.py') != 0:
|
||||
raise RuntimeError, 'tests failed'
|
||||
@@ -129,7 +71,7 @@ def run_tests():
|
||||
|
||||
def cleanup():
|
||||
modules = get_modules()
|
||||
extensions = '*.dll *.pyc *.obj *.exp *.lib'
|
||||
extensions = '*.dll *.pyc *.obj *.exp *.lib *.o *.so'
|
||||
files = []
|
||||
for module in modules:
|
||||
files.append('_' + module + '.cpp')
|
||||
@@ -176,7 +118,7 @@ if __name__ == '__main__':
|
||||
else:
|
||||
module = None
|
||||
try:
|
||||
#main('--multiple', module)
|
||||
main('--multiple', module)
|
||||
main('', module)
|
||||
except RuntimeError, e:
|
||||
print e
|
||||
|
||||
@@ -12,8 +12,8 @@ struct Color
|
||||
int b;
|
||||
};
|
||||
|
||||
const Color black = Color(0, 0, 0);
|
||||
const Color red = Color(255, 0, 0);
|
||||
const Color green = Color(0, 255, 0);
|
||||
const Color blue = Color(0, 0, 255);
|
||||
Color in_use = black;
|
||||
extern const Color black;
|
||||
extern const Color red;
|
||||
extern const Color green;
|
||||
extern const Color blue;
|
||||
extern Color in_use;
|
||||
|
||||
@@ -14,4 +14,5 @@ class VarsTest(unittest.TestCase):
|
||||
testColor(_vars.green, 0, 255, 0)
|
||||
testColor(_vars.blue, 0, 0, 255)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user