From 56134789f799d15edd095a0ab090d50df06b474b Mon Sep 17 00:00:00 2001 From: Bo Peng Date: Tue, 13 Jun 2006 14:16:54 +0000 Subject: [PATCH] Scons: add qt2 frontend for lyx1.4 git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@14096 a592a061-630c-0410-9148-cb99ea01b6c8 --- development/scons/SConscript | 157 ++++++++++++++++++++++++++--------- development/scons/SConstruct | 76 ++++++++++------- 2 files changed, 163 insertions(+), 70 deletions(-) diff --git a/development/scons/SConscript b/development/scons/SConscript index a80cb56ee2..4c65ceef52 100644 --- a/development/scons/SConscript +++ b/development/scons/SConscript @@ -36,6 +36,7 @@ build_tex2lyx = True in ['tex2lyx' in x for x in targets] \ or 'install' in targets or 'all' in targets build_lyxbase = build_lyx or 'lyxbase' in targets build_po = 'po' in targets or 'install' in targets or 'all' in targets +build_qt2 = (build_lyx and env['frontend'] == 'qt2') or 'qt2' in targets build_qt3 = (build_lyx and env['frontend'] == 'qt3') or 'qt3' in targets build_qt4 = (build_lyx and env['frontend'] == 'qt4') or 'qt4' in targets build_msvs_projects = env['USE_VC'] and 'msvs_projects' in targets @@ -63,11 +64,15 @@ if rebuild_targets: build_graphics = ifBuildLib('graphics', 'graphics', build_graphics) build_controllers = ifBuildLib('controllers', 'controllers', build_controllers) build_lyxbase = ifBuildLib('lyxbase', 'lyxbase_pre', build_lyxbase) + build_qt2 = ifBuildLib('qt2', 'qt2', build_qt2) build_qt3 = ifBuildLib('qt3', 'qt3', build_qt3) build_qt4 = ifBuildLib('qt4', 'qt4', build_qt4) # sync frontend and env['frontend'] (maybe build qt4 with frontend=qt3) -if build_qt3: +if build_qt2: + frontend = 'qt2' + env['frontend'] = 'qt2' +elif build_qt3: frontend = 'qt3' env['frontend'] = 'qt3' elif build_qt4: @@ -87,41 +92,19 @@ if build_boost: boostenv = env.Copy() boostenv.AppendUnique(CCFLAGS = '-DBOOST_USER_CONFIG=""') - print 'Processing files in boost/libs/filesystem/src...' + for lib in ['filesystem', 'regex', 'signals', 'iostreams']: + # lyx 1.4 does not have iostreams + if not os.path.isdir(os.path.join(env.subst('$TOP_SRC_DIR'), 'boost', 'libs', lib)): + continue + + print 'Processing files in boost/libs/%s/src...' % lib - filesystem = boostenv.StaticLibrary( - target = '$LOCALLIBPATH/included_boost_filesystem', - source = globSource(dir = env.subst('$TOP_SRC_DIR/boost/libs/filesystem/src'), - pattern = '*.cpp', build_dir = '$BUILDDIR/boost/filesystem/src') - ) - - print 'Processing files in boost/libs/regex/src...' - - regex = boostenv.StaticLibrary( - target = '$LOCALLIBPATH/included_boost_regex', - source = globSource(dir = env.subst('$TOP_SRC_DIR/boost/libs/regex/src'), - pattern = '*.cpp', build_dir = '$BUILDDIR/boost/regex/src') - ) - - print 'Processing files in boost/libs/signals/src...' - - signals = boostenv.StaticLibrary( - target = '$LOCALLIBPATH/included_boost_signals', - source = globSource(dir = env.subst('$TOP_SRC_DIR/boost/libs/signals/src'), - pattern = '*.cpp', build_dir = '$BUILDDIR/boost/signals/src') - ) - - print 'Processing files in boost/libs/iostreams/src...' - - iostreams = boostenv.StaticLibrary( - target = '$LOCALLIBPATH/included_boost_iostreams', - source = globSource(dir = env.subst('$TOP_SRC_DIR/boost/libs/iostreams/src'), - pattern = '*.cpp', build_dir = '$BUILDDIR/boost/iostreams/src') - ) - Alias('boost', filesystem) - Alias('boost', regex) - Alias('boost', signals) - Alias('boost', iostreams) + boostlib = boostenv.StaticLibrary( + target = '$LOCALLIBPATH/included_boost_%s' % lib, + source = globSource(dir = env.subst('$TOP_SRC_DIR/boost/libs/%s/src' % lib), + pattern = '*.cpp', build_dir = '$BUILDDIR/boost/%s/src' % lib) + ) + Alias('boost', boostlib) if build_intl: @@ -186,7 +169,7 @@ if build_support: support = env.StaticLibrary( target = '$LOCALLIBPATH/support', source = globSource(dir = env.subst('$TOP_SRC_DIR/src/support'), pattern = env['LYX_EXT'], - exclude = ['os_win32.C', 'os_unix.C', 'os_cygwin.C', 'atexit.c'], + exclude = ['os_win32.C', 'os_unix.C', 'os_cygwin.C', 'os_os2.C', 'atexit.c'], include = ['package.C'], build_dir = '$BUILDDIR/common/support') ) Alias('support', support) @@ -264,11 +247,109 @@ if build_controllers: # -# src/frontend/qt3/4 +# src/frontend/qt2/3/4 # -if build_qt3 or build_qt4: +if build_qt2 or build_qt3 or build_qt4: env.BuildDir('$BUILDDIR/$frontend', '$TOP_SRC_DIR/src/frontend/$frontend', duplicate = 0) + +if build_qt2: + print "Processing files in src/frontends/qt2..." + + qt2env = env.Copy() + # disable auto scan to speed up non build time + qt2env['QT_AUTOSCAN'] = 0 + qt2env['QT_MOCHPREFIX'] = '' + + # load qt2 tools + qt2env.Tool('qt') + + qt2env.AppendUnique(CPPPATH = [ + '$BUILDDIR/common', + '$BUILDDIR/common/images', + '$BUILDDIR/common/frontends', + '$BUILDDIR/common/frontends/qt2', + '$BUILDDIR/common/frontends/controllers', + '$QT_INC_PATH'] + ) + + qt2_moc_files = ["$BUILDDIR/common/frontends/qt2/%s" % x for x in Split(''' + BulletsModule.C + emptytable.C + FileDialog_private.C + floatplacement.C + iconpalette.C + lengthcombo.C + panelstack.C + QAboutDialog.C + QBibitemDialog.C + QBibtexDialog.C + QBoxDialog.C + QBranchDialog.C + QBrowseBox.C + QChangesDialog.C + QCharacterDialog.C + QCitationDialog.C + QCommandBuffer.C + QCommandEdit.C + QContentPane.C + QDelimiterDialog.C + QDocumentDialog.C + QErrorListDialog.C + QERTDialog.C + QExternalDialog.C + QFloatDialog.C + QGraphicsDialog.C + QIncludeDialog.C + QIndexDialog.C + QLogDialog.C + QLPopupMenu.C + QLPrintDialog.C + QMathDialog.C + QMathMatrixDialog.C + QNoteDialog.C + QParagraphDialog.C + QPrefsDialog.C + QRefDialog.C + QSearchDialog.C + QSendtoDialog.C + qsetborder.C + QShowFileDialog.C + QSpellcheckerDialog.C + QDialogView.C + QTabularCreateDialog.C + QTabularDialog.C + QTexinfoDialog.C + QThesaurusDialog.C + QTocDialog.C + qttableview.C + QtView.C + QURLDialog.C + QVSpaceDialog.C + QWrapDialog.C + QLToolbar.C + socket_callback.C + validators.C + ''')] + + # manually moc and uic files for better performance + qt2_moced_files = [qt2env.Moc(x.replace('.C', '_moc.cpp'), x.replace('.C', '.h')) for x in qt2_moc_files] + + qt2_uiced_files = [qt2env.Uic('$BUILDDIR/common/frontends/qt2/ui/'+x) for x in \ + globSource(dir = env.subst('$TOP_SRC_DIR/src/frontends/qt2/ui'), pattern = '*.ui')] + + qt2_uiced_cc_files = [] + for x in qt2_uiced_files: + qt2_uiced_cc_files.extend(x[1:]) + + qt2 = qt2env.StaticLibrary( + target = '$LOCALLIBPATH/qt2', + source = globSource(dir = env.subst('$TOP_SRC_DIR/src/frontends/qt2/'), pattern = env['LYX_EXT'], + build_dir = '$BUILDDIR/common/frontends/qt2') + qt2_moced_files + qt2_uiced_cc_files + ) + Alias('qt2', qt2) + + if build_qt3: print "Processing files in src/frontends/qt3..." diff --git a/development/scons/SConstruct b/development/scons/SConstruct index f9781e3ed3..2d9f2daa92 100644 --- a/development/scons/SConstruct +++ b/development/scons/SConstruct @@ -23,7 +23,8 @@ # default to lyx, you can use 'scons all' to build all targets except # for install # * options: use scons -h for details about options, the most important -# one is frontend=qt3|qt4. +# one is frontend=qt2|qt3|qt4. +# - qt2 is used by lyx1.4.x # - qt3 is used by default on linux, cygwin and mac # - qt4 is used by default on win32/mingw # @@ -102,7 +103,14 @@ else: #---------------------------------------------------------- # some global settings -PACKAGE_VERSION = '1.5.0svn' +# +# detect version of lyx +# only 1.4.x has frontends/qt2 +if os.path.isdir(os.path.join(TOP_SRC_DIR, 'src', 'frontends', 'qt2')): + PACKAGE_VERSION = '1.4.2svn' +else: + PACKAGE_VERSION = '1.5.0svn' + DEVEL_VERSION = True default_build_mode = 'debug' lyx_ext = '*.C' @@ -209,7 +217,7 @@ opts = Options(['config.py']) opts.AddOptions( # frontend, EnumOption('frontend', 'Main GUI', default_frontend, - allowed_values = ('xform', 'qt3', 'qt4', 'gtk') ), + allowed_values = ('xform', 'qt2', 'qt3', 'qt4', 'gtk') ), # debug or release build EnumOption('mode', 'Building method', default_build_mode, allowed_values = ('debug', 'release') ), @@ -328,7 +336,7 @@ if (not ARGUMENTS.has_key('load_option') or \ opt_cache.pop('qt_dir') # some options will require full rebuild # these are in general things that will change src/config.h - for arg in ['version_suffix', 'nls']: + for arg in ['version_suffix', 'nls', 'boost']: if ARGUMENTS.has_key(arg) and ((not opt_cache.has_key(arg)) or \ ARGUMENTS[arg] != opt_cache[arg]): if fast_start: @@ -336,7 +344,7 @@ if (not ARGUMENTS.has_key('load_option') or \ print fast_start = False # and we do not cache some options - for arg in ['fast_start']: + for arg in ['fast_start', 'load_option']: if opt_cache.has_key(arg): opt_cache.pop(arg) for key in opt_cache.keys(): @@ -595,7 +603,7 @@ if not fast_start: if not fast_start: # # qt3 does not use pkg_config - if frontend == 'qt3': + if frontend in ['qt2', 'qt3']: if not conf.CheckLibWithHeader('qt-mt', 'qapp.h', 'c++', 'QApplication qapp();'): print 'Did not find qt libraries, exiting!' Exit(1) @@ -653,34 +661,38 @@ if not fast_start: # check boost libraries boost_opt = ARGUMENTS.get('boost', default_boost_opt) # check for system boost - succ = False + paths = env['LIBPATH'] + ['/usr/lib', '/usr/local/lib'] + env['BOOST_LIBRARIES'] = [] boost_libpath = None - if boost_opt in ['auto', 'system']: - paths = env['LIBPATH'] + ['/usr/lib', '/usr/local/lib'] - sig = conf.CheckBoostLibraries('boost_signals', paths) - reg = conf.CheckBoostLibraries('boost_regex', paths) - fil = conf.CheckBoostLibraries('boost_filesystem', paths) - ios = conf.CheckBoostLibraries('boost_iostreams', paths) - # if any of them is not found - if ('' in [sig[0], reg[0], fil[0], ios[0]]): - if boost_opt == 'system': + # here I assume that all libraries are in the same directory + for lib in ['signals', 'regex', 'filesystem', 'iostreams']: + # lyx1.4 does not use iostreams + if not os.path.isdir(os.path.join(env.subst('$TOP_SRC_DIR'), 'boost', 'libs', lib)): + continue + if boost_opt == 'included': + env['BOOST_LIBRARIES'].append('included_boost_%s' % lib) + env['INCLUDED_BOOST'] = True + elif boost_opt == 'auto': + res = conf.CheckBoostLibraries('boost_%s' % lib , paths) + # if not found + if res[0] == '': + env['BOOST_LIBRARIES'].append('included_boost_%s' % lib) + env['INCLUDED_BOOST'] = True + else: + env['BOOST_LIBRARIES'].append(res[1]) + env['INCLUDED_BOOST'] = False + boost_libpath = res[0] + elif boost_opt == 'system': + res = conf.CheckBoostLibraries('boost_%s' % lib , paths) + if res[0] == '': 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: - env['BOOST_LIBRARIES'] = [sig[1], reg[1], fil[1], ios[1]] - # assume all boost libraries are in the same path... - boost_libpath = sig[0] - env.AppendUnique(LIBPATH = [sig[0]]) - env['INCLUDED_BOOST'] = False - succ = True - # now, auto and succ = false, or boost=included - if not succ: - # we do not need to set LIBPATH now. - env['BOOST_LIBRARIES'] = ['included_boost_signals', 'included_boost_regex', - 'included_boost_filesystem', 'included_boost_iostreams'] - env['INCLUDED_BOOST'] = True + else: + env['BOOST_LIBRARIES'].append(res[1]) + env.AppendUnique(LIBPATH = [res[0]]) + boost_libpath = res[0] env_cache['BOOST_LIBRARIES'] = env['BOOST_LIBRARIES'] env_cache['INCLUDED_BOOST'] = env['INCLUDED_BOOST'] env_cache['BOOST_LIBPATH'] = boost_libpath @@ -804,7 +816,7 @@ if not fast_start: ('alloca.h', 'HAVE_ALLOCA_H', 'c'), ('stddef.h', 'HAVE_STDDEF_H', 'c'), ('stdint.h', 'HAVE_STDINT_H', 'c'), - ('sys/param.h', 'HAVE_SYS_PARAM_H', 'c') + ('sys/param.h', 'HAVE_SYS_PARAM_H', 'c'), ] for header in headers: @@ -1180,7 +1192,7 @@ env = conf.Finish() # NOTE: Tool('qt') or Tool('qt4') will be loaded later # in their respective directory and specialized env. try: - if frontend == 'qt3': + if frontend in ['qt2', 'qt3']: # note: env.Tool('qt') my set QT_LIB to qt env['QT_LIB'] = 'qt-mt' env['FRONTEND_LIBS'] = ['qt-mt'] @@ -1316,7 +1328,7 @@ Frontend: env['frontend'], packaging_method, env['PREFIX'], env['BIN_DEST_DIR'], env['SHARE_DIR']) -if env['frontend'] in ['qt3', 'qt4']: +if env['frontend'] in ['qt2', 'qt3', 'qt4']: env['VERSION_INFO'] += ''' include dir: %s library dir: %s X11: %s