From 0393cd381b8d5f0f2616890bfffe396855528625 Mon Sep 17 00:00:00 2001 From: Bassem Girgis Date: Tue, 26 Sep 2017 23:34:25 -0500 Subject: [PATCH] Initial commit --- .gitignore | 2 ++ src/execEx/03/SConstruct | 59 ++++++++++++++++++++++++++++++++-------- 2 files changed, 50 insertions(+), 11 deletions(-) diff --git a/.gitignore b/.gitignore index e642982..5bc7188 100644 --- a/.gitignore +++ b/.gitignore @@ -36,3 +36,5 @@ helloworld* env.txt +build/ + diff --git a/src/execEx/03/SConstruct b/src/execEx/03/SConstruct index 519e781..22dfa50 100644 --- a/src/execEx/03/SConstruct +++ b/src/execEx/03/SConstruct @@ -1,15 +1,52 @@ +import os + +Help(""" + + This is the third scons example. In this example we see more things that we + can do with scons. Namely: arguments, variant build directory, and install. + + One can add the help for the expected build arguments using this help + function call + + DEBUG=1,0 - enable debug build, default 1 + ASSERT=1,0 - enable run time assertion, default 1 in DEBUG=1 and 0 otherwise + COMPILER=compilerName - compiler name + BUILDNAME=buildName - build name + +""") + +# +# Processing arguments +# +debugArg = ARGUMENTS.get('DEBUG', '1') +if debugArg not in ['0', '1']: + raise RuntimeError('Check the DEBUG input argument.') + +assertArg = '1' if debugArg == '1' else ARGUMENTS.get('ASSERT', '0') +if assertArg not in ['0', '1']: + raise RuntimeError('Check the ASSERT input argument.') + +compilerName = ARGUMENTS.get('COMPILER', '') +buildName = ARGUMENTS.get('BUILDNAME', 'default') + +# +# Initializing the environment +# +env = Environment(CC='clang', + CXX='clang') + +if compilerName == 'gcc': + env.Replace(CC='gcc') + env.Replace(CXX='g++') + +srcDir = Dir('#').abspath + +buildDir = + -env = Environment() - -open('env.txt', 'w').write(env.Dump()) - +# +# Add build targets +# env.Program(target='helloworld', source=['main.cpp', 'foo.cpp']) - -envClang = env.Clone() -envClang.Replace(CXX='clang') - -envClang.Program(target='helloworld-clang', - source=['main.cpp', 'foo.cpp']) -