Commits

Matt Oswald  committed d868ef0

adding the SCons build scripts

  • Participants
  • Parent commits 6cc8a9f

Comments (0)

Files changed (12)

File .build/build.sconscript

+Import('env')
+
+if env['windows'] == True:
+    SConscript('msvc.sconscript', exports = 'env')
+
+env.Append(CCFLAGS = [ '/W4', '/WX-' ])

File .build/debug.sconscript

+Import("env")
+
+copy = env.Clone()
+copy.Append(CPPDEFINES = ['DEBUG', '_DEBUG'])
+
+Return("copy")

File .build/msvc.sconscript

+Import('env')
+
+env.Append(CCFLAGS = [ '/EHsc' ])
+
+if env['debug'] == True:
+    env.Append(CCFLAGS = [ '/MDd' ])
+else:
+    env.Append(CCFLAGS = [ '/MD' ])

File .build/output.sconscript

+Import("env")
+
+debugTag = ""
+
+debug = env['debug']
+
+if debug == True:
+    debugTag = ".Debug"
+
+outputDir = "#bin/"
+intDir = "#int/"
+
+def getTargetFile(projectName):
+    return outputDir + projectName + '/' + projectName + debugTag
+
+def getIntDir(projectName):
+    return intDir + projectName + ('/debug/' if debug != 0 else '/release/')
+
+env['getTargetFile'] = getTargetFile
+env['getIntDir'] = getIntDir

File .build/release.sconscript

+Import('env')
+
+copy = env.Clone()
+copy.Append(CPPDEFINES = ['NDEBUG'])
+
+Return("copy")
 ##########
 
 # ignore output files
-(bin/|int/|ipch/|TestResults/|/obj/|.suo$|.user$|.sdf$|_ReSharper./)
+(bin/|int/|ipch/|TestResults/|/obj/|.suo$|.user$|.sdf$|_ReSharper./|.dblite$)
+env = Environment()
+
+import platform
+import os
+
+cpus = 0
+if platform.system() == 'Windows':
+    env['windows'] = True
+    cpus = os.environ['NUMBER_OF_PROCESSORS']
+else:
+    env['windows'] = False
+    cpus = os.sysconf('SC_NPROCESSORS_ONLN')
+
+# max jobs?
+if cpus <= 0:
+    cpus = 1
+else:
+    cpus = int(float(cpus) * 1.5)
+
+parallel = int(ARGUMENTS.get('parallel', -1))
+
+if parallel == -1:
+    SetOption('num_jobs', cpus)
+elif parallel == 0:
+    SetOption('num_jobs', 1)
+else:
+    SetOption('num_jobs', parallel)
+
+# what are we building?
+debug = ARGUMENTS.get('debug', 0)
+release = ARGUMENTS.get('release', 0)
+
+# default to building just debug version
+if debug == 0 and release == 0:
+    debug = 1
+
+def buildProjects(env):
+    xUnit = SConscript('xUnit++/sconscript', exports = 'env')
+    env['xUnit'] = xUnit
+
+    console = SConscript('xUnit++.console/sconscript', exports = 'env')
+    Depends(console, xUnit)
+
+    if ARGUMENTS.get('test', 1) == 1:
+        bareTests = SConscript('Tests/BareTests/sconscript', exports = 'env')
+        unitTests = SConscript('Tests/UnitTests/sconscript', exports = 'env')
+
+        Depends(bareTests, [xUnit, console])
+        Depends(unitTests, [xUnit, console])
+
+        AddPostAction(bareTests, Action(str(console[0]) + " " + str(bareTests[0])))
+        AddPostAction(unitTests, Action(str(console[0]) + " " + str(unitTests[0])))
+
+if debug != 0:
+    env['debug'] = True
+
+    SConscript('.build/output.sconscript', exports = 'env')
+    SConscript('.build/build.sconscript', exports = 'env')
+
+    dbg = SConscript('.build/debug.sconscript', exports = 'env')
+    buildProjects(dbg)
+
+if release != 0:
+    env['debug'] = False
+
+    SConscript('.build/output.sconscript', exports = 'env')
+    SConscript('.build/build.sconscript', exports = 'env')
+
+    rel = SConscript('.build/release.sconscript', exports = 'env')
+    buildProjects(rel)

File Tests/BareTests/sconscript

+Import('env')
+
+targetFile = env['getTargetFile']('BareTests')
+intDir = env['getIntDir']('BareTests')
+
+local = env.Clone()
+local.VariantDir(intDir, './', duplicate = 0)
+local.Append(CPPPATH = ['../../xUnit++'])
+
+target = local.SharedLibrary(targetFile + '$SHLIBSUFFIX', Glob(intDir + '*.cpp'), LIBS = env['xUnit'])
+
+Return('target')

File Tests/UnitTests/sconscript

+Import('env')
+
+targetFile = env['getTargetFile']('UnitTests')
+intDir = env['getIntDir']('UnitTests')
+
+local = env.Clone()
+local.VariantDir(intDir, './', duplicate = 0)
+local.Append(CPPPATH = ['../../xUnit++'])
+
+target = local.SharedLibrary(targetFile + '$SHLIBSUFFIX', Glob(intDir + '*.cpp'), LIBS = env['xUnit'])
+
+Return('target')
 	http://www.techytalk.info/c-cplusplus-library-programming-on-linux-part-three-dynamic-libraries-using-posix-api/
 
 
+Wiki
+----
+update install/build stuff: paths have changed
+
+
 Stretch
 -----
 would be nice to have some logging support (Log::Information("msg")) (see how Check was implemented)

File xUnit++.console/sconscript

+Import('env')
+
+targetFile = env['getTargetFile']('xUnit++.console')
+intDir = env['getIntDir']('xUnit++.console')
+
+local = env.Clone()
+local.VariantDir(intDir, './', duplicate = 0)
+local.Append(CPPPATH = ['../xUnit++'])
+
+target = local.Program(targetFile + '.exe', Glob(intDir + '*.cpp'), LIBS = env['xUnit'])
+
+Return('target')

File xUnit++/sconscript

+Import('env')
+
+targetFile = env['getTargetFile']('xUnit++')
+intDir = env['getIntDir']('xUnit++')
+
+local = env.Clone()
+local.VariantDir(intDir, 'src/', duplicate = 0)
+local.Append(CPPPATH = ['xUnit++'])
+
+# bug in scons? this will fail when doing release builds
+if env['debug'] == True:
+    targetFile = targetFile + '$LIBSUFFIX'
+
+target = local.StaticLibrary(targetFile, Glob(intDir + '*.cpp'))
+
+Return('target')