Some fixes to the scons-based building sytem, from Bo Peng (ben.bob@gmail.com)

* SConstruct: add extra_inc_path1, fix mingw logged spawn, try to handle QtCore4 etc
	* src/SConscript: remove lyx_base library
	* src/frontends/qt4/SConscript: remove some extra files 
	* Move scons_utils.py and qt4.py to config directory


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@13813 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Bo Peng 2006-05-08 21:03:01 +00:00
parent 10c8081a54
commit 4b5fae61d3
5 changed files with 41 additions and 32 deletions

View File

@ -35,6 +35,7 @@
# #
# * use extra_inc_path, extra_lib_path, qt_dir, qt_inc_path # * use extra_inc_path, extra_lib_path, qt_dir, qt_inc_path
# qt_lib_path to help locate qt and other libraries # qt_lib_path to help locate qt and other libraries
# (there are extra_inc_path1, extra_lib_path1 for now)
# #
# * (Important) use scons logfile=logfile.log to enable command line # * (Important) use scons logfile=logfile.log to enable command line
# logging. (default is no logging) # logging. (default is no logging)
@ -63,7 +64,8 @@
import os, sys import os, sys
# scons_util defines a few utility function # config/scons_utils.py defines a few utility function
sys.path.append('config')
import scons_utils as utils import scons_utils as utils
#---------------------------------------------------------- #----------------------------------------------------------
@ -205,6 +207,8 @@ opts.AddOptions(
# extra include and libpath # extra include and libpath
PathOption('extra_inc_path', 'Extra include path', '.'), PathOption('extra_inc_path', 'Extra include path', '.'),
PathOption('extra_lib_path', 'Extra library path', '.'), PathOption('extra_lib_path', 'Extra library path', '.'),
PathOption('extra_inc_path1', 'Extra include path', '.'),
PathOption('extra_lib_path1', 'Extra library path', '.'),
# enable assertion, (config.h has ENABLE_ASSERTIOS # enable assertion, (config.h has ENABLE_ASSERTIOS
BoolOption('assertions', 'Use assertions', True), BoolOption('assertions', 'Use assertions', True),
# enable warning, (config.h has WITH_WARNINGS) # enable warning, (config.h has WITH_WARNINGS)
@ -315,6 +319,10 @@ if ARGUMENTS.has_key('extra_inc_path'):
env.Append(CPPPATH = [ARGUMENTS['extra_inc_path']]) env.Append(CPPPATH = [ARGUMENTS['extra_inc_path']])
if ARGUMENTS.has_key('extra_lib_path'): if ARGUMENTS.has_key('extra_lib_path'):
env.Append(LIBPATH = [ARGUMENTS['extra_lib_path']]) env.Append(LIBPATH = [ARGUMENTS['extra_lib_path']])
if ARGUMENTS.has_key('extra_inc_path1'):
env.Append(CPPPATH = [ARGUMENTS['extra_inc_path1']])
if ARGUMENTS.has_key('extra_lib_path1'):
env.Append(LIBPATH = [ARGUMENTS['extra_lib_path1']])
# #
# this is a bit out of place (after auto-configration) # this is a bit out of place (after auto-configration)
@ -362,13 +370,14 @@ elif env['frontend'] == 'qt4':
succ = False succ = False
# first: try pkg_config # first: try pkg_config
if env['HAS_PKG_CONFIG']: if env['HAS_PKG_CONFIG']:
succ = conf.CheckPackage('QtCore') succ = conf.CheckPackage('QtCore') or conf.CheckPackage('QtCore4')
env['QT4_PKG_CONFIG'] = succ env['QT4_PKG_CONFIG'] = succ
# second: try to link to it # second: try to link to it
if not succ: if not succ:
# FIXME: under linux, I can test the following perfectly # FIXME: under linux, I can test the following perfectly
# However, under windows, lib names need to passed as libXXX4.a ... # However, under windows, lib names need to passed as libXXX4.a ...
succ = conf.CheckLibWithHeader('QtCore', 'QtGui/QApplication', 'c++', 'QApplication qapp();') succ = conf.CheckLibWithHeader('QtCore', 'QtGui/QApplication', 'c++', 'QApplication qapp();') or \
conf.CheckLibWithHeader('QtCore4', 'QtGui/QApplication', 'c++', 'QApplication qapp();')
# third: try to look up the path # third: try to look up the path
if not succ: if not succ:
succ = True succ = True
@ -379,7 +388,9 @@ elif env['frontend'] == 'qt4':
succ = False succ = False
break break
# still can not find it # still can not find it
if not succ: if succ:
print "Qt4 libraries are found."
else:
print 'Did not find qt libraries, exiting!' print 'Did not find qt libraries, exiting!'
Exit(1) Exit(1)
@ -660,7 +671,10 @@ try:
elif frontend == 'qt4': elif frontend == 'qt4':
# local qt4 toolset from # local qt4 toolset from
# http://www.iua.upf.es/~dgarcia/Codders/sconstools.html # http://www.iua.upf.es/~dgarcia/Codders/sconstools.html
env['QT_LIB'] = ['QtCore', 'QtGui', 'Qt3Support'] if platform_name == "win32":
env['QT_LIB'] = ['QtCore4', 'QtGui4', 'Qt3Support4']
else:
env['QT_LIB'] = ['QtCore', 'QtGui', 'Qt3Support']
env['EXTRA_LIBS'] = env['QT_LIB'] env['EXTRA_LIBS'] = env['QT_LIB']
except: except:
print "Can not locate qt tools" print "Can not locate qt tools"

View File

@ -22,7 +22,7 @@ if SCons.Util.case_sensitive_suffixes('.h', '.H'):
header_extensions.append('.H') header_extensions.append('.H')
#cplusplus = __import__('c++', globals(), locals(), ['Scons.Tools']) #cplusplus = __import__('c++', globals(), locals(), ['Scons.Tools'])
#cxx_suffixes = cplusplus.CXXSuffixes #cxx_suffixes = cplusplus.CXXSuffixes
cxx_suffixes = [".c", ".cxx", ".cpp", ".cc", ".C"] cxx_suffixes = [".C", ".c", ".cxx", ".cpp", ".cc"]
def _checkMocIncluded(target, source, env): def _checkMocIncluded(target, source, env):
moc = target[0] moc = target[0]
@ -173,8 +173,6 @@ def generate(env):
print "Loading qt4 tool..." print "Loading qt4 tool..."
def locateQt4Command(env, command, qtdir) : def locateQt4Command(env, command, qtdir) :
fullpath = env.Detect([command+'-qt4', command])
if not (fullpath is None) : return fullpath
fullpath1 = os.path.join(qtdir,'bin',command +'-qt4') fullpath1 = os.path.join(qtdir,'bin',command +'-qt4')
if os.access(fullpath1, os.X_OK) or \ if os.access(fullpath1, os.X_OK) or \
os.access(fullpath1+".exe", os.X_OK): os.access(fullpath1+".exe", os.X_OK):
@ -183,6 +181,8 @@ def generate(env):
if os.access(fullpath2, os.X_OK) or \ if os.access(fullpath2, os.X_OK) or \
os.access(fullpath2+".exe", os.X_OK): os.access(fullpath2+".exe", os.X_OK):
return fullpath2 return fullpath2
fullpath = env.Detect([command+'-qt4', command])
if not (fullpath is None) : return fullpath
raise "Qt4 command '" + command + "' not found. Tried: " + fullpath1 + " and "+ fullpath2 raise "Qt4 command '" + command + "' not found. Tried: " + fullpath1 + " and "+ fullpath2
@ -259,14 +259,15 @@ def generate(env):
env.Append( BUILDERS = { 'Qrc': qrcbuilder } ) env.Append( BUILDERS = { 'Qrc': qrcbuilder } )
# Interface builder # Interface builder
env['QT4_UIC4COM'] = [ #env['QT4_UIC4COM'] = [
CLVar('$QT4_UIC $QT4_UICDECLFLAGS -o ${TARGETS[0]} $SOURCE'), # CLVar('$QT4_UIC $QT4_UICDECLFLAGS -o ${TARGETS[0]} $SOURCE'),
] # ]
env['QT4_UIC4COM'] = '$QT4_UIC -o $TARGET $SOURCE'
uic4builder = Builder( uic4builder = Builder(
action='$QT4_UIC4COM', action='$QT4_UIC4COM',
src_suffix='$QT4_UISUFFIX', src_suffix='$QT4_UISUFFIX',
suffix='$QT4_UICDECLSUFFIX', suffix='$QT4_UICDECLSUFFIX',
prefix='$QT4_UICDECLPREFIX', #prefix='$QT4_UICDECLPREFIX',
single_source = True single_source = True
) )
env.Append( BUILDERS = { 'Uic4': uic4builder } ) env.Append( BUILDERS = { 'Uic4': uic4builder } )
@ -351,7 +352,6 @@ def enable_modules(self, modules, debug=False) :
self.AppendUnique(LIBPATH=[os.path.join(self["QTDIR"],"lib",module)]) self.AppendUnique(LIBPATH=[os.path.join(self["QTDIR"],"lib",module)])
self.AppendUnique(CPPPATH=[os.path.join(self["QTDIR"],"include","qt4",module)]) self.AppendUnique(CPPPATH=[os.path.join(self["QTDIR"],"include","qt4",module)])
modules.remove(module) modules.remove(module)
# modified by Bo Peng (/lib/pkgconfig => /lib)
self.ParseConfig('PKG_CONFIG_PATH=%s/lib pkg-config %s --libs --cflags'% self.ParseConfig('PKG_CONFIG_PATH=%s/lib pkg-config %s --libs --cflags'%
( (
self['QTDIR'], self['QTDIR'],

View File

@ -543,6 +543,17 @@ SECTIONS
return(ld_script) return(ld_script)
try:
# these will be used under win32
import win32file
import win32event
import win32process
import win32security
except:
# does not matter if it fails on other systems
pass
class loggedSpawn: class loggedSpawn:
def __init__(self, env, logfile, longarg, info): def __init__(self, env, logfile, longarg, info):
# save the spawn system # save the spawn system
@ -601,12 +612,6 @@ def setLoggedSpawn(env, logfile = '', longarg=False, info=''):
commands to a logfile. If the argument is too long commands to a logfile. If the argument is too long
a win32 spawn will be used instead of the system one a win32 spawn will be used instead of the system one
''' '''
if longarg:
import win32file
import win32event
import win32process
import win32security
import string
# #
# create a new spwn object # create a new spwn object
ls = loggedSpawn(env, logfile, longarg, info) ls = loggedSpawn(env, logfile, longarg, info)

View File

@ -142,6 +142,7 @@ lyx_source = Split('''
vc-backend.C vc-backend.C
version.C version.C
vspace.C vspace.C
main.C
''') ''')
if env.has_key('USE_ASPELL') and env['USE_ASPELL']: if env.has_key('USE_ASPELL') and env['USE_ASPELL']:
@ -151,22 +152,14 @@ elif env.has_key('USE_PSPELL') and env['USE_PSPELL']:
elif env.has_key('USE_ISPELL') and env['USE_ISPELL']: elif env.has_key('USE_ISPELL') and env['USE_ISPELL']:
lyx_source += ['ispell.C'] lyx_source += ['ispell.C']
#
# Create a static library for this directory as well
#
lyx_base = env.StaticLibrary(
target = '$LOCALLIBPATH/lyx_base',
source = lyx_source
)
# #
# Build lyx with given frontend # Build lyx with given frontend
# #
lyx = env.Program( lyx = env.Program(
target = 'lyx', target = 'lyx',
source = ['main.C'], source = lyx_source,
LIBS = [ LIBS = [
'lyx_base',
'mathed', 'mathed',
'insets', 'insets',
'frontends', 'frontends',

View File

@ -21,7 +21,7 @@ qtenv = env.Copy()
# NOTE: I have to patch qt4.py since it does not automatically # NOTE: I have to patch qt4.py since it does not automatically
# process .C file!!! (add to cxx_suffixes ) # process .C file!!! (add to cxx_suffixes )
# #
qtenv.Tool('qt4', ['$TOP_SRC_DIR']) qtenv.Tool('qt4', ['$TOP_SRC_DIR/config'])
qtenv.EnableQt4Modules(env['QT_LIB'], debug = False) qtenv.EnableQt4Modules(env['QT_LIB'], debug = False)
qtenv.Append(CPPPATH = [ qtenv.Append(CPPPATH = [
@ -133,7 +133,6 @@ moc_files = Split('''
QBoxDialog.C QBoxDialog.C
QBranchDialog.C QBranchDialog.C
QBranches.C QBranches.C
QBrowseBox.C
QChangesDialog.C QChangesDialog.C
QCharacterDialog.C QCharacterDialog.C
QCitationDialog.C QCitationDialog.C
@ -244,9 +243,7 @@ source_files = Split('''
checkedwidgets.C checkedwidgets.C
lyx_gui.C lyx_gui.C
lcolorcache.C lcolorcache.C
panelstack.h
panelstack.C panelstack.C
qcoloritem.C
qfontexample.C qfontexample.C
qfont_loader.C qfont_loader.C
qfont_metrics.C qfont_metrics.C