Wednesday 10 September 2014

Setting up to Explore the BDE

First things first, before you want to look around the BDE it might be nice to get it onto your machine and execute some code, so lets see if we can't set you up with that environment.

The Short Story

1) git clone https://github.com/bloomberg/bde.git
2) git clone https://github.com/bloomberg/bde-tools.git 
3) Add bde-tools/bin add to path
4) Install Python 2.7 add to path
5) waf configure
6) waf build
7) waf install

The Longer Story

Not too surprisingly we are going to need to get the code first

git clone https://github.com/bloomberg/bde.git

Next we are going to want to build the code, to do this we make use of the bde-tools which is based on WAF so lets go and grab that too -- probably a good ideas to clone this too so we can keep it up to date.

git clone https://github.com/bloomberg/bde-tools.git

However, before you get carried away, WAF depends on Python 2.6.x-.2.7.x .. not 3.x, so install that if you don't already have it, and make sure you have it on your path.

BDE-Tools has bde-tools/bin/waf|waf.bat which also needs to be on your path, so add that. Right now we are good to go...

If you browse to the root of your BDE clone, you can now run waf configure which should run like this:

>waf configure
Using C:\Python27\python.exe
Setting top to                           : E:\Bloomberg\bde
Setting out to                           : E:\Bloomberg\bde\build
Checking for 'msvc' (c compiler)         : C:\Program Files\Microsoft Visual Studio 12.0\VC\BIN\CL.exe
Checking for 'msvc' (c++ compiler)       : C:\Program Files\Microsoft Visual Studio 12.0\VC\BIN\CL.exe
os_type                                  : windows
os_name                                  : windows_nt
cpu_type                                 : x86
os_ver                                   : 6.1
comp_type                                : cl
comp_ver                                 : 18.00
uplid                                    : windows-windows_nt-x86-6.1-cl-18.00
ufid                                     : dbg_exc_mt
prefix                                   : C:\users\stephenb\appdata\local\temp

Loading BDE metadata                     : ok
Evaluating options for 'bsl'             : ok
Evaluating options for 'bdl'             : ok
Saving configuration                     : ok
'configure' finished successfully (2.732s)

Note however, if you do have both a supported and unsupported python version installed on your machine, WAF may pick up the wrong version, but it will not error at this point, only later.. so take note of the version it selects in line 2 above.

So the output gives you an idea of what is going on here... WAF is interrogating your system to find the appropriate configuration. But what does it do with this information, well if you look at your root folder now you will see a new build folder, which has the "executable" it needs to do the build, along with all the appropriate flags and variables it needs in the build/c4che sub folder.

Okay so now we are bootstrapped and ready to build with waf build:

>waf build
Using C:\Python27\python.exe
Waf: Entering directory `E:\Bloomberg\bde\build'
Waf: using 2 jobs (change with -j)
[  1/312] cxx: groups\bsl\bsltf\bsltf_allocbitwisemoveabletesttype.cpp -> bugroups\bsl\bsltf\bsltf_allocbitwisemoveabletesttype.cpp.1.o
[  2/312] cxx: groups\bsl\bsltf\bsltf_alloctesttype.cpp -> build\groups\bsl\f\bsltf_alloctesttype.cpp.1.o

... lots more ...

[312/312] cxxstlib: build\groups\bsl\bslx\bslx_byteinstream.cpp.22.o build\gs\bsl\bslx\bslx_byteoutstream.cpp.22.o build\groups\bsl\bslx\bslx_instreamfuons.cpp.22.o build\groups\bsl\bslx\bslx_marshallingutil.cpp.22.o build\groupl\bslx\bslx_outstreamfunctions.cpp.22.o build\groups\bsl\bslx\bslx_testinstrxception.cpp.22.o build\groups\bsl\bslx\bslx_testinstream.cpp.22.o build\grobsl\bslx\bslx_testoutstream.cpp.22.o build\groups\bsl\bslx\bslx_typecode.cpp.o build\groups\bsl\bslx\bslx_versionfunctions.cpp.22.o -> build\groups\bsl\bbslx.lib
Waf: Leaving directory `E:\Bloomberg\bde\build'
'build' finished successfully (1m44.321s)

Now that that is all done, we see a whole bunch of folders under the build/groups for each of the different package groups -- which we will get into in a later post -- where our libs have been build to. However, we still have one more step, which will make referencing these libraries much easlier - waf install which will copy our libs and headers into an install location for easy inclusion into our projects.

>waf install
Using C:\Python27\python.exe
Waf: Entering directory `E:\Bloomberg\bde\build'- install C:\users\stephenb\appdata\local\temp\include\bsl\bsltf_allocbitwisemoveabletesttype.h (from groups\bsl\bsltf\bsltf_allocbitwisemoveabletesttype.h)
- install C:\users\stephenb\appdata\local\temp\include\bsl\bsltf_alloctesttype.h (from groups\bsl\bsltf\bsltf_alloctesttype.h)

... lots more ...

- install C:\users\stephenb\appdata\local\temp\include\bdl\bdlma_sequentialpool.h (from groups\bdl\bdlma\bdlma_sequentialpool.h)
Waf: Leaving directory `E:\Bloomberg\bde\build'
'install' finished successfully (1.080s)

If however you are not happy with the default install location you can simply go back to waf config and pass in a new install location

>waf configure --prefix c:\bloomberg\bde
>waf install

Sweet.. now we have our lib and header file in easy to reference location for experimenting with

c:\bloomberg\bde>dir /b
include
lib

c:\bloomberg\bde>dir include /b
bdl
bsl

c:\bloomberg\bde>dir lib /b
bdl.lib
bsl.lib
pkgconfig

Lastly it is probably a good idea to run the unit tests to see that everything is working as expected - although they may not all pass to do this, we run the build again.. this time telling it to build and run the tests.

>waf build --test=run
Using C:\Python27\python.exe
Waf: Entering directory `E:\Bloomberg\bde\build'
Waf: using 2 jobs (change with -j)
[  19/1164] cxx: groups\bsl\bsltf\bsltf_allocbitwisemoveabletesttype.t.cpp -> build\groups\bsl\bsltf\bsltf_allocbitwisemoveabletesttype.t.cpp.2.o
[  20/1164] cxx: groups\bsl\bsltf\bsltf_alloctesttype.t.cpp -> build\groups\bsl\bsltf\bsltf_alloctesttype.t.cpp.3.o
[  31/1164] cxx: groups\bsl\bsltf\bsltf_bitwisemoveabletesttype.t.cpp -> build\groups\bsl\bsltf\bsltf_bitwisemoveabletesttype.t.cpp.4.o
[  32/1164] cxx: groups\bsl\bsltf\bsltf_convertiblevaluewrapper.t.cpp -> build\groups\bsl\bsltf\bsltf_convertiblevaluewrapper.t.cpp.5.o
[  33/1164] cxx: groups\bsl\bsltf\bsltf_degeneratefunctor.t.cpp -> build\groups\bsl\bsltf\bsltf_degeneratefunctor.t.cpp.6.o

... lots more ..

What you may notice is that the tests are each standalone applications... which we can take advantage of in a future post :)

ps> Get-Process bs*

Handles  NPM(K)    PM(K)      WS(K) VM(M)   CPU(s)     Id ProcessName
-------  ------    -----      ----- -----   ------     -- -----------
     13       1      320       1292     9    27.18  10468 bsls_atomic.t
     12       1      280       1160     7     0.00   8380 bsls_bsllock.t

You should be good to go exploring now... Happy BDE hacking!

1 comment: