Mac - Building and Packaging

This page describes how to setup a build environment on OSX. 

Setup a build environment

Xcode

You need Xcode and it's command line tools. Download Xcode from App Store, then start Xcode to approve the license agreement.

Install Command Line Tools:

xcode-select --install

# For Xcode >= 8
cd /Applications/Xcode.app/Contents/Developer/usr/bin/
sudo ln -s xcodebuild xcrun
# note - in order to compile directly in Xcode 8 IDE, remove the xcrun symbolic link

Make sure Command Line Tools are specified in the Xcode preferences

Homebrew and friends

 You also need Homebrew for a little more convenient OSS software installations. The following should get you started:

brew install curl
brew install p7zip
brew install gnu-tar
brew install cmake
brew install gdal
brew install geos

Note on gnu-tar: It may be that the packager for firmware wants to use gnu-tar and not the bsdtar that comes with OSX. Make sure you know how to put it to path or update the symlinks.

SDL

SDL 1.2 can be downloaded from https://www.libsdl.org and copied to /Library/Frameworks. It should work out of the box, but when you have trouble maybe the following helps.

SDL/SDL.h not found error on compile

If you do have trouble similar to LP-188 building the sdlgamepad lib with <SDL/SDL.h> not found error, make sure you add the symlink as following:

# Create a symlink to "nest" headers under SDL as expected by code
cd /Library/Frameworks/SDL.framework/Headers
ln -s SDL .

If this doesn't work and it still can't find the framework, copy the framework into ./ground/gcs/src/libs/sdlgamepad and modify the sdlgamepad.pro file to use this new header and framework path.


Get the code using Git

OSX most likely has Git already installed. 

Choose/create a dir where you want LibrePilot code:

mkdir -p ~/code
cd ~/code

Checkout code :

git clone https://bitbucket.org/librepilot/librepilot.git



Better to fork the repo and clone from your own copy. Easier to create pull requests later.


Change current directory to ~/code/librepilot:

cd ~/code/librepilot

Now you can checkout code from remote Git server:

git checkout next
git pull

Note!: Future dev happens in next branch. Keep your fork up to date with that.

Dev Tools Installation

Install development libraries and tools, these will be downloaded and automatically installed using root Makefile:

make all_sdk_install
make osg_install
make osgearth_install

Build - Run software locally

Take also a look to the Make Basics page and running "make" to see all the options to build pieces of Librepilot individually.

make -j8 opfw_resource
make -j8 gcs
# open the app, refresh the views, create gcs.log in home dir
open ./build/librepilot-gcs_release/LibrePilot\ GCS.app --args -reset -log ~/gcs.log

Note: ./build/librepilot-gcs_release contains the latest .app if you prefer to navigate to it.

Build package

Build a .dmg package (of course, -j8 could be anything less/more depending the number of cores):

make -j8 package 

Again it ends up in ./build directory.
 

Now that you are done, go and create your first pull request with amazing new feature or bugfix!