Abdel, Attached patch adds
$BUILDDIR/config/config.h $BUILDDIR/config/boost_config.h with the following behaviors: 1. boost only uses boost_config.h 2. config.h includes boost_config.h 3. different builds have different config.h (nls etc may change from build to build). Tested under linux. Please let me know if you like it, and if you like further work on this config.h business. Bo
Index: development/scons/SConstruct =================================================================== --- development/scons/SConstruct (revision 14139) +++ development/scons/SConstruct (working copy) @@ -337,6 +337,9 @@ # all built libraries will go to build_dir/libs # (This is different from the make file approach) env['LOCALLIBPATH'] = '$BUILDDIR/libs' +# +# each build has its own config.h +env['LOCALCONFIGPATH'] = '$BUILDDIR/config' env.AppendUnique(LIBPATH = ['$LOCALLIBPATH']) @@ -766,8 +769,80 @@ aspell_lib = 'aspelld' if not fast_start: - print "Generating src/config.h..." + # + boost_config_h = os.path.join(env.Dir('$LOCALCONFIGPATH').path, 'boost_config.h') + # + print "Creating %s..." % boost_config_h + # + utils.createConfigFile(conf, + config_file = boost_config_h, + config_pre = '''/* boost_config.h. Generated by SCons. */ +/* -*- C++ -*- */ +/* + * \file config.h + * This file is part of LyX, the document processor. + * Licence details can be found in the file COPYING. + * + * This is the compilation configuration file for LyX. + * It was generated by scon. + * You might want to change some of the defaults if something goes wrong + * during the compilation. + */ + +#ifndef _BOOST_CONFIG_H +#define _BOOST_CONFIG_H +''', + headers = [ + ('ostream', 'HAVE_OSTREAM', 'cxx'), + ('locale', 'HAVE_LOCALE', 'cxx'), + ('sstream', 'HAVE_SSTREAM', 'cxx'), + ('newapis.h', 'HAVE_NEWAPIS_H', 'c'), + ], + custom_tests = [ + (env.has_key('assertions') and env['assertions'], + 'ENABLE_ASSERTIONS', + 'Define if you want assertions to be enabled in the code' + ), + ], + config_post = ''' + +#define BOOST_USER_CONFIG <boost_config.h> + +#if defined(HAVE_OSTREAM) && defined(HAVE_LOCALE) && defined(HAVE_SSTREAM) +# define USE_BOOST_FORMAT 1 +#else +# define USE_BOOST_FORMAT 0 +#endif + +#if !defined(ENABLE_ASSERTIONS) +# define BOOST_DISABLE_ASSERTS 1 +#endif +#define BOOST_ENABLE_ASSERT_HANDLER 1 + +#define BOOST_DISABLE_THREADS 1 +#define BOOST_NO_WREGEX 1 +#define BOOST_NO_WSTRING 1 + +#ifdef __CYGWIN__ +# define BOOST_POSIX 1 +#endif + +#define BOOST_ALL_NO_LIB 1 + +#if defined(HAVE_NEWAPIS_H) +# define WANT_GETFILEATTRIBUTESEX_WRAPPER 1 +#endif + +#endif +''' + ) + # + # config.h for each build + config_h = os.path.join(env.Dir('$LOCALCONFIGPATH').path, 'config.h') + + print "Generating %s..." % config_h + # AIKSAURUS_H_LOCATION if (conf.CheckCXXHeader("Aiksaurus.h")): aik_location = '<Aiksaurus.h>' @@ -805,7 +880,7 @@ # # create config.h result = utils.createConfigFile(conf, - config_file = os.path.join(top_src_dir, 'src', 'config.h'), + config_file = config_h, config_pre = '''/* src/config.h. Generated by SCons. */ /* -*- C++ -*- */ @@ -827,7 +902,6 @@ ('io.h', 'HAVE_IO_H', 'c'), ('limits.h', 'HAVE_LIMITS_H', 'c'), ('locale.h', 'HAVE_LOCALE_H', 'c'), - ('locale', 'HAVE_LOCALE', 'cxx'), ('process.h', 'HAVE_PROCESS_H', 'c'), ('stdlib.h', 'HAVE_STDLIB_H', 'c'), ('sys/stat.h', 'HAVE_SYS_STAT_H', 'c'), @@ -839,7 +913,6 @@ ('utime.h', 'HAVE_UTIME_H', 'c'), ('direct.h', 'HAVE_DIRECT_H', 'c'), ('istream', 'HAVE_ISTREAM', 'cxx'), - ('ostream', 'HAVE_OSTREAM', 'cxx'), ('ios', 'HAVE_IOS', 'cxx'), ], functions = [ @@ -859,13 +932,13 @@ ('mkstemp', 'HAVE_MKSTEMP', None), ('strerror', 'HAVE_STRERROR', None), ('count', 'HAVE_STD_COUNT', ''' - #include <algorithm> - int count() - { - char a[] = "hello"; - return std::count(a, a+5, 'l'); - } - '''), +#include <algorithm> +int count() +{ + char a[] = "hello"; + return std::count(a, a+5, 'l'); +} +'''), ('getcwd', 'HAVE_GETCWD', None), ('setenv', 'HAVE_SETENV', None), ('putenv', 'HAVE_PUTENV', None), @@ -900,10 +973,6 @@ 'Define if your <locale.h> file defines LC_MESSAGES.' ), (devel_version, 'DEVEL_VERSION', 'Whether or not a development version'), - (env.has_key('assertions') and env['assertions'], - 'ENABLE_ASSERTIONS', - 'Define if you want assertions to be enabled in the code' - ), (env.has_key('nls') and env['nls'], 'ENABLE_NLS', "Define to 1 if translation of program messages to the user's native anguage is requested.", @@ -916,7 +985,7 @@ '_GLIBCXX_CONCEPT_CHECKS', 'libstdc++ concept checking' ), - (os.name != 'nt', 'BOOST_POSIZ', + (os.name != 'nt', 'BOOST_POSIX', 'Indicates to boost which API to use (posix or windows).' ), (spell_engine is not None, spell_engine, @@ -968,32 +1037,9 @@ #endif #endif -#if defined(HAVE_OSTREAM) && defined(HAVE_LOCALE) && defined(HAVE_SSTREAM) -# define USE_BOOST_FORMAT 1 -#else -# define USE_BOOST_FORMAT 0 -#endif +#include <boost_config.h> -#define BOOST_USER_CONFIG <config.h> - -#if !defined(ENABLE_ASSERTIONS) -# define BOOST_DISABLE_ASSERTS 1 #endif -#define BOOST_ENABLE_ASSERT_HANDLER 1 - -#define BOOST_DISABLE_THREADS 1 -#define BOOST_NO_WREGEX 1 -#define BOOST_NO_WSTRING 1 - -#ifdef __CYGWIN__ -# define BOOST_POSIX 1 -#endif - -#if defined(HAVE_NEWAPIS_H) -# define WANT_GETFILEATTRIBUTESEX_WRAPPER 1 -#endif - -#endif ''' ) @@ -1090,11 +1136,12 @@ env.AppendUnique(LIBPATH = ['/usr/X11R6/lib']) # -# boost is always in, src is needed for config.h +# boost is always in, $LOCALCONFIGPATH is needed for config.h +# TOP_SRCDIR/src is used by everyone. # # QT_INC_PATH is not needed for *every* source file env['CPPPATH'].remove(qt_inc_path) -env['CPPPATH'] += ['$TOP_SRCDIR/boost', '$TOP_SRCDIR/src'] +env['CPPPATH'] += ['$TOP_SRCDIR/boost', '$LOCALCONFIGPATH', '$TOP_SRCDIR/src'] # # Customized builders @@ -1286,132 +1333,10 @@ boostenv = env.Copy() # - boost_config_h = os.path.join(top_src_dir, 'boost', 'libs', 'config.h') - if not os.path.isfile(boost_config_h) or not fast_start: - # - print "Creating boost/config.h..." - # - # start another configuration session. - conf = Configure(boostenv, - custom_tests = {'CheckMkdirOneArg' : utils.checkMkdirOneArg}, - ) - # - # create config.h - result = utils.createConfigFile(conf, - config_file = boost_config_h, - config_pre = '''/* boost/libs/config.h. Generated by SCons. */ - -/* -*- C++ -*- */ -/* - * \file config.h - * This file is part of LyX, the document processor. - * Licence details can be found in the file COPYING. - * - * This is the compilation configuration file for LyX. - * It was generated by scon. - * You might want to change some of the defaults if something goes wrong - * during the compilation. - */ - -#ifndef _CONFIG_H -#define _CONFIG_H -''', - headers = [ - ('io.h', 'HAVE_IO_H', 'c'), - ('limits.h', 'HAVE_LIMITS_H', 'c'), - ('locale.h', 'HAVE_LOCALE_H', 'c'), - ('locale', 'HAVE_LOCALE', 'cxx'), - ('process.h', 'HAVE_PROCESS_H', 'c'), - ('stdlib.h', 'HAVE_STDLIB_H', 'c'), - ('sys/stat.h', 'HAVE_SYS_STAT_H', 'c'), - ('sys/time.h', 'HAVE_SYS_TIME_H', 'c'), - ('sys/types.h', 'HAVE_SYS_TYPES_H', 'c'), - ('sys/utime.h', 'HAVE_SYS_UTIME_H', 'c'), - ('sys/socket.h', 'HAVE_SYS_SOCKET_H', 'c'), - ('unistd.h', 'HAVE_UNISTD_H', 'c'), - ('utime.h', 'HAVE_UTIME_H', 'c'), - ('direct.h', 'HAVE_DIRECT_H', 'c'), - ('istream', 'HAVE_ISTREAM', 'cxx'), - ('ostream', 'HAVE_OSTREAM', 'cxx'), - ('ios', 'HAVE_IOS', 'cxx'), - ], - functions = [ - ('open', 'HAVE_OPEN', None), - ('close', 'HAVE_CLOSE', None), - ('popen', 'HAVE_POPEN', None), - ('pclose', 'HAVE_PCLOSE', None), - ('_open', 'HAVE__OPEN', None), - ('_close', 'HAVE__CLOSE', None), - ('_popen', 'HAVE__POPEN', None), - ('_pclose', 'HAVE__PCLOSE', None), - ('getpid', 'HAVE_GETPID', None), - ('_getpid', 'HAVE__GETPID', None), - ('mkdir', 'HAVE_MKDIR', None), - ('_mkdir', 'HAVE__MKDIR', None), - ('mktemp', 'HAVE_MKTEMP', None), - ('mkstemp', 'HAVE_MKSTEMP', None), - ('strerror', 'HAVE_STRERROR', None), - ('getcwd', 'HAVE_GETCWD', None), - ('setenv', 'HAVE_SETENV', None), - ('putenv', 'HAVE_PUTENV', None), - ('fcntl', 'HAVE_FCNTL', None), - ], - custom_tests = [ - (conf.CheckMkdirOneArg(), - 'MKDIR_TAKES_ONE_ARG', - 'Define if mkdir takes only one argument.' - ), - (env.has_key('assertions') and env['assertions'], - 'ENABLE_ASSERTIONS', - 'Define if you want assertions to be enabled in the code' - ), - (env.has_key('warnings') and env['warnings'], - 'WITH_WARNINGS', - 'Define this if you want to see the warning directives put here and there by the developpers to get attention' - ), - (env.has_key('concept_checks') and env['concept_checks'], - '_GLIBCXX_CONCEPT_CHECKS', - 'libstdc++ concept checking' - ), - (os.name != 'nt', 'BOOST_POSIZ', - 'Indicates to boost which API to use (posix or windows).' - ), - ], - extra_items = [ - ('#define BOOST_ALL_NO_LIB 1', - 'disable automatic linking of boost libraries.'), - ], - config_post = ''' - -#if defined(HAVE_OSTREAM) && defined(HAVE_LOCALE) && defined(HAVE_SSTREAM) -# define USE_BOOST_FORMAT 1 -#else -# define USE_BOOST_FORMAT 0 -#endif - -#define BOOST_USER_CONFIG <config.h> - -#if !defined(ENABLE_ASSERTIONS) -# define BOOST_DISABLE_ASSERTS 1 -#endif -#define BOOST_ENABLE_ASSERT_HANDLER 1 - -#define BOOST_DISABLE_THREADS 1 -#define BOOST_NO_WREGEX 1 -#define BOOST_NO_WSTRING 1 - -#ifdef __CYGWIN__ -# define BOOST_POSIX 1 -#endif - -#endif -''' - ) - conf.Finish() # # boost use its own config.h - boostenv['CPPPATH'] = ['$TOP_SRCDIR/boost', '$TOP_SRCDIR/boost/libs'] + extra_inc_paths - boostenv.AppendUnique(CCFLAGS = ['-DBOOST_USER_CONFIG="<config.h>"']) + boostenv['CPPPATH'] = ['$TOP_SRCDIR/boost', '$LOCALCONFIGPATH'] + extra_inc_paths + boostenv.AppendUnique(CCFLAGS = ['-DBOOST_USER_CONFIG="<boost_config.h>"']) for lib in boost_libs: print 'Processing files in boost/libs/%s/src...' % lib @@ -2040,7 +1965,7 @@ print "Processing files in src/tex2lyx..." tex2lyx_env = env.Copy() - # the order is important here. + # tex2lyx_env.Prepend(CPPPATH = ['$BUILDDIR/common/tex2lyx']) tex2lyx_env.AppendUnique(LIBPATH = ['#$LOCALLIBPATH']) Index: development/scons/scons_utils.py =================================================================== --- development/scons/scons_utils.py (revision 14139) +++ development/scons/scons_utils.py (working copy) @@ -18,6 +18,10 @@ def writeToFile(filename, lines, append = False): " utility function: write or append lines to filename " + # create directory if needed + dir = os.path.split(filename)[0] + if dir != '' and not os.path.isdir(dir): + os.makedirs(dir) if append: file = open(filename, 'a') else: