Finish 3rd example

This commit is contained in:
Bassem Girgis
2017-09-27 00:55:23 -05:00
parent 82a38a0c1f
commit 799fc1a2b1
13 changed files with 94 additions and 52 deletions

73
execEx/02/SConstruct Normal file
View File

@@ -0,0 +1,73 @@
Help("""
This is the second scons example. In this example we explore more options in
scons. Once you start doing anything useful with scons other than showing
how simple scons works, you will have to create an environment to have more
control on the build.
One can "Dump()" the environment to see all the underlying details. We can
also compare between Linux and windows environments.
>> ls
foo.cpp foo.hpp main.cpp SConstruct
>> scons
scons: Reading SConscript files ...
------------------>starting
------------------>ending
scons: done reading SConscript files.
scons: Building targets ...
g++ -o foo.o -c foo.cpp
g++ -o main.o -c main.cpp
g++ -o helloworld main.o foo.o
scons: done building targets.
>> ls -a
total 68
drwxr-xr-x 2 brgirgis users 154 Sep 26 23:04 ./
drwxr-xr-x 5 brgirgis users 36 Sep 26 22:44 ../
-rw-r--r-- 1 brgirgis users 21096 Sep 26 23:04 env.txt
-rw-r--r-- 1 brgirgis users 48 Sep 26 22:42 foo.cpp
-rw-r--r-- 1 brgirgis users 109 Sep 26 22:40 foo.hpp
-rw-r--r-- 1 brgirgis users 1256 Sep 26 23:03 foo.o
-rwxr-xr-x 1 brgirgis users 13288 Sep 26 23:03 helloworld*
-rw-r--r-- 1 brgirgis users 117 Sep 26 22:41 main.cpp
-rw-r--r-- 1 brgirgis users 2872 Sep 26 23:03 main.o
-rw-r--r-- 1 brgirgis users 2441 Sep 26 23:04 .sconsign.dblite
-rw-r--r-- 1 brgirgis users 1348 Sep 26 23:04 SConstruct
>> scons --tree=all helloworld
scons: Reading SConscript files ...
------------------>starting
------------------>ending
scons: done reading SConscript files.
scons: Building targets ...
scons: `helloworld' is up to date.
+-helloworld
+-main.o
| +-main.cpp
| +-foo.hpp
| +-/usr/bin/g++
+-foo.o
| +-foo.cpp
| +-foo.hpp
| +-/usr/bin/g++
+-/usr/bin/g++
scons: done building targets.
""")
print('------------------>starting')
env = Environment()
open('env.txt', 'w').write(env.Dump())
env.Program(target='helloworld',
source=['main.cpp', 'foo.cpp'])
print('------------------>ending')

8
execEx/02/foo.cpp Normal file
View File

@@ -0,0 +1,8 @@
#include "foo.hpp"
int
foo()
{
return 32;
}

6
execEx/02/foo.hpp Normal file
View File

@@ -0,0 +1,6 @@
#ifndef SRC_EXECEX_02_FOO_HPP_
#define SRC_EXECEX_02_FOO_HPP_
int foo();
#endif // SRC_EXECEX_02_FOO_HPP_

12
execEx/02/main.cpp Normal file
View File

@@ -0,0 +1,12 @@
#include "foo.hpp"
#include <iostream>
int
main()
{
std::cout << "foo = " << foo() << std::endl;
return 0;
}