replace the homebrew GCH-builder by a lib solution
This commit is contained in:
parent
616d522ea9
commit
32dd0e661a
3 changed files with 128 additions and 34 deletions
32
SConstruct
32
SConstruct
|
|
@ -21,13 +21,6 @@
|
||||||
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
#####################################################################
|
#####################################################################
|
||||||
|
|
||||||
import sys
|
|
||||||
sys.path.append("./admin/scons")
|
|
||||||
|
|
||||||
import os
|
|
||||||
from Buildhelper import *
|
|
||||||
from LumieraEnvironment import *
|
|
||||||
|
|
||||||
|
|
||||||
#-----------------------------------Configuration
|
#-----------------------------------Configuration
|
||||||
OPTIONSCACHEFILE = 'optcache'
|
OPTIONSCACHEFILE = 'optcache'
|
||||||
|
|
@ -37,6 +30,7 @@ BINDIR = 'bin'
|
||||||
TESTDIR = 'tests'
|
TESTDIR = 'tests'
|
||||||
ICONDIR = 'icons'
|
ICONDIR = 'icons'
|
||||||
VERSION = '0.1+pre.01'
|
VERSION = '0.1+pre.01'
|
||||||
|
TOOLDIR = './admin/scons'
|
||||||
SVGRENDERER = 'admin/render-icon'
|
SVGRENDERER = 'admin/render-icon'
|
||||||
#-----------------------------------Configuration
|
#-----------------------------------Configuration
|
||||||
|
|
||||||
|
|
@ -47,6 +41,14 @@ SVGRENDERER = 'admin/render-icon'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
|
sys.path.append(TOOLDIR)
|
||||||
|
|
||||||
|
from Buildhelper import *
|
||||||
|
from LumieraEnvironment import *
|
||||||
|
|
||||||
|
|
||||||
#####################################################################
|
#####################################################################
|
||||||
|
|
||||||
|
|
@ -57,7 +59,10 @@ def setupBasicEnvironment():
|
||||||
EnsureSConsVersion(0,96,90)
|
EnsureSConsVersion(0,96,90)
|
||||||
|
|
||||||
opts = defineCmdlineOptions()
|
opts = defineCmdlineOptions()
|
||||||
env = LumieraEnvironment(options=opts)
|
env = LumieraEnvironment(options=opts
|
||||||
|
,toolpath = [TOOLDIR]
|
||||||
|
,tools = ["default", "BuilderGCH"]
|
||||||
|
)
|
||||||
|
|
||||||
env.Append ( CCCOM=' -std=gnu99') # workaround for a bug: CCCOM currently doesn't honor CFLAGS, only CCFLAGS
|
env.Append ( CCCOM=' -std=gnu99') # workaround for a bug: CCCOM currently doesn't honor CFLAGS, only CCFLAGS
|
||||||
env.Replace( VERSION=VERSION
|
env.Replace( VERSION=VERSION
|
||||||
|
|
@ -70,7 +75,6 @@ def setupBasicEnvironment():
|
||||||
)
|
)
|
||||||
|
|
||||||
RegisterIcon_Builder(env,SVGRENDERER)
|
RegisterIcon_Builder(env,SVGRENDERER)
|
||||||
RegisterPrecompiledHeader_Builder(env)
|
|
||||||
handleNoBugSwitches(env)
|
handleNoBugSwitches(env)
|
||||||
|
|
||||||
env.Append(CPPDEFINES = '_GNU_SOURCE')
|
env.Append(CPPDEFINES = '_GNU_SOURCE')
|
||||||
|
|
@ -278,6 +282,10 @@ def defineBuildTargets(env, artifacts):
|
||||||
setup sub-environments with special build options if necessary.
|
setup sub-environments with special build options if necessary.
|
||||||
We use a custom function to declare a whole tree of srcfiles.
|
We use a custom function to declare a whole tree of srcfiles.
|
||||||
"""
|
"""
|
||||||
|
# use PCH to speed up building
|
||||||
|
env['GCH'] = ( env.PrecompiledHeader('$SRCDIR/pre.hpp')
|
||||||
|
+ env.PrecompiledHeader('$SRCDIR/pre_a.hpp')
|
||||||
|
)
|
||||||
|
|
||||||
objback = srcSubtree(env,'$SRCDIR/backend')
|
objback = srcSubtree(env,'$SRCDIR/backend')
|
||||||
objproc = srcSubtree(env,'$SRCDIR/proc')
|
objproc = srcSubtree(env,'$SRCDIR/proc')
|
||||||
|
|
@ -290,12 +298,6 @@ def defineBuildTargets(env, artifacts):
|
||||||
+ env.StaticLibrary('$BINDIR/lumi.la', objlib)
|
+ env.StaticLibrary('$BINDIR/lumi.la', objlib)
|
||||||
)
|
)
|
||||||
|
|
||||||
# use PCH to speed up building
|
|
||||||
# precomp = ( env.PrecompiledHeader('$SRCDIR/pre')
|
|
||||||
# + env.PrecompiledHeader('$SRCDIR/pre_a')
|
|
||||||
# )
|
|
||||||
# env.Depends(objproc, precomp)
|
|
||||||
# env.Depends(objlib, precomp)
|
|
||||||
|
|
||||||
artifacts['lumiera'] = env.Program('$BINDIR/lumiera', ['$SRCDIR/main.cpp']+ core )
|
artifacts['lumiera'] = env.Program('$BINDIR/lumiera', ['$SRCDIR/main.cpp']+ core )
|
||||||
artifacts['plugins'] = env.SharedLibrary('$BINDIR/lumiera-plugin', objplug)
|
artifacts['plugins'] = env.SharedLibrary('$BINDIR/lumiera-plugin', objplug)
|
||||||
|
|
|
||||||
111
admin/scons/BuilderGCH.py
Normal file
111
admin/scons/BuilderGCH.py
Normal file
|
|
@ -0,0 +1,111 @@
|
||||||
|
# -*- python -*-
|
||||||
|
##
|
||||||
|
## BuilderGCH.py - SCons builder for gcc's precompiled headers
|
||||||
|
##
|
||||||
|
|
||||||
|
# Copyright (C) scons.org/wiki/GchBuilder
|
||||||
|
# 2006 Tim Blechmann
|
||||||
|
# 2008 Hermann Vosseler <Ichthyostega@web.de>
|
||||||
|
#
|
||||||
|
# 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; if not, write to the Free Software
|
||||||
|
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
|
#####################################################################
|
||||||
|
|
||||||
|
# history: 8/2008 adapted for Lumiera build system
|
||||||
|
# changed to accept a list of precompiled header defs
|
||||||
|
|
||||||
|
|
||||||
|
from types import ListType
|
||||||
|
|
||||||
|
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 setup_dependency(target,source,env, key):
|
||||||
|
scanner = SCons.Scanner.C.CScanner()
|
||||||
|
path = scanner.path(env)
|
||||||
|
deps = scanner(source[0], env, path)
|
||||||
|
|
||||||
|
if env.has_key(key) and env[key]:
|
||||||
|
for header in env[key]:
|
||||||
|
header_path = header.path.strip('.gch')
|
||||||
|
if header_path in [x.path for x in deps]:
|
||||||
|
print "Precompiled header(%s) %s \t <--- %s" % (key,header_path,source[0])
|
||||||
|
env.Depends(target, header)
|
||||||
|
|
||||||
|
|
||||||
|
def static_pch_emitter(target,source,env):
|
||||||
|
SCons.Defaults.StaticObjectEmitter( target, source, env )
|
||||||
|
setup_dependency(target,source,env, key='GCH')
|
||||||
|
return (target, source)
|
||||||
|
|
||||||
|
def shared_pch_emitter(target,source,env):
|
||||||
|
SCons.Defaults.SharedObjectEmitter( target, source, env )
|
||||||
|
setup_dependency(target,source,env, key='GCH-sh')
|
||||||
|
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']['GCH-sh']
|
||||||
|
except KeyError:
|
||||||
|
bld = GchBuilder
|
||||||
|
bldsh = GchShBuilder
|
||||||
|
env['BUILDERS']['PrecompiledHeader'] = bld
|
||||||
|
env['BUILDERS']['PrecompiledHeaderShared'] = 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++')
|
||||||
|
|
@ -151,25 +151,6 @@ def RegisterIcon_Builder(env, renderer):
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def RegisterPrecompiledHeader_Builder(env):
|
|
||||||
""" Registeres an Custom Builder for generating a precompiled Header.
|
|
||||||
Note you should define a dependency to the PCH file
|
|
||||||
"""
|
|
||||||
def genCmdline(source, target, env, for_signature):
|
|
||||||
return '$CXXCOM -x c++-header %s' % source[0]
|
|
||||||
def fixSourceDependency(target, source, env):
|
|
||||||
print "precompiled header: %s --> %s" % (source[0],target[0])
|
|
||||||
return (target, source)
|
|
||||||
|
|
||||||
gchBuilder = env.Builder( generator = genCmdline
|
|
||||||
, emitter = fixSourceDependency
|
|
||||||
, suffix = '.gch'
|
|
||||||
, src_suffix = '.hpp'
|
|
||||||
)
|
|
||||||
env.Append(BUILDERS = {'PrecompiledHeader' : gchBuilder})
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def Tarball(env,location,dirs,suffix=''):
|
def Tarball(env,location,dirs,suffix=''):
|
||||||
""" Custom Command: create Tarball of some subdirs
|
""" Custom Command: create Tarball of some subdirs
|
||||||
location: where to create the tar (may optionally include filename.tar.gz)
|
location: where to create the tar (may optionally include filename.tar.gz)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue