root/trunk/docs/README.software_engineers

Revision 927, 14.7 kB (checked in by Gregor, 3 months ago)

README.software_engineers: Documented dsss build --debug.

Line 
1 = DSSS Documentation for Software Engineers =
2
3 DSSS, the D Shared Software System, is a tool to:
4
5 * Build D software.
6 * Install D software.
7 * Configure D software dependencies and libraries.
8 * Maintain a repository of DSSS-compatible D sources to be easily installable
9   via the Internet.
10
11 This document explains the use of DSSS by software engineers wishing to use
12 DSSS as a project management solution.
13
14
15 == OVERVIEW ==
16
17 Software utilizing DSSS is configured with a file named "dsss.conf". This file
18 describes the components of the complete software package and how each component
19 should be built.
20
21 dsss.conf files are plain text files, in a format similar to Windows INI files.
22 They are intentionally minimalistic, and require very little maintenance to keep
23 working.
24
25 Because dsss.conf files are minimalistic, most software packages can be
26 configured for use by DSSS with very simple dsss.conf files. For example, most
27 software packages containing one binary can have a dsss.conf file like the
28 following:
29 [example.d]
30 target = example_binary
31
32 This is all you need for a simple application. DSSS will parse your imports, so
33 you only need to list the file with the entry function (main). In most cases,
34 DSSS is very easy to use. Simple instructions on basic dsss.conf files is
35 available at http://www.dsource.org/projects/dsss/wiki/DSSSByExample
36
37
38 == THE BASICS ==
39
40 dsss.conf files are divided into a number of sections. Most sections describes a
41 single binary or library to be built.
42
43 A section is started with the file name of the source module or package in
44 brackets. File names should always be specified with '/' for the path
45 separator. '\' will work on Windows, but is not portable. '/' works on all
46 platforms.
47
48 In general, sections which are named for modules produce binaries, and sections
49 which are named for packages produce libraries. Each section may have any
50 number of settings, which customize how that section is built.
51
52 When running `dsss build`, sections are built in the order that they appear in
53 the dsss.conf file, with the exception that binaries are always built last.
54
55 = SETTINGS =
56
57 Settings are simple name-value pairs which customize the building of sections.
58 The format is simple:
59 <name>=<value>
60
61 For example,
62 target=example_binary
63
64 It is also possible to add to a setting:
65 <name>+=<value>
66
67 e.g.:
68 a=Hello
69 a+=World
70
71 The setting 'a' is now 'Hello World'. This is most useful with versioning,
72 described later.
73
74 Some settings do not require values. In this case, the setting name alone is
75 sufficient, such as:
76 shared
77
78 Settings may include references to environment variables:
79 a=$PREFIX
80
81 DSSS provides several environment variables for this purpose:
82 PREFIX: The prefix to which the software is being installed.
83 BIN_PREFIX: The prefix for binaries.
84 LIB_PREFIX: The prefix for libraries.
85 INCLUDE_PREFIX: The base prefix for .di files.
86 DOC_PREFIX: The prefix for documentation.
87 ETC_PREFIX: The prefix for configuration files.
88 EXE_EXT: The extension for executable files. Empty on POSIX, ".exe" on Windows.
89 DSSS: The full path to the DSSS binary itself.
90 DSSS_BUILD: The full path to the build tool being used by DSSS (usually
91             rebuild).
92
93 = FLAGS =
94
95 Any section may have a 'buildflags' setting, which specifies the flags to be
96 used while building that section. For example,
97 buildflags=-O
98
99 Flags for use with release and debug builds (when using --debug) can be
100 specified separately in 'releaseflags' and 'debugflags', respectively.
101 'debugflags' defaults to '-debug -gc'.
102
103 = SECTION TYPES =
104
105 Although section types are usually determined automatically from the section
106 name, they may also be overridden with the 'type' setting:
107 [oneFileLib.d]
108 type=library
109
110 The valid values for 'type' (all described in later sections) are:
111 binary
112 library
113 sourcelibrary
114 special
115 subdir
116
117 = BINARIES =
118
119 Sections which are named for D modules (.d files) produce executable binaries
120 when built with DSSS. The target binary file name will be deduced from the name
121 of the .d file, or can be set explicitly with a 'target' line, such as:
122 [example.d]
123 target=example_binary
124
125 A single source file can be used to build multiple binaries, but they must be
126 given different section names. To allow this, section names may have a '+'
127 character, then any descriptive name appended. For example:
128 [example.d+withfeature]
129 target=example_binary_withfeature
130 buildflags=-version=withfeature
131
132 Windows users: Be careful not to set the target of a binary build to the name of
133 a directory. This will work on Windows because it gains the .exe suffix, but
134 will fail on other operating systems.
135
136 = LIBRARIES =
137
138 Sections which are named for D packages (directories) produce libraries when
139 built with DSSS. The name of the library file is derived from the name of the
140 package and the platform. There is no reason to remember this name, however,
141 because DSSS will detect library dependencies and link them in automatically.
142 This name can partially be overridden if desired, in the same way as binaries:
143 [mydpackage]
144 target=dlibrary
145
146 However, the platform will always affect the output library name. On POSIX
147 systems, the above library will be named libSdlibrary.a and libdlibrary.so. On
148 Windows, the above library will be named Sdlibrary.lib.
149
150 By default, all of the .d files within the directory and any subdirectory will
151 be included in the library. Files may be excluded with the 'exclude' setting:
152 [mydpackage]
153 exclude=mydpackage/broken.d
154
155 Entire directories may also be excluded:
156 [mydpackage]
157 exclude=mydpackage/brokenpackage
158
159 The 'exclude' setting is useful in concert with versioning, described in a later
160 section.
161
162 You may also explicitly include files in a library with the 'include' setting:
163 [mydpackage]
164 include=mydpackage/all.d
165
166 Note that, if 'include' is found, only those files listed in 'include' and
167 their dependencies will be included. Please note that the 'include' setting is
168 being tested and may be changed dramatically.
169
170 When using GDC on POSIX, it is also possible to build shared libraries (.so
171 files). To specify that a shared library should be built, set the 'shared'
172 option in the library's section:
173 [mydpackage]
174 shared
175
176 You can set the .so file's version extension (the 1.2.3 in .so.1.2.3) with the
177 soversion setting:
178 [mydpackage]
179 shared
180 soversion=3.2.1
181
182 = SOURCE LIBRARIES =
183
184 Source libraries are libraries which are not compiled until they are used in a
185 binary. They are installed in their source form. Otherwise, they act identically
186 to normal libraries. A source library may be specified by setting the 'type'
187 setting to 'sourcelibrary':
188 [mydpackage]
189 type=sourcelibrary
190
191 = SPECIAL SECTIONS =
192
193 It is also possible to create sections which are not associated with compiling
194 a binary or library. These sections are given names starting with a '+', such
195 as:
196 [+generate]
197
198 The utility of these sections will be seen below, in the section on hooks.
199
200
201 == INSTALLATION ==
202
203 DSSS is capable of installing binaries and libraries to a predetermined
204 directory, usually the prefix in which it is installed. When libraries are
205 installed in this way, they will be usable by DSSS without being explicitly
206 specified.
207
208 If a section should be built but not installed, set the 'noinstall' setting:
209 [test.d]
210 noinstall
211
212
213 == DEPENDENCIES ==
214
215 The primary reason that DSSS exists is to make handling dependencies easier. To
216 this end, is is never necessary to explicitly specify a dependency upon a
217 library which is itself set up to use DSSS. Because DSSS traces D imports and
218 keeps an Internet-accessible repository of package information, installing the
219 dependencies which are supported by DSSS is as easy as typing:
220 $ dsss net deps
221
222 However, dependencies on non-DSSS D libraries or C libraries can be more
223 complicated.
224
225 = INCLUDE PATHS =
226
227 It is possible to specify include paths in the 'buildflags' settings. Import
228 paths are specified with the -I flag:
229 buildflags=-I../prerequisite/import
230
231 = PREREQUISITE LIBRARIES =
232
233 Library search paths are specified with the -S flag:
234 buildflags=-S../prerequisite/lib
235
236 Libraries can be explicitly linked in with the -ll flag. -ll works similarly to
237 -l in most compilers. On POSIX and similar platforms, a flag such as
238 -ll<library>
239 will link in a library named
240 lib<library>.a (or lib<library>.so)
241
242 On Windows (except GDC), the same flag will link a library named
243 <library>.lib
244
245 Libraries linked in with the -ll flag are searched for in the search paths
246 specified by the -S flag.
247
248 The -ll flag is only useful for explicitly linking libraries into binaries. If
249 the DSSS-implemented library depends on a non-DSSS library, the dependency must
250 be specified in a .d file which is part of the DSSS-implemented library. This
251 is done with the 'link' pragma, which must always be specified within
252 version(build):
253 version (build) {
254     pragma(link, "example");
255 }
256
257 The above example will cause any binary linked against the DSSS-implemented
258 library to link against the library named libexample.a (or example.lib on
259 Windows).
260
261
262 == HOOKS ==
263
264 DSSS can run arbitrary commands while building software. There are a number of
265 points at which commands can be run: before and after building, before and after
266 installing, and before and after cleaning up. These commands are added to
267 'prebuild', 'postbuild', 'preinstall', 'postinstall', 'preclean' and 'postclean'
268 lines, respectively.
269
270 Hook commands can be anything which can be run on the shell of the host system,
271 such as:
272 prebuild = echo Hello
273
274 Any number of hook commands may be strung together between semicolons:
275 prebuild = echo Hello ; echo World
276
277 And may span multiple lines by ending each line with a backslash:
278 prebuild = echo \
279     Hello ; \
280     echo World
281
282
283
284 There are also a number of special, builtin commands available.
285
286 = warn and error =
287
288 A warning or error condition can be specified by the hook commands 'warn' and
289 'error'.
290
291 An example of 'error':
292 version (!Posix) {
293     prebuild=error Only POSIX is supported.
294 }
295
296 An example of 'warn':
297 version (Posix) {
298     prebuild=warn POSIX support is untested.
299 }
300
301 When an error hook command is run, building of course halts.
302
303 = install =
304
305 The 'install' command installs a file to the specified directory. If the
306 directory does not exist, it is created. For example:
307 postinstall = install docs/README $DOC_PREFIX
308
309 Files installed in this way are recorded, so that they may be uninstalled
310 easily.
311
312 = installdir =
313
314 'installdir' is similar to 'install', with the exception that it can install
315 entire directories (and all of their subdirectories). The /content/ of the
316 first directory will be installed into the second directory.
317
318 = cd =
319
320 The 'cd' command changes the current directory. It works exactly as on POSIX
321 and Windows shells:
322 prebuild = cd c_source ; make
323
324 It is unnecessary to return to the original directory after 'cd'ing. The
325 directory will be restored after the hook commands have finished.
326
327 = .d files =
328
329 Any .d file may be used as a command. It will be compiled and run on-the-fly:
330 prebuild = generateBindings.d
331
332 = set =
333
334 The 'set' command sets a dsss.conf file setting while DSSS is actually running.
335 The parameters are:
336 set <section>:<setting> <value>
337
338 It is also possible to omit the section from the command to set in the current
339 section:
340 set <setting> <value>
341
342 The special section '*' may be used to set a setting in all sections:
343 set *:<setting> <value>
344
345 For example,
346 set example.d:postbuild echo Hello
347
348 'set' is most useful in concert with the 'eval' command (described below), as
349 it can then be used to set dsss.conf file settings programatically. It is
350 also usable independently of 'eval', but is no better than merely specifying
351 the setting.
352
353 = add =
354
355 The 'add' command is identical to the 'set' command, except that it appends to
356 the current value instead of replacing it.
357
358 For example,
359 add example.d:postbuild World
360
361 = eval =
362
363 The 'eval' command runs a specified command, captures its output, and then runs
364 its output as a command. This allows for very general processes to be
365 encapsulated into binaries, rather than the dsss.conf file itself.
366
367 For example, imagine the scenario that some system specifics need to be detected
368 and utilized in the building of a section. There can be a program, analyze.d,
369 which does the analysis and outputs commands such as
370 add *:postbuild echo Hello
371
372 This program could be run and used with the hook command:
373 prebuild=eval analyze.d
374
375
376 == VERSIONING ==
377
378 dsss.conf files support version statements with a similar syntax to D's own
379 version statements:
380
381 version (Windows) {
382     postbuild=setupWindows.d
383 } else version (Posix) {
384     postbuild=setupPosix.d
385 }
386
387 Unlike D, dsss.conf files support negative versions:
388
389 version (!Windows) {
390     postbuild=giveUserCandy.d
391 }
392
393 dsss.conf's version statements can be used at any point in the dsss.conf file.
394 They can even conditionally include different sections:
395 version (Windows) {
396     [winlib]
397 } else version (Posix) {
398     [posixlib]
399 }
400 type = library
401
402
403 == GLOBAL SETTINGS ==
404
405 There are several settings that DSSS supports which are global. That is, they
406 are specified for the software package as a whole, rather than any section.
407 These are included at the top of the dsss.conf file. Common settings are 'name'
408 (the name of the software package) and 'version'.
409
410 There is also a global setting available to specify which sections should be
411 built normally, 'defaulttargets'. Without it, all sections will be built by
412 default. The section list is simply separated by spaces:
413 defaulttargets=xlib xbin
414
415 It is also possible to specify global settings later in the dsss.conf file by
416 adding an empty section header:
417 []
418 name=exampleSoft
419
420
421 == DEFAULT SETTINGS ==
422
423 It is possible to create default settings with a special "*" section. This is
424 most useful for settings such as 'buildflags':
425
426 [*]
427 buildflags=-O
428
429 Note that any settings in a named section will override those in "*" sections.
430 For example, in this situation:
431
432 [*]
433 buildflags=-O
434
435 [mydlib]
436 buildflags+=-release
437
438 mydlib's buildflags are only "-release".
439
440
441 == ADVANCED FEATURES ==
442
443 There are several advanced features of DSSS which do not need any modification
444 to the dsss.conf file to use.
445
446 The flag '--test', when passed to `dsss build`:
447 $ dsss build --test
448 will cause all of the unit tests to be run.
449
450 The flag '--doc', when passed to `dsss build`:
451 $ dsss build --doc
452 will cause API documentation for every library to be generated with CandyDoc,
453 which beautifies and organizes the documentation.
454
455 The flag '--debug', when passed to `dsss build`:
456 $ dsss build --debug
457 will cause libraries to be built in both a debug- and non-debug mode.
458
459
460 == SUBDIRECTORIES ==
461
462 It is possible to contain an entire DSSS-enabled software package inside of
463 another. This is useful for keeping libraries from different sources separated,
464 and occasionally for adapting non-DSSS-aware packages to use DSSS. Essentially,
465 a section named for the directory of the sub-package has its type set to subdir:
466 [dziplib]
467 type=subdir
468
469 Note that you must manully add buildflags such as -Idziplib if you want to
470 import sources from the subdirectory into sources in the parent directory.
471
472
473 To be written:
474 == NET INSTALLATION ==
Note: See TracBrowser for help on using the browser.