Skip to content

Instantly share code, notes, and snippets.

@kuettler
Last active August 29, 2015 14:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kuettler/e907e51c14f7255e3489 to your computer and use it in GitHub Desktop.
Save kuettler/e907e51c14f7255e3489 to your computer and use it in GitHub Desktop.
Phobos Contributor Tutorial

Phobos Contributor Tutorial

You are young and brave, you use D, love D and you want to contribute a phobos bugfix. Or maybe a documentation update. You know your tools, your Linux is running. Now, what do you do?

Getting the source

First, you want to get the source. Since you want to patch the latest version of phobos, you want to get the latest dmd as well. Thus, there are four source trees you will need: dmd, druntime, phobos and dlang.org.

Use git clone to get those from github, except for phobos. Since you want to change phobos, you need to clone it on the github webpage and get a writable copy:

git clone git@github.com:<YourGitHubName>/phobos.git

Setup Documentation

In order to generate the phobos documentation later on, one symbolic link is needed:

ln -s dlang.org/web .

Optionally, you can use another terminal and run a simple webserver,

cd dlang.org/web
python -m SimpleHTTPServer

to get your documentation preview with images.

Building DMD

Building the whole thing, as described in the Building DMD wiki page, is simply a matter of

cd dmd
make -f posix.mak
cd ../druntime
make -f posix.mak DMD=../dmd/src/dmd
cd ../phobos
make -f posix.mak DMD=../dmd/src/dmd

Now you are in the phobos directory, ready to make some noise.

Working on Phobos

You want to create a pull request. Thus, you want to work on a new branch.

git checkout -b <my_new_feature>

You change the code, add some tests. Afterwards, run all unittests.

make -f posix.mak unittest

Generate the online documentation

make -f posix.mak html

and look at the files in ../web/phobos-prerelease/ or visit phobos-prerelease, if you have the webserver running.

Finally, if everything is nice and shiny, commit locally.

Pushing Upstream

Now it is about time to let the world know. Push your branch to your github account.

git push -f origin <my_new_feature>

At this point you can create a pull request on the github webpage.

Rework Your Changes

Eventually, someone will look at your work and suggest a few changes. At this point in time, phobos will have changed already and you want your changes to sit on top of the latest version, of course. Thus, you need to get the latest changes in your master branch.

git remote add upstream https://github.com/D-Programming-Language/phobos.git
git checkout master
git pull --ff-only upstream master

Now simply rebase you branch to master. Any conflicts are your.

git checkout <my_new_feature>
git rebase master

Incorporate the desired changes, test and commit.

Once you are done, after a long back and forth, you might squash your local commits for bonus points

git rebase -i HEAD~4

(the number 4 is just an example) and push again

git push -f origin <my_new_feature>

and github and the friendly D contributors will take it from here.

Once you did all of the above right, D will be a tiny little bit better, because of you.

Disclaimer

It is January 2015, all of the above will change eventually.

All of the above comes from either the D wiki or can be found elsewhere very easily. Still, being a first time contributor myself, I spend some time getting all pieces together. Now, there is one more document for you to read.

:-D

@dmi7ry
Copy link

dmi7ry commented Jan 10, 2015

You you know your tools

twice "you"

@kuettler
Copy link
Author

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment