diff --git a/.gitignore b/.gitignore index 5bc7188..cd81758 100644 --- a/.gitignore +++ b/.gitignore @@ -37,4 +37,5 @@ helloworld* env.txt build/ +install/ diff --git a/src/execEx/01/SConstruct b/execEx/01/SConstruct similarity index 100% rename from src/execEx/01/SConstruct rename to execEx/01/SConstruct diff --git a/src/execEx/01/main.cpp b/execEx/01/main.cpp similarity index 100% rename from src/execEx/01/main.cpp rename to execEx/01/main.cpp diff --git a/src/execEx/02/SConstruct b/execEx/02/SConstruct similarity index 100% rename from src/execEx/02/SConstruct rename to execEx/02/SConstruct diff --git a/src/execEx/02/foo.cpp b/execEx/02/foo.cpp similarity index 100% rename from src/execEx/02/foo.cpp rename to execEx/02/foo.cpp diff --git a/src/execEx/02/foo.hpp b/execEx/02/foo.hpp similarity index 100% rename from src/execEx/02/foo.hpp rename to execEx/02/foo.hpp diff --git a/src/execEx/02/main.cpp b/execEx/02/main.cpp similarity index 100% rename from src/execEx/02/main.cpp rename to execEx/02/main.cpp diff --git a/execEx/03/SConscript b/execEx/03/SConscript new file mode 100644 index 0000000..75170bd --- /dev/null +++ b/execEx/03/SConscript @@ -0,0 +1,6 @@ +Import('env') + +prog = env.Program(target='helloworld', + source=['main.cpp', 'foo.cpp']) + +env.Install(env.installDir, prog) diff --git a/execEx/03/SConstruct b/execEx/03/SConstruct new file mode 100644 index 0000000..283f310 --- /dev/null +++ b/execEx/03/SConstruct @@ -0,0 +1,87 @@ + +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++') +ccFlags = [] +linkFlags = [] +if compilerName == 'gcc': + env.Replace(CC='gcc', + CXX='g++') + ccFlags = ["-std=c++1z", "-Wall", "-Wuninitialized", "-Wunused", "-Wconversion", "-fpermissive"] + if debugArg == '0': + ccFlags += ["-O3"] + linkFlags = ["-Wl,--export-dynamic"] + else: + ccFlags += ["-g", "-O0"] + linkFlags = ["-g"] +else: + ccFlags = ["-std=c++1z", "-Wall", "-Wuninitialized", "-Wunused", "-Wconversion", "-fpermissive"] + if debugArg == '0': + ccFlags += ["-O3"] + linkFlags = ["-Wl,--export-dynamic"] + else: + ccFlags += ["-g", "-O0"] + linkFlags = ["-g"] + +env['CPPFLAGS'] = ccFlags +env['LINKFLAGS'] = linkFlags + +cppDefine = {} + +if assertArg == '0': + cppDefine['NDEBUG'] = None + +env['CPPDEFINES'] = cppDefine + +# +# Paths setup +# + +env.srcDir = Dir('#').abspath + +env.buildDir = os.path.join(env.srcDir, 'build', buildName) +env.installDir = os.path.join(env.srcDir, 'install', buildName) + +VariantDir(variant_dir=env.buildDir, + src_dir=env.srcDir, + duplicate=0) + +# +# Add build targets +# + +SConscript(os.path.join(env.buildDir, 'SConscript'), + exports={'env' : env}) diff --git a/src/execEx/03/foo.cpp b/execEx/03/foo.cpp similarity index 100% rename from src/execEx/03/foo.cpp rename to execEx/03/foo.cpp diff --git a/src/execEx/03/foo.hpp b/execEx/03/foo.hpp similarity index 100% rename from src/execEx/03/foo.hpp rename to execEx/03/foo.hpp diff --git a/src/execEx/03/main.cpp b/execEx/03/main.cpp similarity index 100% rename from src/execEx/03/main.cpp rename to execEx/03/main.cpp diff --git a/src/execEx/03/SConstruct b/src/execEx/03/SConstruct deleted file mode 100644 index 22dfa50..0000000 --- a/src/execEx/03/SConstruct +++ /dev/null @@ -1,52 +0,0 @@ - -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 = - - -# -# Add build targets -# -env.Program(target='helloworld', - source=['main.cpp', 'foo.cpp'])