Skip to content

Precompiled header proposal #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 50 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
52fc82f
sconsProject: added precompiled header feature (to check)
edubois Feb 1, 2012
268c10b
sconsProject: improvment on precompiled header path
edubois Feb 1, 2012
2db29df
sconsProject: disabled WIN64 constant.
edubois Feb 2, 2012
b704ffe
sconsProject: gcc compilation fixes.
edubois Feb 2, 2012
8bc4d4e
Merge branch 'master' into precompiled_header_proposal
edubois Mar 22, 2012
b069a9d
Merge branch 'master' of github.com:tuttleofx/sconsProject into preco…
edubois Mar 22, 2012
0308ee9
Merge branch 'master' into precompiled_header_proposal
edubois Apr 1, 2012
1f0103a
sconsProject: added qtmain.py (windows non console application).
edubois Apr 12, 2012
7dcbd18
sconsProject: added qtmain.py and some fixes
edubois Apr 13, 2012
2bb8524
sconsProject: fixed wrong merge.
edubois Apr 13, 2012
876d246
qtmain: unix compatibility
edubois Apr 28, 2012
63d7039
Merge branch 'master' into precompiled_header_proposal
edubois Jul 4, 2012
322bd0c
Merge branch 'precompiled_header_proposal' of git://github.com/tuttle…
edubois Jul 4, 2012
08d679a
sconsProject update for precompiled headers.
edubois Jul 5, 2012
2bc6d3c
Merge branch 'master' of git://github.com/tuttleofx/sconsProject into…
edubois Nov 11, 2012
6657204
Merge branch 'master' of git://github.com/tuttleofx/sconsProject into…
edubois Nov 13, 2012
f9c10a8
sconsProject: added /bigobj for visual C++ higher dlls' segments size.
edubois Nov 13, 2012
516da79
Merge branch 'master' of git://github.com/tuttleofx/sconsProject into…
edubois Nov 13, 2012
fa869ec
Merge branch 'precompiled_header_proposal' of git://github.com/tuttle…
edubois Nov 13, 2012
13fcd2c
Merge branch 'master' of git://github.com/tuttleofx/sconsProject into…
edubois Nov 13, 2012
d36c10a
Merge branch 'precompiled_header_proposal' of git://github.com/tuttle…
edubois Nov 13, 2012
89ef26c
Merge branch 'master' of git://github.com/tuttleofx/sconsProject into…
edubois Nov 17, 2012
9ce303c
Merge branch 'precompiled_header_proposal' of git://github.com/tuttle…
edubois Nov 17, 2012
265cdf2
Merge branch 'precompiled_header_proposal' of git://github.com/tuttle…
edubois Nov 18, 2012
f720767
Merge branch 'master' into precompiled_header_proposal
edubois Apr 26, 2013
382b56e
Merge branch 'master' into precompiled_header_proposal
edubois Apr 26, 2013
be912ec
Merge branch 'master' of git://github.com/tuttleofx/sconsProject into…
edubois Apr 29, 2013
b04220e
sconsProject: added multithreaded_static_lib to compile with /MT (vc+…
edubois May 21, 2013
afa65e3
sconsProject: some improvments
edubois May 27, 2013
9fa61cf
Merge branch 'precompiled_header_proposal' of git://github.com/tuttle…
edubois May 27, 2013
5914e52
Merge branch 'master' of git://github.com/tuttleofx/sconsProject into…
edubois May 27, 2013
f9dad5d
Merge branch 'precompiled_header_proposal' of git://github.com/tuttle…
edubois May 27, 2013
f650b2a
Merge branch 'master' of git://github.com/tuttleofx/sconsProject into…
edubois Jul 9, 2013
2bb84c6
Merge branch 'precompiled_header_proposal' of git://github.com/tuttle…
edubois Jul 9, 2013
7ab39b8
sconsProject: experimental branch comments
edubois Jul 9, 2013
c894a5b
Merge branch 'master' into precompiled_header_proposal
edubois Oct 29, 2013
a7fcc3a
sconsProject: qt5 compilation.
edubois Nov 5, 2013
97c2111
sconsProject: fixed compilation issues
edubois Dec 9, 2013
dc422ca
Added CC['wchar'] option because Qt5 binaries are compiled with /Zc:w…
edubois Dec 27, 2013
c1454d9
Fixed scons compilation issue on Windows.
edubois Dec 27, 2013
78b2b4f
Minor fix
edubois Dec 27, 2013
d9d06b6
Merge remote-tracking branch 'origin/HEAD' into precompiled_header_pr…
edubois Jan 28, 2014
a7fc9d3
Merge branch 'precompiled_header_proposal' of git://github.com/tuttle…
edubois Jan 28, 2014
e1f068e
sconsProject: added option to override shared library suffix, which i…
edubois May 8, 2014
7eafdd0
sconsProject: added an option to specify ranlib and ar binaries (usef…
edubois May 8, 2014
e1e0713
Merge branch 'master' of git://github.com/tuttleofx/sconsProject into…
edubois May 8, 2014
c5f665c
sconsProject: added ncurses libraries (ncurses and CDK framework)
edubois Nov 30, 2014
d806e49
Merge branch 'master' into precompiled_header_proposal
edubois Nov 30, 2014
84d08ce
sconsProject: ncurses updates.
edubois Nov 30, 2014
64792a8
sconsProject: added fmod.
edubois Nov 30, 2014
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions __init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
SConsProject


The sconsproject package proposes a way to easily create the compilation system
of your project with the minimum of information. It's an helper around SCons.

Expand Down
1 change: 0 additions & 1 deletion autoconf/_external.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ def postconfigure(self, project, env, level):
'''
Particular case, which allow to add things after all libraries checks.
'''
env.AppendUnique( LIBS = self.getLibs(env) )
return True

def check(self, project, conf):
Expand Down
4 changes: 4 additions & 0 deletions autoconf/cdk.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from _external import *

# CDK is a framework for ncurses
cdk = LibWithHeaderChecker('cdk', ['cdk.h'], 'c')
5 changes: 5 additions & 0 deletions autoconf/fmod.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from _external import *

fmod = LibWithHeaderChecker( 'fmod', 'fmod.h', 'c' )


3 changes: 3 additions & 0 deletions autoconf/ncurses.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from _external import *

ncurses = LibWithHeaderChecker('ncurses', ['ncurses.h'], 'c')
2 changes: 1 addition & 1 deletion autoconf/poco_foundation.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from _external import *
from poco_xml import *

poco_foundation = HeaderChecker( 'poco_foundation', 'Poco/Foundation.h', 'c++', dependencies=[poco_xml] )
poco_foundation = LibWithHeaderChecker( 'poco_foundation', ['Poco/Foundation.h'], 'c++', dependencies=[poco_xml] )

4 changes: 2 additions & 2 deletions autoconf/poco_net.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

windows = os.name.lower() == "nt" and sys.platform.lower().startswith("win")
if windows:
poco_net = HeaderChecker( 'poco_net', 'Poco/Net/Net.h', 'c++', dependencies=[poco_foundation, winsock2] )
poco_net = LibWithHeaderChecker( 'poco_net', 'Poco/Net/Net.h', 'c++', dependencies=[poco_foundation, winsock2] )
else:
poco_net = HeaderChecker( 'poco_net', 'Poco/Net/Net.h', 'c++', dependencies=[poco_foundation] )
poco_net = LibWithHeaderChecker( 'poco_net', 'Poco/Net/Net.h', 'c++', dependencies=[poco_foundation] )

2 changes: 1 addition & 1 deletion autoconf/poco_xml.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from _external import *

poco_xml = HeaderChecker( 'poco_xml', 'Poco/XML/XML.h', 'c++' )
poco_xml = LibWithHeaderChecker( 'poco_xml', 'Poco/XML/XML.h', 'c++' )

154 changes: 154 additions & 0 deletions autoconf/qt5.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
from _external import *
import os
import SCons.Util

def unique(list):
return dict.fromkeys(list).keys()

def subdirs(files):
dirs = unique(map(os.path.dirname, files))
dirs.sort()
return dirs

def locateQt5Command(env, command, bindir):
#print 'locateQt5Command:', command
suffixes = [
'-qt5',
'5',
'',
]
progs = [command+s for s in suffixes]
for prog in progs:
path = env.WhereIs(prog, path=bindir)
if path:
return path
for prog in progs:
path = env.WhereIs(prog)
if path:
return path

msg = 'Qt5 command "' + command + '" not found. Tried: ' + str(progs) + '.'
#raise Exception(msg)
print 'Warning: ', msg
return command

class Qt5Checker(LibWithHeaderChecker):
'''
Qt5 checker
'''
allUiFiles = []

def __init__( self,
modules = [
'QtCore',
'QtGui',
'QtOpenGL',
'QtWidgets',
'QtNetwork',
'QtPrintSupport',
'QtWebKit',
'QtWebKitWidgets',
],
uiFiles = [],
defines = ['QT_NO_KEYWORDS'],
useLocalIncludes = True ):
self.name = 'qt5'
postfix = '' if not windows else '5'
for m in modules:
realName = m + postfix
if realName not in self.libs:
self.libs.append( realName )
self.uiFiles =self.getAbsoluteCwd(uiFiles)
self.defines = defines[:]
self.useLocalIncludes = useLocalIncludes

def setModules(self, modules):
self.libs = modules[:]

def declareUiFiles(self, uiFiles):
self.uiFiles.extend( self.getAbsoluteCwd(uiFiles) )

def initEnv(self, project, env):
# use qt scons tool
env.Tool('qt')

def initOptions(self, project, opts):
LibWithHeaderChecker.initOptions(self, project, opts)
opts.Add( 'bindir_'+self.name, 'Base directory for '+self.name, '${_join_if_basedir_not_empty( dir_'+self.name+ ', "bin" )}' )
return True

def configure(self, project, env):
env.EnableQtEmmitters()

bindir = '$bindir_'+self.name
moc = locateQt5Command(env, 'moc', bindir)
uic = locateQt5Command(env, 'uic', bindir)
rcc = locateQt5Command(env, 'rcc', bindir)
lupdate = locateQt5Command(env, 'lupdate', bindir)
lrelease = locateQt5Command(env, 'lrelease', bindir)

# specific part for Qt5
env.Replace(
# suffixes/prefixes for the headers / sources to generate
QT_UICDECLPREFIX = 'ui_',
QT_UICDECLSUFFIX = '.h',
QT_UICIMPLPREFIX = 'ui_',
QT_UICIMPLSUFFIX = '$CXXFILESUFFIX',
QT_MOCHPREFIX = 'moc_',
QT_MOCHSUFFIX = '$CXXFILESUFFIX',
QT_MOCCXXPREFIX = '',
QT_MOCCXXSUFFIX = '.moc',
QT_UISUFFIX = '.ui',

# Qt commands
# command to generate header from a .ui file
QT_UICCOM = [
SCons.Util.CLVar('$QT_UIC $QT_UICDECLFLAGS -o ${TARGETS[0]} $SOURCE'),
],
)

env.SetDefault(
QT_MOC = moc,
QT_UIC = uic,
QT5_RCC = rcc,
QT5_LUPDATE = lupdate,
QT5_LRELEASE = lrelease,
)

# don't need emitter with qt5
env['BUILDERS']['Uic'].emitter = None

if env['mode'] != 'debug' :
env.AppendUnique( CPPDEFINES = 'QMLJSDEBUGGER' )
env.AppendUnique( CPPDEFINES = 'QT_DECLARATIVE_DEBUG' ) # QtQuick 1
#env.AppendUnique( CPPDEFINES = 'QT_QML_DEBUG' ) # QtQuick 2

return BaseLibChecker.configure(self, project, env)

def check(self, project, conf):
conf.env.AppendUnique( CPPDEFINES = self.defines )
result = True
for mod in self.getLibs(conf.env):
r = self.CheckLibWithHeader( conf, [mod], header=[mod+'/'+mod], language='c++' )
if not r:
print 'error: ',mod
result &= r
return result

def postconfigure(self, project, env, level):
'''
Add things for ui files after all libs check.
'''
if len(self.uiFiles):
for ui in self.uiFiles:
# do not redeclare a ui file
if ui not in Qt5Checker.allUiFiles:
env.Uic( ui )
Qt5Checker.allUiFiles.append( ui )
if self.useLocalIncludes:
env.AppendUnique( CPPPATH=subdirs(self.uiFiles) )
return True

qt5 = Qt5Checker


6 changes: 5 additions & 1 deletion autoconf/qtmain.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
from _external import *

qtmain = LibChecker( 'qtmain' )
if windows:
qtmain = LibChecker( 'qtmain' )
else:
qtmain = ObjectChecker( 'qtmain' )

4 changes: 2 additions & 2 deletions autoconf/qxorm.py
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
from _external import *
from boost import *
from boost_serialization import *
from qt4 import *
from qt5 import *

qxorm = LibWithHeaderChecker(
'QxOrm',
'QxOrm.h',
'c++',
name='qxorm',
dependencies= [ boost, boost_serialization, qt4(modules=[ 'QtCore', 'QtGui', 'QtSql' ] ) ],
dependencies= [ boost, boost_serialization, qt5(modules=[ 'QtCore', 'QtGui', 'QtSql' ] ) ],
)

2 changes: 1 addition & 1 deletion autoconf/sconsProject.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def configure(self, project, env):
env.AppendUnique( CPPDEFINES = 'WINDOWS' )
env.AppendUnique( CPPDEFINES = '_WINDOWS' )
env.AppendUnique( CPPDEFINES = '__WINDOWS__' )
env.AppendUnique( CPPDEFINES = 'WIN'+str(env['osbits']) )
# env.AppendUnique( CPPDEFINES = 'WIN'+str(env['osbits']) )
else:
env.AppendUnique( CPPDEFINES = 'UNIX' )
env.AppendUnique( CPPDEFINES = '__UNIX__' )
Expand Down
2 changes: 2 additions & 0 deletions compiler/clang.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
name = 'clang'
ccBin = 'clang'
cxxBin = 'clang++'
arBin = 'ar'
ranlibBin = 'ranlib'
linkBin = ccBin
linkxxBin = cxxBin
ccVersionStr = 'unknown'
Expand Down
9 changes: 9 additions & 0 deletions compiler/gcc.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
cxxBin = 'g++'
linkBin = ccBin
linkxxBin = cxxBin
arBin = 'ar'
ranlibBin = 'ranlib'
ccVersionStr = 'unknown'
ccVersion = [0,0,0]
cxxVersionStr = 'unknown'
Expand All @@ -23,6 +25,10 @@

CC['define'] = '-D'

CC['bigobj'] = ''
CC['multithreadedlib'] = ''
CC['multithreaded_static_lib'] = ''
CC['singlethreadedlib'] = ''

CC['optimize'] = ['-O3'] #, '-flto']#,
#'-finline-limit=700',
Expand Down Expand Up @@ -72,6 +78,9 @@
CC['cover'] = ['-fprofile-arcs', '-ftest-coverage']
CC['linkcover'] = ['-lgcov']

# @see visual.py
CC['wchar'] = []

##### -fprofile-arcs
# Instrument arcs during compilation. For each function of your program, GCC creates a program flow graph, then finds a spanning tree for the graph. Only arcs that are not on the spanning tree have to be instrumented: the compiler adds code to count the number of times that these arcs are executed. When an arc is the only exit or only entrance to a block, the instrumentation code can be added to the block; otherwise, a new basic block must be created to hold the instrumentation code.
#
Expand Down
6 changes: 6 additions & 0 deletions compiler/visual.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
cxxBin = 'cl'
linkBin = 'link'
linkxxBin = 'link'
arBin = ''
ranlibBin = ''

ccVersionStr = 'unknown'
ccVersion = [0,0,0]
Expand All @@ -15,7 +17,9 @@
CC['exceptionsEnabled'] = '/EHsc' #'/GX'

CC['multithreadedlib'] = '/MD'
CC['multithreaded_static_lib'] = '/MT'
CC['singlethreadedlib'] = '/ML'
CC['bigobj'] = '/bigobj'

CC['optimize'] =['/O2','/Ox','/GA','/GL']
CC['nooptimize'] =['/Od']
Expand Down Expand Up @@ -70,6 +74,8 @@
CC['ssse3'] = ['/arch:SSSE3']
CC['sse4'] = ['/arch:SSE4']

# needed for compatibility with qt5 precompiled library
CC['wchar'] = ['/Zc:wchar_t-']

def retrieveVersion(ccBinArg):
import subprocess
Expand Down
33 changes: 29 additions & 4 deletions project/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -516,8 +516,11 @@ def help_format(env, opt, help, default, actual, aliases):
opts.Add('aliases', 'A list of custom aliases.', [])
opts.Add('jobs', 'Parallel jobs', '1')
opts.Add(SCons.Script.BoolVariable('check_libs', 'Enable/Disable lib checking', True))
opts.Add('SHLIBSUFFIX', 'Specify the shared libraries suffix', '.dll' if self.windows else( '.dylib' if self.macos else '.so' ) )
opts.Add('CC', 'Specify the C Compiler', self.compiler.ccBin)
opts.Add('CXX', 'Specify the C++ Compiler', self.compiler.cxxBin)
opts.Add('AR', 'Specify the C Compiler', self.compiler.arBin)
opts.Add('RANLIB', 'Specify the C++ Compiler', self.compiler.ranlibBin)

opts.Add('SCRIPTTESTXX', 'Specify the script test binary', "nosetests")
opts.Add('SCRIPTTESTFLAGS', 'Specify the script test flags', "--detailed-errors --process-timeout=60 --nocapture")
Expand Down Expand Up @@ -1078,7 +1081,7 @@ def declareTarget(self, localEnv, target, targetName=None):


def StaticLibrary( self, target,
sources=[], dirs=[], libraries=[], includes=[],
sources=[], precsrc='', precinc='', dirs=[], libraries=[], includes=[],
env=None, localEnvFlags={}, replaceLocalEnvFlags={}, externEnvFlags={}, globalEnvFlags={},
dependencies=[], installDir=None, installAs=None, install=True,
headers=[], localHeaders=[],
Expand Down Expand Up @@ -1152,6 +1155,12 @@ def StaticLibrary( self, target,

sourcesFiles = self.getAbsoluteCwd( sourcesFiles )

#adding precompiled headers
if precinc and self.windows:
localEnv['PCHSTOP'] = self.getRealAbsoluteCwd() + '/' + precinc
localEnv.Append( CPPFLAGS = [ '/FI' + self.getRealAbsoluteCwd() + '/' + precinc, '/Zm135' ] )
localEnv['PCH'] = localEnv.PCH( precsrc )[0]

# create the target
dstLib = localEnv.StaticLibrary( target=target, source=sourcesFiles )

Expand Down Expand Up @@ -1198,7 +1207,7 @@ def StaticLibrary( self, target,


def SharedLibrary( self, target,
sources=[], dirs=[], libraries=[], includes=[],
sources=[], precsrc='', precinc='', dirs=[], libraries=[], includes=[],
env=None, localEnvFlags={}, replaceLocalEnvFlags={}, externEnvFlags={}, globalEnvFlags={},
dependencies=[], installDir=None, installAs=None, install=True,
headers=[], localHeaders=[],
Expand Down Expand Up @@ -1266,6 +1275,12 @@ def SharedLibrary( self, target,

sourcesFiles = self.getAbsoluteCwd( sourcesFiles )

#adding precompiled headers
if precinc and self.windows:
localEnv['PCHSTOP'] = self.getRealAbsoluteCwd() + '/' + precinc
localEnv.Append( CPPFLAGS = [ '/FI' + self.getRealAbsoluteCwd() + '/' + precinc, '/Zm135' ] )
localEnv['PCH'] = localEnv.PCH( precsrc )[0]

#print "target:", target
localEnv['PDB'] = str(target) + '.pdb'
# create the target
Expand Down Expand Up @@ -1318,7 +1333,7 @@ def SharedLibrary( self, target,
return dstLibInstall

def Program( self, target,
sources=[], dirs=[], libraries=[], includes=[],
sources=[], dirs=[], libraries=[], includes=[], rc_files = [], precsrc = [], precinc = [],
env=None, localEnvFlags={}, replaceLocalEnvFlags={}, externEnvFlags={}, globalEnvFlags={},
dependencies=[], installDir=None, install=True,
headers=[], localHeaders=[],
Expand Down Expand Up @@ -1381,9 +1396,19 @@ def Program( self, target,

sourcesFiles = self.getAbsoluteCwd( sourcesFiles )

# Add rc files (windows only)
if self.windows:
for rc in rc_files:
print rc
# sourcesFiles.append( localEnv.RES( rc ) );

if precinc and self.windows:
localEnv['PCHSTOP'] = self.getRealAbsoluteCwd() + '/' + precinc
localEnv.Append( CPPFLAGS = [ '/FI' + self.getRealAbsoluteCwd() + '/' + precinc, '/Zm135' ] )
localEnv['PCH'] = localEnv.PCH( precsrc )[0]

# create the target
dst = localEnv.Program( target=target, source=sourcesFiles )

dstInstall = localEnv.Install( installDir if installDir else self.inOutputBin(), dst ) if install else dst
localEnv.Alias( target, dstInstall )
self.declareTarget(localEnv, target)
Expand Down
Loading