| 1 |
This document intends to explain how DSSS works on a low level, its theory of |
|---|
| 2 |
operation, and how it is implemented. It is assumed that the reader is |
|---|
| 3 |
experienced with the D language, build tools such as bud and rebuild, and DSSS. |
|---|
| 4 |
|
|---|
| 5 |
DSSS' function is simple in principle, but rather complex in practice. |
|---|
| 6 |
Essentially, the goal of DSSS is to minimize the amount of information the user |
|---|
| 7 |
needs to provide to compile and use D software. Some of the ways it |
|---|
| 8 |
accomplishes this is with transparent dependency management, library handling |
|---|
| 9 |
and consistent installation. This documentation will divide the process into |
|---|
| 10 |
three section: Building, installing, and the 'net' feature. |
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
Building |
|---|
| 14 |
-------- |
|---|
| 15 |
|
|---|
| 16 |
There are three classes of builds: binaries, libraries, and non-compilation |
|---|
| 17 |
sections. Since the non-compilations sections (sourcelibrary and extra |
|---|
| 18 |
sections) are not built, they are not discussed here. |
|---|
| 19 |
|
|---|
| 20 |
In either binaries or libraries, the list of files to be passed into the build |
|---|
| 21 |
tool is generated: |
|---|
| 22 |
1) If the section name is a file name, that file is the only element. |
|---|
| 23 |
2) If the section name is a directory name, all files in that directory or any |
|---|
| 24 |
of its subdirectories which are: |
|---|
| 25 |
* Not covered by a more specific directory-named section and |
|---|
| 26 |
* Not in the 'exclude' variable for the section. |
|---|
| 27 |
|
|---|
| 28 |
The target file name (when not specified) is generated. The exact semantics |
|---|
| 29 |
behind this generation is discussed in the next section. |
|---|
| 30 |
|
|---|
| 31 |
If a library is being built, .di (D Interface) files are generated from every |
|---|
| 32 |
file which is to be built into the library. These .di files should be generated |
|---|
| 33 |
by the compiler, but due to compiler limitations, they are generated by |
|---|
| 34 |
duplicating the .d files. The .di files then have pragmas added such that they |
|---|
| 35 |
are associated with the proper libraries, such as: |
|---|
| 36 |
version (build) { |
|---|
| 37 |
pragma(link, "SDG-foolib"); |
|---|
| 38 |
} |
|---|
| 39 |
|
|---|
| 40 |
|
|---|
| 41 |
Target Name Generation |
|---|
| 42 |
---------------------- |
|---|
| 43 |
|
|---|
| 44 |
With binaries, the generated name is simply the section name without the .d |
|---|
| 45 |
extension, and with a .exe extension on Windows. Libraries have a more complex |
|---|
| 46 |
naming scheme. |
|---|
| 47 |
|
|---|
| 48 |
Library naming is based around the standard library naming convention of the |
|---|
| 49 |
host operating system, so on Posix systems libraries are named lib<something>.a |
|---|
| 50 |
or lib<something>.so.<soversion>, and on Windows they are named |
|---|
| 51 |
<something>.lib. The middle part (<something>) contains a "host specifier" and |
|---|
| 52 |
the name of the package that the library contains. The host specifier is a |
|---|
| 53 |
character sequence which encodes the type of the library and the required host |
|---|
| 54 |
compiler. The specifier is in the form: |
|---|
| 55 |
[S]D{D,G} |
|---|
| 56 |
|
|---|
| 57 |
The 'S' specifies a static library, it is elided for shared libraries. The |
|---|
| 58 |
first 'D' specifies that the library is in D. The second D or G specifies that |
|---|
| 59 |
the library requires DMD or GDC, respectively. |
|---|
| 60 |
|
|---|
| 61 |
After the host specifier is a hyphen, then the package specifier. The package |
|---|
| 62 |
specifier is simply the D package that the library contains, with dots replaced |
|---|
| 63 |
with hyphens. |
|---|
| 64 |
|
|---|
| 65 |
This library target name generation is beneficial because it creates no |
|---|
| 66 |
conflicts, and makes the contents of the libraries immediately obvious. |
|---|
| 67 |
|
|---|
| 68 |
|
|---|
| 69 |
Installing |
|---|
| 70 |
---------- |
|---|
| 71 |
|
|---|
| 72 |
DSSS installation simply involves going through each section and copying the |
|---|
| 73 |
produced binaries to the appropriate paths. .di files are copied into the |
|---|
| 74 |
import path, .lib or .a files are copied into the lib path, and binary programs |
|---|
| 75 |
are copied into the binary path. These paths, by default are: |
|---|
| 76 |
Import path: <DSSS' prefix>/include/d |
|---|
| 77 |
Lib path: <DSSS' prefix>/lib |
|---|
| 78 |
Bin path: <DSSS' prefix>/bin |
|---|
| 79 |
|
|---|
| 80 |
DSSS keeps track of everything it intalls for a given software package in the file: |
|---|
| 81 |
<DSSS' prefix>/share/dsss/manifest/<package name>.manifest |
|---|
| 82 |
so that it can be uninstalled in the future. |
|---|
| 83 |
|
|---|
| 84 |
The lib and import paths are also added to the build program's command line at |
|---|
| 85 |
build time, such that a tool being built with DSSS can use previously-installed |
|---|
| 86 |
libraries. |
|---|
| 87 |
|
|---|
| 88 |
There is also an 'install' pseudocommand, to be used in a preinstall or |
|---|
| 89 |
postinstall setting, which will install any file to any path, adding it to the |
|---|
| 90 |
manifest file. |
|---|
| 91 |
|
|---|
| 92 |
|
|---|
| 93 |
The 'net' Feature |
|---|
| 94 |
----------------- |
|---|
| 95 |
|
|---|
| 96 |
`dsss net` is one of DSSS' most alluring features. It allows the user to |
|---|
| 97 |
easily install D software packages, and also resolve depenencies. |
|---|
| 98 |
|
|---|
| 99 |
The mechanism behind the 'net' feature is quite simple. There is a central |
|---|
| 100 |
'sources' repository which DSSS uses. The list of source repositories is stored |
|---|
| 101 |
in the file |
|---|
| 102 |
<DSSS' prefix>/etc/dsss/list.list |
|---|
| 103 |
|
|---|
| 104 |
When a source list repository is selected, DSSS downloads three files from it: |
|---|
| 105 |
source.list, pkgs.list and mirrors.list. The function of the files are as |
|---|
| 106 |
follows: |
|---|
| 107 |
|
|---|
| 108 |
source.list |
|---|
| 109 |
Associates software package names with upstream repositories, in svn or |
|---|
| 110 |
.tar.gz format, as well as associating necessary patch files with packages. |
|---|
| 111 |
This file is maintained manually. |
|---|
| 112 |
|
|---|
| 113 |
pkgs.list |
|---|
| 114 |
Associates packages with the latest version numbers, and lists static |
|---|
| 115 |
dependencies of modules upon packages, and packages on other packages. This |
|---|
| 116 |
file includes the list of modules provided by any package, e.g.: |
|---|
| 117 |
wx/Button.d 0.10 wxd |
|---|
| 118 |
This file is generated. See below. |
|---|
| 119 |
|
|---|
| 120 |
mirrors.list |
|---|
| 121 |
Simply lists mirrors, alternative locations to download software packages |
|---|
| 122 |
from. This file is maintained manually. |
|---|
| 123 |
|
|---|
| 124 |
When the command `dsss net install <package>` is given, DSSS looks in |
|---|
| 125 |
source.list to find the upstream repository of the package to install from. It |
|---|
| 126 |
then downloads the package, applies any patches necessary, traces dependencies |
|---|
| 127 |
(explained below), then simply runs `dsss build` and `dsss install`. |
|---|
| 128 |
|
|---|
| 129 |
Dependencies are also traced by the `dsss net` feature, through `dsss net |
|---|
| 130 |
install` or `dsss net deps`. The process of seeking dependencies is simple: |
|---|
| 131 |
|
|---|
| 132 |
1) Every source file in the current package is parsed for imports. |
|---|
| 133 |
2) Imports which correspond to modules which are not installed are looked up in |
|---|
| 134 |
pkgs.list, and associated with software package names. |
|---|
| 135 |
3) Those packages which were found in step 2 are installed via `dsss net |
|---|
| 136 |
install`. |
|---|
| 137 |
|
|---|
| 138 |
|
|---|
| 139 |
pkgs.list |
|---|
| 140 |
--------- |
|---|
| 141 |
|
|---|
| 142 |
The pkgs.list file is generated by an aptly named program, pkgslist.d. This |
|---|
| 143 |
program is available in DSSS' subversion repository. Its function is: |
|---|
| 144 |
|
|---|
| 145 |
1) Download all software installable via DSSS (this tool also generates DSSS' |
|---|
| 146 |
mirrors). |
|---|
| 147 |
2) For each software package downloaded, using the same algorithm as sss.build, |
|---|
| 148 |
find all of the D files (not library files or binary programs) the package |
|---|
| 149 |
would install. |
|---|
| 150 |
3) In the pkgs.list file, associate the D files found in step 2 with the |
|---|
| 151 |
appropriate software packages. |
|---|