0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-12-01 09:32:32 +01:00

playing with pre-compiled headers

This commit is contained in:
Eliot Horowitz 2009-09-09 09:46:12 -04:00
parent 45f6a97f04
commit 3315fba0bb
2 changed files with 120 additions and 2 deletions

View File

@ -215,7 +215,7 @@ nojni = not GetOption( "nojni" ) is None
usesm = not GetOption( "usesm" ) is None usesm = not GetOption( "usesm" ) is None
usejvm = not GetOption( "usejvm" ) is None usejvm = not GetOption( "usejvm" ) is None
env = Environment( MSVS_ARCH=msarch ) env = Environment( MSVS_ARCH=msarch , tools = ["default", "gch"], toolpath = '.' )
if GetOption( "cxx" ) is not None: if GetOption( "cxx" ) is not None:
env["CC"] = GetOption( "cxx" ) env["CC"] = GetOption( "cxx" )
env["CXX"] = GetOption( "cxx" ) env["CXX"] = GetOption( "cxx" )
@ -295,6 +295,8 @@ serverOnlyFiles += coreShardFiles + [ "s/d_logic.cpp" ]
allClientFiles = commonFiles + coreDbFiles + [ "client/clientOnly.cpp" , "client/gridfs.cpp" ]; allClientFiles = commonFiles + coreDbFiles + [ "client/clientOnly.cpp" , "client/gridfs.cpp" ];
allCXXFiles = allClientFiles + coreShardFiles + shardServerFiles + serverOnlyFiles;
# ---- other build setup ----- # ---- other build setup -----
platform = os.sys.platform platform = os.sys.platform
@ -511,7 +513,7 @@ if not nojni and useJavaHome:
env.Append( LINKFLAGS="-Xlinker -rpath -Xlinker " + javaHome + "jre/lib/" + javaVersion ) env.Append( LINKFLAGS="-Xlinker -rpath -Xlinker " + javaHome + "jre/lib/" + javaVersion )
if nix: if nix:
env.Append( CPPFLAGS="-fPIC -fno-strict-aliasing -ggdb -pthread -Wall -Wsign-compare -Wno-unknown-pragmas" ) env.Append( CPPFLAGS="-fPIC -fno-strict-aliasing -ggdb -pthread -Wall -Wsign-compare -Wno-unknown-pragmas -Winvalid-pch" )
env.Append( CXXFLAGS=" -Wnon-virtual-dtor " ) env.Append( CXXFLAGS=" -Wnon-virtual-dtor " )
env.Append( LINKFLAGS=" -fPIC -pthread " ) env.Append( LINKFLAGS=" -fPIC -pthread " )
env.Append( LIBS=[] ) env.Append( LIBS=[] )
@ -537,6 +539,14 @@ if nix:
if GetOption( "profile" ) is not None: if GetOption( "profile" ) is not None:
env.Append( LINKFLAGS=" -pg " ) env.Append( LINKFLAGS=" -pg " )
# pre-compiled headers
if 'Gch' in dir( env ):
print( "using precompiled headers" )
env['Gch'] = env.Gch( [ "stdafx.h" ] )[0]
#Depends( "stdafx.o" , "stdafx.h.gch" )
#SideEffect( "dummyGCHSideEffect" , "stdafx.h.gch" )
if "uname" in dir(os): if "uname" in dir(os):
hacks = buildscripts.findHacks( os.uname() ) hacks = buildscripts.findHacks( os.uname() )
if hacks is not None: if hacks is not None:

108
gch.py Normal file
View File

@ -0,0 +1,108 @@
# $Id$
#
# SCons builder for gcc's precompiled headers
# Copyright (C) 2006 Tim Blechmann
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; see the file COPYING. If not, write to
# the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA.
# $Revision$
# $LastChangedRevision$
# $LastChangedDate$
# $LastChangedBy$
import SCons.Action
import SCons.Builder
import SCons.Scanner.C
import SCons.Util
import SCons.Script
SCons.Script.EnsureSConsVersion(0,96,92)
GchAction = SCons.Action.Action('$GCHCOM', '$GCHCOMSTR')
GchShAction = SCons.Action.Action('$GCHSHCOM', '$GCHSHCOMSTR')
def gen_suffix(env, sources):
return sources[0].get_suffix() + env['GCHSUFFIX']
GchShBuilder = SCons.Builder.Builder(action = GchShAction,
source_scanner = SCons.Scanner.C.CScanner(),
suffix = gen_suffix)
GchBuilder = SCons.Builder.Builder(action = GchAction,
source_scanner = SCons.Scanner.C.CScanner(),
suffix = gen_suffix)
def static_pch_emitter(target,source,env):
SCons.Defaults.StaticObjectEmitter( target, source, env )
scanner = SCons.Scanner.C.CScanner()
path = scanner.path(env)
deps = scanner(source[0], env, path)
if env.has_key('Gch') and env['Gch']:
if env['Gch'].path.strip('.gch') in [x.path for x in deps]:
env.Depends(target, env['Gch'])
return (target, source)
def shared_pch_emitter(target,source,env):
SCons.Defaults.SharedObjectEmitter( target, source, env )
scanner = SCons.Scanner.C.CScanner()
path = scanner.path(env)
deps = scanner(source[0], env, path)
if env.has_key('GchSh') and env['GchSh']:
if env['GchSh'].path.strip('.gch') in [x.path for x in deps]:
env.Depends(target, env['GchSh'])
return (target, source)
def generate(env):
"""
Add builders and construction variables for the Gch builder.
"""
env.Append(BUILDERS = {
'gch': env.Builder(
action = GchAction,
target_factory = env.fs.File,
),
'gchsh': env.Builder(
action = GchShAction,
target_factory = env.fs.File,
),
})
try:
bld = env['BUILDERS']['Gch']
bldsh = env['BUILDERS']['GchSh']
except KeyError:
bld = GchBuilder
bldsh = GchShBuilder
env['BUILDERS']['Gch'] = bld
env['BUILDERS']['GchSh'] = bldsh
env['GCHCOM'] = '$CXX -o $TARGET -x c++-header -c $CXXFLAGS $_CCCOMCOM $SOURCE'
env['GCHSHCOM'] = '$CXX -o $TARGET -x c++-header -c $SHCXXFLAGS $_CCCOMCOM $SOURCE'
env['GCHSUFFIX'] = '.gch'
for suffix in SCons.Util.Split('.c .C .cc .cxx .cpp .c++'):
env['BUILDERS']['StaticObject'].add_emitter( suffix, static_pch_emitter )
env['BUILDERS']['SharedObject'].add_emitter( suffix, shared_pch_emitter )
def exists(env):
return env.Detect('g++')