Bo Peng wrote:
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.
I have a compile error with MSVC:
cl /TP /EHsc /Zi /wd4819 /wd4996 /nologo /ID:\program\GnuWin32\include
/ID:\program\Aspell-0.60.4\include /ID:\devel\lyx\trunk\boost
/Imsvc-debug\config /ID:\de
vel\lyx\trunk\src /c D:\devel\lyx\trunk\src\support\os.C
/Fomsvc-debug\common\support\os.obj
os.C
D:\program\SDK\Include\NewAPIs.h(406) : error C2440: 'initializing' :
cannot convert from 'LPVOID' to 'LPWIN32_FILE_ATTRIBUTE_DATA'
Conversion from 'void*' to pointer to non-'void' requires an
explicit cast
I don't know much about this NewAPI thing so it would be better to just
disable it for now.
I have fixed with brute force the manifest problem. Feel free to find a
better solution.
Patch attached.
Abdel.
Index: SConstruct
===================================================================
--- SConstruct (revision 14138)
+++ SConstruct (working copy)
@@ -145,8 +145,8 @@
allowed_values = ('windows', 'posix', 'macosx')),
#
BoolOption('fast_start', 'Whether or not use cached tests and keep current
config.h', True),
- # FIXME: I do not know how pch is working. Ignore this option now.
- BoolOption('pch', '(NA) Whether or not use pch', None),
+ #
+ BoolOption('pch', 'Whether or not use pch', False),
# enable assertion, (config.h has ENABLE_ASSERTIOS
BoolOption('assertions', 'Use assertions', True),
# enable warning, (config.h has WITH_WARNINGS)
@@ -309,6 +309,8 @@
# for simplicity, use var instead of env[var]
frontend = env['frontend']
prefix = env['prefix']
+mode = env['mode']
+use_pch = env['pch']
if platform_name == 'win32':
if env.has_key('use_vc'):
@@ -330,11 +332,14 @@
env['BUILDDIR'] = env['build_dir']
else:
# Determine the name of the build $mode
- env['BUILDDIR'] = '#' + env['mode']
+ env['BUILDDIR'] = '#' + mode
# 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'])
@@ -443,6 +448,10 @@
env['CC'] = 'g++'
env['LINK'] = 'g++'
+# only support gcc now
+if use_pch and not use_vc:
+ CCFLAGS_required.extend(['-Winvalid-pch'])
+
# for debug/release mode
if env.has_key('optimization') and env['optimization'] is not None:
# if user supplies optimization flags, use it anyway
@@ -452,14 +461,14 @@
else:
set_default_optimization_flags = True
-if env['mode'] == 'debug':
+if mode == 'debug':
if use_vc:
CCFLAGS_required.append('/Zi')
LINKFLAGS_required.extend(['/debug', '/map'])
else:
CCFLAGS_required.append('-g')
- CCFLAGS_default.append('-Wall')
-elif env['mode'] == 'release' and set_default_optimization_flags:
+ CCFLAGS_default.extend(['-Wall', '-O'])
+elif mode == 'release' and set_default_optimization_flags:
if use_vc:
CCFLAGS_default.append('/O2')
else:
@@ -643,9 +652,15 @@
# now, if msvc2005 is used, we will need that QT_LIB_PATH/QT_LIB.manifest file
if use_vc:
# glob file xxx.dll.manifest (msvc 2003 may not have it)
- manifests = glob.glob(os.path.join(qt_lib_path, '*.dll.manifest'))
- if manifests != []:
- env['LINKCOM'] = [env['LINKCOM'], 'mt.exe /MANIFEST %s
/outputresource:$TARGET;1' % manifests[0]]
+ #manifests = glob.glob(os.path.join(qt_lib_path, '*.dll.manifest'))
+ #if manifests != []:
+ # env['LINKCOM'] = [env['LINKCOM'], 'mt.exe /MANIFEST %s
/outputresource:$TARGET;1' % manifests[0]]
+ if mode == 'debug':
+ manifest = os.path.join(qt_lib_path, 'QtGuid4.dll.manifest')
+ else:
+ manifest = os.path.join(qt_lib_path, 'QtGui4.dll.manifest')
+ env['LINKCOM'] = [env['LINKCOM'], 'mt.exe /MANIFEST %s
/outputresource:$TARGET;1' % manifest]
+
# check socket libs
if not fast_start:
@@ -754,9 +769,86 @@
#----------------------------------------------------------
# Generating config.h
#----------------------------------------------------------
+aspell_lib = 'aspell'
+# assume that we use aspell, aspelld compiled for msvc
+if platform_name == 'win32' and mode == 'debug' and use_vc:
+ 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>'
@@ -770,7 +862,7 @@
env['USE_ASPELL'] = False
env['USE_PSPELL'] = False
env['USE_ISPELL'] = False
- if spell_opt in ['auto', 'aspell'] and conf.CheckLib('aspell'):
+ if spell_opt in ['auto', 'aspell'] and conf.CheckLib(aspell_lib):
spell_engine = 'USE_ASPELL'
elif spell_opt in ['auto', 'pspell'] and conf.CheckLib('pspell'):
spell_engine = 'USE_PSPELL'
@@ -794,7 +886,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++ -*- */
@@ -816,7 +908,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'),
@@ -828,7 +919,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 = [
@@ -848,13 +938,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),
@@ -889,10 +979,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.",
@@ -905,7 +991,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,
@@ -957,32 +1043,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
'''
)
@@ -1000,7 +1063,7 @@
# (doing nothing obvious), adding fast_start=yes
# to a build with fast_start=no will result in a rebuild
# Note that the exact header file to check does not matter
- conf.CheckCHeader('io.h')
+ # conf.CheckCHeader('io.h')
# only a few variables need to be rescanned
for key in ['USE_ASPELL', 'USE_PSPELL', 'USE_ISPELL', 'HAVE_FCNTL',\
'HAVE_ICONV', 'HAVE_LIBGDI32', 'HAVE_LIBAIKSAURUS',
@@ -1026,11 +1089,19 @@
qt_libs = ['qt-mt']
frontend_libs = ['qt-mt']
elif frontend == 'qt4':
- if platform_name == "win32":
- qt_libs = ['QtCore4', 'QtGui4']
+ qt_libs = ['QtCore', 'QtGui']
+ # set the right lib names
+ if platform_name == 'win32':
+ if mode == 'debug' and use_vc:
+ qt_lib_suffix = 'd4'
+ else:
+ qt_lib_suffix = '4'
else:
- qt_libs = ['QtCore', 'QtGui']
- frontend_libs = qt_libs
+ if mode == 'debug':
+ qt_lib_suffix = '_debug'
+ else:
+ qt_lib_suffix = ''
+ frontend_libs = [x + qt_lib_suffix for x in qt_libs]
except:
print "Can not locate qt tools"
print "What I get is "
@@ -1055,7 +1126,7 @@
('HAVE_ICONV', env['ICONV_LIB']),
('HAVE_LIBGDI32', 'gdi32'),
('HAVE_LIBAIKSAURUS', env['AIKSAURUS_LIB']),
- ('USE_ASPELL', 'aspell'),
+ ('USE_ASPELL', aspell_lib),
('USE_ISPELL', 'ispell'),
('USE_PSPELL', 'pspell'),
]
@@ -1071,17 +1142,29 @@
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
#
# install customized builders
env['BUILDERS']['substFile'] = Builder(action = utils.env_subst)
+if use_pch and not use_vc:
+ env['CCPCHFLAGS'] = '-x c++-header'
+ env['BUILDERS']['PCH'] = Builder(
+ action = '$CXX $CPPFLAGS $_CPPDEFFLAGS $_CPPINCFLAGS $CCPCHFLAGS $SOURCES
-o $TARGET',
+ suffix = '.h.pch', src_suffix = '.h'
+ )
+else:
+ # do nothing
+ def emptyTarget(target, source, env):
+ return [], source
+ env['BUILDERS']['PCH'] = Builder(action = '', emitter = emptyTarget)
#
# A Link script for cygwin see
@@ -1256,132 +1339,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
@@ -1588,10 +1549,13 @@
# src/mathed
#
print "Processing files in src/mathed..."
-
+ env['PCH_H'] = '$TOP_SRCDIR/src/mathed/pch.h'
+ env['PCH_FILE'] = env.PCH(env['PCH_H'])
+ #
mathed = env.StaticLibrary(
target = '$LOCALLIBPATH/mathed',
- source = utils.globSource(dir = env.subst('$TOP_SRCDIR/src/mathed'),
pattern = lyx_ext,
+ source = env['PCH_FILE'] + utils.globSource(dir =
env.subst('$TOP_SRCDIR/src/mathed'),
+ pattern = lyx_ext,
exclude = ['math_xyarrowinset.C', 'math_mboxinset.C', 'formulamacro.C'],
build_dir = '$BUILDDIR/common/mathed')
)
@@ -1603,10 +1567,11 @@
# src/insets
#
print "Processing files in src/insets..."
-
+ #
insets = env.StaticLibrary(
target = '$LOCALLIBPATH/insets',
- source = utils.globSource(dir = env.subst('$TOP_SRCDIR/src/insets'),
pattern = lyx_ext,
+ source = utils.globSource(dir = env.subst('$TOP_SRCDIR/src/insets'),
+ pattern = lyx_ext,
exclude = ['insettheorem.C'], build_dir = '$BUILDDIR/common/insets')
)
Alias('insets', insets)
@@ -1869,7 +1834,7 @@
# process .C file!!! (add to cxx_suffixes )
#
qt4env.Tool('qt4', [scons_dir])
- qt4env.EnableQt4Modules(qt_libs, debug = False)
+ qt4env.EnableQt4Modules(qt_libs, debug = (mode == 'debug'))
qt4env.AppendUnique(CPPPATH = [
'$BUILDDIR/common',
@@ -1921,7 +1886,7 @@
QGraphicsDialog.C
QIncludeDialog.C
QIndexDialog.C
- QLAction.C
+ Action.C
QLogDialog.C
QViewSourceDialog.C
QViewSource.C
@@ -1970,7 +1935,6 @@
qt4 = qt4env.StaticLibrary(
target = '$LOCALLIBPATH/qt4',
- LIBS = qt_libs,
source = utils.globSource(dir =
env.subst('$TOP_SRCDIR/src/frontends/qt4'), pattern = lyx_ext,
exclude = ['QBrowseBox.C'], build_dir = '$BUILDDIR/common/frontends/qt4')
)
@@ -2007,7 +1971,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'])