Using Git on Windows
Contents
Preamble
On Windows Git runs via an MSYS shell which is installed with Git. But to run the DMD test-suite you need to have an MSYS installation that has some tools which are missing from the Git MSYS system. Therefore you need a separate MSYS install. Additionally, using the MSYS shell from a Windows command prompt is difficult (lack of easy copy and paste functionality, tiny fonts, limited window size, etc..).
By using Console2 you can improve your workflow with Git.
Requirements
Download Console2 and extract it somewhere.
Download MSYS and install it.
Setting up Console2
Set up a Git Tab
Run Console2, open the Edit->Settings menu, and select the Tabs tree on the left. Click on the Add button and then set a Title (e.g. Git). Set the Shell to C:\Program Files\Git\bin\sh.exe --login -i (or wherever you've installed Git). You can set the Startup dir so you're always ready to cd to a project and start using Git.
You can now use CTRL+F1 to open this tab (configurable in settings).
Set up an MSYS Tab
Click the Add button again, and set the Title to e.g. msys. Set the Shell to C:\msys\1.0\bin\sh.exe --login -i (or wherever you've installed MSYS). Note that using the Startup Dir may not work, but there's a workaround.
Working with git-head and release versions of DMD, Druntime and Phobos
A simple way to work with both an existing D installation and git-head is to have two DMD folders, both of which are in the PATH environment variable, e.g.:
C:\dmd2 # A release version of DMD
C:\dmd-git # the src subdir inside contains git-head of dmd, druntime and phobos
To create and fully prepare the dmd-git folder you can take these steps:
- Fork DMD/Druntime/Phobos on Github (fork the ones you intend working on, or all if you want to)
- Copy the existing dmd2 dir and rename it to dmd-git
- Delete everything in the dmd-git\src directory
- Open the Git Tab (CTRL+F1), enter the src directory and clone your forks (replace YourUserName accordingly):
cd /c/dmd-git/src
git clone git@github.com:<YourUserName>/dmd.git
cd dmd
git remote add upstream https://github.com/D-Programming-Language/dmd
cd..
git clone git@github.com:<YourUserName>/druntime.git
cd druntime
git remote add upstream https://github.com/D-Programming-Language/druntime
cd..
git clone git@github.com:<YourUserName>/phobos.git
cd phobos
git remote add upstream https://github.com/D-Programming-Language/phobos
cd..
Then set C:\dmd2\windows\bin and C:\dmd-git\windows\bin so they're both in PATH. You can put the release version in PATH before the git version so it overrides it. When you work on the git-head version simply rename the release version so the git-head version is picked up when running dmd from a console window.
Set up the MSYS startup dir and aliases
You should have a profile file in the C:\msys\1.0\etc folder. Open it in a text editor and change cd $HOME$ to wherever you're keeping a local clone of DMD, e.g.:
cd /c/dmd-git/src/dmd/test
You can also add some aliases to simplify running the DMD test-suite:
alias tclean="make clean"
alias tall="make"
alias tfail="make DMD=/c/dmd-git/windows/bin/dmd run_fail_compilation_tests"
alias tcomp="make DMD=/c/dmd-git/windows/bin/dmd run_compilable_tests"
alias trun="make DMD=/c/dmd-git/windows/bin/dmd run_runnable_tests"
Now when you open the MSYS Tab (e.g. CTRL+F2) you can immediately begin running the test-suite by entering tall.
Editing Environment Variables
You can use the freeware Rapid Environment Editor to edit the PATH and other environment variables. Remember that after editing the environment variables you may need to re-login so the system can pick the changes up.