This page is a collection of tips for how to begin as a Developer working on FreeSWITCH.
FreeSWITCH source code is now hosted at GitHub.
Hosted at SignalWire GitHub:
FreeSWITCH Master - https://github.com/signalwire/freeswitch
Hosted at FreesWITCH GitHub:
FreeSWITCH Sounds - https://github.com/freeswitch/freeswitch-sounds
FreeSWITCH Contributions - https://github.com/freeswitch/freeswitch-contrib
Sofia SIP Library - https://github.com/freeswitch/sofia-sip
SpanDSP Library - https://github.com/freeswitch/spandsp
Developers must first install git: http://git-scm.com/book/en/Getting-Started-Installing-Git
Our https now requires TLS1.2. If your distro does not support this, please report this problem to them. As an alternative you can use ssh to check out packages and code with a JIRA account.
You can get the latest code by changing to your working source code directory, then:
If you only want to obtain a specific branch use:
or more simply:
The contrib area can be downloaded with:
After you check out the code, git can be configured for the FreeSWITCH project:
Syncing with Trunk
As the main trunk is undergoing lots of changes, you may from time to time want to pull changes from trunk into your local copy. This can allow you to pull in bug fixes, feature enhancements, etc. This is important in making certain that any of your changes remain compatible with the main trunk.
Delete Pulled Branch
To delete your local branch just switch back to master and then delete the topic branch:
Push to Master
If you like the changes you can merge them to your local master branch and then push them your remote repository:
- Create a fork of github.com/signalwire/freeswitch to be able to contribute pull requests.
- Create a feature branch for each new feature
- Submit pull request when feature is completed and tested
Github has put a nice website up around the pull request workflow that makes it very simple for a contributor to initiate the request, and for others to see the changes that have been made, and make comments on those changes without ever having to pull the changes to their local repository.
There are a few shortcuts you can take if the user has sent a pull request via Github. The pull request URL itself can be used to obtain a patch and apply it to your local master branch and push the changes with two easy commands. If the pull request URL is https://github.com/FreeSWITCH/FreeSWITCH/pull/2 simply append .patch to the URL to get a patch file. We can use curl to grab the patch and push it directly into our local repository with the git am command.
Add your changes to your staging area:
Diff your changes with your local repository:
Commit the changes in your staging area to your local repository:
Diff your changes with the remote repository:
Push changes to the remote repository
Git Bisect - Tracking Down Breaks and Bugs Extremely Rapidly With git
If something was working or behaving correctly before, but is not any more git has a great tool called bisect which can help find the issue with a binary tree search to find where it broke.
The syntax is:
Where bad_commit is a commit that is known to be bad (i.e. HEAD) and good_commit is a commit that was known to work. Optionally, you can specify only a specific sub path (i.e. lib/) where it broke and then it will only look at commits that affected that path or other paths. Here's an example of finding something that broke within the last 10 commits:
Once you do that you are now in bisect mode. You want to compile and test to try to reproduce the bug. Once you know if that version works or not just tell git with:
then it will move on to the next commit for you to test. If you cannot figure out if it was bad or good use 'git bisect skip' to move on to the next commit. Once it figures out what commit (or commits) would be possible to blame it will let you know. The great part is that it is far quicker than trying to do it by hand. Let's say in a worst case scenario you only know it worked 6 months ago and now its broken and there are 1000 commits in between then and now. You would in the worst case only have to test 11 different builds.
When you are done you can use:
to reset back to where you were.
In addition git bisect can find the place that it first broke on its own. If you have a script that can return if it works or doesn't work you can use:
Note that the script (my_script in the above example) should exit with code 0 if the current source code is good, and exit with a code between 1 and 127 (inclusive), except 125, if the current source code is bad.
Then you do not need to do any testing by yourself just let git find the problem commit. Once you know the problem commit there is a far higher chance your bug report will be handled faster when you can tell the developers exactly where to work.
If You Change Code You Must Branch with Git
Git is not like most other source control systems: branching is actually so easy that the recommended method of making feature changes is generally to branch. Branching allows you to make changes and commit them locally even though you most likely cannot commit them directly to FreeSWITCH Master. This also allows you more easily to preserve your changes as you upgrade FreeSWITCH. If you branch for each feature or fix you try to add to FreeSWITCH it makes submitting and updating patches far easier. Branching takes two seconds. Just run:
so for example:
will create a new branch from master for your work. You can switch to a branch by doing:
So git checkout master will change you back to master or git checkout codec_g729_windows will change to your branch. You do not need to commit your changes before changing branches, it will save your place automatically. To update a branch after you do a git pull on master you would run:
In your branch, most of the time git will figure out the proper merging for you without intervention.
Checking Out Previous Revisions
To list commits cd to where you have cloned the git repo and type:
Then to switch to that commit do:
then, if you want to go back to the master:
Note that if the revision you are trying to switch to is newer than your clone then you will need to first bring your clone up to date:
Cleaning Out Previous Revisions
Michal Bielicki: that will kill everything that is not from the current git
When making large jumps between revisions you'll need to clean your old libs and mods to avoid errors like this:
To fix this just run:
GUIs and Utilities
There are a couple user interfaces to Git available with the Git suite. These GUIs require the tcl/tk toolkits installed.
Portable graphical interface to Git. See the git-gui(1) man page.
The git repository browser. See the gitk(1) man page.
Other Cool Tools
- tig - Curses-based text GUI for git
- magit - emacs addon for git. Travis Cross says it is beyond cool!
- The Git website: http://git-scm.com/
- Git cheat sheet: http://cheat.errtheblog.com/s/git
- Git from the bottom up, very nice Git intro: http://www.newartisans.com/2008/04/git-from-the-bottom-up.html (pdf first link, second paragraph)
- Pro Git, a book on using Git that is freely available online: http://progit.org/
- Git Model: http://nvie.com/git-model
- Developer Documentation
- git commit guidelines — Essential instructions to follow before you commit your patches to the FreeSWITCH tree