root/branches/tango/docs/README.software_engineers

Revision 796, 13.5 kB (checked in by Gregor, 1 year ago)

MERGE: trunk r795

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 Windows users: Be careful not to set the target of a binary build to the name of
126 a directory. This will work on Windows because it gains the .exe suffix, but
127 will fail on other operating systems.
128
129 = LIBRARIES =
130
131 Sections which are named for D packages (directories) produce libraries when
132 built with DSSS. The name of the library file is derived from the name of the
133 package and the platform. There is no reason to remember this name, however,
134 because DSSS will detect library dependencies and link them in automatically.
135 This name can partially be overridden if desired, in the same way as binaries:
136 [mydpackage]
137 target=dlibrary
138
139 However, the platform will always affect the output library name. On POSIX
140 systems, the above library will be named libSdlibrary.a and libdlibrary.so. On
141 Windows, the above library will be named Sdlibrary.lib.
142
143 By default, all of the .d files within the directory and any subdirectory will
144 be included in the library. Files may be excluded with the 'exclude' setting:
145 [mydpackage]
146 exclude=mydpackage/broken.d
147
148 Entire directories may also be excluded:
149 [mydpackage]
150 exclude=mydpackage/brokenpackage
151
152 The 'exclude' setting is useful in concert with versioning, described in a later
153 section.
154
155 When using GDC on POSIX, it is also possible to build shared libraries (.so
156 files). To specify that a shared library should be built, set the 'shared'
157 option in the library's section:
158 [mydpackage]
159 shared
160
161 You can set the .so file's version extension (the 1.2.3 in .so.1.2.3) with the
162 soversion setting:
163 [mydpackage]
164 shared
165 soversion=3.2.1
166
167 = SOURCE LIBRARIES =
168
169 Source libraries are libraries which are not compiled until they are used in a
170 binary. They are installed in their source form. Otherwise, they act identically
171 to normal libraries. A source library may be specified by setting the 'type'
172 setting to 'sourcelibrary':
173 [mydpackage]
174 type=sourcelibrary
175
176 = SPECIAL SECTIONS =
177
178 It is also possible to create sections which are not associated with compiling
179 a binary or library. These sections are given names starting with a '+', such
180 as:
181 [+generate]
182
183 The utility of these sections will be seen below, in the section on hooks.
184
185
186 == INSTALLATION ==
187
188 DSSS is capable of installing binaries and libraries to a predetermined
189 directory, usually the prefix in which it is installed. When libraries are
190 installed in this way, they will be usable by DSSS without being explicitly
191 specified.
192
193 If a section should be built but not installed, set the 'noinstall' setting:
194 [test.d]
195 noinstall
196
197
198 == DEPENDENCIES ==
199
200 The primary reason that DSSS exists is to make handling dependencies easier. To
201 this end, is is never necessary to explicitly specify a dependency upon a
202 library which is itself set up to use DSSS. Because DSSS traces D imports and
203 keeps an Internet-accessible repository of package information, installing the
204 dependencies which are supported by DSSS is as easy as typing:
205 $ dsss net deps
206
207 However, dependencies on non-DSSS D libraries or C libraries can be more
208 complicated.
209
210 = INCLUDE PATHS =
211
212 It is possible to specify include paths in the 'buildflags' settings. Import
213 paths are specified with the -I flag:
214 buildflags=-I../prerequisite/import
215
216 = PREREQUISITE LIBRARIES =
217
218 Library search paths are specified with the -S flag:
219 buildflags=-S../prerequisite/lib
220
221 Libraries can be explicitly linked in with the -ll flag. -ll works similarly to
222 -l in most compilers. On POSIX and similar platforms, a flag such as
223 -ll<library>
224 will link in a library named
225 lib<library>.a (or lib<library>.so)
226
227 On Windows (except GDC), the same flag will link a library named
228 <library>.lib
229
230 Libraries linked in with the -ll flag are searched for in the search paths
231 specified by the -S flag.
232
233 The -ll flag is only useful for explicitly linking libraries into binaries. If
234 the DSSS-implemented library depends on a non-DSSS library, the dependency must
235 be specified in a .d file which is part of the DSSS-implemented library. This
236 is done with the 'link' pragma, which must always be specified within
237 version(build):
238 version (build) {
239     pragma(link, "example");
240 }
241
242 The above example will cause any binary linked against the DSSS-implemented
243 library to link against the library named libexample.a (or example.lib on
244 Windows).
245
246
247 == HOOKS ==
248
249 DSSS can run arbitrary commands while building software. There are a number of
250 points at which commands can be run: before and after building, before and after
251 installing, and before and after cleaning up. These commands are added to
252 'prebuild', 'postbuild', 'preinstall', 'postinstall', 'preclean' and 'postclean'
253 lines, respectively.
254
255 Hook commands can be anything which can be run on the shell of the host system,
256 such as:
257 prebuild = echo Hello
258
259 Any number of hook commands may be strung together between semicolons:
260 prebuild = echo Hello ; echo World
261
262 And may span multiple lines by ending each line with a backslash:
263 prebuild = echo \
264     Hello ; \
265     echo World
266
267
268
269 There are also a number of special, builtin commands available.
270
271 = warn and error =
272
273 A warning or error condition can be specified by the hook commands 'warn' and
274 'error'.
275
276 An example of 'error':
277 version (!Posix) {
278     prebuild=error Only POSIX is supported.
279 }
280
281 An example of 'warn':
282 version (Posix) {
283     prebuild=warn POSIX support is untested.
284 }
285
286 When an error hook command is run, building of course halts.
287
288 = install =
289
290 The 'install' command installs a file to the specified directory. If the
291 directory does not exist, it is created. For example:
292 postinstall = install docs/README $DOC_PREFIX
293
294 Files installed in this way are recorded, so that they may be uninstalled
295 easily.
296
297 = installdir =
298
299 'installdir' is similar to 'install', with the exception that it can install
300 entire directories (and all of their subdirectories). The /content/ of the
301 first directory will be installed into the second directory.
302
303 = cd =
304
305 The 'cd' command changes the current directory. It works exactly as on POSIX
306 and Windows shells:
307 prebuild = cd c_source ; make
308
309 It is unnecessary to return to the original directory after 'cd'ing. The
310 directory will be restored after the hook commands have finished.
311
312 = .d files =
313
314 Any .d file may be used as a command. It will be compiled and run on-the-fly:
315 prebuild = generateBindings.d
316
317 = set =
318
319 The 'set' command sets a dsss.conf file setting while DSSS is actually running.
320 The parameters are:
321 set <section>:<setting> <value>
322
323 It is also possible to omit the section from the command to set in the current
324 section:
325 set <setting> <value>
326
327 The special section '*' may be used to set a setting in all sections:
328 set *:<setting> <value>
329
330 For example,
331 set example.d:postbuild echo Hello
332
333 'set' is most useful in concert with the 'eval' command (described below), as
334 it can then be used to set dsss.conf file settings programatically. It is
335 also usable independently of 'eval', but is no better than merely specifying
336 the setting.
337
338 = add =
339
340 The 'add' command is identical to the 'set' command, except that it appends to
341 the current value instead of replacing it.
342
343 For example,
344 add example.d:postbuild World
345
346 = eval =
347
348 The 'eval' command runs a specified command, captures its output, and then runs
349 its output as a command. This allows for very general processes to be
350 encapsulated into binaries, rather than the dsss.conf file itself.
351
352 For example, imagine the scenario that some system specifics need to be detected
353 and utilized in the building of a section. There can be a program, analyze.d,
354 which does the analysis and outputs commands such as
355 add *:postbuild echo Hello
356
357 This program could be run and used with the hook command:
358 prebuild=eval analyze.d
359
360
361 == VERSIONING ==
362
363 dsss.conf files support version statements with a similar syntax to D's own
364 version statements:
365
366 version (Windows) {
367     postbuild=setupWindows.d
368 } else version (Posix) {
369     postbuild=setupPosix.d
370 }
371
372 Unlike D, dsss.conf files support negative versions:
373
374 version (!Windows) {
375     postbuild=giveUserCandy.d
376 }
377
378 dsss.conf's version statements can be used at any point in the dsss.conf file.
379 They can even conditionally include different sections:
380 version (Windows) {
381     [winlib]
382 } else version (Posix) {
383     [posixlib]
384 }
385 type = library
386
387
388 == GLOBAL SETTINGS ==
389
390 There are several settings that DSSS supports which are global. That is, they
391 are specified for the software package as a whole, rather than any section.
392 These are included at the top of the dsss.conf file. Common settings are 'name'
393 (the name of the software package) and 'version'.
394
395 There is also a global setting available to specify which sections should be
396 built normally, 'defaulttargets'. Without it, all sections will be built by
397 default. The section list is simply separated by spaces:
398 defaulttargets=xlib xbin
399
400 It is also possible to specify global settings later in the dsss.conf file by
401 adding an empty section header:
402 []
403 name=exampleSoft
404
405
406 == DEFAULT SETTINGS ==
407
408 It is possible to create default settings with a special "*" section. This is
409 most useful for settings such as 'buildflags':
410
411 [*]
412 buildflags=-O
413
414 Note that any settings in a named section will override those in "*" sections.
415 For example, in this situation:
416
417 [*]
418 buildflags=-O
419
420 [mydlib]
421 buildflags+=-release
422
423 mydlib's buildflags are only "-release".
424
425
426 == ADVANCED FEATURES ==
427
428 There are several advanced features of DSSS which do not need any modification
429 to the dsss.conf file to use.
430
431 The flag '--test', when passed to `dsss build`:
432 $ dsss build --test
433 will cause all of the unit tests to be run.
434
435 The flag '--doc', when passed to `dsss build`:
436 $ dsss build --doc
437 will cause API documentation for every library to be generated with CandyDoc,
438 which beautifies and organizes the documentation.
439
440
441 To-be-written:
442 == SUBDIRECTORIES ==
443 == NET INSTALLATION ==
Note: See TracBrowser for help on using the browser.