Building Spring on MacOSX

From Spring
Revision as of 13:06, 10 December 2013 by Abma (talk | contribs) (simplify)
Jump to navigationJump to search

Development < Building Spring < Building Spring on MacOSX

If you want only to play a spring game, follow the Spring_on_MacOSX Tutorial.


Build from source on MacOSX

Guide is for x86/Intel based OSX installs

I am hoping that with our efforts on the forum that we can have an .app bundle released everytime spring is updated and that will save most people needing to go through the headache of compiling from source code. But if you must try, then here's the steps to help!

I cannot stress enough that this will most likely only work on Intel based systems at this stage. With my understanding of how unitsync works, it seems like online play will not be possible between PPC and x86 architecture.

Get Dependencies

Install the Xcode developers package (this requires a free membership to apple's ADC website) and mac ports.


Using Macports

As hint: set "buildmakejobs" to cpu-core count + 1 in /opt/local/etc/macports/macports.conf. For example:

buildmakejobs 5

Once you have downloaded and configured Macports use these commands to download / compile and install the required dependencies:


sudo port install cmake libsdl boost libpng jpeg \
                  tiff libogg libvorbis python27 libdevil git-core binutils \
                  openal p7zip glew gcc47

binutils are required because of "addr2line", this allows finding bugs.

now select the installed gcc as default:

sudo port select --set gcc mp-gcc47
hash -r

if you don't know the installed gcc, type:

port select --list gcc

pre-select the correct compiler:

export CC=/opt/local/bin/gcc-mp-4.7
export CXX=/opt/local/bin/g++-mp-4.7

If all was successful, you are very close to being able to compile Spring naively!

Obtaining the Source

Tarballs

(For playing online official games on lobby.springrts.com - the spring lobby server)

Using Git is the recommended way to get the sources of the engine. In spite of, you can use the official tarballs to compile Spring without git.

Note: Do NOT use the zip-files from github, they are missing important data to compile Spring.

See Building spring for build instructions.

Git

Spring project page at github

Master repo URI: git://github.com/spring/spring.git
Backup repo: git://git.code.sf.net/p/springrts/code

Branches of interest:

  • master - latest stable, enforced for official games on lobby.springrts.com
  • maintenance - fixes for the latest stable
  • develop - major developments (most active, larger developments)

Assuming the GIT command line client is installed, you can clone (get locally) the repository with the commands below.

Latest Stable (master branch, useless for development purposes, lives as maintenance moving forward)

git clone --recursive git://github.com/spring/spring.git -b master

To later update it (get the changes other people did) with:

git pull --rebase

Maintenance (maintenance branch)

git clone --recursive git://github.com/spring/spring.git -b maintenance

Bleeding-edge (develop branch)

git clone --recursive git://github.com/spring/spring.git -b develop

Working with git

Please note that patches to the code must be done for either develop or maintenance. Such patches can be then sent to one of the developers with repository access. If you are new to git and github, you may want to have a look at this guide to get you started.

Note: you can switch branches this way:<syntaxhighlight lang="bash">

  1. (optional) backup your current code changes

git stash

  1. switch branch

git checkout $MY_OTHER_BRANCH

  1. sometimes needed
  2. note, it deletes all your unstashed changes and all non-pushed commits on the new branch,
  3. but it doesn't delete untracked files.
  4. git reset --hard
  1. update/sync with remote repo

git pull --rebase

  1. (optional) if you want to apply the code changes backed-up in the first step
  2. git stash pop # reapplies your changes and DELETES the backup
  3. or
  4. git stash apply --index 0 # reapplies your changes and keep the backup (see `git stash list`)

</syntaxhighlight>

Submodules

To obtain the submodules you should clone the repository with --recursive as mentioned above. If you haven't done this, you can execute the following code <syntaxhighlight lang="bash"> git submodule sync git submodule update --init

</syntaxhighlight>

To update the submodules, you have to execute the same commands again or pull normally.

Build And Install

Configure and build:

cmake .
make spring

Install:

make install-spring