59 | | 1. [wiki:SourceDownloads Download or check out] Tango sources. |
---|
60 | | 2. In what follows we assume you've checked out tango into `C:\dmd\import`. If you chose another path, consider avoiding names that contain spaces or parenthesis as these cause problems with some windows command line tools. |
---|
61 | | 3. Edit `C:\dmd\bin\sc.ini` as in point 3 of previous section. |
---|
62 | | 4. Build ''tango-base-dmd.lib'' by running ''build-dmd.bat'' in the lib folder. This requires the Digital Mars C compiler and the Digital Mars ''make'' utility located in `/dm/bin` which must be the first 'make' executable encountered in the search path. These tools are both provided by the dmc.zip package linked off the DMD download page: http://www.digitalmars.com/d/dcompiler.html |
---|
63 | | 5. In the same folder, also run ''build-win32.bat'' to create the ''tango-win32-dmd.lib''. |
---|
64 | | 6. In the same folder, finish building Tango by running ''build-tango.bat'' to create the ''tango-user-dmd.lib''. |
---|
65 | | 7. If you have ''tango-base-dmd.lib'' already in your dmd/lib (or where your DMD looks for libraries) directory, it is recommended to back this up (or any other former runtime .lib files that might be replaced). |
---|
66 | | 8. Place the ''tango-base-dmd.lib'' ''tango-user-dmd.lib'' and ''tango-win32-dmd.lib'' libraries into dmd/lib for the D compiler. |
---|
67 | | 9. Please note that while ''tango-base-dmd.lib'' and ''tango-win32-dmd.lib'' will be automatically linked, ''tango-user-dmd.lib'' will not. This is to allow for configurations where ''tango-user-dmd.lib'' does not exist (such as when using Bud or Rebuild). To ensure that ''tango-user-dmd.lib'' is linked to an application, either of the following two methods should work. |
---|
68 | | * a. Add ''-L+tango-user-dmd.lib'' to the end of the DFLAGS line in ''sc.ini''. |
---|
69 | | * b. Add the following to files being compiled: |
---|
70 | | {{{ |
---|
71 | | pragma(lib, "tango-user-dmd.lib"); |
---|
72 | | }}} |
---|
73 | | * c. Include ''tango-user-dmd.lib'' in the list of files to be compiled when using dmd.exe. |
---|
| 59 | Note that these instructions are applicable to the current trunk (post-0.99.8 |
---|
| 60 | release) and DMD 1.046 or higher. They may not apply to older releases of |
---|
| 61 | Tango and/or DMD. |
---|
| 62 | |
---|
| 63 | Also note that these instructions assume a pristine environment. If you wish |
---|
| 64 | to install Tango into an already configured compiler, make sure you follow the |
---|
| 65 | instructions for "Manual Install" in the section on Compiling. |
---|
| 66 | |
---|
| 67 | === Prerequisites === |
---|
| 68 | |
---|
| 69 | You will need both the DigitalMars D and C compilers. You can download DMD |
---|
| 70 | from the |
---|
| 71 | [http://www.digitalmars.com/d/download.html DigitalMars D download page]. |
---|
| 72 | If you are compiling trunk, you will need DMD version 1.045 or higher. |
---|
| 73 | Note that Tango is not currently compatible with D 2.x. |
---|
| 74 | |
---|
| 75 | You can download DMC from the same link; specifically, you want `dmc.zip`. |
---|
| 76 | |
---|
| 77 | Next, extract the DMD and DMC compilers somewhere. For our purposes, we will |
---|
| 78 | assume both were extracted to the same directory. You should have a dm |
---|
| 79 | directory and a dmd directory. Most paths in this guide are relative to the |
---|
| 80 | directory where you extracted them. |
---|
| 81 | |
---|
| 82 | Finally, you will need the Tango source. You can obtain this from |
---|
| 83 | [wiki:SourceDownloads]. Whether you download a snapshot or check out from |
---|
| 84 | source control, you should ensure the `tango` directory (containing |
---|
| 85 | `README.txt`) is located at `dmd\windows\tango`. |
---|
| 86 | |
---|
| 87 | === Bootstrap Tango === |
---|
| 88 | |
---|
| 89 | This only needs to be done once; once you have compiled Tango at least once, |
---|
| 90 | this step is unnecessary. |
---|
| 91 | |
---|
| 92 | Firstly, delete (or rename) the `dmd\src\phobos` directory, then create a new, |
---|
| 93 | empty `dmd\src\phobos` directory. Copy the `dmd\windows\tango\user\object.di` |
---|
| 94 | file to `dmd\src\phobos\object.di`. |
---|
| 95 | |
---|
| 96 | Once Tango has been installed, your temporary bootstrap `dmd\src\phobos` |
---|
| 97 | directory can be removed. |
---|
| 98 | |
---|
| 99 | === Compile === |
---|
| 100 | |
---|
| 101 | First, ensure that the D compiler you are installing Tango into is the first D |
---|
| 102 | compiler on your system `PATH`. If you do not have any other copies of DMD |
---|
| 103 | installed on your system, you don't need to worry about this. |
---|
| 104 | |
---|
| 105 | You also need to ensure that `dm\bin` is on your `PATH`. |
---|
| 106 | |
---|
| 107 | If you are unsure as to what your PATH should look like, the following |
---|
| 108 | batch file configures a minimal PATH for a Windows XP system, and opens a |
---|
| 109 | command prompt: |
---|
| 110 | |
---|
| 111 | {{{ |
---|
| 112 | SET DMD=\PATH\TO\DMD |
---|
| 113 | SET DMC=\PATH\TO\DMC |
---|
| 114 | |
---|
| 115 | SET PATH=%DMD%\windows\bin;%DMC%\bin;%SYSTEMROOT%\system32;%SYSTEMROOT%;%SYSTEMROOT%\system32\Wbem |
---|
| 116 | |
---|
| 117 | START CMD |
---|
| 118 | }}} |
---|
| 119 | |
---|
| 120 | Note that you will have to change the first two lines to reference the correct |
---|
| 121 | directories. |
---|
| 122 | |
---|
| 123 | ==== Automated Build and Install ==== |
---|
| 124 | |
---|
| 125 | This is recommended for end users who are installing into a pristine |
---|
| 126 | environment. Note that this will overwrite your `sc.ini` file. See the |
---|
| 127 | next section for details on how to do this manually. |
---|
| 128 | |
---|
| 129 | Go to `dmd\windows\tango\build` and execute `build.bat`. DO NOT |
---|
| 130 | execute this batch file from a different working directory, or compilation |
---|
| 131 | will fail. |
---|
| 132 | |
---|
| 133 | Once this is done, proceed to the Test section to verify the install worked. |
---|
| 134 | |
---|
| 135 | Note that if you need to see it, the original unmodified `sc.ini` is available |
---|
| 136 | as `sc.ini.phobos`. |
---|
| 137 | |
---|
| 138 | ==== Manually Build and Install ==== |
---|
| 139 | |
---|
| 140 | This is recommended for end users who are installing into an existing |
---|
| 141 | compiler, and for developers who wish to work on Tango itself. |
---|
| 142 | |
---|
| 143 | The first step is to go to `dmd\windows\tango\build` and execute |
---|
| 144 | `build-dmd.bat`. This will build the Tango runtime for DMD. This will |
---|
| 145 | produce the following files (relative to the `build` directory): |
---|
| 146 | |
---|
| 147 | * `libs\tango-base-dmd.lib` |
---|
| 148 | * `libs\tango-base-dmd-dbg.lib` |
---|
| 149 | |
---|
| 150 | These should be copied into `dmd\windows\lib`. |
---|
| 151 | |
---|
| 152 | Second, you can optionally build the Tango user library as a static library. |
---|
| 153 | This will speed compilation of programs. If you want to do this, again go to |
---|
| 154 | `dmd\windows\tango\build` and execute `build-tango.bat`. Do not be alarmed if |
---|
| 155 | you do not see any output for some time; the program just has a surprisingly |
---|
| 156 | large output buffer! |
---|
| 157 | |
---|
| 158 | The result of this, `libs\tango-user-dmd.lib` should be copied to |
---|
| 159 | `dmd\windows\lib`. |
---|
| 160 | |
---|
| 161 | Finally, you need to configure DMD to use Tango. To do this, open the |
---|
| 162 | `dmd\windows\bin\sc.ini` file in a text editor. One line of this file will |
---|
| 163 | look like this: |
---|
| 164 | |
---|
| 165 | {{{ |
---|
| 166 | DFLAGS="-I%@P%\..\..\src\phobos" |
---|
| 167 | }}} |
---|
| 168 | |
---|
| 169 | You want to delete `"-I%@P%\..\..\src\phobos"` and replace it with |
---|
| 170 | `"-I%@P%\..\tango\user"`. |
---|
| 171 | |
---|
| 172 | You will also want to add the following to the `DFLAGS` setting (note: you do |
---|
| 173 | not need to insert these within quotes; the quotes surround the `-I` flag to |
---|
| 174 | guard against spaces in the path.) |
---|
| 175 | |
---|
| 176 | {{{ |
---|
| 177 | -version=Tango -defaultlib=tango-base-dmd.lib -debuglib=tango-base-dmd-dbg.lib |
---|
| 178 | }}} |
---|
| 179 | |
---|
| 180 | If you compiled the user library to a static library, you can add the |
---|
| 181 | following to `DFLAGS` as well. Please note that this can conflict with |
---|
| 182 | automated build tools if you intend to modify Tango itself. |
---|
| 183 | |
---|
| 184 | {{{ |
---|
| 185 | -L+tango-user-dmd.lib |
---|
| 186 | }}} |
---|
| 187 | |
---|
| 188 | === Test === |
---|
| 189 | |
---|
| 190 | Create a file called `happy.d` (in `dmd\windows` is fine) with the |
---|
| 191 | following contents: |
---|
| 192 | |
---|
| 193 | {{{ |
---|
| 194 | #!d |
---|
| 195 | import tango.io.Stdout; |
---|
| 196 | |
---|
| 197 | void main() |
---|
| 198 | { |
---|
| 199 | Stdout("Don't Worry, Be Happy!").newline; |
---|
| 200 | } |
---|
| 201 | }}} |
---|
| 202 | |
---|
| 203 | Compile with the command `dmd happy` and run it to ensure it correctly |
---|
| 204 | outputs "Don't Worry, Be Happy!" and terminates without error. |
---|
| 205 | |
---|
| 206 | If you installed manually and chose not to add the `-L+tango-user-dmd.lib` |
---|
| 207 | switch to `DFLAGS`, you will need to compile with |
---|
| 208 | `dmd -L+tango-user-dmd.lib happy`. |
---|
| 209 | |
---|
| 210 | === Clean-Up === |
---|
| 211 | |
---|
| 212 | You can now remove the following superfluous files and directories if you desire: |
---|
| 213 | |
---|
| 214 | * `dmd\freebsd` |
---|
| 215 | * `dmd\linux` |
---|
| 216 | * `dmd\man` |
---|
| 217 | * `dmd\osx` |
---|
| 218 | * `dmd\src\phobos` (the temporary bootstrap directory you created) |
---|
| 219 | |
---|
| 220 | With that, you are done! You can update to the latest trunk version of Tango |
---|
| 221 | by updating the `dmd\windows\tango` directory, and then following the |
---|
| 222 | instructions for compilation. |
---|