Project

General

Profile

Wiki » History » Version 13

Nathan Neri, 04/16/2020 12:53 PM
updating some options

1 1 Redmine Admin
# What is Bilder?
2
3
{{>toc}}
4
5 12 Tech-X Corporation
Bilder is a cross-platform (Linux, OS X, Windows), meta-build or package management system applicable to LCFs, such as 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 installed in common areas, so that multiple packages can make use of the same dependency builds.
6 1 Redmine Admin
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 3 Redmine Admin
  * 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 1 Redmine Admin
* 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 3 Redmine Admin
  * 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 11 Jonathan Smith
* Ability to force builds of legacy versions of packages
36 1 Redmine Admin
37
## What does Bilder not handle?
38
39
* Installing compilers
40
* Probably much more
41
42
# Preparing your machine for Bilder
43
44
* [[Preparing a Windows machine for Bilder]]
45
* [[Preparing a Linux machine for Bilder]]
46
* [[Preparing a Mac machine for Bilder]]
47
48
Then check out a bilder repo and build. Below are some examples.
49
50
# EXAMPLE1: Python Packages
51
52
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.
53
54
~~~~~~
55 6 John Cary
svn checkout http://ice.txcorp.com/svnrepos/code/bilder/pypkgs/trunk pypkgs
56 1 Redmine Admin
cd pypkgs
57
./mkpypkgs.sh
58
~~~~~~
59
60 2 Tech-X Corporation
# EXAMPLE2: VisIt Visual Analysis Package #
61 1 Redmine Admin
62 2 Tech-X Corporation
![https://wci.llnl.gov/codes/visit/](VisIt)
63
64
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.
65 1 Redmine Admin
66
~~~~~~
67 6 John Cary
svn checkout http://ice.txcorp.com/svnrepos/code/bilder/visitall/trunk visitall
68 1 Redmine Admin
cd visitall
69
./mkvisitall.sh
70
~~~~~~
71
72
# Getting Bilder
73
74
Bilder is a set of shell scripts to configure software. All the configure scripts are available from a subversion repository. To access Bilder, enter:
75
76
~~~~~~
77 10 Ted Sume
svn co http://ice.txcorp.com/svnrepos/code/bilder/trunk bilder
78 1 Redmine Admin
~~~~~~
79
80
# Configuring Bilder
81
82
## Required configuration information 
83
84
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.)
85
86
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.,
87
88
~~~~~~
89
PACKAGE_REPOS_FILE=${PACKAGE_REPOS_FILE:-"$BILDER_CONFDIR/numpkgssvn.txt"}
90
~~~~~~
91
92
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.
93
94
The Package Repos File, then contains the repos to be searched for packages, with the format:
95
96
~~~~~~
97
    $ cat numpkgssvn.txt 
98
    ####
99
    #
100
    # File:    numpkgssvn.sh
101
    #
102
    # Purpose: List the package repos in the format,
103
    #          subdir,method=URL
104
    #          Where subdir is the desired location for the repo,
105
    #          method = svn to get by svn, empty to get with wget
106
    #          URL is the resource locator
107
    #
108
    # Version: $Id: numpkgssvn.txt 54 2012-04-08 13:52:09Z cary $
109
    #
110
    ####
111 10 Ted Sume
    PACKAGE_REPO: numpkgs,svn=http://ice.txcorp.com/svnrepos/code/numpkgs/trunk
112 1 Redmine Admin
~~~~~~
113
114
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.
115
116
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, 
117
118
~~~~~~
119 10 Ted Sume
svn co --depth=empty http://ice.txcorp.com/svnrepos/code/numpkgs/trunk numpkgs
120 1 Redmine Admin
~~~~~~
121
122
and packages will be obtained by
123
124
~~~~~~
125
svn up pkgname
126
~~~~~~
127
128
in the numpkgs subdirectory.
129
130
## Optional logic in bilderrc 
131
132
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.
133
134
You can also find the following three methods:
135
136
* _bilderGetAuxData_ defines how to get any auxiliary data needed by a package
137
* _bilderFinalAction_ defines a final action (like posting to a dashboard) to be undertaken at the end of a build run
138
* _signInstaller_ to sign any installers that you create during your build
139
140
## Optional additional logic 
141
142 7 John Cary
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/domains: 
143 1 Redmine Admin
144
~~~~~~
145 7 John Cary
domains$ ls
146
alcf.anl.gov	hpc.mil		nersc.gov	tacc.utexas.edu
147 1 Redmine Admin
~~~~~~
148
149
# Running Bilder
150
151
## Running Bilder for the Novice User 
152
153
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.
154
155
For example, Tech-X maintains the _visitall_ repo, which can be obtained by:
156
157
~~~~~~
158 10 Ted Sume
svn co http://ice.txcorp.com/svnrepos/code/visitall/trunk visitall
159 1 Redmine Admin
~~~~~~
160
161 7 John Cary
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.
162 1 Redmine Admin
163
~~~~~~
164 8 John Cary
visitall$ ./mkvisitall-default.sh -h
165
166
Usage: ./mkvisitall-default.sh [WRAPPER OPTIONS] -- [BILDER OPTIONS]
167
168
This wrapper script calls the main Bilder script with arguments
169
to set default locations for build and installation directories
170
on a domainname basis.  It also handles launching the build in a
171
queue.  This script is also meant to ease the use of non-gfortran
172
compilers.  It uses these values to form arguments for the main
173
bilder script, mkvisitall.sh, which it additionally sends the arguments
174
after the double dash, --.
175
176
WRAPPER OPTIONS
177
  -b <dir> .......... Set builds directory. If not used, bilder chooses a default.
178
  -c ................ All-user installations: for non-LCFS, goes into /contrib,
179
                        /volatile or /internal, for LCFSs, goes into group areas
180
  -C ................ Install in separate tarball and repo install dirs
181
...
182
  -- ................ End processing of args for mkall-default.sh, all remaining
183
                        args are passed to the script.
184
185
If you want to see the command line arguments for mkvisitall.sh, then you
186
should run the following command:
187
188
        ./mkvisitall.sh -h
189 1 Redmine Admin
~~~~~~
190
191
192
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].
193
194
195
## Running Bilder for the Advanced User ... 
196
197 7 John Cary
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, e.g.,
198 1 Redmine Admin
199
~~~~~~
200 7 John Cary
visitall$ ./mkvisitall.sh -h
201
Usage: ./mkvisitall.sh [options]
202
BILDER OPTIONS
203
  -a ................ Update non-subversion packages
204
  -A <addl_sp> ...... Add this to the supra search path.
205
  -b <build_dir> .... Build in <build_dir>.
206
  ...
207 1 Redmine Admin
~~~~~~
208
209
210
## Notes on Installation Directories and Path Modifications 
211
212
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.
213
214
Bilder defines two installation directories, which may be the same.
215
216 5 Redmine Admin
Tarballs are installed in ''the tarball directory'' or \<tarballdir\>, specified by the _-k_ flag. This is the _/contrib_ directory at Tech-X.
217 1 Redmine Admin
218 5 Redmine Admin
Code from repositories is installed in ''the repo directory'' or \<repodir\>, the directory specified by the _-i_ flag.  At Tech-X, this is typically _/volatile_ or _/internal_.
219 1 Redmine Admin
220
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_.
221
222
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.
223
224
225
## Debugging Bilder Errors 
226
227
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.
228
229
230
# Bilder's Build Types
231
232
The standard builds of Bilder are
233
234
* ser: static, serial build
235
* par: static, parallel (MPI) build
236
* sersh: shared, serial build
237
* parsh: shared, parallel (MPI) build
238 9 John Cary
* pycsh: shared build compatible with the way Python was built
239 1 Redmine Admin
240
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.
241
242
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.
243
244
## Static builds 
245
246
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.
247
248
## Shared builds 
249
250
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.
251
252 9 John Cary
## pycsh builds 
253 1 Redmine Admin
254 9 John Cary
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 pycsh build only when the serial compiler is not the compiler used to build Python.
255 1 Redmine Admin
256
# Bilder Hierarchy
257
258 9 John Cary
It is possible to specialize Bilder: per machine, per project and per person. by sourcing file(s) at each level of hierarchy:
259 1 Redmine Admin
260
## Bilder default settings 
261
262
When no specialization files are used, Bilder uses the default settings for the project.
263
264
## By Machine 
265
266
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.
267
268
## By Project 
269
270
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.
271
272
## By Person 
273
274
### Default settings using .bilddefrc 
275
276
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. 
277
278
### Settings using .bilderrc 
279
280
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. 
281
282
## Per package per person 
283
284
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.
285
286
# Running Bilder Through The Defaults Scripts
287
288
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:
289
290
~~~~~~
291
    $ cat mkfcall-default.sh 
292
    #!/bin/bash
293
    #
294
    # Determine (and possibly execute) the default Bilder command
295
    # for Facetsall.
296
    #
297
    # $Id: mkfcall-default.sh 593 2012-03-09 15:26:46Z cary $
298
    #
299
    h2.#########################################################
300
    # 
301
    # Set the default variables
302
    mydir=`dirname $0`
303
    mydir=${mydir:-"."}
304
    mydir=`(cd $mydir; pwd -P)`
305
    # Where to find configuration info
306
    BILDER_CONFDIR=$mydir/bilderconf
307
    # Subdir under INSTALL_ROOTDIR where this package is installed
308
    PROJECT_INSTSUBDIR=facets
309
    source $mydir/bilder/mkall-default.sh
310
311
    # Build the package
312
    runBilderCmd
313
    res=$?
314
    exit $res
315
~~~~~~
316
317 13 Nathan Neri
The options, (see bilder/bildopts.sh for an up to date list of options in your local revision of bilder, as well as their implementations)
318 1 Redmine Admin
319
~~~~~~
320
    $ ./mkfcall-default.sh -h
321
    source /Users/cary/projects/facetsall/bilder/runnr/runnrfcns.sh
322
    WARNING: runnrGetHostVars unable to determine the domain name.
323
    Usage: ./mkfcall-default.sh [options]
324
    This script is meant to handle some of the vagaries that occur
325
    at LCFs and clusters in large systems (which have complicated file
326
    systems) such as those that have high performance scratch systems
327
    and NFS mounted home systems.  This script is also meant to ease
328
    the use of non-gfortran compilers.
329
    OPTIONS
330
      -c              common installations: for non-LCFS, goes into /contrib,
331
                      /volatile or /internal, for LCFSs, goes into group areas
332
      -C              Install in separate tarball and repo install dirs 
333
                      (internal/volatile) rather than software
334
      -E "<options>"  quoted list of extra options to pass to the mk script
335
      -f <file>       File that contains extra arguments to pass
336
                      Default: .extra_args
337
      -F <compiler>   Specify fortran compiler on non-LCF systems
338
      -g              Label the gnu builds the same way other builds occur.
339
      -H <host name>  use rules for this hostname (carver, surveyor, intrepid)
340
      -h              print this message
341
      -i              Software directory is labeled with "internal" if '$USER'
342
                      is member of internal install list
343
      -I              Install in $HOME instead of default location
344
                      (projects directory at LCFs, BUILD_ROOTDIR on non-LCFs)
345
      -j              Maximum allowed value of the arg of make -j
346
      -k              On non-LCFs: Try to find a tarball directory (/contrib)
347
                      On LCFs:     Install tarballs (instead of using facetspkgs)
348
      -m              force this machine file
349
      -n              invoke with a nohup and a redirect output
350
      -p              just print the command
351
      -q <timelimit>  run in queue if possible, with limit of timelimit time
352
      -t              Pass the -t flag to the  mk script (turn on testing)
353
      -v <file>       A file containing a list (without commas) of declared
354
                      environment variables to be passed to mk*.sh script
355
      -w <file>       Specify the name of a file which has a comma-delimited
356
                      list of packages not to build (e.g.,
357
                      plasma_state,nubeam,uedge) Default: .nobuild
358
      --              End processing of args for mkall-default.sh, all remaining
359
                      args are passed to the script.
360
~~~~~~
361
362
363
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.
364
365
An example invocation look like
366
367
~~~~~~
368
mkfcall-default.sh -cin -- -oXZ -E BUILD_ATLAS=true
369
~~~~~~
370
371
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.
372
373
# Using Jenkins with Bilder
374
375
### Setting up Jenkins for use with Bilder ###
376
377
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.
378
379
## Starting up a Linux Jenkins master node 
380
381
Install Jenkins using the installation mechanism for your platform.  E.g., see
382
https://wiki.jenkins-ci.org/display/JENKINS/Installing+Jenkins+on+RedHat+distributions.
383
384
*IMPORTANT:* Before starting Jenkins for the first time:
385
* 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)
386
* set the permissions of the Jenkins build directory (e.g., /home/bilder/jenkins)
387
* Add jenkins to any groups as needed (e.g., contrib, research, xxusers)
388
* modify {{{/etc/sysconfig/jenkins}}} as needed.  Our settings are
389
390
391
~~~~~~
392 9 John Cary
JENKINS_HOME="/home/bilder/jenkins"
393
JENKINS_PORT="8300"
394
JENKINS_AJP_PORT="8309"
395
JENKINS_ARGS="--argumentsRealm.passwd.jenkins=somepassword --argumentsRealm.roles.jenkins=admin"
396 1 Redmine Admin
~~~~~~
397
398
(_somepassword_ is not literal.)
399
400
Create an ssh key for jenkins:
401
402
~~~~~~
403 9 John Cary
sudo -u jenkins ssh-keygen
404 1 Redmine Admin
~~~~~~
405
406
It cannot have a passphrase.
407
408
409
Start the jenkins service:
410
411
~~~~~~
412 9 John Cary
sudo service jenkins start
413 1 Redmine Admin
~~~~~~
414
415
416
Set Jenkins to start on boot:
417
418
~~~~~~
419 9 John Cary
sudo chkconfig --level 35 jenkins on
420 1 Redmine Admin
~~~~~~
421
422
## Preparing a Unix Jenkins slave node 
423
424
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.
425
426
* On the service node, create the user who will run Jenkins.
427
* As that user create the directory where Jenkins will work
428
* Add that user to any groups needed to give it appropriate permissions (e.g., contrib, research, xxusers)
429
* For public-key authentication
430 3 Redmine Admin
  * Add the public key created above for jenkins to that user's ~/.ssh/authorized_keys
431
  * On the master, check that you can do passwordless login by trying: "_sudo -u jenkins ssh jenkins@yourhost_"
432 1 Redmine Admin
* For password authentication
433 3 Redmine Admin
  * Configure /etc/sshd_config to allow password authentication (PasswordAuthentication yes) and restart sshd
434 1 Redmine Admin
435
## Configuring the Linux Jenkins master node 
436
437
* 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.
438
* Go to Manage Jenkins -> Manage Plugins -> Available and install the plugins,
439 3 Redmine Admin
  * Jenkins cross-platform shell (XShell)
440
  * Conditional Build-Step
441
  * Matrix Tie Parent
442
  * Jenkins build timeout (Build-timeout)
443 1 Redmine Admin
* 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).
444
* Go to Manage Jenkins -> Configure system and select/set
445 3 Redmine Admin
  * Enable security
446
  * Jenkins's own user database
447
  * _If you wish_, allow users to sign up
448
  * Project-based Matrix Authorization Strategy
449 4 Redmine Admin
      * Add an administrator name with all privileges
450
      * Give anonymous user Overall Read (only)
451 3 Redmine Admin
  * Default user e-mail suffix: e.g., @yourdomain
452
  * Sender: jenkins@yourdomain
453 1 Redmine Admin
* Go to Manage Jenkins -> Manage Nodes -> New Node
454 4 Redmine Admin
  * Fill in name
455
  * Dumb Slave
456
  * You are taken to the configure form:
457
      * \# of executors = 1
458
      * Remote FS root: what you decided upon when creating the slave
459
      * Usage: Leave this machine for tied jobs onlye
460
      * Launch methog: Launch slave gents on Unix machines via SSH
461
      * Advanced:
462
          * Host 
463
          * Username (jenkins)
464 1 Redmine Admin
465
## Creating your first Bilder-Jenkins project 
466
467
We will create the first project to build on the master node. Later we will add more nodes.
468
469
* Go to Jenkins -> New Job
470
    * Build multi-configuration project
471
* Set name (here we will do visitall as our example)
472
* Enable project-based security
473
    * For open source builds, give Anonymous Job Read and Job Workspace permission
474
    * Add user/group as needed
475
* Source Code Management
476
    * Subversion
477
    * Put in your URL, e.g., https://ice.txcorp.com/svnrepos/code/visitall/trunk
478
    * Put in your svn credentials as requested
479
* Build Triggers (examples)
480
    * Build Periodically
481
        * Enter cron parameters, e.g., 0 20 * * *
482
    * Or have this build launched as a post-build step of another build
483
* Configuration Matrix
484
    * Add axis -> slaves (is this available before we add nodes?)
485
        * Add master and the above unix slave
486
* Build Environment
487
    * Abort the build if stuck (if desired)
488
        * Enter your timeout
489
    * Tie parent build to a node
490
        * Select master node
491
* Build
492
    * Add build step -> Invoke XShell command
493
        * Command line: bilder/bildtrol/unibild -d mkvisitall
494
        * Executable is in workspace dir
495
* Post-build Actions
496
    * Aggregate downstream test results
497
        * Select both
498
    * Archive the artifacts (select, see below for settings)
499
    * E-mail Notification
500
        * Set as desired
501
502
503
## Creating a Windows Slave 
504
505
* Get all tools in place on the slave machine by following the instructions at https://ice.txcorp.com/trac/bilder/wiki/BilderOnWindows
506
* Create the jenkins user account (if not already defined) as an Administrative account and log into the windows machine as the jenkins user
507
* Make sure the slave's Windows name and its domain name are consistent.
508
* 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`
509
* Create the build directory (e.g., C:\winsame\jenkins)
510
* Set the owner to that directory to the jenkins user via properties->security->advanced->owner.
511
* Install the Visual C++ redistributables from http://www.microsoft.com/download/en/details.aspx?id=5582
512
* Follow the networking, registry, and security related instructions at https://wiki.jenkins-ci.org/display/JENKINS/Windows+slaves+fail+to+start+via+DCOM
513
* (Cribbing from https://issues.jenkins-ci.org/browse/JENKINS-12820)
514
* Start a web browser on the windows slave and connect to the master jenkins web page.
515
* Manage Jenkins -> Manage Nodes -> New Node
516
* Create a new node (Slave node)
517
  * Fill in name, choose it to be the same as the Windows name of the slave
518
  * Dumb Slave
519
  * In the configure form, set
520
    * \# of executors: 1
521
    * Remote FS root: the directory created above (e.g., C:\winsame\jenkins)
522
    * Usage: Leave this machine for tied jobs only
523
    * Launch method: Launch slave agents via java web start
524
* Launch the slave
525
* Press the newly appeared button: Launch by webstart  
526
* A pop up window will be visible with a message as "Connected"
527
* In that pop up window click File-> Install as Windows Service
528
* Find jenkins service in the control panel, ensure that the owner is the jenkins user
529
* UNCHECKED: Set startup to Automatic
530
* Return to browser, take slave node off line in jenkins
531
* Set launch method to: Windows slave as a Windows Service
532
  * Advanced:
533
    * Administrative username (jenkins) ''You may need to type it as computername\jenkins if you get an invalid service account error''
534
    * Password (set as selected in slave setup)
535
    * Use Administrator account given above
536
* Relaunch slave node
537
538
### Use the Slave on the Master 
539
540
You should now be able to select this slave as a build node.
541
542
543
## Launching Bilder through Jenkins 
544
545
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.
546
547
### Building and testing: jenkinsbild 
548
549
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
550
case, the simplest XShell command is
551
552
~~~~~~
553 9 John Cary
bilder/jenkins/jenkinsbild mkvisitall
554 1 Redmine Admin
~~~~~~
555
556
which leads to execution of
557
558
~~~~~~
559 9 John Cary
./mkvisitall-default.sh -t -Ci -b builds-internal  -- -Z -w 7
560 1 Redmine Admin
~~~~~~
561
562
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.
563
564
The _jenkinsbild_ script has very few options:
565
566
567
~~~~~~
568 9 John Cary
Usage: $0 [options]
569 1 Redmine Admin
GENERAL OPTIONS
570 13 Nathan Neri
  -c <doc copy file>. file defines how to copy documentation, if desired
571
  -E <env pairs> .... comma separated list of environment variables and values,
572
                      e.g., FOO=f,BAR=b
573
  -h ................ Print this and exit
574
  -m <machines file>. file defining machine files for all platforms
575 1 Redmine Admin
  -n ................ Do not add tests
576 9 John Cary
  -p ................ Print the command only.
577 13 Nathan Neri
  -s <step> ......... Sets which build step: 1 = internal, 2 = volatile.
578
  -f ................ Force build step 2 to execute independent of the
579
                      results of step 1.  Tests will execute unless -n
580
                      specified.
581 1 Redmine Admin
~~~~~~
582
583
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.
584
585
Using mingw on cygwin (-m) is useful for codes that cannot build with Visual Studio.
586
587
Not adding the tests is useful in many instances where one is counting on only a few hosts to do testing.
588
589
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.
590
591
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:
592
593
* Step 1 did nothing as there was a sufficiently recent build.  Then step 2 does a full build with tests.
594
* Step 1 was fully successful, both builds and tests.  Then step 2 is not executed.
595
* 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.
596
* Step 1 builds failed (and so corresponding tests were not attempted). Then step 2 is not executed, as it will fail as well.
597
598
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.
599
600 9 John Cary
For either build step, one wants to archive the artifacts listed in bilder/jenkins/jenkinsclean.sh.
601 1 Redmine Admin
in order to collect all results of builds and tests and any created installers.
602
603
### Posting test results: jenkinstest 
604
605
606
# Bilder Architecture
607
608
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.
609
610
## Task flow 
611
612
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.
613
614
### Global method definition 
615
616
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.
617
618
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_.
619
620
### Option parsing 
621
622
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.
623
624
### Initialization 
625
626
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.
627
628 9 John Cary
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 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, the flags for all of these compilers are set. 
629 1 Redmine Admin
630
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.
631
632
Finally, bildvars.sh prints out all of the determined values.
633
634
### Package building 
635
636 9 John Cary
A Bilder-derived script, like _mkvisitall.sh_, after sourcing _bildall.sh_, specifies targets.  Bilder then uses the information in the package files to determine the dependencies, after which Bilder builds the packages in the order from least to most dependent, which all builds for a package occurring in parallel.
637 1 Redmine Admin
638 9 John Cary
One can write special package files for building multiple packages simultaneously.  That feature is rarely used so we will not discuss it further.
639 1 Redmine Admin
640 9 John Cary
This ability to have multiple builds of possibly 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.
641 1 Redmine Admin
642
### Concluding 
643
644
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.
645
646
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.
647
648
## Package files 
649
650
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., for visitall
651
652 6 John Cary
~~~~~~
653 1 Redmine Admin
visitall$ svn pg svn:externals .
654
bilder http://ice.txcorp.com/svnrepos/code/bilder/trunk
655 6 John Cary
bilderconf http://ice.txcorp.com/svnrepos/code/bilder/bilderconf/trunk
656
visit http://portal.nersc.gov/svn/visit/trunk/src
657
visitwindows/distribution http://portal.nersc.gov/svn/visit/trunk/windowsbuild/distribution
658
visittest/data http://portal.nersc.gov/svn/visit/trunk/data
659
visittest/test http://portal.nersc.gov/svn/visit/trunk/test
660
~~~~~~
661
662 1 Redmine Admin
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.
663
664
Instantiation is carried out by sourcing the package file. At this point, the data associated with that package is initialized as necessary.
665
666
### Package-build data 
667
668
The public data members for a package _PKG__ are
669
670
~~~~~~
671 9 John Cary
PKG_BLDRVERSION # Either the version to install or the
672
                # version from the code repository
673
PKG_DEPS        # The dependencies of this package
674
PKG_BUILDS      # The names of the builds for this package
675
PKG_UMASK       # The "umask" that determines the permissions
676
                # for installation of this package
677 1 Redmine Admin
~~~~~~
678
679
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
680
has _pkgname_ that holds the name of a package, one can can extract, e.g., BLDRVERSION via
681
682
~~~~~~
683
    vervar=`echo $pkgname | tr 'a-z./-' 'A-Z___'`_BLDRVERSION
684
~~~~~~
685
686
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_.
687
688
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_.
689
690
### Exposed package-build methods 
691
692
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.
693
694
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.
695
696
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
697
all builds, the tests are launched.  These are treated just like builds, so the process IDs are stored as in the case of builds.
698
699 9 John Cary
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 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.
700 1 Redmine Admin
701
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. 
702
703
The object-oriented analogy is that each package-build object has an interface with three methods.  The syntax translation is _buildPkg_ -> _pkg.build_.
704
705
### Private package-build data 
706
707 9 John Cary
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 package-build object as containing an object for each build of that package.  
708 1 Redmine Admin
709
### Internal objects 
710
711
Builds
712
713
Tests
714
715
###  Combined package objects 
716
717
###  Future directions
718
719
720
# Linear Algebra Libraries in Bilder
721
722
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).
723
724
For numpy and all things that depend on it, Bilder uses ATLAS (if it has been built), and otherwise it uses LAPACK.
725
726
For non Python packages, the current logic is
727
728
## Darwin 
729
730
Always use -framework Accelerate
731
732
## Linux and Windows 
733
734
* SYSTEM_LAPACK_SER_LIB and SYSTEM_BLAS_SER_LIB are used if set.
735
* Otherwise, if USE_ATLAS is true, then ATLAS is used.
736
* Otherwise, use Netlib LAPACK if that is found.
737
* Otherwise
738
    * If on Windows, use CLAPACK
739
    * If on Linux, use any system blas/lapack
740
741
The results of the search are put into the variables, CMAKE_LINLIB_SER_ARGS, CONFIG_LINLIB_SER_ARGS, LINLIB_SER_LIBS.
742
743
744
# Extending Bilder
745
746
Bilder builds packages using the general logic in bildfcns.sh, the operating-system logic in bildvars.sh,
747
logic for a particular package in the _Bilder package file_ (kept in the packages subdir), logic for a
748
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.
749
750
* [[Adding support for a new package]]
751
* [[Adding support for a new machine or operating system/compiler combination]]
752
753
# Debugging your builds
754
755
This section describes some of the things that can go wrong and explains how to fix them.
756
757
# Bilder With IDEs
758
759
This is a page to collect notes on using IDEs to develop code while at the same time using bilder to build the project.
760
761
* Reference for using Eclipse with CMake, http://www.vtk.org/Wiki/CMake:Eclipse_UNIX_Tutorial