= Installing Phobos and Tango Side by Side = == The Simple Route: use Tangobos == Tangobos represents the phobos API running within Tango. You can download Tangobos as part of a Tango bundle, or get it from the [http://www.dsource.org/projects/tangobos/ source] instead. See [TangobosInfo this page] for more on Tangobos. == Alternate Routes == ''Methods 1 through 3 are about DMD on Windows. Method 4 for DMD on Linux. Tips for other setups (GDC, ...) are welcome.'' ''NB: Some of this may be out of date for newer compiler releases, where the -defaultlib switch can be utilized.'' == Method 0: Two Installations == The simplest way to have both Phobos and Tango installed is to have two installations of the D compiler, each with their own sc.ini. However, this is annoying for any number of reasons. But it works "OK" with GDC as well as DMD. == Method 1 (windows): Environment variables == Another approach is to configure DMD via environment variables, and leave sc.ini almost empty. === Edit sc.ini === The sc.ini file looks something like this: {{{ #!ini [Environment] LIB="%@P%\..\lib";\dm\lib DFLAGS="-I%@P%\..\src\phobos" LINKCMD=%@P%\..\..\dm\bin\link.exe }}} The LIB and DFLAGS settings are the important ones, with respect to configuring Tango. We want to comment them out: {{{ #!ini [Environment] ;LIB="%@P%\..\lib";\dm\lib ;DFLAGS="-I%@P%\..\src\phobos" LINKCMD=%@P%\..\..\dm\bin\link.exe }}} === Write batch files === Create two batch files, call them ''dmd-phobos.bat'' and ''dmd-tango.bat''. In each, set the DFLAGS and LIB environment variables to appropriate values. Below are some reasonable examples. You will want to change the D_ROOT and TANGO_ROOT variables to suit your own system. {{{ #!bat @echo off REM dmd-phobos.bat Set D_ROOT=C: Set PATH=%D_ROOT%\dmd\bin;%D_ROOT%\dm\bin;%PATH% Set DFLAGS=-I%D_ROOT%\dmd\src\phobos Set LIB=%D_ROOT%\dmd\lib;%D_ROOT%\dm\lib echo Environment configured for DMD/Phobos }}} {{{ #!bat @echo off REM dmd-tango.bat Set D_ROOT=C: Set TANGO_ROOT=C:\tango Set PATH=%D_ROOT%\dmd\bin;%D_ROOT%\dm\bin;%PATH% Set DFLAGS=-I%TANGO_ROOT% -version=Tango Set LIB=%TANGO_ROOT%\lib echo Environment configured for DMD/Tango }}} === Configuring Rebuild === Gregor Richards recently added a feature to his [http://dsource.org/projects/dsss/wiki/Rebuild Rebuild] utility allowing users to override the "default" profile with the REBUILDPROFILE environment variable. If your "default" profile is set to ''dmd-win'', simply add this to ''dmd-tango.bat'': {{{ #!bat Set REBUILDPROFILE=dmd-win-tango }}} === Configuring shortcuts === Now that you have your two batch files, create a shortcut for each of them. Set the "Target" field of the DMD-Phobos shortcut to this: {{{ %comspec% /k dmd-phobos.bat }}} And set the "Target" of the DMD-Tango shortcut to this: {{{ %comspec% /k dmd-tango.bat }}} The COMSPEC environment variable always points to the command prompt utility. The /k option causes it to run a program before giving the user the prompt. == Method 2 (windows, possibly posix): Using Separate INI Files == You can also set up two separate ''sc.ini'' files: one for compiling Phobos programs, and one for compiling Tango programs. This will allow you to switch between the two on the command-line. This should also work on POSIX platforms with ''dmd.conf'', but it has not been tested. 1. Copy the files that came in DMD's ''lib'' directory to a peer directory called ''lib.phobos''. * '''Note''': you will want to keep the ''lib'' directory for storing shared libraries. 2. Install Tango so that its library files are in a peer directory called ''lib.tango''. 3. Copy-and-paste your ''sc.ini'' file to new files named ''sc.phobos.ini'' and ''sc.tango.ini''. Delete the old ''sc.ini'' file after you have done this. 4. Edit the ''LIB='' line of ''sc.phobos.ini'' to read: {{{ #!ini LIB="%@P%\..\lib.phobos";"%@P%\..\lib";"%@P%\..\..\dm\lib" }}} 5. Edit the ''LIB='' line of ''sc.tango.ini'' to read: {{{ #!ini LIB="%@P%\..\lib.tango";"%@P%\..\lib";"%@P%\..\..\dm\lib" }}} 6. Edit the ''DFLAGS='' line of ''sc.tango.ini'' to read: {{{ #!ini DFLAGS=-I%@P%\..\tango }}} 7. Edit the ''inifile=...'' line in the ''dmd-win'' file in your Rebuild configuration directory to read: {{{ #!ini inifile=sc.phobos.ini }}} 8. Edit the ''inifile=...'' line in the ''dmd-win-tango'' file in your Rebuild configuration directory to read: {{{ #!ini inifile=sc.tango.ini }}} This should complete the changes. To compile a Phobos program, add {{{-dc=dmd-win}}} to your Rebuild command line, and to compile a Tango program, add {{{-dc=dmd-win-tango}}}. The default compiler profile is indicated by the ''default'' file in your Rebuild configuration directory. You can also set the profile using the aforementioned environment variable. == Method 3 (windows): NTFS Junctions (two installations) == Prerequisites: 1. Windows 2000 or above (not 9x!). 2. You must use the NTFS file system. 3. http://www.microsoft.com/technet/sysinternals/FileAndDisk/Junction.mspx 4. DMD + Phobos from Digital Mars 5. DMD + Tango from the Tango downloads page Steps: 1. Extract "junction.exe" into your PATH, I simply extracted it into C:\Windows. 2. Extract DMD/Phobos into c:\dmd1_phobos. 3. Extract DMD/Tango into c:\dmd1_tango. 4. Open notepad, copy/paste this into a new file, "dmd1_phobos.bat": {{{ @echo off junction -d c:\dmd junction c:\dmd c:\dmd1_phobos }}} 5. Repeat step 4, but call it "dmd1_tango.bat" and replace "c:\dmd1_phobos" with "c:\dmd1_tango". To switch between Phobos and Tango, simply double click the corresponding batch file. The location of the batch files does not matter. I recommend creating shortcuts and placing them on your desktop, and binding them to shortcuts in your IDE. == Method 4 (posix): Switching dmd.conf, multiple import directories == Install DMD, with a common import directory (empty for now) and a separate phobos import directory, e.g.: $PREFIX/include/d (this is for any libraries you install and want available regardless of whether tango or phobos is in use) $PREFIX/include/d-phobos Edit your dmd.conf file to include both these directories (-I.../d -I.../d-phobos) and name it dmd.conf.phobos. Install tango, and put the imports (object.di, std, tango) in a third import directory, e.g.: $PREFIX/include/d-tango Edit another dmd.conf file, dmd.conf.tango, as above (but with d-tango not d-phobos), as well as what the tango install instructions say. Make sure you have both tango and phobos libraries installed (from tango 0.99.3 or later). Now just switch between the two dmd.conf files to switch from tango to phobos and back. Here's one script using symlinks: (Paste this into an executable script called dmd-switch-to and put it inside your $PATH. Make sure to change the DMDHOME variable value. Make your dmd.conf files dmd.conf.tango & dmd.conf.phobos .) {{{ #!bash #!/bin/sh DMDHOME="/path/to/dmd" case $1 in tango) if [ -f $DMDHOME/bin/dmd.conf.tango ] ; then ln -fs $DMDHOME/bin/dmd.conf.tango $DMDHOME/bin/dmd.conf fi ;; phobos) if [ -f $DMDHOME/bin/dmd.conf.phobos ] ; then ln -fs $DMDHOME/bin/dmd.conf.phobos $DMDHOME/bin/dmd.conf fi ;; status) if [ -e $DMDHOME/bin/dmd.conf ] ; then ls -al $DMDHOME/bin/dmd.conf | awk '{ print $10 }' else echo "${DMDHOME}/bin/dmd.conf does not exist" fi ;; esac }}} Here's another (very similar functionally, but it'll tell you what's currently in use) which renames the files: [http://diggory.hardy.googlepages.com/dmd-switch] (Edit the PREFIX variable; make one of your dmd.conf files dmd.conf and the other dmd.conf.tango/phobos .)