Scons: do not build boost dependency tree, use debug/release boost system library, check for boost system header files

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@14338 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Bo Peng 2006-07-05 15:33:38 +00:00
parent efc3b4e52a
commit e85cfec957
2 changed files with 104 additions and 49 deletions

View File

@ -701,42 +701,43 @@ if not fast_start:
# check boost libraries
boost_opt = ARGUMENTS.get('boost', 'auto')
# check for system boost
paths = env['LIBPATH'] + ['/usr/lib', '/usr/local/lib']
# real libraries (included or system)
boost_libraries = []
lib_paths = env['LIBPATH'] + ['/usr/lib', '/usr/local/lib']
inc_paths = env['CPPPATH'] + ['/usr/include', '/usr/local/include']
# default to $BUILDDIR/libs (use None since this path will be added anyway)
boost_libpath = None
# here I assume that all libraries are in the same directory
for lib in boost_libs:
if boost_opt == 'included':
boost_libraries.append('included_boost_%s' % lib)
env['INCLUDED_BOOST'] = True
boost_libraries = ['included_boost_%s' % x for x in boost_libs]
included_boost = True
env['BOOST_INC_PATH'] = '$TOP_SRCDIR/boost'
elif boost_opt == 'auto':
res = conf.CheckBoostLibraries('boost_%s' % lib , paths)
# if not found
if res[0] == '':
boost_libraries.append('included_boost_%s' % lib)
env['INCLUDED_BOOST'] = True
res = conf.CheckBoostLibraries(boost_libs, lib_paths, inc_paths, mode == 'debug')
# if not found, use local boost
if res[0] is None:
boost_libraries = ['included_boost_%s' % x for x in boost_libs]
included_boost = True
env['BOOST_INC_PATH'] = '$TOP_SRCDIR/boost'
else:
boost_libraries.append(res[1])
env['INCLUDED_BOOST'] = False
boost_libpath = res[0]
included_boost = False
(boost_libraries, boost_libpath, env['BOOST_INC_PATH']) = res
elif boost_opt == 'system':
res = conf.CheckBoostLibraries('boost_%s' % lib , paths)
if res[0] == '':
res = conf.CheckBoostLibraries(boost_libs, lib_paths, inc_paths, mode == 'debug')
if res[0] is None:
print "Can not find system boost libraries"
print "Please supply a path through extra_lib_path and try again."
print "Or use boost=included to use included boost libraries."
Exit(2)
else:
boost_libraries.append(res[1])
env.AppendUnique(LIBPATH = [res[0]])
boost_libpath = res[0]
included_boost = False
(boost_libraries, boost_libpath, env['BOOST_INC_PATH']) = res
env_cache['BOOST_LIBRARIES'] = boost_libraries
env_cache['INCLUDED_BOOST'] = env['INCLUDED_BOOST']
env_cache['INCLUDED_BOOST'] = included_boost
env_cache['BOOST_INC_PATH'] = env['BOOST_INC_PATH']
env_cache['BOOST_LIBPATH'] = boost_libpath
else:
boost_libraries = env_cache['BOOST_LIBRARIES']
env['INCLUDED_BOOST'] = env_cache['INCLUDED_BOOST']
included_boost = env_cache['INCLUDED_BOOST']
env['BOOST_INC_PATH'] = env_cache['BOOST_INC_PATH']
boost_libpath = env_cache['BOOST_LIBPATH']
if boost_libpath is not None:
@ -1307,7 +1308,16 @@ if env['X11']:
# BUILDDIR/common: for config.h
# TOP_SRCDIR/src: for support/* etc
#
env['CPPPATH'] += ['$TOP_SRCDIR/boost', '$BUILDDIR/common', '$TOP_SRCDIR/src']
env['CPPPATH'] += ['$BUILDDIR/common', '$TOP_SRCDIR/src']
#
# Separating boost directories from CPPPATH stops scons from building
# the dependency tree of boost header files, and effectively reduce
# the null build time of lyx from 29s to 16s.
if use_vc:
env.AppendUnique(CCFLAGS = ['/I$BOOST_INC_PATH'])
else:
env.AppendUnique(CCFLAGS = ['-I$BOOST_INC_PATH'])
# for intl/config.h, intl/libintl.h and intl/libgnuintl.h
if env['nls'] and included_gettext:
env['CPPPATH'].append('$BUILDDIR/intl')
@ -1429,7 +1439,7 @@ targets = BUILD_TARGETS
# msvc need to pass full target name, so I have to look for path/lyx etc
build_lyx = targets == [] or True in ['lyx' in x for x in targets] \
or 'install' in targets or 'all' in targets
build_boost = (env['INCLUDED_BOOST'] and not libExists('boost_regex')) or 'boost' in targets
build_boost = (included_boost and not libExists('boost_regex')) or 'boost' in targets
build_intl = (included_gettext and not libExists('included_intl')) or 'intl' in targets
build_support = build_lyx or True in [x in targets for x in ['support', 'client', 'tex2lyx']]
build_mathed = build_lyx or 'mathed' in targets

View File

@ -153,24 +153,69 @@ int main()
return ('int', 'int *', 'struct timeval *')
def checkBoostLibraries(conf, lib, pathes):
''' look for boost libraries '''
conf.Message('Checking for boost library %s... ' % lib)
for path in pathes:
def checkBoostLibraries(conf, libs, lib_paths, inc_paths, isDebug):
''' look for boost libraries
libs: library names
lib_paths: try these paths for boost libraries
inc_paths: try these paths for boost headers
isDebug: if true, use debug libraries
'''
conf.Message('Checking for boost library %s... ' % ', '.join(libs))
found_lib = False
found_inc = False
lib_names = []
lib_path = None
inc_path = None
for path in lib_paths:
# direct form: e.g. libboost_iostreams.a
if os.path.isfile(os.path.join(path, 'lib%s.a' % lib)):
# ignore isDebug
if False not in [os.path.isfile(os.path.join(path, 'libboost_%s.a' % lib)) for lib in libs]:
conf.Result('yes')
return (path, lib)
# check things like libboost_iostreams-gcc.a
files = glob.glob(os.path.join(path, 'lib%s-*.a' % lib))
# if there are more than one, choose the first one
# FIXME: choose the best one.
if len(files) >= 1:
# get xxx-gcc from /usr/local/lib/libboost_xxx-gcc.a
found_lib = True
lib_path = path
lib_names = libs
break
for lib in libs:
# get all the libs, then filter for the right library
files = glob.glob(os.path.join(path, 'libboost_%s-*.a' % lib))
# check things like libboost_iostreams-gcc-mt-d-1_33_1.a
if len(files) > 0:
if isDebug:
files = filter(lambda x: re.search('libboost_%s-\w+-mt-d-[\d-]+' % lib, x), files)
else:
files = filter(lambda x: re.search('libboost_%s-\w+-mt-[\d-]+' % lib, x), files)
if len(files) == 0:
print 'Warning: %s directory seems to have the boost libraries, but ' % path
print 'I can not find one that has the form lib%s-xxx-mt[-d]-x_xx_x.a' % lib
print 'Check your boost installation, or change select criteria in scons_util.py'
if len(files) > 0:
# get xxx-gcc-1_33_1 from /usr/local/lib/libboost_xxx-gcc-1_33_1.a
lib_names.append(files[0].split(os.sep)[-1][3:-2])
if len(lib_names) == len(libs):
found_lib = True
lib_path = path
break
if not found_lib:
conf.Result('no')
return (None, None, None)
# check for boost header file
for path in inc_paths:
# check path/boost/regex.h
if os.path.isfile(os.path.join(path, 'boost', 'regex.h')):
inc_path = path
found_inc = True
else: # check path/boost_1_xx_x/boost
dirs = glob.glob(os.path.join(path, 'boost-*'))
if len(dirs) > 0 and os.path.isfile(os.path.join(dirs[0], 'boost', 'regex.h')):
inc_path = dirs[0]
found_inc = True
# return result
if found_inc:
conf.Result('yes')
return (path, files[0].split(os.sep)[-1][3:-2])
conf.Result('n')
return ('','')
return (lib_names, lib_path, inc_path)
else:
conf.Result('no')
return (None, None, None)
def checkCommand(conf, cmd):