Project

General

Profile

Wiki » History » Version 1

Redmine Admin, 10/30/2015 03:55 PM

1 1 Redmine Admin
# What is Bilder?
2
3
{{>toc}}
4
5
Bilder is a cross-platform (Linux, OS X, Windows), meta-build or package management system applicable to LCFs, such the IBM Blue Gene and the Cray series of computers.  It automatically downloads packages, then configures, builds and installs them. It handles updating and building of a collection of packages and projects that have dependency relationships. When one package is updated, Bilder ensures that its dependents are updated as well. It can install in common areas, so that multiple packages can make use of the same dependency builds.
6
7
As of January 16, 2012, Bilder handles multiple builds of over 150 packages, with the multiple builds being, e.g., serial, parallel, shared, or static, as needed.  The platforms include Linux, OS X, AIX, and the specialized Linuces found on the IBM Blue Gene P and the Cray XT4.  It handles the compiler sets of gcc, XL, PathScale and PGI.
8
9
Bilder is not for replacing build systems.  Instead it works with the build systems that come with each package.  It supports packages with builds systems of autotools, CMake, qmake, Distutils, and the one-off builds systems of, e.g., lapack, ATLAS, and PETSc.  In essence, Bilder acts as a repository of build knowledge.
10
11
## Bilder Characteristics
12
13
* Build workflow automation, handling interpackage dependencies, with builds triggered when a dependency has been built.
14
* Uses soft inter-package dependencies: Suppose component A depends on B, and is updated but does not build (fails or is excluded).  Attempt to build A anyway if any other dependency is rebuilt or if A is updated, as the newer A may be consistent with an existing installation of B, or A may be able to build without B.
15
* Integration with version control systems.
16
* Integration with testing.
17
* Support for multiple OSs: Linux, OS X, Windows
18
* Support for multiple compiler sets (gcc, XL, PGI, PathScale, Visual Studio)
19
** LCFs have particular preferred compilers, e.g., for which some libraries have been built
20
** Need to compare performance of code generated by different compilers
21
** Have to use built libraries  (HDF5, Lapack) when possible for performance
22
* Ability to use different underlying package configuration/build systems.
23
* Support for different kinds of builds (e.g., parallel, serial, static, shared) for any package.
24
* Collection of build provenance information, including logging of all steps and notification using emails and dashboards.
25
* Allows disabling the builds of particular packages (e.g., so that a system version will be used).
26
* Parallel (multi-threaded or multi-process) builds of independent builds or packages.
27
* Out of place build and installation: with defaults and also user-specified locations.
28
* Defaults for all parameters on all supported platforms that can be overridden by users.
29
* Integration with the Jenkins continuous integration tool.
30
* Searching for packages within the installation area.
31
* Isolation of general logic from specific logic and data
32
** General logic in top-level Bilder files
33
** Package specific logic and data in package files (the files in the package subdirectory)
34
** Machine specific logic and data in machine files (the files in the machines subdirectory)
35
36
## What does Bilder not handle?
37
38
* Installing compilers
39
* Probably much more
40
41
# Preparing your machine for Bilder
42
43
* [[Preparing a Windows machine for Bilder]]
44
* [[Preparing a Linux machine for Bilder]]
45
* [[Preparing a Mac machine for Bilder]]
46
47
Then check out a bilder repo and build. Below are some examples.
48
49
# EXAMPLE1: Python Packages
50
51
Build ipython, scipy, tables with one command! This will build these packages and all of their dependencies, which are ipython scipy tables tornado pyzmq pyqt matplotlib hdf5 numexpr setuptools zeromq Cython qt sip numpy Python atlas clapack_cmake chrpath sqlite bzip2 lapack cmake.
52
53
~~~~~~
54
svn checkout https://svn.code.sf.net/p/bilder/code/pypkgs/trunk pypkgs
55
cd pypkgs
56
./mkpypkgs.sh
57
~~~~~~
58
59
# EXAMPLE2: VisIt Visual Analysis Package
60
61
Build the "VisIt":https://wci.llnl.gov/codes/visit/ visualization tool with one command! This will build VisIt and all its dependencies, which are visit Imaging visit_vtk qt mesa hdf5 openmpi zlib cmake bzip2.
62
63
~~~~~~
64
svn checkout https://svn.code.sf.net/p/bilder/code/visitall/trunk visitall
65
cd visitall
66
./mkvisitall.sh
67
~~~~~~
68
69
# Getting Bilder
70
71
Bilder is a set of shell scripts to configure software. All the configure scripts are available from a subversion repository. To access Bilder, enter:
72
73
~~~~~~
74
svn co http://svn.code.sf.net/p/bilder/code/trunk bilder
75
~~~~~~
76
77
# Configuring Bilder
78
79
## Required configuration information 
80
81
Before running Bilder you need to tell it where its configuration information is.  This is a directory.  The value of the environment variable, BILDER_CONFDIR, is set to it.  (E.g., BILDER_CONFDIR=/etc/bilder.)
82
83
Inside that directory, there must be at least two files.  The first, _bilderrc_, defines a variable, _PACKAGE_REPOS_FILE_, that contains the name of the file containing the repositories to be searched for tarballs for packages to be built.  E.g.,
84
85
~~~~~~
86
PACKAGE_REPOS_FILE=${PACKAGE_REPOS_FILE:-"$BILDER_CONFDIR/numpkgssvn.txt"}
87
~~~~~~
88
89
This follows the standard Bilder style, that no variable with a value is overwritten.  This allows the person executing the build instruction to override any variable value on the command line, e.g., using env.
90
91
The Package Repos File, then contains the repos to be searched for packages, with the format:
92
93
~~~~~~
94
    $ cat numpkgssvn.txt 
95
    ####
96
    #
97
    # File:    numpkgssvn.sh
98
    #
99
    # Purpose: List the package repos in the format,
100
    #          subdir,method=URL
101
    #          Where subdir is the desired location for the repo,
102
    #          method = svn to get by svn, empty to get with wget
103
    #          URL is the resource locator
104
    #
105
    # Version: $Id: numpkgssvn.txt 54 2012-04-08 13:52:09Z cary $
106
    #
107
    ####
108
    PACKAGE_REPO: numpkgs,svn=https://ice.txcorp.com/svnrepos/code/numpkgs/trunk
109
~~~~~~
110
111
Each line starting with _PACKAGE_REPO:_ defines the subdir (in this case numpkgs) into which the packages are put, the method (in this case svn) for getting the packages, and after the equals sign, the URL for the directory containing all packages.
112
113
For the method (part between the command and the equals sign) of svn, this means that the svn repo will be checked out as empty, 
114
115
~~~~~~
116
svn co --depth=empty https://ice.txcorp.com/svnrepos/code/numpkgs/trunk numpkgs
117
~~~~~~
118
119
and packages will be obtained by
120
121
~~~~~~
122
svn up pkgname
123
~~~~~~
124
125
in the numpkgs subdirectory.
126
127
## Optional logic in bilderrc 
128
129
It can happen that "hostname -f" does not give the fully qualified hostname for your machine.  In this case, you can define __FQHOSTNAME__ to contain that hostname.
130
131
You can also find the following three methods:
132
133
* _bilderGetAuxData_ defines how to get any auxiliary data needed by a package
134
* _bilderFinalAction_ defines a final action (like posting to a dashboard) to be undertaken at the end of a build run
135
* _signInstaller_ to sign any installers that you create during your build
136
137
## Optional additional logic 
138
139
You can provide specific logic in domainname files that also define default installation directories and such in files named with the domain name.  Examples are seen in bilder/runnr.  E.g., 
140
141
~~~~~~
142
    $ cat nersc.gov 
143
    ##############################################################
144
    ##
145
    ## File:    nersc.gov
146
    ##
147
    ## Purpose: Helper functions for setting variables and queues by domain
148
    ##
149
    ## Version: $Id: nersc.gov 5644 2012-04-02 13:35:02Z cary $
150
    ##
151
    ## /* vim: set filetype=sh : */
152
    ##
153
    ##############################################################
154
    #
155
    # Adjust the auxiliary names:
156
    #   MAILSRVR, INSTALLER_HOST, INSTALLER_ROOTDIR, FQMAILHOST, BLDRHOSTID
157
    #
158
    runnrSetNamesByDomain() {
159
    # Hosts for which FQMAILHOST is not obvious.  Also ensure that an
160
    # install host name is set for all cases.
161
      case $UQHOSTNAME in
162
        cvrsvc[0-9]*)
163
          FQMAILHOST=carver.nersc.gov
164
          ;;
165
        dirac[0-9]*)
166
          FQMAILHOST=dirac.nersc.gov
167
          ;;
168
        freedom[0-9]*)
169
          FQMAILHOST=freedom.nersc.gov
170
          RUNNRSYSTEM=XT4
171
          ;;
172
        hopper[01][0-9]*)
173
          FQMAILHOST=hopper.nersc.gov
174
          RUNNRSYSTEM=XE6
175
          ;;
176
        nid[0-9]*)
177
          FQMAILHOST=franklin.nersc.gov
178
          RUNNRSYSTEM=XT4
179
          ;;
180
      esac
181
    }
182
    runnrSetNamesByDomain
183
    cat >/dev/null <<EOF  ## (Block comment)
184
    MODULES AT NERSC
185
~~~~~~
186
187
This is an incomplete list of modules that have to be loaded on the machines that use modules.
188
189
~~~~~~
190
FRANKLIN:
191
Currently Loaded Modulefiles:
192
    1) modules/3.1.6.5
193
    2) moab/5.2.5
194
    3) torque/2.4.1b1-snap.200905131530
195
    4) xtpe-barcelona
196
    5) xtpe-target-cnl
197
    6) MySQL/5.0.45
198
    7) xt-service/2.1.50HDB_PS13A
199
    8) xt-libc/2.1.50HDB_PS13A
200
    9) xt-os/2.1.50HDB_PS13A
201
   10) xt-boot/2.1.50HDB_PS13A
202
   11) xt-lustre-ss/2.1.50HDB_PS13A_1.6.5
203
   12) Base-opts/2.1.50HDB_PS13A
204
   13) PrgEnv-gnu/2.1.50HDB_PS13A
205
   14) xt-asyncpe/3.3
206
   15) xt-pe/2.1.50HDB_PS13A
207
   16) xt-mpt/3.5.0
208
   17) xt-libsci/10.4.0
209
   18) gcc/4.4.1
210
   19) java/jdk1.6.0_07
211
   20) python/2.6.2
212
   21) subversion/1.6.4
213
   22) szip/2.1
214
~~~~~~
215
216
~~~~~~
217
HOPPER:
218
Currently Loaded Modulefiles:
219
    1) modules/3.1.6             9) xt-asyncpe/3.4
220
    2) torque/2.4.1b1           10) PrgEnv-pgi/2.2.41
221
    3) moab/5.3.4               11) xtpe-target-cnl
222
    4) pgi/9.0.4                12) eswrap/1.0.5
223
    5) xt-libsci/10.4.0         13) xtpe-shanghai
224
    6) xt-mpt/3.5.0             14) gcc/4.3.3
225
    7) xt-pe/2.2.41             15) java/jdk1.6.0_15
226
    8) xt-sysroot/2.2.20090720  16) szip/2.1
227
~~~~~~
228
229
~~~~~~
230
CARVER:
231
bilder needs to find either a pgi or a gcc module in your modules list.
232
EOF
233
~~~~~~
234
235
~~~~~~
236
    #
237
    # Determine RUNNR_QTARGET, RUNNR_QUEUE, RUNNR_ACCOUNT, RUNNR_PPN
238
    #
239
    runnrSetQInfoByDomain() {
240
      RUNNR_QTARGET=${RUNNR_QTARGET:-"headnode"}
241
      local fqdn
242
      if ! fqdn=`hostname -f 2>/dev/null`; then
243
        fqdn=`hostname`
244
      fi
245
      case $SCRIPT_NAME in
246
        mkfcall | mkfcpkgs)
247
          RUNNR_ACCOUNT=${RUNNR_ACCOUNT:-"m681"}    # FACETS
248
          ;;
249
        mkvpall)
250
          RUNNR_ACCOUNT=${RUNNR_ACCOUNT:-"m778"}    # ComPASS
251
          ;;
252
        *)
253
          RUNNR_ACCOUNT=${RUNNR_ACCOUNT:-"m778"}    # ComPASS
254
          ;;
255
      esac
256
      RUNNR_QUEUE=${RUNNR_QUEUE:-"regular"}
257
      RUNNR_NCPUSVAR=mppwidth
258
    }
259
    runnrSetQInfoByDomain
260
~~~~~~
261
262
~~~~~~
263
    #
264
    # Set default options.  This has to be called after option parsing.
265
    # Should set
266
    #  CONTRIB_ROOTDIR    The root directory for common installations of tarballs
267
    #  INSTALL_ROOTDIR    The root directory for common installations of repos
268
    #  USERINST_ROOTDIR   The root directory for user installations (same for
269
    #                     tarballs and repos)
270
    #  INSTALL_SUBDIR_SFX Added to subdir (software, contrib, volatile, internal)
271
    #                     to complete the installation dir
272
    #  BUILD_ROOTDIR      Where builds are to take place
273
    #  BILDER_ADDL_ARGS   Any additional args to pass to Bilder
274
    #  MACHINEFILE        The machine file to use
275
    #
276
    setBilderHostVars() {
277
      #
278
      # Preliminary variables
279
      #   Determine the compiler and version for machinefile and namespacing
280
      #
281
      local compkey=`modulecmd bash list -t 2>&1 | grep PrgEnv | sed -e 's/^PrgEnv-//' -e 's?/.*??'`
282
      # echo compkey = $compkey
283
      if test -z "$compkey"; then
284
        local comp=
285
        for comp in pgi gcc gnu; do
286
          compkey=`module list -t 2>&1 | grep ^$comp | sed -e 's?/.*$??'`
287
          if test -n "$compkey"; then
288
            break
289
          fi
290
        done
291
      fi
292
      if test -z "$compkey"; then
293
        echo "Cannot determine the compkey.  Quitting."
294
        exit 1
295
      fi
296
      # echo "compkey = $compkey."
297
      case $compkey in
298
        gnu)   compkey=gcc;;
299
        path*) compkey=path;;
300
      esac
301
      echo compkey = $compkey
302
      local compver=`modulecmd bash list -t 2>&1 | grep ^$compkey | sed -e 's?^.*/??'`
303
      local majorminor=`echo $compver | sed -e "s/\(^[^\.]*\.[^\.]*\).*/\1/"`
304
      compver=$majorminor
305
      echo compver = $compver
306
      # echo "Quitting in nersc.gov."; exit
307
~~~~~~
308
309
~~~~~~
310
      # Set the installation and project subdirs
311
      CONTRIB_ROOTDIR=/project/projectdirs/facets
312
      if test -z "$PROJECT_INSTSUBDIR"; then
313
        echo "PROJECT_INSTSUBDIR not set.  Quitting."
314
        exit 1
315
      fi
316
      INSTALL_ROOTDIR=/project/projectdirs/$PROJECT_INSTSUBDIR
317
      local machinedir=$UQMAILHOST
318
      if test $UQMAILHOST = freedom; then
319
        machinedir=franklin
320
      fi
321
      CONTRIB_ROOTDIR=$CONTRIB_ROOTDIR/$machinedir
322
      USERINST_ROOTDIR=$INSTALL_ROOTDIR/$USER/$machinedir
323
      INSTALL_ROOTDIR=$INSTALL_ROOTDIR/$machinedir
324
      INSTALL_SUBDIR_SFX="-$compkey-$compver"
325
~~~~~~
326
327
~~~~~~
328
      # Set the build directory
329
      if test -n "$GSCRATCH"; then
330
        BUILD_ROOTDIR=${BUILD_ROOTDIR:-"$GSCRATCH/builds-${UQHOSTNAME}-$compkey"}
331
      elif test -n "$SCRATCH"; then
332
        BUILD_ROOTDIR=${BUILD_ROOTDIR:-"$SCRATCH/builds-${UQHOSTNAME}-$compkey"}
333
      fi
334
~~~~~~
335
336
~~~~~~
337
      # Add to BILDER_ARGS
338
      BILDER_ADDL_ARGS=-P
339
~~~~~~
340
341
~~~~~~
342
      # Set machine file
343
      case $machinedir in
344
        hopper | franklin) MACHINEFILE=${MACHINEFILE:-"cray.$compkey"};;
345
        *) MACHINEFILE=${MACHINEFILE:-"nersclinux.$compkey"};;
346
      esac
347
    }
348
~~~~~~
349
350
This file may also, as seen above, define the method, setBilderHostVars, which also can set the various variables defining where builds should take place, where installations should go, etc.
351
352
353
# Running Bilder
354
355
## Running Bilder for the Novice User 
356
357
First you will need to check out a ''meta-project'' svn repo that includes the source that you want to build along with the bilder scripts repo.
358
359
For example, Tech-X maintains the _visitall_ repo, which can be obtained by:
360
361
~~~~~~
362
svn co https://ice.txcorp.com/svnrepos/code/visitall/trunk visitall
363
~~~~~~
364
365
366
In the bilder'ized project, if there is a script usually named "mk<project>all-default.sh" where <project> is the project name that may be abbreviated (e.g. for visitall the script is mkvisitall.sh), then this is the easiest way to run bilder. The options of a top level "default" Bilder script can be seen by running the script with the -h flag:
367
368
~~~~~~
369
    $ ./mkvisitall-default.sh -h
370
    source /Users/cary/projects/visitall/bilder/runnr/runnrfcns.sh
371
    Usage: ./mkvisitall-default.sh [options]
372
    This script is meant to handle some of the vagaries that occur at LCFs and
373
    clusters in large systems (which have complicated file systems) such as those 
374
    that have high performance scratch systems and NFS mounted home systems. This 
375
    script is also meant to ease the use of non-gfortran compilers.
376
    OPTIONS
377
    -c              common installations: for non-LCFS, goes into /contrib,
378
                    /volatile or /internal, for LCFSs, goes into group areas
379
    -C              Install in separate tarball and repo install dirs
380
                    (internal/volatile) rather than in one area (software).
381
    -E <env pairs>  Comma-delimited list of environment var=value pair
382
    -f <file>       File that contains extra arguments to pass
383
                    Default: .extra_args
384
    -F <compiler>   Specify fortran compiler on non-LCF systems
385
    -g              Label the gnu builds the same way other builds occur.
386
    -H <host name>  use rules for this hostname (carver, surveyor, intrepid)
387
    -h              print this message
388
    -i              Software directory is labeled with "internal" if '$USER'
389
                    is member of internal install list
390
    -I              Install in $HOME instead of default location
391
                    (projects directory at LCFs, BUILD_ROOTDIR on non-LCFs)
392
    -j              Maximum allowed value of the arg of make -j
393
    -k              On non-LCFs: Try to find a tarball directory (/contrib)
394
                    On LCFs:     Install tarballs (instead of using facetspkgs)
395
    -m              force this machine file
396
    -n              invoke with a nohup and a redirect output
397
    -p              just print the command
398
    -q <timelimit>  run in queue if possible, with limit of timelimit time
399
    -t              Pass the -t flag to the  mk script (turn on testing)
400
    -v <file>       A file containing a list (without commas) of declared
401
                    environment variables to be passed to mk*.sh script
402
    -w <file>       Specify the name of a file which has a comma-delimited
403
                    list of packages not to build (e.g.,
404
                    plasma_state,nubeam,uedge) Default: .nobuild
405
    --              End processing of args for mkall-default.sh, all remaining
406
                    args are passed to the script.
407
~~~~~~
408
409
410
For this script to work, you must have defined the location of your Bilder configuration directory in the environment variable, BILDER_CONFDIR.  This will be discussed more in [ConfiguringBilder].
411
412
413
## Running Bilder for the Advanced User ... 
414
415
In the bilder'ized project, there will be a script named "mk<project>all.sh" where <project> is the project name that may be abbreviated (e.g. for nautilus the script is mkvisitall.sh). The options of a top level Bilder script can be seen by running the script with the -h flag:
416
417
~~~~~~
418
    $ ./mkvisitall.sh -h
419
    /Users/cary/projects/visitall/bilder/runnr/runnrfcns.sh sourced.
420
    Usage: ./mkvisitall.sh [options]
421
    GENERAL OPTIONS
422
      -A <addl_sp>        Add this to the supra search path
423
      -b <build_dir>      Build in <build_dir>
424
      -B <build_type>     CMake build type
425
      -c ............... Configure packages but don't build
426
      -C ............... Create installers
427
      -d ............... Create debug builds (limited package support)
428
      -D ............... Build/install docs
429
      -e <addr>          Email log to specified recipients
430
      -E <env pairs>.... Comma-delimited list of environment var=value pair
431
      -F ............... Force installation of packages that have local
432
                         modifications
433
      -g ............... Allow use of gfortran with version <4.3
434
      -h ............... Print this message
435
      -i <install_dir>   Set comma delimited list of installation directories
436
                         for code in subdirs, expected to be svn repos; install
437
                         in first directory unless command line contains -2,
438
                         in which case install in the last directory.
439
                         <install_dir> defaults to $HOME/software if not set.
440
      -I ............... Install even if tests fail (ignore test results)
441
      -j <n>             Pass arg to make with -j
442
      -k <tarball_dir>   Set installation directory for code in tarballs,
443
                         expected to be found in one of the pkg repo subdirs;
444
                         <tarball_dir> defaults to <install_dir> if not set.
445
      -l <mpi launcher>  The executable that launches an MPI job
446
      -L ............... Directory for logs (if different from build)
447
      -m <hostfile>      File to source for machine specific defs
448
      -M ............... Maximally thread
449
      -o ............... Install openmpi if not on cygwin.
450
      -O ............... Install optional packages = ATLAS, parallel visit, ...
451
      -p <path>          Specify a supra-search-path
452
      -P ............... Force build of python(does not apply to OS X or Windows)
453
      -r ............... Remove other installations of a package upon successful
454
                         installation of that package
455
      -R ............... Build RELEASE (i.e., licensed) version of executable,
456
                         if applicable.
457
      -S ............... Build static
458
      -t ............... Run tests
459
      -u ............... Do "svn up" at start
460
      -U ............... Do not get (direct access or svn up) tarballs
461
      -v ............... Verbose: print debug information from bilder
462
      -w <wait days>      Wait this many days before doing a new installation
463
      -W <disable builds> Build without these packages (comma delimited list)
464
                          e.g., -W nubeam,plasma_state
465
      -X ............... Build experimental (new) versions of packages
466
      -Z ............... Do not execute the final action
467
      -2 ............... Use the second installation directory of the comma
468
                         delimited list.  Causes -FI options.
469
~~~~~~
470
471
472
## Notes on Installation Directories and Path Modifications 
473
474
Bilder builds all software, when possible, in ''the build directory'' or  <builddir>, which is specified by the _-b_ flag.  It also unpacks tarballs into this directory before building them.
475
476
Bilder defines two installation directories, which may be the same.
477
478
Tarballs are installed in ''the tarball directory'' or <tarballdir>, which is specified by the _-k_ flag. This is the _/contrib_ directory at Tech-X.
479
480
Code from repositories is installed in ''the repo directory'' or <repodir>, the directory that is specified by the _-i_ flag.  At Tech-X, this is typically _/volatile_ or _/internal_.
481
482
If only one of the above directories is specified, then the other directory defaults to the specified directory.  If neither directory is specified, then both directories default to _$HOME/software_.
483
484
During the build process, _/contrib/autotools/bin:/contrib/valgrind/bin:/contrib/mpi/bin:/contrib/hdf5/bin:/contrib/bin:_ is added to the front of the path so that the installed packages are use to build the packages.
485
486
487
## Debugging Bilder Errors 
488
489
Bilder is a set of bash scripts. The [https://ice.txcorp.com/svnrepos/code/bilder/trunk/ trunk version of the scripts] will tell you exactly what bilder is doing if you know bash programming.
490
491
492
# Bilder's Build Types
493
494
The standard builds of Bilder are
495
496
* ser: static, serial build
497
* par: static, parallel (MPI) build
498
* sersh: shared, serial build
499
* parsh: shared, parallel (MPI) build
500
* cc4py: shared build compatible with the way Python was built
501
502
The Bilder standard is to install each build in its own directory.  While libtool allows shared and static builds to be done within the same build, cmake generally does not as discussed at [http://www.cmake.org/Wiki/CMake_FAQ#Library_questions].  Further, to do this on Windows, library names have to differ, as otherwise the static library and the shared interface library files would overwrite each other.  So in the end, is it simply easier to install shared and static libraries in their own directories.
503
504
In all cases, the builds are to be "as complete as possible".  E.g., for HDF5 on Darwin, shared libraries are not supported with fortran.  So in this case, sersh has to disable the fortran libraries.  However, completeness may depend on other criteria.  So, e.g., for trilinos, complete builds are provided, but so are builds that are as complete as possible and compatible with licenses that allow free reuse in commercial products.
505
506
## Static builds 
507
508
The static builds provide the most portable builds, as they eliminate or minimize the need to be compatible with any system shared libraries.  The are also the most widely supported.  For Windows, these mean libraries that import the static runtime library (libcmt).  Generally this means that, for Windows, one should not use a static dependency for a shared build of a project, as doing so typically leads to the dreaded runtime conflict, e.g., http://stackoverflow.com/questions/2360084/runtime-library-mis-matches-and-vc-oh-the-misery.
509
510
## Shared builds 
511
512
Shared builds allow one to reuse libraries among executables, but then one has the difficulty of finding those libraries at runtime.  This can be particularly difficult when moving an installation from one machine to another or when installing a package.  To minimize these headaches, Bilder, as much as possible, uses rpath on Linux.  However, packages need to figure out how to modify any executables or libraries post-build to make an installer.
513
514
## Cc4py builds 
515
516
This is a special build that is just a shared build using the compiler that Python was compiled with.  This is generally gcc for Unices and Visual Studio for Windows.  One adds a cc4py build only when the serial compiler is not the compiler used to build Python.
517
518
# Bilder Hierarchy
519
520
It is possible to specialize Bilder: per machine, per poject and per person. by sourcing file(s) at each level of hierarchy:
521
522
## Bilder default settings 
523
524
When no specialization files are used, Bilder uses the default settings for the project.
525
526
## By Machine 
527
528
Set of machine files under bilder/machines directory to specify machine specific variables and settings. For example, to build a project on Windows platform with cygwin using Visual Studio 9, we have cygwin.vs9 machine file which sets up the environment as needed by Visual Studio 9. The machine files can be specified by "-m" option.
529
530
## By Project 
531
532
Please see [wiki:ConfiguringBilder Configuring Bilder] on how to set up per project configurations. Here, information needed for the project such as where to obtain third party dependency libraries, default installation directories, set the various variables defining where builds should take place, where installations should go, etc. can be specified.
533
534
## By Person 
535
536
### Default settings using .bilddefrc 
537
538
Every person building a project using Bilder can specify his/her own default settings by creating a .bilddefrc file in their home directory. This will be sourced in the mkXYZall-default.sh file to override any other default project settings. 
539
540
### Settings using .bilderrc 
541
542
Every person building a project using Bilder can specify his/her own settings by creating a .bilderrc file in their home directory. This will be sourced in the mkXYZall.sh file to override any other project settings. 
543
544
## Per package per person 
545
546
In cases where it is necessary to specify settings per package per person, a XYZ.conf file can be specified in the BILDER_CONFDIR/packages directory. If found, this file will be sourced in the mkXYZ.sh script to override all the other settings. If this file is modified, then Bilder will reconfigure and build the package.
547
548
# Running Bilder Through The Defaults Scripts
549
550
The full set of options for Bilder are many, and this gives rise to the potential for mistakes. To facilitate this, we have created the defaultsfcns.sh and mkall-defaults.sh, and then then associated defaults scripts include the latter and execute runBilderCmd:
551
552
~~~~~~
553
    $ cat mkfcall-default.sh 
554
    #!/bin/bash
555
    #
556
    # Determine (and possibly execute) the default Bilder command
557
    # for Facetsall.
558
    #
559
    # $Id: mkfcall-default.sh 593 2012-03-09 15:26:46Z cary $
560
    #
561
    h2.#########################################################
562
    # 
563
    # Set the default variables
564
    mydir=`dirname $0`
565
    mydir=${mydir:-"."}
566
    mydir=`(cd $mydir; pwd -P)`
567
    # Where to find configuration info
568
    BILDER_CONFDIR=$mydir/bilderconf
569
    # Subdir under INSTALL_ROOTDIR where this package is installed
570
    PROJECT_INSTSUBDIR=facets
571
    source $mydir/bilder/mkall-default.sh
572
573
    # Build the package
574
    runBilderCmd
575
    res=$?
576
    exit $res
577
~~~~~~
578
579
The options,
580
581
~~~~~~
582
    $ ./mkfcall-default.sh -h
583
    source /Users/cary/projects/facetsall/bilder/runnr/runnrfcns.sh
584
    WARNING: runnrGetHostVars unable to determine the domain name.
585
    Usage: ./mkfcall-default.sh [options]
586
    This script is meant to handle some of the vagaries that occur
587
    at LCFs and clusters in large systems (which have complicated file
588
    systems) such as those that have high performance scratch systems
589
    and NFS mounted home systems.  This script is also meant to ease
590
    the use of non-gfortran compilers.
591
    OPTIONS
592
      -c              common installations: for non-LCFS, goes into /contrib,
593
                      /volatile or /internal, for LCFSs, goes into group areas
594
      -C              Install in separate tarball and repo install dirs 
595
                      (internal/volatile) rather than software
596
      -E "<options>"  quoted list of extra options to pass to the mk script
597
      -f <file>       File that contains extra arguments to pass
598
                      Default: .extra_args
599
      -F <compiler>   Specify fortran compiler on non-LCF systems
600
      -g              Label the gnu builds the same way other builds occur.
601
      -H <host name>  use rules for this hostname (carver, surveyor, intrepid)
602
      -h              print this message
603
      -i              Software directory is labeled with "internal" if '$USER'
604
                      is member of internal install list
605
      -I              Install in $HOME instead of default location
606
                      (projects directory at LCFs, BUILD_ROOTDIR on non-LCFs)
607
      -j              Maximum allowed value of the arg of make -j
608
      -k              On non-LCFs: Try to find a tarball directory (/contrib)
609
                      On LCFs:     Install tarballs (instead of using facetspkgs)
610
      -m              force this machine file
611
      -n              invoke with a nohup and a redirect output
612
      -p              just print the command
613
      -q <timelimit>  run in queue if possible, with limit of timelimit time
614
      -t              Pass the -t flag to the  mk script (turn on testing)
615
      -v <file>       A file containing a list (without commas) of declared
616
                      environment variables to be passed to mk*.sh script
617
      -w <file>       Specify the name of a file which has a comma-delimited
618
                      list of packages not to build (e.g.,
619
                      plasma_state,nubeam,uedge) Default: .nobuild
620
      --              End processing of args for mkall-default.sh, all remaining
621
                      args are passed to the script.
622
~~~~~~
623
624
625
mostly deal with which directory is to be used for installation, what is the time limit for the build, any extra options to be passed to the build, whether on the command line or in a file.
626
627
An example invocation look like
628
629
~~~~~~
630
mkfcall-default.sh -cin -- -oXZ -E BUILD_ATLAS=true
631
~~~~~~
632
633
which will (c) install in areas common to all users, (i) using the internal rather than the volatile directory for repo installations, (n) in background via nohup, -- what follows are more args for the base script, which are (o) build openmpi if on OS X or Linux, (X) build the newer, experimental packages, (Z) do not invoke the user defined bilderFinalAction method, (E) set this comma delimited list of environment variables, in this case to build Atlas if on Linux or Windows.
634
635
# Using Jenkins with Bilder
636
637
### Setting up Jenkins for use with Bilder ###
638
639
This set of pages is intended to describe how to set up the Jenkins continuous integration tools for launching Bilder jobs (which then handle the builds and testing). It is not intended to describe the most general way to set up Jenkins, but instead it describes a way that relies on having a Linux master node.
640
641
642
## Starting up a Linux Jenkins master node 
643
644
Install Jenkins using the installation mechanism for your platform.  E.g., see
645
https://wiki.jenkins-ci.org/display/JENKINS/Installing+Jenkins+on+RedHat+distributions.
646
647
*IMPORTANT:* Before starting Jenkins for the first time:
648
* create the directory where Jenkins will do its builds (known as _JENKINS_HOME_, not to be confused with the Jenkins home directory in /etc/passwd, which is initially set to /var/lib/jenkins, which we will assume here)
649
* set the permissions of the Jenkins build directory (e.g., /home/bilder/jenkins)
650
* Add jenkins to any groups as needed (e.g., contrib, research, xxusers)
651
* modify {{{/etc/sysconfig/jenkins}}} as needed.  Our settings are
652
653
654
~~~~~~
655
    JENKINS_HOME="/home/bilder/jenkins"
656
    JENKINS_PORT="8300"
657
    JENKINS_AJP_PORT="8309"
658
    JENKINS_ARGS="--argumentsRealm.passwd.jenkins=somepassword --argumentsRealm.roles.jenkins=admin"
659
~~~~~~
660
661
(_somepassword_ is not literal.)
662
663
Create an ssh key for jenkins:
664
665
666
~~~~~~
667
    sudo -u jenkins ssh-keygen
668
~~~~~~
669
670
671
It cannot have a passphrase.
672
673
674
Start the jenkins service:
675
676
677
~~~~~~
678
    sudo service jenkins start
679
~~~~~~
680
681
682
683
Set Jenkins to start on boot:
684
685
~~~~~~
686
    sudo chkconfig --level 35 jenkins on
687
~~~~~~
688
689
690
691
## Preparing a Unix Jenkins slave node 
692
693
We will have one node prepared to act as a Jenkins slave for now.  For ease, we will create a Unix slave.  Later we will add more slaves.
694
695
* On the service node, create the user who will run Jenkins.
696
* As that user create the directory where Jenkins will work
697
* Add that user to any groups needed to give it appropriate permissions (e.g., contrib, research, xxusers)
698
* For public-key authentication
699
** Add the public key created above for jenkins to that user's ~/.ssh/authorized_keys
700
** On the master, check that you can do passwordless login by trying: "_sudo -u jenkins ssh jenkins@yourhost_"
701
* For password authentication
702
** Configure /etc/sshd_config to allow password authentication (PasswordAuthentication yes) and restart sshd
703
704
## Configuring the Linux Jenkins master node 
705
706
* Open a browser and go to _master.yourdomain:8300_ and log in as admin with the password that you set in the JENKINS_ARGS variable, above.
707
* Go to Manage Jenkins -> Manage Plugins -> Available and install the plugins,
708
** Jenkins cross-platform shell (XShell)
709
** Conditional Build-Step
710
** Matrix Tie Parent
711
** Jenkins build timeout (Build-timeout)
712
* Go to Manage Jenkins -> Manage Users and then use _Create User_ to create the users for your Jenkins installation. Make sure to create an administrative user perhaps yourself).
713
* Go to Manage Jenkins -> Configure system and select/set
714
** Enable security
715
** Jenkins's own user database
716
** _If you wish_, allow users to sign up
717
** Project-based Matrix Authorization Strategy
718
*** Add an administrator name with all privileges
719
*** Give anonymous user Overall Read (only)
720
** Default user e-mail suffix: e.g., @yourdomain
721
** Sender: jenkins@yourdomain
722
* Go to Manage Jenkins -> Manage Nodes -> New Node
723
** Fill in name
724
** Dumb Slave
725
** You are taken to the configure form:
726
*** \# of executors = 1
727
*** Remote FS root: what you decided upon when creating the slave
728
*** Usage: Leave this machine for tied jobs onlye
729
*** Launch methog: Launch slave gents on Unix machines via SSH
730
*** Advanced:
731
**** Host
732
**** Username (jenkins)
733
734
## Creating your first Bilder-Jenkins project 
735
736
We will create the first project to build on the master node. Later we will add more nodes.
737
738
* Go to Jenkins -> New Job
739
    * Build multi-configuration project
740
* Set name (here we will do visitall as our example)
741
* Enable project-based security
742
    * For open source builds, give Anonymous Job Read and Job Workspace permission
743
    * Add user/group as needed
744
* Source Code Management
745
    * Subversion
746
    * Put in your URL, e.g., https://ice.txcorp.com/svnrepos/code/visitall/trunk
747
    * Put in your svn credentials as requested
748
* Build Triggers (examples)
749
    * Build Periodically
750
        * Enter cron parameters, e.g., 0 20 * * *
751
    * Or have this build launched as a post-build step of another build
752
* Configuration Matrix
753
    * Add axis -> slaves (is this available before we add nodes?)
754
        * Add master and the above unix slave
755
* Build Environment
756
    * Abort the build if stuck (if desired)
757
        * Enter your timeout
758
    * Tie parent build to a node
759
        * Select master node
760
* Build
761
    * Add build step -> Invoke XShell command
762
        * Command line: bilder/bildtrol/unibild -d mkvisitall
763
        * Executable is in workspace dir
764
* Post-build Actions
765
    * Aggregate downstream test results
766
        * Select both
767
    * Archive the artifacts (select, see below for settings)
768
    * E-mail Notification
769
        * Set as desired
770
771
772
## Creating a Windows Slave 
773
774
* Get all tools in place on the slave machine by following the instructions at https://ice.txcorp.com/trac/bilder/wiki/BilderOnWindows
775
* Create the jenkins user account (if not already defined) as an Administrative account and log into the windows machine as the jenkins user
776
* Make sure the slave's Windows name and its domain name are consistent.
777
* Install Java (see http://www.java.com) and update the path to include `C:\Windows\SYSWOW64` if on 64 bit Windows and then `C:\Program Files (x86)\Java\jre6\bin`
778
* Create the build directory (e.g., C:\winsame\jenkins)
779
* Set the owner to that directory to the jenkins user via properties->security->advanced->owner.
780
* Install the Visual C++ redistributables from http://www.microsoft.com/download/en/details.aspx?id=5582
781
* Follow the networking, registry, and security related instructions at https://wiki.jenkins-ci.org/display/JENKINS/Windows+slaves+fail+to+start+via+DCOM
782
* (Cribbing from https://issues.jenkins-ci.org/browse/JENKINS-12820)
783
* Start a web browser on the windows slave and connect to the master jenkins web page.
784
* Manage Jenkins -> Manage Nodes -> New Node
785
* Create a new node (Slave node)
786
  * Fill in name, choose it to be the same as the Windows name of the slave
787
  * Dumb Slave
788
  * In the configure form, set
789
    * \# of executors: 1
790
    * Remote FS root: the directory created above (e.g., C:\winsame\jenkins)
791
    * Usage: Leave this machine for tied jobs only
792
    * Launch method: Launch slave agents via java web start
793
* Launch the slave
794
* Press the newly appeared button: Launch by webstart  
795
* A pop up window will be visible with a message as "Connected"
796
* In that pop up window click File-> Install as Windows Service
797
* Find jenkins service in the control panel, ensure that the owner is the jenkins user
798
* UNCHECKED: Set startup to Automatic
799
* Return to browser, take slave node off line in jenkins
800
* Set launch method to: Windows slave as a Windows Service
801
  * Advanced:
802
    * Administrative username (jenkins) ''You may need to type it as computername\jenkins if you get an invalid service account error''
803
    * Password (set as selected in slave setup)
804
    * Use Administrator account given above
805
* Relaunch slave node
806
807
### Use the Slave on the Master 
808
809
You should now be able to select this slave as a build node.
810
811
812
## Launching Bilder through Jenkins 
813
814
Jenkins runs Bilder through the scripts in the bildtrol subdir using the XShell command. The XShell command, when configured to launch _somescript_, actually invokes _somescript.bat_ on Windows and _somescript_ on unix.  The Bilder _.bat_ scripts simply translate the arguments and use them in a call to _somescript_, which is run through Cygwin.
815
816
### Building and testing: jenkinsbild 
817
818
The script, _jenkinsbild_, launches a build from Jenkins using the default scripts.  For this example, we consider building the visualization package _VisIT_, for which the repo is _https://ice.txcorp.com/svnrepos/code/visitall/trunk_.  This repo uses externals to bring in the VisIT source code.  In this
819
case, the simplest XShell command is
820
821
~~~~~~
822
    bilder/jenkins/jenkinsbild mkvisitall
823
~~~~~~
824
825
which leads to execution of
826
827
~~~~~~
828
    ./mkvisitall-default.sh -t -Ci -b builds-internal  -- -Z -w 7
829
~~~~~~
830
831
which action is described in the rest of the Bilder documentation, but in particular, testing is invoked (-t), packages and repos are installed in separate areas (-C), use the ''internal'' directory for repo installation, do not do any post build action (-Z), and if a build less than 7 days old is found, do not execute the build (-w 7). The arguments after *--* are passed directly to the underlying Bilder script, mkvisitall.sh.
832
833
The _jenkinsbild_ script has very few options:
834
835
836
~~~~~~
837
    Usage: $0 [options]
838
    GENERAL OPTIONS
839
      -b ................ Use internal/volatile build directory naming
840
      -m ................ Use mingw on cygwin
841
      -n ................ Do not add tests
842
      -p ................ Print the command only.
843
      -s step ..........  Sets which build step: 1 = internal, 2 = volatile.
844
      -2 ................ Sets build step to 2.
845
~~~~~~
846
847
At present, the internal/volatile build directory naming is in fact always true.  In this case, the first step (the default) builds in the subdir, *builds-internal*, and the second step (selected with -2 or -s 2) builds in the subdir, *builds-volatile*. Correspondingly, the repo installation directory is the *internal* directory on step 1 and the *volatile* directory on step 2.
848
849
Using mingw on cygwin (-m) is useful for codes that cannot build with Visual Studio.
850
851
Not adding the tests is useful in many instances where one is counting on only a few hosts to do testing.
852
853
The build step (-s2 or -2) will build in *builds-volatile* and install in the volatile directory, but it also determines several options by looking at the email subject of any step-1 build.
854
855
This is geared towards a general philosophy of having two builds, the stable (or internal) build that is done more rarely, and a volatile build that is done every night. So what is done in step 2 depends on the step 1 result, which can be determined from the email subject file, left behind. There are four cases:
856
857
* Step 1 did nothing as there was a sufficiently recent build.  Then step 2 does a full build with tests.
858
* Step 1 was fully successful, both builds and tests.  Then step 2 is not executed.
859
* Step 1 builds succeeded, but some tests failed (and so some packages were not installed).  Then step 2 is executed without testing, as that was done in step 1, and this permits installation of the built, but untested packages.
860
* Step 1 builds failed (and so corresponding tests were not attempted). Then step 2 is not executed, as it will fail as well.
861
862
The error code returned by jenkinsbild for is success (0) if even only the builds succeeded but not the tests. This way the dashboard indicates jenkinsbild build success only. A subsequent job, jenkinstest, determines whether tests passed by examining the email subjects left behind.
863
864
For either build step, one wants to archive the artifacts,
865
866
~~~~~~
867
mk*all.sh,jenkinsbild.log,builds-*/bilderenv.txt,builds-*/*-summary.txt,\
868
builds-*/*.log,builds-*/*-chain.txt,*/*-preconfig.sh,*/preconfig.txt,\
869
builds-*/*/*/*-config.sh,builds-*/*/*/*-config.txt,\
870
builds-*/*/*/*-build.sh,builds-*/*/*/*-build.txt,\
871
builds-*/*/*/*-test.sh,builds-*/*/*/*-test.txt,\
872
builds-*/*/*/*-submit.sh,builds-*/*/*/*-submit.txt,\
873
builds-*/*/*/*-install.sh,builds-*/*/*/*-install.txt,\
874
*tests/*-config.sh,*tests/*-config.txt,*tests/*-build.sh,\
875
*tests/*-build.txt,*tests/*-install.sh,*tests/*-install.txt,\
876
*tests/runtxtest-*.txt,*tests/*-txtest.log,\
877
builds-*/*/*/*-Darwin-*.dmg,builds-*/*/*/*-win_x??-*.exe,\
878
builds-*/*/*/*-Linux-x86*-*.tar.gz
879
~~~~~~
880
881
in order to collect all results of builds and tests and any created installers.
882
883
### Posting test results: jenkinstest 
884
885
886
# Bilder Architecture
887
888
Bilder has a largely Object Oriented structure, even though it is written in Bash. But like all (even OO) programs, it has a procedural aspect.  Further it is task oriented (as opposed to event driven), with clear start and conclusion. We will break this architecture down into these three aspects: the task flow, the primary objects, and the procedures.
889
890
## Task flow 
891
892
Bilder scripts, like mkvisitall.sh, begin by setting some identifying variables, BILDER_NAME, BILDER_PACKAGE, ORBITER_NAME, and then continue by sourcing bildall.sh, which brings in the Bilder infrastructure: initializations of variables and methods used for building, testing, and installing packages.
893
894
### Global method definition 
895
896
The file, bildall.sh, brings in all of the global methods by first sourcing runr/runrfcns.sh, which contains the minimal methods for executing builds in job queues and reporting the results. It then obtains all of the more Bilder-specific methods by sourcing bildfcns.sh. These include generic methods for determining the build system, preconfiguring, configuring, building, testing (including running tests and collecting results), and installing. These files are the heart of Bilder, as they do all the heavy lifting.
897
898
A trivial, but important method is _techo_, which prints output to both stdout and to a log file.  Another is _decho_, which does the same, but only if DEBUG=true, which is set by the option _-d_.
899
900
### Option parsing 
901
902
Options are parsed through the sourcing of bildopts.sh, which is sourced by bildall.sh.  It then sets some basic command-line-argument derived variables, such as the installation directories, which it checks for writability. This file, bildopts.sh, has been written in such a way that Bilder-derived scripts (like mkvisitall.sh) can add their own arguments.
903
904
### Initialization 
905
906
Initialization is carried out by sourcing of two files, bildinit.sh and bildvars.sh (which are both sourced by bildall.sh). The purpose of bildinit.sh is to handle timing, to clear out indicating variables (like PIDLIST and configFailures), get the Bilder version, and define any path-like environment variables that might get changed in the course of the run.
907
908
The purpose of bildvars.sh is to determine useful variables for the build.  The first comes from a possible machine file, then by OS (AIX, CYGWIN, Darwin, or Linux; MinGW is a work in progress). Then unset variables are set to default
909
values. These variables contain the compilers for serial (front-end nodes), back-end nodes, parallel, and gcc (as some packages build only with gcc, and the names of the gcc compilers can vary from one system to another).  As well,
910
the flags for all of these compilers are set. 
911
912
There are some packages that are so basic, that bilder defines variables for them.  These include HDF5, the linear algebra libraries (lapack, blas, atlas), and Boost. These definitions allow the locations of these libraries to be defined on a per machine basis. This is needed particularly for LCFs, which have special builds of HDF5, BLAS, and LAPACK, and for CYGWIN, which must have Boost to make up for deficiencies in the Visual Studio compilers.
913
914
Finally, bildvars.sh prints out all of the determined values.
915
916
### Package building 
917
918
A Bilder-derived script, like _mkvisitall.sh_, after sourcing _bildall.sh_, then builds packages in groups. In the simplest case, a package is built in a straight-through sequence, like
919
920
~~~~~~
921
    source $BILDER_TOPDIR/bilder/packages/facets.sh
922
    buildFacets
923
    testFacets
924
    installFacets
925
~~~~~~
926
927
(The call to _testFacets_ can be ignored if thepackage is not tested.)  The methods for building, testing, and installing a package are defined in the ppropriate file under the packages subdirectory.
928
929
Bilder, however, has the capability of doing threaded builds, such as in the sequence,
930
931
~~~~~~
932
    source $BILDER_TOPDIR/bilder/packages/trilinos.sh
933
    buildTrilinos
934
    source $BILDER_TOPDIR/bilder/packages/txphysics.sh
935
    buildTxphysics
936
    source $BILDER_TOPDIR/bilder/packages/txbase.sh
937
    buildTxbase
938
    installTxbase
939
    installTxphysics
940
    installTrilinos
941
~~~~~~
942
943
In this case, all of the builds for _Trilinos_, _TxPhysics_, and _TxBase_ are launched and so are occurring simultaneously. Then _installTxbase_ waits for
944
the _TxBase_ build to complete, then it installs it. Then it waits on and installs _TxPhysics_ and _Trilinos_.
945
946
This ability to build multiple, non-interdependent packages simultaneously is a key feature of Bilder. It leads to great savings in time, especially with packages that must be built in serial due to a lack of dependency determination.
947
948
### Concluding 
949
950
The last part of the task flow is to install the configuration files, to summarize the build, and to email and post log files, build files, and the summary. The configuration files, which are created by _createConfigFiles_ and installed by _installConfigFiles_ into the installation directory, contain the necessary additions to environment variables to pick up the installed software.
951
952
The method, _finish_, then does the remaining tasks. It creates the summary file and emails it to the contact specified by the option parsing.  It then posts all log and build files to Orbiter.
953
954
## Package files 
955
956
Package files define how a package is acquired, how it is configured for building on the particular platform for all builds, how all builds are done, and how they are all installed.  Here we introduce an important distinction: the **tarball packages** are those obtained in the tar.gz format; the **repo packages** are obtained from a Subversion source code repo. Generic tarball packages are found in the Tech-X maintained Subversion repo at https://ice.txcorp.com/svnrepos/code/numpkgs and are available by anonymous svn. The repo packages are typically svn externals to a Bilder project, e.g.,
957
958
~~~~~~
959
    $ svn pg svn:externals .
960
    bilder svn://svn.code.sf.net/p/bilder/code/trunk
961
    visit http://portal.nersc.gov/svn/visit/trunk/src
962
    visitresources http://portal.nersc.gov/svn/visit/trunk/windowsbuild/resources
963
~~~~~~
964
965
Though written in _Bash_, Bilder uses object concepts. Each package file under packages acts an object, with instantiation, exposed (public) data members, private data members, and methods.  As in OO, these **package-build** objects have the same data members and a common interface.
966
967
Instantiation is carried out by sourcing the package file. At this point, the data associated with that package is initialized as necessary.
968
969
### Package-build data 
970
971
The public data members for a package _PKG__ are
972
973
~~~~~~
974
    PKG_BLDRVERSION # Either the version to install or the
975
                    # version from the code repository
976
    PKG_DEPS        # The dependencies of this package
977
    PKG_BUILDS      # The names of the builds for this package
978
    PKG_UMASK       # The "umask" that determines the permissions
979
                    # for installation of this package
980
~~~~~~
981
982
In the syntax of C++, the first underscore would be represented by '.', i.e., pgk.DEPS. Even dynamic binding can be implemented in _Bash_.  I.e., if one
983
has _pkgname_ that holds the name of a package, one can can extract, e.g., BLDRVERSION via
984
985
~~~~~~
986
    vervar=`echo $pkgname | tr 'a-z./-' 'A-Z___'`_BLDRVERSION
987
~~~~~~
988
989
Admittedly, many of these constructs would more easily be accomplished in a language like Python that naturally supports object orientation. The trade-off is that then one does not have the nearly trivial expression of executable invocation or threading that one has in _Bash_.
990
991
In addition, there are the per-build, public variables _PKG_BUILD_OTHER_ARGS_ (e.g., _FACETS_PAR_OTHER_ARGS_ or _BABEL_STATIC_OTHER_ARGS_. These are added to the command-line when configuring a package.  In some cases, a package has more than one builds system, like HDF5, in which case one has two sets of variables, e.g., _HDF5_PAR_CMAKE_OTHER_ARGS_ and _HDF5_PAR_CONFIG_OTHER_ARGS_.
992
993
### Exposed package-build methods 
994
995
All package files are supposed to provide three methods, e.g., _buildPkg_, _testPkg_, and _installPkg_, where "Pkg" is the name of the package being built.  E.g., FACETS has buildFacets, testFacets, installFacets. For untested packages, the second method can simply be empty.
996
997
The method, _buildPkg_, is supposed to determine whether a package needs to be built.  If so, it should either acquire a tarball package or preconfigure (prepare the build system for) a repo package, then configure the package, and finally launch the builds of the package.  Preconfiguring in the example of an _autotools_ package involves invoking the _autoreconf_ and other executables for creating the various configuration scripts.  In many other cases there is no associated action.  If the Bilder infrastructure is used, then all builds are executed in a separate thread, and at the end of the _buildPkg_ method all the process IDs for these builds have been stored in both the variable PIDLIST, and the particular process ID for build "ser" of package "pkg" is stored in the variable, PKG_SER_PID.
998
999
The method, _testPkg_, is supposed to determine whether a package is being tested.  If not, it simply returns.  But if the package is being tested, then _testPkg_ executes _wait_ for each build.  Upon successful completion of
1000
all builds, the tests are launched.  These are treated just like builds, so the process IDs are stored as in the case of builds.
1001
1002
The last method, _installPkg_, in the case of a tested package, waits for the tests to complete, then installs the package if the tests completed successfully, after which is sets the tests as being installed, so that tests will not be
1003
run again unless the version or dependencies of the package change.  In the other case, where the package is not being tested, it waits for the builds to complete and installs any successful builds.
1004
1005
All three methods for any package are supposed to compensate for any errors or omissions in the build systems. Errors include fixing up library dependencies on Darwin, setting permissions of the installed software, and so forth. 
1006
1007
The object-oriented analogy is that each package-build object has an interface with three methods.  The syntax translation is _buildPkg_ -> _pkg.build_.
1008
1009
### Private package-build data 
1010
1011
In the course of its build, any package will generate other variables with values. These are organized on a per-build basis, and so one can think of each 
1012
package-build object as containing an object for each build of that package.  
1013
1014
### Internal objects 
1015
1016
Builds
1017
1018
Tests
1019
1020
###  Combined package objects 
1021
1022
###  Future directions
1023
1024
Dependency determination.
1025
1026
1027
# Linear Algebra Libraries in Bilder
1028
1029
There are a wide variety of ways to get LAPACK and BLAS: Netlib's libraries (reference LAPACK and BLAS), CLapack (for when one does not have a Fortran compilers), ATLAS (for cpu-tuned libraries), GOTOBLAS (from TACC), and system libraries (MKL, ACML).
1030
1031
For numpy and all things that depend on it, Bilder uses ATLAS (if it has been built), and otherwise it uses LAPACK.
1032
1033
For non Python packages, the current logic is
1034
1035
## Darwin 
1036
1037
Always use -framework Accelerate
1038
1039
## Linux and Windows 
1040
1041
* SYSTEM_LAPACK_SER_LIB and SYSTEM_BLAS_SER_LIB are used if set.
1042
* Otherwise, if USE_ATLAS is true, then ATLAS is used.
1043
* Otherwise, use Netlib LAPACK if that is found.
1044
* Otherwise
1045
    * If on Windows, use CLAPACK
1046
    * If on Linux, use any system blas/lapack
1047
1048
The results of the search are put into the variables, CMAKE_LINLIB_SER_ARGS, CONFIG_LINLIB_SER_ARGS, LINLIB_SER_LIBS.
1049
1050
1051
# Extending Bilder
1052
1053
Bilder builds packages using the general logic in bildfcns.sh, the operating-system logic in bildvars.sh,
1054
logic for a particular package in the _Bilder package file_ (kept in the packages subdir), logic for a
1055
particular machine in the _Bilder machine file_ (kept in the machines subdir), and additional settings for a particular package on a particular machine in the Bilder machine file.  To extend Bilder, one adds the files that introduce the particular logic for a package or a machine.
1056
1057
* [[Adding support for a new package]]
1058
* [[Adding support for a new machine or operating system/compiler combination]]
1059
1060
# Debugging your builds
1061
1062
This section describes some of the things that can go wrong and explains how to fix them.
1063
1064
# Bilder With IDEs
1065
1066
This is a page to collect notes on using IDEs to develop code while at the same time using bilder to build the project.
1067
1068
* Reference for using Eclipse with CMake, http://www.vtk.org/Wiki/CMake:Eclipse_UNIX_Tutorial